aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-06-30 15:51:10 -0500
committerTed Gould <ted@canonical.com>2009-06-30 15:51:10 -0500
commitcc19423ef4f8d060d7dfa7ab7eb0655e67be3efa (patch)
tree478867e5a59cb9a01ad4e70f05b028d315f42edb /src
parenta6afde93e447dc090d0ec245bedc3295441a391c (diff)
downloadayatana-indicator-session-cc19423ef4f8d060d7dfa7ab7eb0655e67be3efa.tar.gz
ayatana-indicator-session-cc19423ef4f8d060d7dfa7ab7eb0655e67be3efa.tar.bz2
ayatana-indicator-session-cc19423ef4f8d060d7dfa7ab7eb0655e67be3efa.zip
Trying to flesh out the add function some more, but this commit doesn't build as apparently switches have to have integers now. This takes half of the fun out of C if you can't use crazy function pointers everywhere! Where's the sport in readable code?
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sus.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/indicator-sus.c b/src/indicator-sus.c
index 4e7d4b2..9368300 100644
--- a/src/indicator-sus.c
+++ b/src/indicator-sus.c
@@ -30,6 +30,7 @@ GtkLabel *
get_label (void)
{
GtkLabel * returnval = GTK_LABEL(gtk_label_new("Ted Gould"));
+ gtk_widget_show(GTK_WIDGET(returnval));
return returnval;
}
@@ -40,16 +41,39 @@ get_icon (void)
}
static void
-menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint positionoffset)
+child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void))
{
- GList * location = g_list_find(GTK_MENU_SHELL(source)->children, addee);
- guint position = g_list_position(GTK_MENU_SHELL(source)->children, location);
+ position += posfunc();
+
+ DbusmenuGtkClient * client = NULL;
+ gchar * errorstr = NULL;
+ switch (posfunc) {
+ case status_menu_pos_offset:
+ client = status_client;
+ errorstr = "Status";
+ break;
+ case users_menu_pos_offset:
+ client = users_client;
+ errorstr = "Users";
+ break;
+ case session_menu_pos_offset:
+ client = session_client;
+ errorstr = "Session";
+ break;
+ default:
+ g_warning("Child Added called with an unknown position function!");
+ return;
+ }
+
+ GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, child);
- position += positionoffset;
- g_debug("Adding a widget: %d", position);
+ if (widget == NULL) {
+ g_warning("Had a menu item added to the %s menu, but yet it didn't have a GtkWidget with it. Can't add that to a menu now can we? You need to figure this @#$# out!", errorstr);
+ return;
+ }
- gtk_menu_insert(addto, addee, position);
- gtk_widget_show(addee);
+ gtk_menu_insert(main_menu, GTK_WIDGET(widget), position);
+ gtk_widget_show(GTK_WIDGET(widget));
gtk_widget_hide(loading_item);
@@ -57,13 +81,6 @@ menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint posit
}
static void
-child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void))
-{
- menu_add(NULL, NULL, NULL, 0);
-
-}
-
-static void
child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, guint (*posfunc) (void))
{