From a94e5d414a44af3c3f4ae2bb0c00978c0270dd1a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 8 Jun 2009 16:59:12 -0500 Subject: Renaming the C file as well. --- src/indicator-sus.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/indicator-sus.c (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c new file mode 100644 index 0000000..4c1c163 --- /dev/null +++ b/src/indicator-sus.c @@ -0,0 +1,85 @@ + +#include +#include + +#include +#include + +#include +INDICATOR_SET_VERSION +INDICATOR_SET_NAME("users-status-session") + +#include "dbus-shared-names.h" + +static GtkMenu * status_menu = NULL; +static GtkMenu * users_menu = NULL; +static GtkMenu * session_menu = NULL; +static GtkMenu * main_menu = NULL; + +GtkLabel * +get_label (void) +{ + GtkLabel * returnval = GTK_LABEL(gtk_label_new("Ted Gould")); + return returnval; +} + +GtkImage * +get_icon (void) +{ + return NULL; +} + +GtkMenu * +get_menu (void) +{ + guint returnval = 0; + GError * error = NULL; + + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + DBusGProxy * proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + + if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_STATUS_DBUS_NAME, 0, &returnval, &error)) { + g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); + g_error_free(error); + return NULL; + } + + if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { + g_error("Return value isn't indicative of success: %d", returnval); + return NULL; + } + + status_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT)); + + if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_USERS_DBUS_NAME, 0, &returnval, &error)) { + g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); + g_error_free(error); + return NULL; + } + + if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { + g_error("Return value isn't indicative of success: %d", returnval); + return NULL; + } + + users_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); + + if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_SESSION_DBUS_NAME, 0, &returnval, &error)) { + g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); + g_error_free(error); + return NULL; + } + + if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { + g_error("Return value isn't indicative of success: %d", returnval); + return NULL; + } + + session_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + + main_menu = GTK_MENU(gtk_menu_new()); + + return main_menu; +} + + -- cgit v1.2.3 From 35477b8fb1bd21c4cccf039c4648af47972414a9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 12 Jun 2009 16:34:22 -0500 Subject: Brining in the client side of the API --- src/indicator-sus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 4c1c163..5d6c219 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -10,6 +10,7 @@ INDICATOR_SET_VERSION INDICATOR_SET_NAME("users-status-session") #include "dbus-shared-names.h" +#include "status-service-client.h" static GtkMenu * status_menu = NULL; static GtkMenu * users_menu = NULL; -- cgit v1.2.3 From 377777d3cde780875ab39ffb647e4009153365bc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 07:21:36 -0500 Subject: Splitting out the menu loading and process starting code to make it lazy and push it into the idle loop. No blocking DBus on startup. --- src/indicator-sus.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 10 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 5d6c219..15d4e5a 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -17,6 +17,9 @@ static GtkMenu * users_menu = NULL; static GtkMenu * session_menu = NULL; static GtkMenu * main_menu = NULL; +static DBusGConnection * connection = NULL; +static DBusGProxy * proxy = NULL; + GtkLabel * get_label (void) { @@ -30,54 +33,97 @@ get_icon (void) return NULL; } -GtkMenu * -get_menu (void) +static gboolean +build_status_menu (gpointer userdata) { guint returnval = 0; GError * error = NULL; - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - DBusGProxy * proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + if (proxy == NULL) { + /* If we don't have DBus, let's stay in the idle loop */ + return TRUE; + } if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_STATUS_DBUS_NAME, 0, &returnval, &error)) { g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); g_error_free(error); - return NULL; + return FALSE; } if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { g_error("Return value isn't indicative of success: %d", returnval); - return NULL; + return FALSE; } status_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT)); + return FALSE; +} + +static gboolean +build_users_menu (gpointer userdata) +{ + guint returnval = 0; + GError * error = NULL; + + if (proxy == NULL) { + /* If we don't have DBus, let's stay in the idle loop */ + return TRUE; + } + if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_USERS_DBUS_NAME, 0, &returnval, &error)) { g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); g_error_free(error); - return NULL; + return FALSE; } if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { g_error("Return value isn't indicative of success: %d", returnval); - return NULL; + return FALSE; } users_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); + return FALSE; +} + +static gboolean +build_session_menu (gpointer userdata) +{ + guint returnval = 0; + GError * error = NULL; + + if (proxy == NULL) { + /* If we don't have DBus, let's stay in the idle loop */ + return TRUE; + } + if (!org_freedesktop_DBus_start_service_by_name (proxy, INDICATOR_SESSION_DBUS_NAME, 0, &returnval, &error)) { g_error("Unable to send message to DBus to start service: %s", error != NULL ? error->message : "(NULL error)" ); g_error_free(error); - return NULL; + return FALSE; } if (returnval != DBUS_START_REPLY_SUCCESS && returnval != DBUS_START_REPLY_ALREADY_RUNNING) { g_error("Return value isn't indicative of success: %d", returnval); - return NULL; + return FALSE; } session_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + return FALSE; +} + +GtkMenu * +get_menu (void) +{ + connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + + g_idle_add(build_status_menu, NULL); + g_idle_add(build_users_menu, NULL); + g_idle_add(build_session_menu, NULL); + main_menu = GTK_MENU(gtk_menu_new()); return main_menu; -- cgit v1.2.3 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(+) (limited to 'src/indicator-sus.c') 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(+) (limited to 'src/indicator-sus.c') 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(+) (limited to 'src/indicator-sus.c') 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 From 901278c9c269c5052cf5ebc54ef859c63f0b94f2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 14:42:15 -0500 Subject: Oh, the signal is 'add' not 'added'. How I love to have random strings without checking, all the elegance of Python. --- src/indicator-sus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 6b69269..d8b808a 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -109,7 +109,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); + g_signal_connect(G_OBJECT(status_menu), "add", 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! */ @@ -140,7 +140,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); + g_signal_connect(G_OBJECT(users_menu), "add", 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! */ @@ -171,7 +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); + g_signal_connect(G_OBJECT(session_menu), "add", G_CALLBACK(session_menu_add), main_menu); return FALSE; } -- cgit v1.2.3 From 2cb6204a90437626211aa4337942d3f072985756 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Jun 2009 15:32:49 -0500 Subject: Showing the added menu and adding in a loading item. --- src/indicator-sus.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index d8b808a..84eb929 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -20,6 +20,7 @@ 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 GtkWidget * loading_item = NULL; static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; @@ -44,8 +45,13 @@ menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint posit guint position = g_list_position(GTK_MENU_SHELL(source)->children, location); position += positionoffset; + g_debug("Adding a widget: %d", position); gtk_menu_insert(addto, addee, position); + gtk_widget_show(addee); + + gtk_widget_hide(loading_item); + return; } @@ -81,7 +87,6 @@ session_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdat } menu_add(container, widget, GTK_MENU(userdata), position); - gtk_widget_show(status_separator); return; } @@ -112,6 +117,7 @@ build_status_menu (gpointer userdata) g_signal_connect(G_OBJECT(status_menu), "add", G_CALLBACK(status_menu_add), main_menu); status_separator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator); gtk_widget_hide(status_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ return FALSE; @@ -143,6 +149,7 @@ build_users_menu (gpointer userdata) g_signal_connect(G_OBJECT(users_menu), "add", G_CALLBACK(users_menu_add), main_menu); users_separator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), users_separator); gtk_widget_hide(users_separator); /* Should be default, I'm just being explicit. $(%*#$ hide already! */ return FALSE; @@ -187,6 +194,8 @@ get_menu (void) g_idle_add(build_session_menu, NULL); main_menu = GTK_MENU(gtk_menu_new()); + loading_item = gtk_menu_item_new_with_label("Loading..."); + gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), loading_item); return main_menu; } -- cgit v1.2.3 From 23fa731fafd03ac156f4b2b121250fa7a76a9a53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 22 Jun 2009 22:49:02 -0500 Subject: Using the new dbusmenu signal for item added --- src/indicator-sus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 84eb929..53a0db6 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -114,7 +114,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), "add", G_CALLBACK(status_menu_add), main_menu); + g_signal_connect(G_OBJECT(status_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(status_menu_add), main_menu); status_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator); @@ -146,7 +146,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), "add", G_CALLBACK(users_menu_add), main_menu); + g_signal_connect(G_OBJECT(users_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(users_menu_add), main_menu); users_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), users_separator); @@ -178,7 +178,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), "add", G_CALLBACK(session_menu_add), main_menu); + g_signal_connect(G_OBJECT(session_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(session_menu_add), main_menu); return FALSE; } -- cgit v1.2.3 From 4512d99684ff8d0f009cc69c0351b827dd369988 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 26 Jun 2009 16:48:06 -0500 Subject: Phase one switch to the client instead of the menu --- src/indicator-sus.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 53a0db6..cd3337d 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -1,6 +1,6 @@ #include -#include +#include #include #include @@ -12,9 +12,10 @@ INDICATOR_SET_NAME("users-status-session") #include "dbus-shared-names.h" #include "status-service-client.h" -static GtkMenu * status_menu = NULL; -static GtkMenu * users_menu = NULL; -static GtkMenu * session_menu = NULL; +static DbusmenuGtkClient * status_client = NULL; +static DbusmenuGtkClient * users_client = NULL; +static DbusmenuGtkClient * session_client = NULL; + static GtkMenu * main_menu = NULL; static GtkWidget * status_separator = NULL; @@ -113,8 +114,8 @@ build_status_menu (gpointer userdata) return FALSE; } - status_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT)); - g_signal_connect(G_OBJECT(status_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(status_menu_add), main_menu); + status_client = dbusmenu_gtkclient_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT); + g_signal_connect(G_OBJECT(status_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(status_menu_add), main_menu); status_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator); @@ -145,8 +146,8 @@ build_users_menu (gpointer userdata) return FALSE; } - users_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); - g_signal_connect(G_OBJECT(users_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(users_menu_add), main_menu); + users_client = dbusmenu_gtkclient_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT); + g_signal_connect(G_OBJECT(users_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(users_menu_add), main_menu); users_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), users_separator); @@ -177,8 +178,8 @@ build_session_menu (gpointer userdata) return FALSE; } - session_menu = GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - g_signal_connect(G_OBJECT(session_menu), DBUSMENU_GTKMENU_SIGNAL_ADD, G_CALLBACK(session_menu_add), main_menu); + session_client = dbusmenu_gtkclient_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); + g_signal_connect(G_OBJECT(session_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(session_menu_add), main_menu); return FALSE; } -- cgit v1.2.3 From 07ad2f2a1125f6b84f5ed71bb6bfa5407522716c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 11:02:04 -0500 Subject: Working more on changing the style of how things work for clients. This is the session based items. --- src/indicator-sus.c | 74 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 15 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index cd3337d..4efc1b2 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -78,20 +78,6 @@ users_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) 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); - return; -} - - static gboolean build_status_menu (gpointer userdata) { @@ -156,6 +142,62 @@ build_users_menu (gpointer userdata) return FALSE; } +static void +child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void)) +{ + + +} + +static void +child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, guint (*posfunc) (void)) +{ + + +} + +/* Session Menu Stuff */ + +static guint +session_menu_pos_offset (void) +{ + 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; + } + + return position; +} + +static void +session_menu_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +{ + return; +} + +static void +session_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, GtkMenu * main) +{ + if (newroot == NULL) { + /* We're assuming this'll crash the least so it doesn't + hide a separator. May be a bad choice. */ + return; + } + + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), session_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(session_menu_removed), NULL); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), session_menu_pos_offset); + + GList * child = NULL; + guint count = 0; + for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, session_menu_pos_offset); + } + + return; +} + static gboolean build_session_menu (gpointer userdata) { @@ -179,11 +221,13 @@ build_session_menu (gpointer userdata) } session_client = dbusmenu_gtkclient_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT); - g_signal_connect(G_OBJECT(session_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(session_menu_add), main_menu); + g_signal_connect(G_OBJECT(session_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(session_menu_root_changed), main_menu); return FALSE; } +/* Base menu stuff */ + GtkMenu * get_menu (void) { -- cgit v1.2.3 From 23bead1b2a7c60dc8380b7cc7acf30eecf973f45 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 15:20:32 -0500 Subject: Adding in stuff for the users menu. Getting better at this. --- src/indicator-sus.c | 102 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 27 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 4efc1b2..75030b3 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -57,24 +57,26 @@ menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint posit } static void -status_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) +child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void)) { - 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) +child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, guint (*posfunc) (void)) { - 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); + +} + + +/* Status Menu */ +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; } @@ -110,6 +112,63 @@ build_status_menu (gpointer userdata) return FALSE; } +/* Users menu */ + +static guint +users_menu_pos_offset (void) +{ + 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; + } + + return position; +} + +static void +users_menu_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) +{ + gtk_widget_show(GTK_WIDGET(users_separator)); + return; +} + +static void +users_menu_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +{ + if (g_list_length(dbusmenu_menuitem_get_children(root)) == 0) { + gtk_widget_hide(GTK_WIDGET(users_separator)); + } + + return; +} + +static void +users_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, GtkMenu * main) +{ + if (newroot == NULL) { + gtk_widget_hide(GTK_WIDGET(users_separator)); + return; + } + + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), users_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(users_menu_added), NULL); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(users_menu_removed), NULL); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), users_menu_pos_offset); + + GList * child = NULL; + guint count = 0; + for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, users_menu_pos_offset); + } + + if (count > 0) { + gtk_widget_show(GTK_WIDGET(users_separator)); + } + + return; +} + static gboolean build_users_menu (gpointer userdata) { @@ -133,7 +192,7 @@ build_users_menu (gpointer userdata) } users_client = dbusmenu_gtkclient_new(INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT); - g_signal_connect(G_OBJECT(users_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(users_menu_add), main_menu); + g_signal_connect(G_OBJECT(users_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(users_menu_root_changed), main_menu); users_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), users_separator); @@ -142,20 +201,6 @@ build_users_menu (gpointer userdata) return FALSE; } -static void -child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void)) -{ - - -} - -static void -child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, guint oldpos, guint (*posfunc) (void)) -{ - - -} - /* Session Menu Stuff */ static guint @@ -165,6 +210,9 @@ session_menu_pos_offset (void) 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; + } else 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; } return position; -- cgit v1.2.3 From a6afde93e447dc090d0ec245bedc3295441a391c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 15:27:38 -0500 Subject: Switching over the status menu too. Woot! --- src/indicator-sus.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 75030b3..4e7d4b2 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -59,7 +59,7 @@ 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); } @@ -72,11 +72,52 @@ child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos, /* Status Menu */ +static guint +status_menu_pos_offset (void) +{ + return 0; +} + +static void +status_menu_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) +{ + gtk_widget_show(GTK_WIDGET(status_separator)); + return; +} + static void -status_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata) +status_menu_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) { - menu_add(container, widget, GTK_MENU(userdata), 0); - gtk_widget_show(status_separator); + if (g_list_length(dbusmenu_menuitem_get_children(root)) == 0) { + gtk_widget_hide(GTK_WIDGET(status_separator)); + } + + return; +} + +static void +status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, GtkMenu * main) +{ + if (newroot == NULL) { + gtk_widget_hide(GTK_WIDGET(status_separator)); + return; + } + + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), status_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_added), NULL); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_removed), NULL); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), status_menu_pos_offset); + + GList * child = NULL; + guint count = 0; + for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, status_menu_pos_offset); + } + + if (count > 0) { + gtk_widget_show(GTK_WIDGET(status_separator)); + } + return; } @@ -103,7 +144,7 @@ build_status_menu (gpointer userdata) } status_client = dbusmenu_gtkclient_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT); - g_signal_connect(G_OBJECT(status_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(status_menu_add), main_menu); + g_signal_connect(G_OBJECT(status_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(status_menu_root_changed), main_menu); status_separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator); -- cgit v1.2.3 From cc19423ef4f8d060d7dfa7ab7eb0655e67be3efa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 15:51:10 -0500 Subject: 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? --- src/indicator-sus.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'src/indicator-sus.c') 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,29 +41,45 @@ 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); return; } -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)) { -- cgit v1.2.3 From 6bd2d42ccd10366788fc0721b61e0f984cb77543 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 16:14:01 -0500 Subject: Bah, I hate pointers some days. --- src/indicator-sus.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 9368300..88bea47 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -26,6 +26,18 @@ static GtkWidget * loading_item = NULL; static DBusGConnection * connection = NULL; static DBusGProxy * proxy = NULL; +typedef enum { + STATUS_SECTION, + USERS_SECTION, + SESSION_SECTION, + END_OF_SECTIONS +} section_t; + +static void child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, gpointer section); +static guint status_menu_pos_offset (void); +static guint users_menu_pos_offset (void); +static guint session_menu_pos_offset (void); + GtkLabel * get_label (void) { @@ -41,30 +53,34 @@ get_icon (void) } static void -child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void)) +child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, gpointer section) { - position += posfunc(); - DbusmenuGtkClient * client = NULL; gchar * errorstr = NULL; - switch (posfunc) { - case status_menu_pos_offset: + guint (*posfunc) (void) = NULL; + + switch (GPOINTER_TO_UINT(section)) { + case STATUS_SECTION: client = status_client; errorstr = "Status"; + posfunc = status_menu_pos_offset; break; - case users_menu_pos_offset: + case USERS_SECTION: client = users_client; errorstr = "Users"; + posfunc = users_menu_pos_offset; break; - case session_menu_pos_offset: + case SESSION_SECTION: client = session_client; errorstr = "Session"; + posfunc = session_menu_pos_offset; break; default: g_warning("Child Added called with an unknown position function!"); return; } + position += posfunc(); GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, child); if (widget == NULL) { @@ -120,15 +136,15 @@ status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, return; } - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), status_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), GUINT_TO_POINTER(STATUS_SECTION)); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_added), NULL); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_removed), NULL); - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), status_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), GUINT_TO_POINTER(STATUS_SECTION)); GList * child = NULL; guint count = 0; for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { - child_added(newroot, DBUSMENU_MENUITEM(child->data), count, status_menu_pos_offset); + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, GUINT_TO_POINTER(STATUS_SECTION)); } if (count > 0) { @@ -209,15 +225,15 @@ users_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, return; } - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), users_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), GUINT_TO_POINTER(USERS_SECTION)); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(users_menu_added), NULL); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(users_menu_removed), NULL); - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), users_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), GUINT_TO_POINTER(USERS_SECTION)); GList * child = NULL; guint count = 0; for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { - child_added(newroot, DBUSMENU_MENUITEM(child->data), count, users_menu_pos_offset); + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, GUINT_TO_POINTER(USERS_SECTION)); } if (count > 0) { @@ -291,14 +307,14 @@ session_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot return; } - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), session_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), GUINT_TO_POINTER(SESSION_SECTION)); g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(session_menu_removed), NULL); - g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), session_menu_pos_offset); + g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), GUINT_TO_POINTER(SESSION_SECTION)); GList * child = NULL; guint count = 0; for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) { - child_added(newroot, DBUSMENU_MENUITEM(child->data), count, session_menu_pos_offset); + child_added(newroot, DBUSMENU_MENUITEM(child->data), count, GUINT_TO_POINTER(SESSION_SECTION)); } return; -- cgit v1.2.3 From f084e851c5ef36e6afa920c9198c4a53e7f7c1c3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 16:40:46 -0500 Subject: Showing the loading item. Atleast that works now. --- src/indicator-sus.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 88bea47..7deb6e8 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -81,6 +81,7 @@ child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position } position += posfunc(); + g_debug("SUS: Adding child: %d", position); GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, child); if (widget == NULL) { @@ -363,6 +364,7 @@ get_menu (void) main_menu = GTK_MENU(gtk_menu_new()); loading_item = gtk_menu_item_new_with_label("Loading..."); gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), loading_item); + gtk_widget_show(GTK_WIDGET(loading_item)); return main_menu; } -- cgit v1.2.3 From 17e41d8a3a128e07189fd3163900390372c2b07c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 30 Jun 2009 16:46:42 -0500 Subject: Some debugging info. --- src/indicator-sus.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/indicator-sus.c') diff --git a/src/indicator-sus.c b/src/indicator-sus.c index 7deb6e8..18b6c44 100644 --- a/src/indicator-sus.c +++ b/src/indicator-sus.c @@ -158,6 +158,7 @@ status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, static gboolean build_status_menu (gpointer userdata) { + g_debug("Building Status Menu"); guint returnval = 0; GError * error = NULL; @@ -247,6 +248,7 @@ users_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, static gboolean build_users_menu (gpointer userdata) { + g_debug("Building Users Menu"); guint returnval = 0; GError * error = NULL; @@ -324,6 +326,7 @@ session_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot static gboolean build_session_menu (gpointer userdata) { + g_debug("Building Session Menu"); guint returnval = 0; GError * error = NULL; @@ -356,6 +359,9 @@ get_menu (void) { connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + if (proxy == NULL) { + g_warning("Unable to get proxy for DBus itself. Seriously."); + } g_idle_add(build_status_menu, NULL); g_idle_add(build_users_menu, NULL); -- cgit v1.2.3