aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app-menu-item.c1
-rw-r--r--src/dbus-data.h5
-rw-r--r--src/indicator-messages.c26
-rw-r--r--src/launcher-menu-item.c1
-rw-r--r--src/messages-service.c1
5 files changed, 29 insertions, 5 deletions
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index 676f03e..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);
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 97220c6..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,6 +414,8 @@ 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);
@@ -413,7 +425,15 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu
GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
/* Set the minimum size, we always want it to take space */
+ gint width, height;
+ 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
+ + 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);
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 5d9de12..a47af03 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -197,6 +197,7 @@ 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_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]));
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) {