diff options
Diffstat (limited to 'src/indicator-messages.c')
-rw-r--r-- | src/indicator-messages.c | 37 |
1 files changed, 30 insertions, 7 deletions
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)); |