Merge lp:~bratsche/indicator-application/menu-changes into lp:indicator-application/0.4

Proposed by Cody Russell
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bratsche/indicator-application/menu-changes
Merge into: lp:indicator-application/0.4
Diff against target: 172 lines (+59/-35)
2 files modified
example/simple-client.c (+3/-2)
src/libappindicator/app-indicator.c (+56/-33)
To merge this branch: bzr merge lp:~bratsche/indicator-application/menu-changes
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+19205@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Cody Russell (bratsche) wrote :

This branch fixes issues where menuitems' visibility isn't reflected remotely on the app indicator.

It also watches for additions or removals of menuitems to the GtkMenu, and when those happen it causes the dbusmenu to rebuild itself.

Revision history for this message
Ted Gould (ted) wrote :

Approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'example/simple-client.c'
2--- example/simple-client.c 2010-02-12 01:54:18 +0000
3+++ example/simple-client.c 2010-02-12 21:45:28 +0000
4@@ -57,7 +57,6 @@
5 {
6 GtkWidget *target = (GtkWidget *)data;
7
8- gtk_menu_item_set_label (GTK_MENU_ITEM (target), "modified!!");
9 gtk_widget_set_sensitive (target, !GTK_WIDGET_IS_SENSITIVE (target));
10 }
11
12@@ -73,6 +72,7 @@
13 {
14 GtkWidget *menu;
15 GtkWidget *mi;
16+ GtkWidget *prev_mi;
17
18 menu = gtk_menu_new ();
19
20@@ -81,10 +81,11 @@
21 g_signal_connect (mi, "activate",
22 G_CALLBACK (item_clicked_cb), "Sub 1");
23
24+ prev_mi = mi;
25 mi = gtk_menu_item_new_with_label ("Sub 2");
26 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
27 g_signal_connect (mi, "activate",
28- G_CALLBACK (item_clicked_cb), "Sub 2");
29+ G_CALLBACK (toggle_sensitivity_cb), prev_mi);
30
31 mi = gtk_menu_item_new_with_label ("Sub 3");
32 gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
33
34=== modified file 'src/libappindicator/app-indicator.c'
35--- src/libappindicator/app-indicator.c 2010-02-12 21:23:20 +0000
36+++ src/libappindicator/app-indicator.c 2010-02-12 21:45:28 +0000
37@@ -447,23 +447,23 @@
38
39 switch (prop_id) {
40 case PROP_ID:
41- if (priv->id != NULL) {
42- g_warning ("Resetting ID value when I already had a value of: %s", priv->id);
43- break;
44- }
45-
46- priv->id = g_strdup (g_value_get_string (value));
47-
48- priv->clean_id = g_strdup(priv->id);
49- gchar * cleaner;
50- for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) {
51- if (!g_ascii_isalnum(*cleaner)) {
52- *cleaner = '_';
53- }
54- }
55-
56- check_connect (self);
57- break;
58+ if (priv->id != NULL) {
59+ g_warning ("Resetting ID value when I already had a value of: %s", priv->id);
60+ break;
61+ }
62+
63+ priv->id = g_strdup (g_value_get_string (value));
64+
65+ priv->clean_id = g_strdup(priv->id);
66+ gchar * cleaner;
67+ for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) {
68+ if (!g_ascii_isalnum(*cleaner)) {
69+ *cleaner = '_';
70+ }
71+ }
72+
73+ check_connect (self);
74+ break;
75
76 case PROP_CATEGORY:
77 enum_val = g_enum_get_value_by_nick ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY),
78@@ -506,11 +506,11 @@
79 break;
80
81 case PROP_ICON_THEME_PATH:
82- if (priv->icon_path != NULL) {
83- g_free(priv->icon_path);
84- }
85- priv->icon_path = g_value_dup_string(value);
86- break;
87+ if (priv->icon_path != NULL) {
88+ g_free(priv->icon_path);
89+ }
90+ priv->icon_path = g_value_dup_string(value);
91+ break;
92
93 default:
94 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
95@@ -556,14 +556,14 @@
96 break;
97
98 case PROP_MENU:
99- if (priv->menuservice != NULL) {
100- GValue strval = {0};
101- g_value_init(&strval, G_TYPE_STRING);
102- g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval);
103- g_value_set_boxed(value, g_value_get_string(&strval));
104- g_value_unset(&strval);
105- }
106- break;
107+ if (priv->menuservice != NULL) {
108+ GValue strval = { 0 };
109+ g_value_init(&strval, G_TYPE_STRING);
110+ g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval);
111+ g_value_set_boxed(value, g_value_get_string(&strval));
112+ g_value_unset(&strval);
113+ }
114+ break;
115
116 case PROP_CONNECTED:
117 g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE);
118@@ -1128,6 +1128,12 @@
119 DBUSMENU_MENUITEM_PROP_LABEL,
120 gtk_menu_item_get_label (GTK_MENU_ITEM (widget)));
121 }
122+ else if (pspec->name == g_intern_static_string ("visible"))
123+ {
124+ dbusmenu_menuitem_property_set_bool (child,
125+ DBUSMENU_MENUITEM_PROP_VISIBLE,
126+ gtk_widget_get_visible (widget));
127+ }
128 }
129
130 static void
131@@ -1262,14 +1268,22 @@
132 return;
133 }
134
135+static void
136+client_menu_changed (GtkWidget *widget,
137+ GtkWidget *child,
138+ AppIndicator *indicator)
139+{
140+ setup_dbusmenu (indicator);
141+}
142+
143 /**
144 app_indicator_set_menu:
145 @self: The #AppIndicator
146 @menu: A #GtkMenu to set
147
148- Sets the menu that should be shown when the Application Indicator
149- is clicked on in the panel. An application indicator will not
150- be rendered unless it has a menu.
151+ Sets the menu that should be shown when the Application Indicator
152+ is clicked on in the panel. An application indicator will not
153+ be rendered unless it has a menu.
154 **/
155 void
156 app_indicator_set_menu (AppIndicator *self, GtkMenu *menu)
157@@ -1293,6 +1307,15 @@
158 setup_dbusmenu (self);
159
160 check_connect (self);
161+
162+ g_signal_connect (menu,
163+ "add",
164+ G_CALLBACK (client_menu_changed),
165+ self);
166+ g_signal_connect (menu,
167+ "remove",
168+ G_CALLBACK (client_menu_changed),
169+ self);
170 }
171
172 /**

Subscribers

People subscribed via source and target branches