[empathy: 2/3] Use pixbuf for PixbufCellRenderer in protocol chooser



commit b0bd73cfa5658971f12c86a1f3711cab663a3f40
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Sun May 29 09:02:32 2011 -0700

    Use pixbuf for PixbufCellRenderer in protocol chooser
    
    If an icon-name is given to a PixbufCellRenderer it will re-load the
    image from the icon theme every time the size gets requested for a
    different cell. Which happens a *LOT*.
    
    Instead load the icon the row is added to the model, such that the
    cell renderer can simply request the size of the pixbuf. This massive
    speeds up the performance of the protocol chooser combobox.

 libempathy-gtk/empathy-account-chooser.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index 2b0478e..2df4a15 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -609,7 +609,7 @@ account_chooser_setup (EmpathyAccountChooser *chooser)
 	gtk_cell_layout_clear (GTK_CELL_LAYOUT (combobox));
 
 	store = gtk_list_store_new (COL_ACCOUNT_COUNT,
-				    G_TYPE_STRING,    /* Image */
+				    GDK_TYPE_PIXBUF,    /* Image */
 				    G_TYPE_STRING,    /* Name */
 				    G_TYPE_BOOLEAN,   /* Enabled */
 				    G_TYPE_UINT,      /* Row type */
@@ -625,10 +625,9 @@ account_chooser_setup (EmpathyAccountChooser *chooser)
 	renderer = gtk_cell_renderer_pixbuf_new ();
 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, FALSE);
 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer,
-					"icon-name", COL_ACCOUNT_IMAGE,
+					"pixbuf", COL_ACCOUNT_IMAGE,
 					"sensitive", COL_ACCOUNT_ENABLED,
 					NULL);
-	g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
 
 	renderer = gtk_cell_renderer_text_new ();
 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
@@ -763,6 +762,7 @@ account_chooser_filter_ready_cb (gboolean is_enabled,
 	GtkListStore              *store;
 	GtkComboBox               *combobox;
 	const gchar               *icon_name;
+	GdkPixbuf                 *pixbuf;
 
 	chooser = fr_data->chooser;
 	priv = GET_PRIV (chooser);
@@ -772,13 +772,18 @@ account_chooser_filter_ready_cb (gboolean is_enabled,
 	store = GTK_LIST_STORE (gtk_combo_box_get_model (combobox));
 
 	icon_name = tp_account_get_icon_name (account);
+	pixbuf = empathy_pixbuf_from_icon_name (icon_name,
+		GTK_ICON_SIZE_BUTTON);
 
 	gtk_list_store_set (store, iter,
-			    COL_ACCOUNT_IMAGE, icon_name,
+			    COL_ACCOUNT_IMAGE, pixbuf,
 			    COL_ACCOUNT_TEXT, tp_account_get_display_name (account),
 			    COL_ACCOUNT_ENABLED, is_enabled,
 			    -1);
 
+	if (pixbuf != NULL)
+		g_object_unref (pixbuf);
+
 	/* set first connected account as active account */
 	if (priv->account_manually_set == FALSE &&
 	    priv->set_active_item == FALSE && is_enabled) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]