Merge lp:~ted/indicator-session/async-menu into lp:indicator-session/0.1

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/indicator-session/async-menu
Merge into: lp:indicator-session/0.1
Diff against target: 95 lines
1 file modified
src/indicator-session.c (+46/-6)
To merge this branch: bzr merge lp:~ted/indicator-session/async-menu
Reviewer Review Type Date Requested Status
Petri Lehtinen (community) Approve
Neil J. Patel (community) Approve
Review via email: mp+12869@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Better handling of menus.

Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good. Approved.

review: Approve
Revision history for this message
Petri Lehtinen (petri) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-session.c'
2--- src/indicator-session.c 2009-09-28 22:43:06 +0000
3+++ src/indicator-session.c 2009-10-05 13:35:18 +0000
4@@ -84,10 +84,52 @@
5
6 typedef struct _realized_data_t realized_data_t;
7 struct _realized_data_t {
8- guint position;
9 section_t section;
10 };
11
12+static void
13+resort_menu (void)
14+{
15+ guint location = 0;
16+ guint clientnum;
17+
18+ for (clientnum = 0; clientnum < 3; clientnum++) {
19+ DbusmenuGtkClient * client = NULL;
20+ if (clientnum == 0) client = status_client;
21+ if (clientnum == 1) client = users_client;
22+ if (clientnum == 2) client = session_client;
23+
24+ if (client == NULL) continue;
25+
26+ DbusmenuMenuitem * root = dbusmenu_client_get_root(DBUSMENU_CLIENT(client));
27+
28+ GList * children = dbusmenu_menuitem_get_children(root);
29+ if (children == NULL) {
30+ continue;
31+ }
32+
33+ GList * child;
34+ for (child = children; child != NULL; child = g_list_next(child)) {
35+ GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, DBUSMENU_MENUITEM(child->data));
36+ if (widget != NULL) {
37+ gtk_menu_reorder_child(main_menu, GTK_WIDGET(widget), location);
38+ location++;
39+ }
40+ }
41+
42+ if (clientnum == 0) {
43+ gtk_menu_reorder_child(main_menu, status_separator, location);
44+ location++;
45+ }
46+ if (clientnum == 1) {
47+ gtk_menu_reorder_child(main_menu, users_separator, location);
48+ location++;
49+ }
50+ }
51+
52+ return;
53+}
54+
55 static void
56 child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, gpointer section)
57 {
58@@ -97,7 +139,6 @@
59 return;
60 }
61
62- data->position = position;
63 data->section = GPOINTER_TO_UINT(section);
64
65 g_signal_connect(G_OBJECT(child), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(child_realized), data);
66@@ -111,7 +152,6 @@
67 g_return_if_fail(DBUSMENU_IS_MENUITEM(child));
68
69 realized_data_t * data = (realized_data_t *)userdata;
70- guint position = data->position;
71 section_t section = data->section;
72 g_free(data);
73
74@@ -145,8 +185,6 @@
75 return;
76 }
77
78- position += posfunc();
79- g_debug("SUS: Adding child: %d", position);
80 GtkMenuItem * widget = dbusmenu_gtkclient_menuitem_get(client, child);
81
82 if (widget == NULL) {
83@@ -154,9 +192,11 @@
84 return;
85 }
86
87- gtk_menu_insert(main_menu, GTK_WIDGET(widget), position);
88+ gtk_menu_append(main_menu, GTK_WIDGET(widget));
89 gtk_widget_show(GTK_WIDGET(widget));
90
91+ resort_menu();
92+
93 gtk_widget_hide(loading_item);
94
95 return;

Subscribers

People subscribed via source and target branches