Merge lp:~dbarth/indicator-messages/triangle-n-icon into lp:indicator-messages/0.5

Proposed by David Barth
Status: Merged
Merged at revision: 195
Proposed branch: lp:~dbarth/indicator-messages/triangle-n-icon
Merge into: lp:indicator-messages/0.5
Diff against target: 166 lines (+36/-12)
5 files modified
src/app-menu-item.c (+1/-2)
src/dbus-data.h (+3/-2)
src/indicator-messages.c (+30/-7)
src/launcher-menu-item.c (+1/-1)
src/messages-service.c (+1/-0)
To merge this branch: bzr merge lp:~dbarth/indicator-messages/triangle-n-icon
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+33828@code.launchpad.net

Description of the change

Adjusts the icon position of application menuitems, also makes sure launcher menu items are seen as app-menu-items too.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Seems fine, sad to loose even more relative sizing of the arrows moving to fixed pixel sizes.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app-menu-item.c'
2--- src/app-menu-item.c 2010-04-16 15:12:11 +0000
3+++ src/app-menu-item.c 2010-08-26 19:41:23 +0000
4@@ -328,6 +328,7 @@
5 priv->desktop = g_strdup(value);
6
7 dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
8+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_RUNNING, TRUE);
9
10 update_label(self);
11
12@@ -355,7 +356,6 @@
13 AppMenuItem * self = APP_MENU_ITEM(data);
14 AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
15 DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child);
16- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
17
18 priv->shortcuts = g_list_insert(priv->shortcuts, mip, position);
19
20@@ -456,7 +456,6 @@
21 g_debug("\tProcessing %d children", g_list_length(children));
22 while (children != NULL) {
23 DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data));
24- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
25 priv->shortcuts = g_list_append(priv->shortcuts, mip);
26 g_signal_emit(G_OBJECT(self), signals[SHORTCUT_ADDED], 0, mip, TRUE);
27 children = g_list_next(children);
28
29=== modified file 'src/dbus-data.h'
30--- src/dbus-data.h 2010-03-23 20:45:35 +0000
31+++ src/dbus-data.h 2010-08-26 19:41:23 +0000
32@@ -9,8 +9,9 @@
33 #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service"
34
35 #define APPLICATION_MENUITEM_TYPE "application-item"
36-#define APPLICATION_MENUITEM_PROP_NAME "app-name"
37-#define APPLICATION_MENUITEM_PROP_ICON "app-icon"
38+#define APPLICATION_MENUITEM_PROP_NAME "label"
39+#define APPLICATION_MENUITEM_PROP_ICON "icon-name"
40+#define APPLICATION_MENUITEM_PROP_RUNNING "app-running"
41
42 #define INDICATOR_MENUITEM_TYPE "indicator-item"
43 #define INDICATOR_MENUITEM_PROP_LABEL "indicator-label"
44
45=== modified file 'src/indicator-messages.c'
46--- src/indicator-messages.c 2010-07-29 16:09:26 +0000
47+++ src/indicator-messages.c 2010-08-26 19:41:23 +0000
48@@ -287,6 +287,11 @@
49 }
50 }
51
52+ if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_RUNNING)) {
53+ /* TODO: should hide/show the triangle live if the menu was open.
54+ In practice, this is rarely needed. */
55+ }
56+
57 return;
58 }
59
60@@ -299,13 +304,18 @@
61 int x, y, arrow_width, arrow_height;
62
63 if (!GTK_IS_WIDGET (widget)) return FALSE;
64+ if (!DBUSMENU_IS_MENUITEM (data)) return FALSE;
65+
66+ /* render the triangle indicator only if the application is running */
67+ if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), APPLICATION_MENUITEM_PROP_RUNNING))
68+ return FALSE;;
69
70 /* get style */
71 style = gtk_widget_get_style (widget);
72
73 /* set arrow position / dimensions */
74- arrow_width = (int) ((double)widget->allocation.height * 0.25f);
75- arrow_height = (int) ((double)widget->allocation.height * 0.50f);
76+ arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
77+ arrow_height = 9;
78 x = widget->allocation.x;
79 y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0;
80
81@@ -326,7 +336,7 @@
82 cairo_fill (cr);
83
84 /* remember to destroy cairo context to avoid leaks */
85- cairo_destroy (cr);
86+ cairo_destroy (cr);
87
88 return FALSE;
89 }
90@@ -404,7 +414,10 @@
91 static gboolean
92 new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
93 {
94+ g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
95+
96 GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new());
97+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE);
98
99 gint padding = 4;
100 gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL);
101@@ -416,9 +429,12 @@
102 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
103
104 GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU);
105- gtk_widget_set_size_request(icon, width, height);
106- gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5);
107- gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding);
108+ gtk_widget_set_size_request(icon, width
109+ + 5 /* ref triangle is 5x9 pixels */
110+ + 2 /* padding */,
111+ height);
112+ gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5);
113+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon);
114 gtk_widget_show(icon);
115
116 /* Application name in a label */
117@@ -489,6 +505,10 @@
118 if (resized_pixbuf != pixbuf) {
119 g_object_unref(resized_pixbuf);
120 }
121+
122+ gtk_widget_show(mi_data->icon);
123+ } else {
124+ gtk_widget_hide(mi_data->icon);
125 }
126 }
127
128@@ -550,7 +570,10 @@
129 }
130 gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5);
131 gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding);
132- gtk_widget_show(mi_data->icon);
133+
134+ if (pixbuf != NULL) {
135+ gtk_widget_show(mi_data->icon);
136+ }
137
138 /* Label, probably a username, chat room or mailbox name */
139 mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL));
140
141=== modified file 'src/launcher-menu-item.c'
142--- src/launcher-menu-item.c 2010-03-25 15:28:25 +0000
143+++ src/launcher-menu-item.c 2010-08-26 19:41:23 +0000
144@@ -197,9 +197,9 @@
145 gint i;
146 for (i = 0; nicks[i] != NULL; i++) {
147 DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
148+ dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
149 g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]);
150
151- dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
152 dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]));
153 g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self);
154
155
156=== modified file 'src/messages-service.c'
157--- src/messages-service.c 2010-04-28 10:33:57 +0000
158+++ src/messages-service.c 2010-08-26 19:41:23 +0000
159@@ -1346,6 +1346,7 @@
160 launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort);
161
162 /* Add it to the menu */
163+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(ll->menuitem), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
164 dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem));
165 GList * shortcuts = launcher_menu_item_get_items(ll->menuitem);
166 while (shortcuts != NULL) {

Subscribers

People subscribed via source and target branches