diff options
author | Ted Gould <ted@canonical.com> | 2009-06-19 13:43:52 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-06-19 13:43:52 -0500 |
commit | 10c2d306e534559ab2bb48470bfe39e8e53feaeb (patch) | |
tree | f48fd47ad377d0d6faf52312bd3a25aad9f0c59b | |
parent | 3f7108fb2724ec6286fa8a30bcdbc19d54562b07 (diff) | |
parent | 7f2cb8b3f917ceddd4ebae8dd8e55f966cbd0fcc (diff) | |
download | ayatana-indicator-session-10c2d306e534559ab2bb48470bfe39e8e53feaeb.tar.gz ayatana-indicator-session-10c2d306e534559ab2bb48470bfe39e8e53feaeb.tar.bz2 ayatana-indicator-session-10c2d306e534559ab2bb48470bfe39e8e53feaeb.zip |
Code to start merging in menus.
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | src/indicator-sus.c | 62 |
2 files changed, 68 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 8debe7f..aebb4a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +indicator-sus (0.1~ppa2~indicator4) UNRELEASED; urgency=low + + * Code to start merging in menus. + + -- Ted Gould <ted@ubuntu.com> Fri, 19 Jun 2009 13:43:36 -0500 + indicator-sus (0.1~ppa2~indicator3) jaunty; urgency=low * Updating from branch, lazy loading the services. diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 15d4e5a..6b69269 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -17,6 +17,10 @@ static GtkMenu * users_menu = NULL; static GtkMenu * session_menu = NULL; static GtkMenu * main_menu = NULL; +static GtkWidget * status_separator = NULL; +static GtkWidget * users_separator = NULL; +#define SEPARATOR_SHOWN(sep) (sep != NULL && GTK_WIDGET_VISIBLE(sep)) + static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; @@ -33,6 +37,55 @@ get_icon (void) return NULL; } +static void +menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint positionoffset) +{ + GList * location = g_list_find(GTK_MENU_SHELL(source)->children, addee); + guint position = g_list_position(GTK_MENU_SHELL(source)->children, location); + + position += positionoffset; + + gtk_menu_insert(addto, addee, position); + return; +} + +static void +status_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) +{ + menu_add(container, widget, GTK_MENU(userdata), 0); + gtk_widget_show(status_separator); + return; +} + +static void +users_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) +{ + guint position = 0; + if (SEPARATOR_SHOWN(status_separator)) { + GList * location = g_list_find(GTK_MENU_SHELL(main_menu)->children, status_separator); + position = g_list_position(GTK_MENU_SHELL(main_menu)->children, location) + 1; + } + + menu_add(container, widget, GTK_MENU(userdata), position); + gtk_widget_show(users_separator); + return; +} + +static void +session_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) +{ + guint position = 0; + if (SEPARATOR_SHOWN(users_separator)) { + GList * location = g_list_find(GTK_MENU_SHELL(main_menu)->children, users_separator); + position = g_list_position(GTK_MENU_SHELL(main_menu)->children, location) + 1; + } + + menu_add(container, widget, GTK_MENU(userdata), position); + gtk_widget_show(status_separator); + return; +} + + static gboolean build_status_menu (gpointer userdata) { @@ -56,6 +109,10 @@ build_status_menu (gpointer userdata) } status_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT)); + g_signal_connect(G_OBJECT(status_menu), "added", G_CALLBACK(status_menu_add), main_menu); + + status_separator = gtk_separator_menu_item_new(); + gtk_widget_hide(status_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ return FALSE; } @@ -83,6 +140,10 @@ build_users_menu (gpointer userdata) } users_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); + g_signal_connect(G_OBJECT(users_menu), "added", G_CALLBACK(users_menu_add), main_menu); + + users_separator = gtk_separator_menu_item_new(); + gtk_widget_hide(users_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ return FALSE; } @@ -110,6 +171,7 @@ build_session_menu (gpointer userdata) } session_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + g_signal_connect(G_OBJECT(session_menu), "added", G_CALLBACK(session_menu_add), main_menu); return FALSE; } |