]> git.0d.be Git - empathy.git/commitdiff
Use pixbuf for PixbufCellRenderer in protocol chooser
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 29 May 2011 16:02:32 +0000 (09:02 -0700)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Sun, 29 May 2011 16:02:32 +0000 (09:02 -0700)
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

index 2b0478e79831fb0e7817405b40d7e0fbcaa6bf99..2df4a153a4c006b7f8ffde8873fe0630939baeaf 100644 (file)
@@ -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) {