aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indicator-session.c')
-rw-r--r--src/indicator-session.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c
index a4bb5e1..c367e3a 100644
--- a/src/indicator-session.c
+++ b/src/indicator-session.c
@@ -84,10 +84,52 @@ get_icon (void)
typedef struct _realized_data_t realized_data_t;
struct _realized_data_t {
- guint position;
section_t section;
};
+static void
+resort_menu (void)
+{
+ guint location = 0;
+ guint clientnum;
+
+ for (clientnum = 0; clientnum < 3; clientnum++) {
+ DbusmenuGtkClient * client = NULL;
+ if (clientnum == 0) client = status_client;
+ if (clientnum == 1) client = users_client;
+ if (clientnum == 2) client = session_client;
+
+ if (client == NULL) continue;
+
+ DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(client));
+
+ GList * children = dbusmenu_menuitem_get_children(root);
+ if (children == NULL) {
+ continue;
+ }
+
+ GList * child;
+ for (child = children; child != NULL; child = g_list_next(child)) {
+ GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, DBUSMENU_MENUITEM(child->data));
+ if (widget != NULL) {
+ gtk_menu_reorder_child(main_menu, GTK_WIDGET(widget), location);
+ location++;
+ }
+ }
+
+ if (clientnum == 0) {
+ gtk_menu_reorder_child(main_menu, status_separator, location);
+ location++;
+ }
+ if (clientnum == 1) {
+ gtk_menu_reorder_child(main_menu, users_separator, location);
+ location++;
+ }
+ }
+
+ return;
+}
+
static void
child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, gpointer section)
{
@@ -97,7 +139,6 @@ child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position
return;
}
- data->position = position;
data->section = GPOINTER_TO_UINT(section);
g_signal_connect(G_OBJECT(child), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(child_realized), data);
@@ -111,7 +152,6 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata)
g_return_if_fail(DBUSMENU_IS_MENUITEM(child));
realized_data_t * data = (realized_data_t *)userdata;
- guint position = data->position;
section_t section = data->section;
g_free(data);
@@ -145,8 +185,6 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata)
return;
}
- position += posfunc();
- g_debug("SUS: Adding child: %d", position);
GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, child);
if (widget == NULL) {
@@ -154,9 +192,11 @@ child_realized (DbusmenuMenuitem * child, gpointer userdata)
return;
}
- gtk_menu_insert(main_menu, GTK_WIDGET(widget), position);
+ gtk_menu_append(main_menu, GTK_WIDGET(widget));
gtk_widget_show(GTK_WIDGET(widget));
+ resort_menu();
+
gtk_widget_hide(loading_item);
return;