++ gnome-control-center-2.32.1/debian/patches/142_fix_icons_for_default_apps.patch Description: Fix icons for new glib url handlers Author: Michael Terry Bug: https://bugzilla.gnome.org/show_bug.cgi?id=638775 Index: gnome-control-center-2.32.1/capplets/default-applications/gnome-da-capplet.c =================================================================== --- gnome-control-center-2.32.1.orig/capplets/default-applications/gnome-da-capplet.c 2011-01-05 16:05:40.623854462 -0500 +++ gnome-control-center-2.32.1/capplets/default-applications/gnome-da-capplet.c 2011-01-05 16:12:03.030460004 -0500 @@ -35,7 +35,7 @@ enum { - PIXBUF_COL, + ICON_COL, TEXT_COL, N_COLUMNS }; @@ -193,33 +193,6 @@ gtk_widget_set_sensitive (capplet->mobility_command_label, is_custom_active); } -static void -refresh_combo_box_icons (GtkIconTheme *theme, GtkComboBox *combo_box, GList *app_list) -{ - GList *entry; - GnomeDAItem *item; - GtkTreeModel *model; - GtkTreeIter iter; - GdkPixbuf *pixbuf; - - for (entry = app_list; entry != NULL; entry = g_list_next (entry)) { - item = (GnomeDAItem *) entry->data; - - model = gtk_combo_box_get_model (combo_box); - - if (item->icon_path && gtk_tree_model_get_iter_from_string (model, &iter, item->icon_path)) { - pixbuf = gtk_icon_theme_load_icon (theme, item->icon_name, 22, 0, NULL); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - PIXBUF_COL, pixbuf, - -1); - - if (pixbuf) - g_object_unref (pixbuf); - } - } -} - static struct { const gchar *name; const gchar *icon; @@ -246,13 +219,6 @@ icon = gtk_builder_get_object (capplet->builder, icons[i].name); set_icon (GTK_IMAGE (icon), theme, icons[i].icon); } - - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers); - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers); - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players); - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals); - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats); - refresh_combo_box_icons (theme, GTK_COMBO_BOX (capplet->mobility_combo_box), capplet->mobility_ats); } static void @@ -397,33 +363,31 @@ } static void -fill_combo_box (GtkIconTheme *theme, GtkComboBox *combo_box, GList *app_list, gboolean add_custom) +fill_combo_box (GtkComboBox *combo_box, GList *app_list, gboolean add_custom) { GList *entry; GtkTreeModel *model; GtkCellRenderer *renderer; GtkTreeIter iter; - GdkPixbuf *pixbuf; - - if (theme == NULL) { - theme = gtk_icon_theme_get_default (); - } if (add_custom) { gtk_combo_box_set_row_separator_func (combo_box, is_separator, GINT_TO_POINTER (g_list_length (app_list)), NULL); } - model = GTK_TREE_MODEL (gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING)); + model = GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_ICON, G_TYPE_STRING)); gtk_combo_box_set_model (combo_box, model); renderer = gtk_cell_renderer_pixbuf_new (); /* not all cells have a pixbuf, this prevents the combo box to shrink */ - gtk_cell_renderer_set_fixed_size (renderer, -1, 22); + gtk_cell_renderer_set_fixed_size (renderer, -1, 24); + g_object_set (G_OBJECT (renderer), + "stock-size", GTK_ICON_SIZE_LARGE_TOOLBAR, + NULL); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "pixbuf", PIXBUF_COL, + "gicon", ICON_COL, NULL); renderer = gtk_cell_renderer_text_new (); @@ -436,18 +400,11 @@ GnomeDAItem *item; item = (GnomeDAItem *) entry->data; - pixbuf = gtk_icon_theme_load_icon (theme, item->icon_name, 22, 0, NULL); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - PIXBUF_COL, pixbuf, + ICON_COL, item->icon, TEXT_COL, item->name, -1); - - item->icon_path = gtk_tree_model_get_string_from_iter (model, &iter); - - if (pixbuf) - g_object_unref (pixbuf); } if (add_custom) { @@ -455,7 +412,7 @@ gtk_list_store_set (GTK_LIST_STORE (model), &iter, -1); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - PIXBUF_COL, NULL, + ICON_COL, NULL, TEXT_COL, _("Custom"), -1); } @@ -528,12 +485,12 @@ g_signal_connect (capplet->window, "screen-changed", G_CALLBACK (screen_changed_cb), capplet); screen_changed_cb (capplet->window, gdk_screen_get_default (), capplet); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers, FALSE); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers, FALSE); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals, TRUE); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players, TRUE); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats, TRUE); - fill_combo_box (capplet->icon_theme, GTK_COMBO_BOX (capplet->mobility_combo_box), capplet->mobility_ats, TRUE); + fill_combo_box (GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers, FALSE); + fill_combo_box (GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers, FALSE); + fill_combo_box (GTK_COMBO_BOX (capplet->term_combo_box), capplet->terminals, TRUE); + fill_combo_box (GTK_COMBO_BOX (capplet->media_combo_box), capplet->media_players, TRUE); + fill_combo_box (GTK_COMBO_BOX (capplet->visual_combo_box), capplet->visual_ats, TRUE); + fill_combo_box (GTK_COMBO_BOX (capplet->mobility_combo_box), capplet->mobility_ats, TRUE); set_combo_to_default_for_scheme (GTK_COMBO_BOX (capplet->web_combo_box), capplet->web_browsers, "http"); set_combo_to_default_for_scheme (GTK_COMBO_BOX (capplet->mail_combo_box), capplet->mail_readers, "mailto"); Index: gnome-control-center-2.32.1/capplets/default-applications/gnome-da-item.c =================================================================== --- gnome-control-center-2.32.1.orig/capplets/default-applications/gnome-da-item.c 2011-01-05 16:04:48.644316418 -0500 +++ gnome-control-center-2.32.1/capplets/default-applications/gnome-da-item.c 2011-01-05 16:05:40.653854197 -0500 @@ -79,8 +79,8 @@ g_free (item->generic.name); g_free (item->generic.executable); g_free (item->generic.command); - g_free (item->generic.icon_name); - g_free (item->generic.icon_path); + if (item->generic.icon) + g_object_unref (item->generic.icon); g_object_unref (item->app_info); @@ -95,8 +95,8 @@ g_free (item->generic.name); g_free (item->generic.executable); g_free (item->generic.command); - g_free (item->generic.icon_name); - g_free (item->generic.icon_path); + if (item->generic.icon) + g_object_unref (item->generic.icon); g_free (item); } @@ -109,8 +109,8 @@ g_free (item->generic.name); g_free (item->generic.executable); g_free (item->generic.command); - g_free (item->generic.icon_name); - g_free (item->generic.icon_path); + if (item->generic.icon) + g_object_unref (item->generic.icon); g_free (item->exec_flag); @@ -125,8 +125,8 @@ g_free (item->generic.name); g_free (item->generic.executable); g_free (item->generic.command); - g_free (item->generic.icon_name); - g_free (item->generic.icon_path); + if (item->generic.icon) + g_object_unref (item->generic.icon); g_free (item); } @@ -139,8 +139,8 @@ g_free (item->generic.name); g_free (item->generic.executable); g_free (item->generic.command); - g_free (item->generic.icon_name); - g_free (item->generic.icon_path); + if (item->generic.icon) + g_object_unref (item->generic.icon); g_free (item); } Index: gnome-control-center-2.32.1/capplets/default-applications/gnome-da-item.h =================================================================== --- gnome-control-center-2.32.1.orig/capplets/default-applications/gnome-da-item.h 2011-01-05 16:04:48.684316062 -0500 +++ gnome-control-center-2.32.1/capplets/default-applications/gnome-da-item.h 2011-01-05 16:05:40.653854197 -0500 @@ -35,8 +35,7 @@ gchar *name; gchar *executable; gchar *command; - gchar *icon_name; - gchar *icon_path; + GIcon *icon; }; struct _GnomeDASimpleItem { Index: gnome-control-center-2.32.1/capplets/default-applications/gnome-da-xml.c =================================================================== --- gnome-control-center-2.32.1.orig/capplets/default-applications/gnome-da-xml.c 2011-01-05 16:04:48.624316596 -0500 +++ gnome-control-center-2.32.1/capplets/default-applications/gnome-da-xml.c 2011-01-05 16:05:40.653854197 -0500 @@ -152,7 +152,7 @@ term_item->generic.name = gnome_da_xml_get_string (element, "name"); term_item->generic.executable = executable; term_item->generic.command = gnome_da_xml_get_string (element, "command"); - term_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + term_item->generic.icon = g_themed_icon_new (gnome_da_xml_get_string (element, "icon-name")); term_item->exec_flag = gnome_da_xml_get_string (element, "exec-flag"); @@ -173,7 +173,7 @@ media_item->generic.name = gnome_da_xml_get_string (element, "name"); media_item->generic.executable = executable; media_item->generic.command = gnome_da_xml_get_string (element, "command"); - media_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + media_item->generic.icon = g_themed_icon_new (gnome_da_xml_get_string (element, "icon-name")); media_item->run_in_terminal = gnome_da_xml_get_bool (element, "run-in-terminal"); @@ -194,7 +194,7 @@ visual_item->generic.name = gnome_da_xml_get_string (element, "name"); visual_item->generic.executable = executable; visual_item->generic.command = gnome_da_xml_get_string (element, "command"); - visual_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + visual_item->generic.icon = g_themed_icon_new (gnome_da_xml_get_string (element, "icon-name")); visual_item->run_at_startup = gnome_da_xml_get_bool (element, "run-at-startup"); @@ -215,7 +215,7 @@ mobility_item->generic.name = gnome_da_xml_get_string (element, "name"); mobility_item->generic.executable = executable; mobility_item->generic.command = gnome_da_xml_get_string (element, "command"); - mobility_item->generic.icon_name = gnome_da_xml_get_string (element, "icon-name"); + mobility_item->generic.icon = g_themed_icon_new (gnome_da_xml_get_string (element, "icon-name")); mobility_item->run_at_startup = gnome_da_xml_get_bool (element, "run-at-startup"); @@ -246,12 +246,18 @@ executable = g_app_info_get_executable (app_info); if (is_executable_valid (executable)) { GnomeDAURLItem *url_item; + GIcon *icon; url_item = gnome_da_url_item_new (); url_item->generic.name = g_strdup (g_app_info_get_display_name (app_info)); url_item->generic.executable = g_strdup (executable); url_item->generic.command = g_strdup (g_app_info_get_commandline (app_info)); - url_item->generic.icon_name = g_strdup (g_app_info_get_name (app_info)); + + icon = g_app_info_get_icon (app_info); + if (icon != NULL) { + url_item->generic.icon = g_object_ref (icon); + } + /* Steal the reference */ url_item->app_info = app_info;