aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app-menu-item.c3
-rw-r--r--src/dbus-data.h5
-rw-r--r--src/indicator-messages.c37
-rw-r--r--src/launcher-menu-item.c2
-rw-r--r--src/messages-service.c1
5 files changed, 36 insertions, 12 deletions
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index c276a90..0b0588e 100644
--- a/src/app-menu-item.c
+++ b/src/app-menu-item.c
@@ -328,6 +328,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar
priv->desktop = g_strdup(value);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_RUNNING, TRUE);
update_label(self);
@@ -355,7 +356,6 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio
AppMenuItem * self = APP_MENU_ITEM(data);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child);
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
priv->shortcuts = g_list_insert(priv->shortcuts, mip, position);
@@ -456,7 +456,6 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data
g_debug("\tProcessing %d children", g_list_length(children));
while (children != NULL) {
DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data));
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
priv->shortcuts = g_list_append(priv->shortcuts, mip);
g_signal_emit(G_OBJECT(self), signals[SHORTCUT_ADDED], 0, mip, TRUE);
children = g_list_next(children);
diff --git a/src/dbus-data.h b/src/dbus-data.h
index c16b2b5..100ac0a 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -9,8 +9,9 @@
#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service"
#define APPLICATION_MENUITEM_TYPE "application-item"
-#define APPLICATION_MENUITEM_PROP_NAME "app-name"
-#define APPLICATION_MENUITEM_PROP_ICON "app-icon"
+#define APPLICATION_MENUITEM_PROP_NAME "label"
+#define APPLICATION_MENUITEM_PROP_ICON "icon-name"
+#define APPLICATION_MENUITEM_PROP_RUNNING "app-running"
#define INDICATOR_MENUITEM_TYPE "indicator-item"
#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label"
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index df2d972..302b9e5 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -287,6 +287,11 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value,
}
}
+ if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_RUNNING)) {
+ /* TODO: should hide/show the triangle live if the menu was open.
+ In practice, this is rarely needed. */
+ }
+
return;
}
@@ -299,13 +304,18 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer
int x, y, arrow_width, arrow_height;
if (!GTK_IS_WIDGET (widget)) return FALSE;
+ if (!DBUSMENU_IS_MENUITEM (data)) return FALSE;
+
+ /* render the triangle indicator only if the application is running */
+ if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), APPLICATION_MENUITEM_PROP_RUNNING))
+ return FALSE;;
/* get style */
style = gtk_widget_get_style (widget);
/* set arrow position / dimensions */
- arrow_width = (int) ((double)widget->allocation.height * 0.25f);
- arrow_height = (int) ((double)widget->allocation.height * 0.50f);
+ arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
+ arrow_height = 9;
x = widget->allocation.x;
y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0;
@@ -326,7 +336,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer
cairo_fill (cr);
/* remember to destroy cairo context to avoid leaks */
- cairo_destroy (cr);
+ cairo_destroy (cr);
return FALSE;
}
@@ -404,7 +414,10 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
static gboolean
new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
+ g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
+
GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new());
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE);
gint padding = 4;
gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL);
@@ -416,9 +429,12 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu
gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU);
- gtk_widget_set_size_request(icon, width, height);
- gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding);
+ gtk_widget_set_size_request(icon, width
+ + 5 /* ref triangle is 5x9 pixels */
+ + 2 /* padding */,
+ height);
+ gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5);
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon);
gtk_widget_show(icon);
/* Application name in a label */
@@ -489,6 +505,10 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, i
if (resized_pixbuf != pixbuf) {
g_object_unref(resized_pixbuf);
}
+
+ gtk_widget_show(mi_data->icon);
+ } else {
+ gtk_widget_hide(mi_data->icon);
}
}
@@ -550,7 +570,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
}
gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding);
- gtk_widget_show(mi_data->icon);
+
+ if (pixbuf != NULL) {
+ gtk_widget_show(mi_data->icon);
+ }
/* Label, probably a username, chat room or mailbox name */
mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL));
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 63e5594..a47af03 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -197,9 +197,9 @@ launcher_menu_item_new (const gchar * desktop_file)
gint i;
for (i = 0; nicks[i] != NULL; i++) {
DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]);
- dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]));
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self);
diff --git a/src/messages-service.c b/src/messages-service.c
index 0783d91..b87c2ff 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -1346,6 +1346,7 @@ build_launcher_core (const gchar * desktop)
launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort);
/* Add it to the menu */
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(ll->menuitem), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem));
GList * shortcuts = launcher_menu_item_get_items(ll->menuitem);
while (shortcuts != NULL) {