[Telepathy] [PATCH 2/9] Chooser: factor CellLayout creation code in empathy_chooser_setup_cell_layout
Niv Sardi
xaiki at debian.org
Mon Jun 8 13:31:37 PDT 2009
And use it to give the completion menu a layout, and icons next to the
completion entries !
Signed-off-by: Niv Sardi <xaiki at debian.org>
---
libempathy-gtk/empathy-presence-chooser.c | 39 +++++++++++++++++-----------
1 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 16e364c..7a2a52e 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -152,6 +152,27 @@ empathy_presence_chooser_class_init (EmpathyPresenceChooserClass *klass)
}
static void
+empathy_chooser_setup_cell_layout (GtkCellLayout *layout)
+{
+ GtkCellRenderer *renderer;
+
+ gtk_cell_layout_clear (layout);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (layout, renderer, FALSE);
+ gtk_cell_layout_set_attributes (layout, renderer,
+ "icon-name", COL_STATE_ICON_NAME,
+ NULL);
+ g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (layout, renderer, TRUE);
+ gtk_cell_layout_set_attributes (layout, renderer,
+ "markup", COL_DISPLAY_MARKUP,
+ NULL);
+}
+
+static void
presence_chooser_create_model (EmpathyPresenceChooser *self)
{
GtkListStore *store;
@@ -237,6 +258,8 @@ presence_chooser_create_model (EmpathyPresenceChooser *self)
gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
gtk_entry_completion_set_text_column (completion, COL_STATUS_TEXT);
gtk_entry_completion_set_inline_completion(completion, TRUE);
+
+ empathy_chooser_setup_cell_layout (GTK_CELL_LAYOUT (completion));
gtk_entry_set_completion (GTK_ENTRY (entry), completion);
g_object_unref (store);
@@ -722,7 +745,6 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
EmpathyPresenceChooserPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser,
EMPATHY_TYPE_PRESENCE_CHOOSER, EmpathyPresenceChooserPriv);
GtkWidget *entry;
- GtkCellRenderer *renderer;
chooser->priv = priv;
@@ -752,20 +774,7 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
G_CALLBACK (presence_chooser_entry_button_press_event_cb),
chooser);
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (chooser));
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
- "icon-name", COL_STATE_ICON_NAME,
- NULL);
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_MENU, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (chooser), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (chooser), renderer,
- "markup", COL_DISPLAY_MARKUP,
- NULL);
+ empathy_chooser_setup_cell_layout (GTK_CELL_LAYOUT (chooser));
g_signal_connect (chooser, "notify::popup-shown",
G_CALLBACK (presence_chooser_popup_shown_cb), NULL);
--
1.6.3.1
More information about the telepathy
mailing list