aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-02-03 19:43:39 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-02-03 19:43:39 +0100
commit54b82d7275a9c37a815c7ed7840798c6492e9b81 (patch)
tree3ef9a6ecdeceb8a69701543332cdc26ff325df47
parent7595847dcd7e6e7f69a61031d1e3dfbe16f7baac (diff)
downloadayatana-indicator-messages-54b82d7275a9c37a815c7ed7840798c6492e9b81.tar.gz
ayatana-indicator-messages-54b82d7275a9c37a815c7ed7840798c6492e9b81.tar.bz2
ayatana-indicator-messages-54b82d7275a9c37a815c7ed7840798c6492e9b81.zip
Only draw right items as lozenges if they contain a count
-rw-r--r--src/dbus-data.h9
-rw-r--r--src/im-menu-item.c6
-rw-r--r--src/indicator-messages.c13
3 files changed, 24 insertions, 4 deletions
diff --git a/src/dbus-data.h b/src/dbus-data.h
index abff3aa..fac732e 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -13,10 +13,11 @@
#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"
-#define INDICATOR_MENUITEM_PROP_ICON "indicator-icon"
-#define INDICATOR_MENUITEM_PROP_RIGHT "right-side-text"
+#define INDICATOR_MENUITEM_TYPE "indicator-item"
+#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label"
+#define INDICATOR_MENUITEM_PROP_ICON "indicator-icon"
+#define INDICATOR_MENUITEM_PROP_RIGHT "right-side-text"
+#define INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE "right-is-lozenge"
#define MAX_NUMBER_OF_INDICATORS 7
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index 25fea52..e7c0177 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -340,6 +340,9 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate
g_free(priv->count);
priv->count = NULL;
update_time(self);
+ dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM (self),
+ INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE,
+ FALSE);
}
return;
}
@@ -350,6 +353,9 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate
priv->count = g_strdup_printf("%s", propertydata);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count);
+ dbusmenu_menuitem_property_set_bool (DBUSMENU_MENUITEM (self),
+ INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE,
+ TRUE);
return;
}
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index 34152ac..3059e1f 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -518,9 +518,14 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
PangoLayout * layout;
PangoRectangle layout_extents;
gint font_size = gtk_widget_get_font_size (widget);
+ gboolean is_lozenge = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "is-lozenge"));
if (!GTK_IS_WIDGET (widget)) return FALSE;
+ /* let the label handle the drawing if it's not a lozenge */
+ if (!is_lozenge)
+ return FALSE;
+
/* get style */
style = gtk_widget_get_style (widget);
@@ -637,6 +642,9 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value,
} else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT)) {
/* Set the right label */
gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL));
+ } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE)) {
+ g_object_set_data (G_OBJECT (mi_data->right), "is-lozenge", GINT_TO_POINTER (TRUE));
+ gtk_widget_queue_draw (mi_data->right);
} else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_ICON)) {
/* We don't use the value here, which is probably less efficient,
but it's easier to use the easy function. And since th value
@@ -743,6 +751,9 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
/* Usually either the time or the count on the individual
item. */
mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT));
+ g_object_set_data (G_OBJECT (mi_data->right),
+ "is-lozenge",
+ GINT_TO_POINTER (dbusmenu_menuitem_property_get_bool (newitem, INDICATOR_MENUITEM_PROP_RIGHT_IS_LOZENGE)));
/* install extra decoration overlay */
#if GTK_CHECK_VERSION(3, 0, 0)
g_signal_connect (G_OBJECT (mi_data->right), "draw",
@@ -755,6 +766,8 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0);
gtk_label_set_width_chars (GTK_LABEL (mi_data->right), 2);
+ gtk_style_context_add_class (gtk_widget_get_style_context (mi_data->right),
+ "accelerator");
gtk_widget_show(mi_data->right);
gtk_container_add(GTK_CONTAINER(gmi), hbox);