[empathy] roster-view: display the favorite icon for the 'top' group
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] roster-view: display the favorite icon for the 'top' group
- Date: Fri, 15 Jun 2012 11:19:33 +0000 (UTC)
commit 094e0583ad0361dd0981e5b9bf238a20e66248a3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Jun 14 17:42:28 2012 +0200
roster-view: display the favorite icon for the 'top' group
https://bugzilla.gnome.org/show_bug.cgi?id=678091
libempathy-gtk/empathy-roster-group.c | 45 +++++++++++++++++++++++++++++++-
libempathy-gtk/empathy-roster-group.h | 3 +-
libempathy-gtk/empathy-roster-view.c | 5 +++-
3 files changed, 49 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-roster-group.c b/libempathy-gtk/empathy-roster-group.c
index bffd6a8..643fed5 100644
--- a/libempathy-gtk/empathy-roster-group.c
+++ b/libempathy-gtk/empathy-roster-group.c
@@ -9,6 +9,7 @@ G_DEFINE_TYPE (EmpathyRosterGroup, empathy_roster_group, GTK_TYPE_EXPANDER)
enum
{
PROP_NAME = 1,
+ PROP_ICON,
N_PROPS
};
@@ -24,6 +25,7 @@ static guint signals[LAST_SIGNAL];
struct _EmpathyRosterGroupPriv
{
gchar *name;
+ gchar *icon_name;
/* Widgets associated with this group. EmpathyRosterGroup is not responsible
* of packing/displaying these widgets. This hash table is a just a set
@@ -44,6 +46,9 @@ empathy_roster_group_get_property (GObject *object,
case PROP_NAME:
g_value_set_string (value, self->priv->name);
break;
+ case PROP_ICON:
+ g_value_set_string (value, self->priv->icon_name);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -64,6 +69,10 @@ empathy_roster_group_set_property (GObject *object,
g_assert (self->priv->name == NULL); /* construct-only */
self->priv->name = g_value_dup_string (value);
break;
+ case PROP_ICON:
+ g_assert (self->priv->icon_name == NULL); /* construct-only */
+ self->priv->icon_name = g_value_dup_string (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -77,15 +86,38 @@ empathy_roster_group_constructed (GObject *object)
void (*chain_up) (GObject *) =
((GObjectClass *) empathy_roster_group_parent_class)->constructed;
gchar *tmp;
+ GtkWidget *box, *label;
if (chain_up != NULL)
chain_up (object);
g_assert (self->priv->name != NULL);
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+
+ /* Icon, if any */
+ if (!tp_str_empty (self->priv->icon_name))
+ {
+ GtkWidget *icon;
+
+ icon = gtk_image_new_from_icon_name (self->priv->icon_name,
+ GTK_ICON_SIZE_MENU);
+
+ if (icon != NULL)
+ gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0);
+ }
+
+ /* Label */
tmp = g_strdup_printf ("<b>%s</b>", self->priv->name);
- gtk_expander_set_label (GTK_EXPANDER (self), tmp);
+ label = gtk_label_new (tmp);
g_free (tmp);
+
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (box);
+
+ gtk_expander_set_label_widget (GTK_EXPANDER (self), box);
}
static void
@@ -109,6 +141,7 @@ empathy_roster_group_finalize (GObject *object)
((GObjectClass *) empathy_roster_group_parent_class)->finalize;
g_free (self->priv->name);
+ g_free (self->priv->icon_name);
if (chain_up != NULL)
chain_up (object);
@@ -133,6 +166,12 @@ empathy_roster_group_class_init (
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (oclass, PROP_NAME, spec);
+ spec = g_param_spec_string ("icon", "Icon",
+ "Icon name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (oclass, PROP_ICON, spec);
+
g_type_class_add_private (klass, sizeof (EmpathyRosterGroupPriv));
}
@@ -146,10 +185,12 @@ empathy_roster_group_init (EmpathyRosterGroup *self)
}
GtkWidget *
-empathy_roster_group_new (const gchar *name)
+empathy_roster_group_new (const gchar *name,
+ const gchar *icon)
{
return g_object_new (EMPATHY_TYPE_ROSTER_GROUP,
"name", name,
+ "icon", icon,
"use-markup", TRUE,
"expanded", TRUE,
NULL);
diff --git a/libempathy-gtk/empathy-roster-group.h b/libempathy-gtk/empathy-roster-group.h
index 314ed3b..405455b 100644
--- a/libempathy-gtk/empathy-roster-group.h
+++ b/libempathy-gtk/empathy-roster-group.h
@@ -46,7 +46,8 @@ GType empathy_roster_group_get_type (void);
EMPATHY_TYPE_ROSTER_GROUP, \
EmpathyRosterGroupClass))
-GtkWidget * empathy_roster_group_new (const gchar *name);
+GtkWidget * empathy_roster_group_new (const gchar *name,
+ const gchar *icon);
const gchar * empathy_roster_group_get_name (EmpathyRosterGroup *self);
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index 130fbab..201c5e6 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -221,7 +221,10 @@ ensure_roster_group (EmpathyRosterView *self,
if (roster_group != NULL)
return EMPATHY_ROSTER_GROUP (roster_group);
- roster_group = empathy_roster_group_new (group);
+ if (!tp_strdiff (group, TOP_GROUP))
+ roster_group = empathy_roster_group_new (group, "emblem-favorite-symbolic");
+ else
+ roster_group = empathy_roster_group_new (group, NULL);
g_signal_connect (roster_group, "notify::expanded",
G_CALLBACK (group_expanded_cb), self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]