Merge lp:~ted/libdbusmenu/reorder into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/libdbusmenu/reorder
Merge into: lp:libdbusmenu/0.5
Diff against target: None lines
To merge this branch: bzr merge lp:~ted/libdbusmenu/reorder
Reviewer Review Type Date Requested Status
David Barth (community) Approve
Neil J. Patel (community) Approve
Review via email: mp+11492@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Fixing the reordering for the messaging menu.

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

Looks good. Extra comments are handy too :). Approved.

review: Approve
Revision history for this message
David Barth (dbarth) wrote :

Works for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-gtk/client.c'
2--- libdbusmenu-gtk/client.c 2009-09-03 19:16:01 +0000
3+++ libdbusmenu-gtk/client.c 2009-09-09 21:50:48 +0000
4@@ -55,6 +55,7 @@
5 /* GObject Stuff */
6 G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT);
7
8+/* Basic build for the class. Only a finalize and dispose handler. */
9 static void
10 dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass)
11 {
12@@ -66,6 +67,8 @@
13 return;
14 }
15
16+/* Registers the three times of menuitems that we're going to handle
17+ for the gtk world. And tracks when a new item gets added. */
18 static void
19 dbusmenu_gtkclient_init (DbusmenuGtkClient *self)
20 {
21@@ -78,6 +81,7 @@
22 return;
23 }
24
25+/* Just calling the super class. Future use. */
26 static void
27 dbusmenu_gtkclient_dispose (GObject *object)
28 {
29@@ -86,6 +90,7 @@
30 return;
31 }
32
33+/* Just calling the super class. Future use. */
34 static void
35 dbusmenu_gtkclient_finalize (GObject *object)
36 {
37@@ -159,9 +164,9 @@
38 return;
39 }
40
41-/* This takes a new DbusmenuMenuitem and attaches the
42- various things that we need to make it work in a
43- GTK World. */
44+/* The new menuitem signal only happens if we don't have a type handler
45+ for the type of the item. This should be an error condition and we're
46+ printing out a message. */
47 static void
48 new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata)
49 {
50@@ -171,6 +176,22 @@
51 return;
52 }
53
54+/**
55+ dbusmenu_gtkclient_newitem_base:
56+ @client: The client handling everything on this connection
57+ @item: The #DbusmenuMenuitem to attach the GTK-isms to
58+ @gmi: A #GtkMenuItem representing the GTK world's view of this menuitem
59+ @parent: The parent #DbusmenuMenuitem
60+
61+ This function provides some of the basic connectivity for being in
62+ the GTK world. Things like visibility and sensitivity of the item are
63+ handled here so that the subclasses don't have to. If you're building
64+ your on GTK menu item you can use this function to apply those basic
65+ attributes so that you don't have to deal with them either.
66+
67+ This also handles passing the "activate" signal back to the
68+ #DbusmenuMenuitem side of thing.
69+*/
70 void
71 dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * item, GtkMenuItem * gmi, DbusmenuMenuitem * parent)
72 {
73@@ -224,6 +245,7 @@
74 static void
75 delete_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, DbusmenuGtkClient * gtkclient)
76 {
77+ /* If it's a root item, we shouldn't be dealing with it here. */
78 if (dbusmenu_menuitem_get_root(mi)) { return; }
79
80 if (g_list_length(dbusmenu_menuitem_get_children(mi)) == 0) {
81@@ -242,6 +264,7 @@
82 static void
83 move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint new, guint old, DbusmenuGtkClient * gtkclient)
84 {
85+ /* If it's a root item, we shouldn't be dealing with it here. */
86 if (dbusmenu_menuitem_get_root(mi)) { return; }
87
88 gpointer ann_menu = g_object_get_data(G_OBJECT(mi), data_menu);
89
90=== modified file 'libdbusmenu-gtk/menu.c'
91--- libdbusmenu-gtk/menu.c 2009-08-27 13:49:11 +0000
92+++ libdbusmenu-gtk/menu.c 2009-09-09 22:09:10 +0000
93@@ -185,6 +185,9 @@
94
95 /* Internal Functions */
96
97+/* Called when a new child of the root item is
98+ added. Sets up a signal for when it's actually
99+ realized. */
100 static void
101 root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, DbusmenuGtkMenu * menu)
102 {
103@@ -193,6 +196,8 @@
104 return;
105 }
106
107+/* When one of the children move we need to react to that and
108+ move it on the GTK side as well. */
109 static void
110 root_child_moved (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newposition, guint oldposition, DbusmenuGtkMenu * menu)
111 {
112@@ -202,6 +207,7 @@
113 return;
114 }
115
116+/* When a root child item disappears. */
117 static void
118 root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGtkMenu * menu)
119 {
120@@ -212,6 +218,8 @@
121 return;
122 }
123
124+/* Called when the child is realized, and thus has all of it's
125+ properties and GTK-isms. We can put it in our menu here. */
126 static void
127 child_realized (DbusmenuMenuitem * child, gpointer userdata)
128 {
129@@ -220,10 +228,20 @@
130 DbusmenuGtkMenu * menu = DBUSMENU_GTKMENU(userdata);
131 DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu);
132
133- gtk_menu_append(menu, GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)));
134+ GtkWidget * child_widget = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child));
135+
136+ if (child_widget != NULL) {
137+ gtk_menu_append(menu, child_widget);
138+ gtk_menu_reorder_child(GTK_MENU(menu), child_widget, dbusmenu_menuitem_get_position(child, dbusmenu_client_get_root(DBUSMENU_CLIENT(priv->client))));
139+ } else {
140+ g_warning("Child is realized, but doesn't have a GTK Widget!");
141+ }
142+
143 return;
144 }
145
146+/* When the root menuitem changes we need to resetup things so that
147+ we're back in the game. */
148 static void
149 root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGtkMenu * menu) {
150 if (newroot == NULL) {

Subscribers

People subscribed via source and target branches