aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libindicator/indicator-ng.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/libindicator/indicator-ng.c b/libindicator/indicator-ng.c
index 05ece8d..f27fbf0 100644
--- a/libindicator/indicator-ng.c
+++ b/libindicator/indicator-ng.c
@@ -161,11 +161,17 @@ indicator_ng_set_icon_from_string (IndicatorNg *self,
if (str == NULL || *str == '\0')
{
- gtk_image_clear (self->entry.image);
- gtk_widget_hide (GTK_WIDGET (self->entry.image));
+ if (self->entry.image)
+ {
+ gtk_image_clear (self->entry.image);
+ gtk_widget_hide (GTK_WIDGET (self->entry.image));
+ }
return;
}
+ if (!self->entry.image)
+ self->entry.image = g_object_ref_sink (gtk_image_new ());
+
gtk_widget_show (GTK_WIDGET (self->entry.image));
icon = g_icon_new_for_string (str, &error);
@@ -183,6 +189,24 @@ indicator_ng_set_icon_from_string (IndicatorNg *self,
}
static void
+indicator_ng_set_label (IndicatorNg *self,
+ const gchar *label)
+{
+ if (label == NULL || *label == '\0')
+ {
+ if (self->entry.label)
+ gtk_widget_hide (GTK_WIDGET (self->entry.label));
+ return;
+ }
+
+ if (!self->entry.label)
+ self->entry.label = g_object_ref_sink (gtk_label_new (NULL));
+
+ gtk_label_set_label (GTK_LABEL (self->entry.label), label);
+ gtk_widget_show (GTK_WIDGET (self->entry.label));
+}
+
+static void
indicator_ng_update_entry (IndicatorNg *self)
{
GVariant *state;
@@ -207,7 +231,7 @@ indicator_ng_update_entry (IndicatorNg *self)
g_variant_get (state, "(&s&s&sb)", &label, &iconstr, &accessible_desc, &visible);
- gtk_label_set_label (GTK_LABEL (self->entry.label), label);
+ indicator_ng_set_label (self, label);
indicator_ng_set_icon_from_string (self, iconstr);
indicator_ng_set_accessible_desc (self, accessible_desc);
indicator_object_set_visible (INDICATOR_OBJECT (self), visible);
@@ -407,10 +431,6 @@ indicator_ng_initable_iface_init (GInitableIface *initable)
static void
indicator_ng_init (IndicatorNg *self)
{
- self->entry.label = g_object_ref_sink (gtk_label_new (NULL));
- gtk_widget_show (GTK_WIDGET (self->entry.label));
-
- self->entry.image = g_object_ref_sink (gtk_image_new ());
self->entry.menu = g_object_ref_sink (gtk_menu_new ());
/* work around IndicatorObject's warning that the accessible