From 310a2c18788756cb5e5a5c321ce6ca918a786c6e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 10:20:06 -0500 Subject: Adding in separators --- src/indicator-sus.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 15d4e5a..86c84e2 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; @@ -57,6 +61,9 @@ build_status_menu (gpointer userdata) status_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT)); + status_separator = gtk_separator_menu_item_new(); + gtk_widget_hide(status_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ + return FALSE; } @@ -84,6 +91,9 @@ build_users_menu (gpointer userdata) users_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); + users_separator = gtk_separator_menu_item_new(); + gtk_widget_hide(users_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ + return FALSE; } -- cgit v1.2.3 From c99e8b57e531374bff266fedb16a3915618af701 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 13:38:01 -0500 Subject: Bubbling up the position information to a final function to put things on the main menu. --- src/indicator-sus.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 86c84e2..b2419b9 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -37,6 +37,50 @@ get_icon (void) return NULL; } +static void +menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint positionoffset) +{ + + +} + +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) { @@ -60,6 +104,7 @@ 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! */ @@ -90,6 +135,7 @@ 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! */ @@ -120,6 +166,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; } -- cgit v1.2.3 From 7f2cb8b3f917ceddd4ebae8dd8e55f966cbd0fcc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 13:43:01 -0500 Subject: Fleshing out the insertion function. Let's get some menus. --- src/indicator-sus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/indicator-sus.c b/src/indicator-sus.c index b2419b9..6b69269 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -40,8 +40,13 @@ get_icon (void) 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 -- cgit v1.2.3