aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-09-04 19:20:20 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-09-04 19:20:20 +0200
commit6a496d6b6b4a3a102d8177fadd0b2faeb8ac646a (patch)
tree1fbe9c4277ff291c951e0ce98ea281309397d343 /src
parent4f9764785ecaf4bb4b43211340eeb37741c09ccc (diff)
downloadayatana-indicator-messages-6a496d6b6b4a3a102d8177fadd0b2faeb8ac646a.tar.gz
ayatana-indicator-messages-6a496d6b6b4a3a102d8177fadd0b2faeb8ac646a.tar.bz2
ayatana-indicator-messages-6a496d6b6b4a3a102d8177fadd0b2faeb8ac646a.zip
ido-detail-label: factor common code out of set_text and _count
This was only half-heartedly done with the _clear function, which left a dangling pointer. Contributed by Charles Kerr. Thanks!
Diffstat (limited to 'src')
-rw-r--r--src/ido-detail-label.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/ido-detail-label.c b/src/ido-detail-label.c
index 2b996c9..780a2dd 100644
--- a/src/ido-detail-label.c
+++ b/src/ido-detail-label.c
@@ -309,13 +309,6 @@ ido_detail_label_get_text (IdoDetailLabel *label)
return label->priv->text;
}
-static void
-ido_detail_label_clear (IdoDetailLabel *label)
-{
- g_free (label->priv->text);
- g_clear_object (&label->priv->layout);
-}
-
/* collapse_whitespace:
* @str: the source string
*
@@ -359,38 +352,45 @@ collapse_whitespace (const gchar *str)
return g_string_free (result, FALSE);
}
+static void
+ido_detail_label_set_text_impl (IdoDetailLabel *label,
+ const gchar *text,
+ gboolean draw_lozenge)
+{
+ IdoDetailLabelPrivate * priv = label->priv;
+
+ g_clear_object (&priv->layout);
+ g_free (priv->text);
+
+ priv->text = g_strdup (text);
+ priv->draw_lozenge = draw_lozenge;
+
+ g_object_notify_by_pspec (G_OBJECT (label), properties[PROP_TEXT]);
+ gtk_widget_queue_resize (GTK_WIDGET (label));
+}
+
void
ido_detail_label_set_text (IdoDetailLabel *label,
const gchar *text)
{
- IdoDetailLabelPrivate *priv;
+ gchar *str;
g_return_if_fail (IDO_IS_DETAIL_LABEL (label));
- priv = label->priv;
- ido_detail_label_clear (label);
-
- priv->text = collapse_whitespace (text);
- label->priv->draw_lozenge = FALSE;
-
- g_object_notify_by_pspec (G_OBJECT (label), properties[PROP_TEXT]);
- gtk_widget_queue_resize (GTK_WIDGET (label));
+ str = collapse_whitespace (text);
+ ido_detail_label_set_text_impl (label, str, FALSE);
+ g_free (str);
}
void
ido_detail_label_set_count (IdoDetailLabel *label,
gint count)
{
- IdoDetailLabelPrivate *priv;
+ gchar *text;
g_return_if_fail (IDO_IS_DETAIL_LABEL (label));
- priv = label->priv;
-
- ido_detail_label_clear (label);
- priv->text = g_strdup_printf ("%d", count);
- label->priv->draw_lozenge = TRUE;
-
- g_object_notify_by_pspec (G_OBJECT (label), properties[PROP_TEXT]);
- gtk_widget_queue_resize (GTK_WIDGET (label));
+ text = g_strdup_printf ("%d", count);
+ ido_detail_label_set_text_impl (label, text, TRUE);
+ g_free (text);
}