diff options
author | Victor Kareh <[email protected]> | 2018-04-02 22:02:39 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-04-05 09:09:50 +0200 |
commit | dade92d4f1edb6f47933e77229801971cb458ef1 (patch) | |
tree | db2545721a093328979a305a2c92e428ad65e230 /src | |
parent | 556663ac4b8eb03b86fa70eeb6b959e1d27281e2 (diff) | |
download | caja-dade92d4f1edb6f47933e77229801971cb458ef1.tar.bz2 caja-dade92d4f1edb6f47933e77229801971cb458ef1.tar.xz |
HiDPI: Convert Pixbufs to Cairo Surfaces
This allows icons in most places to scale up properly for HiDPI
displays.
Diffstat (limited to 'src')
-rw-r--r-- | src/caja-bookmarks-window.c | 21 | ||||
-rw-r--r-- | src/caja-emblem-sidebar.c | 10 | ||||
-rw-r--r-- | src/caja-history-sidebar.c | 17 | ||||
-rw-r--r-- | src/caja-pathbar.c | 28 | ||||
-rw-r--r-- | src/caja-places-sidebar.c | 52 | ||||
-rw-r--r-- | src/caja-property-browser.c | 8 | ||||
-rw-r--r-- | src/caja-window-menus.c | 20 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 78 | ||||
-rw-r--r-- | src/file-manager/fm-tree-model.c | 110 | ||||
-rw-r--r-- | src/file-manager/fm-tree-model.h | 4 | ||||
-rw-r--r-- | src/file-manager/fm-tree-view.c | 5 |
11 files changed, 183 insertions, 170 deletions
diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index 60254cfd..e94ce944 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -35,6 +35,7 @@ #include <eel/eel-mate-extensions.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#include <cairo-gobject.h> /* Static variables to keep track of window state. If there were * more than one bookmark-editing window, these would be struct or @@ -176,7 +177,7 @@ static GtkListStore * create_bookmark_store (void) { return gtk_list_store_new (BOOKMARK_LIST_COLUMN_COUNT, - GDK_TYPE_PIXBUF, + CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_STRING, G_TYPE_OBJECT, PANGO_TYPE_STYLE); @@ -296,7 +297,7 @@ create_bookmarks_window (CajaBookmarkList *list, CajaWindow *window_source) rend = gtk_cell_renderer_pixbuf_new (); col = gtk_tree_view_column_new_with_attributes ("Icon", rend, - "pixbuf", + "surface", BOOKMARK_LIST_COLUMN_ICON, NULL); gtk_tree_view_append_column (bookmark_list_widget, @@ -839,7 +840,7 @@ update_bookmark_from_text (void) { CajaBookmark *bookmark, *bookmark_in_list; char *name; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; guint selected_row; GtkTreeIter iter; GFile *location; @@ -885,17 +886,17 @@ update_bookmark_from_text (void) name = caja_bookmark_get_name (bookmark_in_list); - pixbuf = caja_bookmark_get_pixbuf (bookmark_in_list, GTK_ICON_SIZE_MENU); + surface = caja_bookmark_get_surface (bookmark_in_list, GTK_ICON_SIZE_MENU); gtk_list_store_set (bookmark_list_store, &iter, BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark_in_list, BOOKMARK_LIST_COLUMN_NAME, name, - BOOKMARK_LIST_COLUMN_ICON, pixbuf, + BOOKMARK_LIST_COLUMN_ICON, surface, -1); g_signal_handler_unblock (bookmark_list_store, row_changed_signal_id); - g_object_unref (pixbuf); + cairo_surface_destroy (surface); g_free (name); } } @@ -1018,16 +1019,16 @@ repopulate (void) { CajaBookmark *bookmark; char *bookmark_name; - GdkPixbuf *bookmark_pixbuf; + cairo_surface_t *bookmark_surface; GtkTreeIter iter; bookmark = caja_bookmark_list_item_at (bookmarks, index); bookmark_name = caja_bookmark_get_name (bookmark); - bookmark_pixbuf = caja_bookmark_get_pixbuf (bookmark, GTK_ICON_SIZE_MENU); + bookmark_surface = caja_bookmark_get_surface (bookmark, GTK_ICON_SIZE_MENU); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - BOOKMARK_LIST_COLUMN_ICON, bookmark_pixbuf, + BOOKMARK_LIST_COLUMN_ICON, bookmark_surface, BOOKMARK_LIST_COLUMN_NAME, bookmark_name, BOOKMARK_LIST_COLUMN_BOOKMARK, bookmark, BOOKMARK_LIST_COLUMN_STYLE, PANGO_STYLE_NORMAL, @@ -1044,7 +1045,7 @@ repopulate (void) } g_free (bookmark_name); - g_object_unref (bookmark_pixbuf); + cairo_surface_destroy (bookmark_surface); } g_signal_handler_unblock (store, row_changed_signal_id); diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index a1c7f573..c0842355 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -386,15 +386,13 @@ create_emblem_widget_with_pixbuf (CajaEmblemSidebar *emblem_sidebar, { GtkWidget *image, *event_box; GdkPixbuf *prelight_pixbuf; - gint scale; image = eel_labeled_image_new (display_name, pixbuf); - scale = gtk_widget_get_scale_factor (image); eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (image), - STANDARD_EMBLEM_HEIGHT * scale); + STANDARD_EMBLEM_HEIGHT); eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (image), - EMBLEM_LABEL_SPACING * scale); + EMBLEM_LABEL_SPACING); event_box = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (event_box), image); @@ -450,10 +448,8 @@ create_emblem_widget (CajaEmblemSidebar *emblem_sidebar, char *keyword; GdkPixbuf *pixbuf; CajaIconInfo *info; - gint scale; - scale = gtk_widget_get_scale_factor (GTK_WIDGET (emblem_sidebar->details->emblems_table)); - info = caja_icon_info_lookup_from_name (name, CAJA_ICON_SIZE_STANDARD, scale); + info = caja_icon_info_lookup_from_name (name, CAJA_ICON_SIZE_STANDARD, 1); pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD); diff --git a/src/caja-history-sidebar.c b/src/caja-history-sidebar.c index de4e71dc..2b6ddd92 100644 --- a/src/caja-history-sidebar.c +++ b/src/caja-history-sidebar.c @@ -30,6 +30,7 @@ #include <eel/eel-gtk-extensions.h> #include <gtk/gtk.h> #include <glib/gi18n.h> +#include <cairo-gobject.h> #include <libcaja-private/caja-bookmark.h> #include <libcaja-private/caja-global-preferences.h> #include <libcaja-private/caja-sidebar-provider.h> @@ -89,8 +90,8 @@ update_history (CajaHistorySidebar *sidebar) { GtkListStore *store; GtkTreeSelection *selection; - CajaBookmark *bookmark; - GdkPixbuf *pixbuf; + CajaBookmark *bookmark; + cairo_surface_t *surface; GtkTreeIter iter; char *name; GList *l, *history; @@ -104,19 +105,19 @@ update_history (CajaHistorySidebar *sidebar) { bookmark = caja_bookmark_copy (l->data); - pixbuf = caja_bookmark_get_pixbuf (bookmark, GTK_ICON_SIZE_MENU); + surface = caja_bookmark_get_surface (bookmark, GTK_ICON_SIZE_MENU); name = caja_bookmark_get_name (bookmark); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - HISTORY_SIDEBAR_COLUMN_ICON, pixbuf, + HISTORY_SIDEBAR_COLUMN_ICON, surface, HISTORY_SIDEBAR_COLUMN_NAME, name, HISTORY_SIDEBAR_COLUMN_BOOKMARK, bookmark, -1); g_object_unref (bookmark); - if (pixbuf != NULL) + if (surface != NULL) { - g_object_unref (pixbuf); + cairo_surface_destroy (surface); } g_free (name); } @@ -249,7 +250,7 @@ caja_history_sidebar_init (CajaHistorySidebar *sidebar) cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (col, cell, FALSE); gtk_tree_view_column_set_attributes (col, cell, - "pixbuf", HISTORY_SIDEBAR_COLUMN_ICON, + "surface", HISTORY_SIDEBAR_COLUMN_ICON, NULL); cell = gtk_cell_renderer_text_new (); @@ -262,7 +263,7 @@ caja_history_sidebar_init (CajaHistorySidebar *sidebar) gtk_tree_view_append_column (tree_view, col); store = gtk_list_store_new (HISTORY_SIDEBAR_COLUMN_COUNT, - GDK_TYPE_PIXBUF, + CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_STRING, CAJA_TYPE_BOOKMARK); diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index 533f2f7f..fe0a0590 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -75,7 +75,7 @@ struct _ButtonData unsigned int file_changed_signal_id; /* custom icon */ - GdkPixbuf *custom_icon; + cairo_surface_t *custom_icon; /* flag to indicate its the base folder in the URI */ gboolean is_base_dir; @@ -218,12 +218,12 @@ trash_state_changed_cb (CajaTrashMonitor *monitor, { GIcon *icon; CajaIconInfo *icon_info; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; icon = caja_trash_monitor_get_icon (); icon_info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale); - pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, CAJA_PATH_BAR_ICON_SIZE); - gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), pixbuf); + surface = caja_icon_info_get_surface_at_size (icon_info, CAJA_PATH_BAR_ICON_SIZE); + gtk_image_set_from_surface (GTK_IMAGE (button_data->image), surface); } } g_object_unref (file); @@ -1382,7 +1382,7 @@ button_data_free (ButtonData *button_data) g_free (button_data->dir_name); if (button_data->custom_icon) { - g_object_unref (button_data->custom_icon); + cairo_surface_destroy (button_data->custom_icon); } if (button_data->file != NULL) { @@ -1447,7 +1447,7 @@ static void caja_path_bar_update_button_appearance (ButtonData *button_data) { CajaIconInfo *icon_info; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; const gchar *dir_name = get_dir_name (button_data); if (button_data->label != NULL) @@ -1474,27 +1474,27 @@ caja_path_bar_update_button_appearance (ButtonData *button_data) { if (button_data->custom_icon) { - gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), button_data->custom_icon); + gtk_image_set_from_surface (GTK_IMAGE (button_data->image), button_data->custom_icon); gtk_widget_show (GTK_WIDGET (button_data->image)); } else { icon_info = get_type_icon_info (button_data); - pixbuf = NULL; + surface = NULL; if (icon_info != NULL) { - pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, CAJA_PATH_BAR_ICON_SIZE); + surface = caja_icon_info_get_surface_at_size (icon_info, CAJA_PATH_BAR_ICON_SIZE); g_object_unref (icon_info); } - if (pixbuf != NULL) + if (surface != NULL) { - gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), pixbuf); + gtk_image_set_from_surface (GTK_IMAGE (button_data->image), surface); gtk_style_context_add_class (gtk_widget_get_style_context (button_data->button), "image-button"); gtk_widget_show (GTK_WIDGET (button_data->image)); - g_object_unref (pixbuf); + cairo_surface_destroy (surface); } else { @@ -1567,7 +1567,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data) } info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale); g_object_unref (icon); - button_data->custom_icon = caja_icon_info_get_pixbuf_at_size (info, CAJA_PATH_BAR_ICON_SIZE); + button_data->custom_icon = caja_icon_info_get_surface_at_size (info, CAJA_PATH_BAR_ICON_SIZE); g_object_unref (info); button_data->dir_name = g_mount_get_name (mount); button_data->type = MOUNT_BUTTON; @@ -1591,7 +1591,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data) } info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale); g_object_unref (icon); - button_data->custom_icon = caja_icon_info_get_pixbuf_at_size (info, CAJA_PATH_BAR_ICON_SIZE); + button_data->custom_icon = caja_icon_info_get_surface_at_size (info, CAJA_PATH_BAR_ICON_SIZE); g_object_unref (info); button_data->type = DEFAULT_LOCATION_BUTTON; button_data->fake_root = TRUE; diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 49ca3e56..2b1ade5a 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -49,6 +49,7 @@ #include <libcaja-private/caja-window-slot-info.h> #include <gio/gio.h> #include <libnotify/notify.h> +#include <cairo-gobject.h> #include "caja-bookmark-list.h" #include "caja-places-sidebar.h" @@ -228,10 +229,11 @@ G_DEFINE_TYPE_WITH_CODE (CajaPlacesSidebarProvider, caja_places_sidebar_provider G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR_PROVIDER, sidebar_provider_iface_init)); -static GdkPixbuf * +static cairo_surface_t * get_eject_icon (gboolean highlighted) { GdkPixbuf *eject; + cairo_surface_t *eject_surface; CajaIconInfo *eject_icon_info; int icon_size, icon_scale; @@ -248,9 +250,12 @@ get_eject_icon (gboolean highlighted) eject = high; } + eject_surface = gdk_cairo_surface_create_from_pixbuf (eject, icon_scale, NULL); + g_object_unref (eject_icon_info); + g_object_unref (eject); - return eject; + return eject_surface; } static gboolean @@ -338,15 +343,16 @@ add_place (CajaPlacesSidebar *sidebar, const int index, const char *tooltip) { - GdkPixbuf *pixbuf; - GtkTreeIter iter, child_iter; - GdkPixbuf *eject; - CajaIconInfo *icon_info; - int icon_size; - int icon_scale; - gboolean show_eject; - gboolean show_unmount; - gboolean show_eject_button; + GdkPixbuf *pixbuf; + cairo_surface_t *surface; + GtkTreeIter iter, child_iter; + cairo_surface_t *eject; + CajaIconInfo *icon_info; + int icon_size; + int icon_scale; + gboolean show_eject; + gboolean show_unmount; + gboolean show_eject_button; check_heading_for_section (sidebar, section_type); @@ -357,6 +363,16 @@ add_place (CajaPlacesSidebar *sidebar, pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); g_object_unref (icon_info); + if (pixbuf != NULL) + { + surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, icon_scale, NULL); + g_object_unref (pixbuf); + } + else + { + surface = NULL; + } + check_unmount_and_eject (mount, volume, drive, &show_unmount, &show_eject); @@ -382,7 +398,7 @@ add_place (CajaPlacesSidebar *sidebar, gtk_list_store_append (sidebar->store, &iter); gtk_list_store_set (sidebar->store, &iter, - PLACES_SIDEBAR_COLUMN_ICON, pixbuf, + PLACES_SIDEBAR_COLUMN_ICON, surface, PLACES_SIDEBAR_COLUMN_NAME, name, PLACES_SIDEBAR_COLUMN_URI, uri, PLACES_SIDEBAR_COLUMN_DRIVE, drive, @@ -398,9 +414,9 @@ add_place (CajaPlacesSidebar *sidebar, PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type, -1); - if (pixbuf != NULL) + if (surface != NULL) { - g_object_unref (pixbuf); + cairo_surface_destroy (surface); } gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model)); gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (sidebar->filter_model), @@ -3187,7 +3203,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (col, cell, FALSE); gtk_tree_view_column_set_attributes (col, cell, - "pixbuf", PLACES_SIDEBAR_COLUMN_ICON, + "surface", PLACES_SIDEBAR_COLUMN_ICON, NULL); gtk_tree_view_column_set_cell_data_func (col, cell, icon_cell_renderer_func, @@ -3219,7 +3235,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) gtk_tree_view_column_pack_start (col, cell, FALSE); gtk_tree_view_column_set_attributes (col, cell, "visible", PLACES_SIDEBAR_COLUMN_EJECT, - "pixbuf", PLACES_SIDEBAR_COLUMN_EJECT_ICON, + "surface", PLACES_SIDEBAR_COLUMN_EJECT_ICON, NULL); /* normal text renderer */ @@ -3252,13 +3268,13 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) G_TYPE_VOLUME, G_TYPE_MOUNT, G_TYPE_STRING, - GDK_TYPE_PIXBUF, + CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, - GDK_TYPE_PIXBUF, + CAIRO_GOBJECT_TYPE_SURFACE, G_TYPE_INT, G_TYPE_STRING); diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index 90bcff16..15cfc169 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -722,7 +722,6 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name) char *icon_name; gboolean is_reset; CajaIconInfo *info; - gint icon_scale; if (property_browser->details->category_type == CAJA_PROPERTY_EMBLEM) { @@ -740,8 +739,7 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name) else { icon_name = caja_emblem_get_icon_name_from_keyword (file_name); - icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (property_browser->details->content_table)); - info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, icon_scale); + info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, 1); pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD); g_object_unref (info); g_free (icon_name); @@ -1797,7 +1795,6 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) guint num_images; char *path; CajaIconInfo *info; - gint icon_scale; g_return_if_fail (CAJA_IS_PROPERTY_BROWSER (property_browser)); g_return_if_fail (EEL_IS_IMAGE_TABLE (property_browser->details->content_table)); @@ -1810,7 +1807,6 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) property_browser->details->keywords = NULL; icons = caja_emblem_list_available (); - icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (property_browser->details->content_table)); property_browser->details->has_local = FALSE; l = icons; @@ -1834,7 +1830,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) g_free (object_name); continue; } - info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, icon_scale); + info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, 1); object_pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD); object_label = g_strdup (caja_icon_info_get_display_name (info)); g_object_unref (info); diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 0cf325dc..e5b462c7 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -175,7 +175,7 @@ caja_menus_append_bookmark_to_menu (CajaWindow *window, char action_name[128]; char *name; char *path; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; GtkAction *action; GtkWidget *menuitem; @@ -185,8 +185,8 @@ caja_menus_append_bookmark_to_menu (CajaWindow *window, bookmark_holder = bookmark_holder_new (bookmark, window, refresh_callback, failed_callback); name = caja_bookmark_get_name (bookmark); - /* Create menu item with pixbuf */ - pixbuf = caja_bookmark_get_pixbuf (bookmark, GTK_ICON_SIZE_MENU); + /* Create menu item with surface */ + surface = caja_bookmark_get_surface (bookmark, GTK_ICON_SIZE_MENU); g_snprintf (action_name, sizeof (action_name), "%s%d", parent_id, index_in_parent); @@ -196,8 +196,8 @@ caja_menus_append_bookmark_to_menu (CajaWindow *window, NULL); g_object_set_data_full (G_OBJECT (action), "menu-icon", - g_object_ref (pixbuf), - g_object_unref); + cairo_surface_reference (surface), + cairo_surface_destroy); g_signal_connect_data (action, "activate", G_CALLBACK (activate_bookmark_in_menu_item), @@ -223,7 +223,7 @@ caja_menus_append_bookmark_to_menu (CajaWindow *window, gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE); - g_object_unref (pixbuf); + cairo_surface_destroy (surface); g_free (path); g_free (name); } @@ -724,7 +724,7 @@ connect_proxy_cb (GtkUIManager *manager, GtkWidget *proxy, CajaWindow *window) { - GdkPixbuf *icon; + cairo_surface_t *icon; GtkWidget *widget; if (GTK_IS_MENU_ITEM (proxy)) @@ -735,12 +735,12 @@ connect_proxy_cb (GtkUIManager *manager, G_CALLBACK (menu_item_deselect_cb), window); - /* This is a way to easily get pixbufs into the menu items */ + /* This is a way to easily get surfaces into the menu items */ icon = g_object_get_data (G_OBJECT (action), "menu-icon"); if (icon != NULL) { gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), - gtk_image_new_from_pixbuf (icon)); + gtk_image_new_from_surface (icon)); } } if (GTK_IS_TOOL_BUTTON (proxy)) @@ -748,7 +748,7 @@ connect_proxy_cb (GtkUIManager *manager, icon = g_object_get_data (G_OBJECT (action), "toolbar-icon"); if (icon != NULL) { - widget = gtk_image_new_from_pixbuf (icon); + widget = gtk_image_new_from_surface (icon); gtk_widget_show (widget); gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (proxy), widget); diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 62d4fec1..d753cb68 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -4389,7 +4389,7 @@ add_submenu (GtkUIManager *ui_manager, const char *parent_path, const char *uri, const char *label, - GdkPixbuf *pixbuf, + cairo_surface_t *surface, gboolean add_action) { char *escaped_label; @@ -4409,10 +4409,10 @@ add_submenu (GtkUIManager *ui_manager, escaped_label, NULL, NULL); - if (pixbuf != NULL) { + if (surface != NULL) { g_object_set_data_full (G_OBJECT (action), "menu-icon", - g_object_ref (pixbuf), - g_object_unref); + cairo_surface_reference (surface), + cairo_surface_destroy); } g_object_set (action, "hide-if-empty", FALSE, NULL); @@ -4887,12 +4887,12 @@ extension_action_callback (GtkAction *action, } } -static GdkPixbuf * +static cairo_surface_t * get_menu_icon (const char *icon_name, GtkWidget *widget) { CajaIconInfo *info; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; int size, scale; size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); @@ -4903,28 +4903,28 @@ get_menu_icon (const char *icon_name, } else { info = caja_icon_info_lookup_from_name (icon_name, size, scale); } - pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); + surface = caja_icon_info_get_surface_nodefault_at_size (info, size); g_object_unref (info); - return pixbuf; + return surface; } -static GdkPixbuf * +static cairo_surface_t * get_menu_icon_for_file (CajaFile *file, GtkWidget *widget) { CajaIconInfo *info; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; int size, scale; size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); scale = gtk_widget_get_scale_factor (widget); info = caja_file_get_icon (file, size, scale, 0); - pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); + surface = caja_icon_info_get_surface_nodefault_at_size (info, size); g_object_unref (info); - return pixbuf; + return surface; } static GtkAction * @@ -4935,7 +4935,7 @@ add_extension_action_for_files (FMDirectoryView *view, char *name, *label, *tip, *icon; gboolean sensitive, priority; GtkAction *action; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; ExtensionActionCallbackData *data; g_object_get (G_OBJECT (item), @@ -4951,11 +4951,11 @@ add_extension_action_for_files (FMDirectoryView *view, icon); if (icon != NULL) { - pixbuf = get_menu_icon (icon, GTK_WIDGET (view)); - if (pixbuf != NULL) { + surface = get_menu_icon (icon, GTK_WIDGET (view)); + if (surface != NULL) { g_object_set_data_full (G_OBJECT (action), "menu-icon", - pixbuf, - g_object_unref); + surface, + cairo_surface_destroy); } } @@ -5400,7 +5400,7 @@ add_script_to_scripts_menus (FMDirectoryView *directory_view, char *uri; char *action_name; char *escaped_label; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; GtkUIManager *ui_manager; GtkAction *action; @@ -5418,11 +5418,11 @@ add_script_to_scripts_menus (FMDirectoryView *directory_view, tip, NULL); - pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); - if (pixbuf != NULL) { + surface = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); + if (surface != NULL) { g_object_set_data_full (G_OBJECT (action), "menu-icon", - pixbuf, - g_object_unref); + surface, + cairo_surface_destroy); } g_signal_connect_data (action, "activate", @@ -5475,19 +5475,19 @@ add_submenu_to_directory_menus (FMDirectoryView *directory_view, const char *popup_bg_path) { char *name; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; char *uri; GtkUIManager *ui_manager; ui_manager = caja_window_info_get_ui_manager (directory_view->details->window); uri = caja_file_get_uri (file); name = caja_file_get_display_name (file); - pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); - add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, pixbuf, TRUE); - add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, pixbuf, FALSE); - add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, pixbuf, FALSE); - if (pixbuf) { - g_object_unref (pixbuf); + surface = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); + add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, surface, TRUE); + add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, surface, FALSE); + add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, surface, FALSE); + if (surface) { + cairo_surface_destroy (surface); } g_free (name); g_free (uri); @@ -5646,7 +5646,7 @@ add_template_to_templates_menus (FMDirectoryView *directory_view, { char *tmp, *tip, *uri, *name; char *escaped_label; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; char *action_name; CreateTemplateParameters *parameters; GtkUIManager *ui_manager; @@ -5669,11 +5669,11 @@ add_template_to_templates_menus (FMDirectoryView *directory_view, tip, NULL); - pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); - if (pixbuf != NULL) { + surface = get_menu_icon_for_file (file, GTK_WIDGET (directory_view)); + if (surface != NULL) { g_object_set_data_full (G_OBJECT (action), "menu-icon", - pixbuf, - g_object_unref); + surface, + cairo_surface_destroy); } g_signal_connect_data (action, "activate", @@ -7562,17 +7562,17 @@ connect_proxy (FMDirectoryView *view, GtkWidget *proxy, GtkActionGroup *action_group) { - GdkPixbuf *pixbuf; + cairo_surface_t *surface; GtkWidget *image; if (strcmp (gtk_action_get_name (action), FM_ACTION_NEW_EMPTY_FILE) == 0 && GTK_IS_IMAGE_MENU_ITEM (proxy)) { - pixbuf = get_menu_icon ("text-x-generic", GTK_WIDGET (view)); - if (pixbuf != NULL) { - image = gtk_image_new_from_pixbuf (pixbuf); + surface = get_menu_icon ("text-x-generic", GTK_WIDGET (view)); + if (surface != NULL) { + image = gtk_image_new_from_surface (surface); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image); - g_object_unref (pixbuf); + cairo_surface_destroy (surface); } } } diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index e3bcfd3c..fd9bf074 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -36,6 +36,7 @@ #include <libcaja-private/caja-file.h> #include <gtk/gtk.h> #include <string.h> +#include <cairo-gobject.h> enum { @@ -64,8 +65,8 @@ struct TreeNode char *display_name; GIcon *icon; GMount *mount; - GdkPixbuf *closed_pixbuf; - GdkPixbuf *open_pixbuf; + cairo_surface_t *closed_surface; + cairo_surface_t *open_surface; FMTreeModelRoot *root; @@ -217,8 +218,11 @@ tree_node_destroy (FMTreeModel *model, TreeNode *node) g_object_unref (node->file); g_free (node->display_name); object_unref_if_not_NULL (node->icon); - object_unref_if_not_NULL (node->closed_pixbuf); - object_unref_if_not_NULL (node->open_pixbuf); + + if (node->closed_surface != NULL) + cairo_surface_destroy (node->closed_surface); + if (node->open_surface) + cairo_surface_destroy (node->open_surface); g_assert (node->done_loading_id == 0); g_assert (node->files_added_id == 0); @@ -253,24 +257,24 @@ tree_node_parent (TreeNode *node, TreeNode *parent) parent->first_child = node; } -static GdkPixbuf * +static cairo_surface_t * get_menu_icon (GIcon *icon) { CajaIconInfo *info; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; int size, scale; size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); scale = gdk_window_get_scale_factor (gdk_get_default_root_window ()); info = caja_icon_info_lookup (icon, size, scale); - pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); + surface = caja_icon_info_get_surface_nodefault_at_size (info, size); g_object_unref (info); - return pixbuf; + return surface; } -static GdkPixbuf * +static cairo_surface_t * get_menu_icon_for_file (TreeNode *node, CajaFile *file, CajaFileIconFlags flags) @@ -278,7 +282,7 @@ get_menu_icon_for_file (TreeNode *node, CajaIconInfo *info; GIcon *gicon, *emblem_icon, *emblemed_icon; GEmblem *emblem; - GdkPixbuf *pixbuf, *retval; + cairo_surface_t *surface, *retval; gboolean highlight; int size, scale; FMTreeModel *model; @@ -324,7 +328,7 @@ get_menu_icon_for_file (TreeNode *node, g_list_free_full (emblem_icons, g_object_unref); info = caja_icon_info_lookup (gicon, size, scale); - retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); + retval = caja_icon_info_get_surface_nodefault_at_size (info, size); model = node->root->model; g_object_unref (gicon); @@ -334,12 +338,12 @@ get_menu_icon_for_file (TreeNode *node, if (highlight) { - pixbuf = eel_create_spotlight_pixbuf (retval); + surface = eel_create_spotlight_surface (retval, scale); - if (pixbuf != NULL) + if (surface != NULL) { - g_object_unref (retval); - retval = pixbuf; + cairo_surface_destroy (retval); + retval = surface; } } @@ -348,9 +352,9 @@ get_menu_icon_for_file (TreeNode *node, return retval; } -static GdkPixbuf * -tree_node_get_pixbuf (TreeNode *node, - CajaFileIconFlags flags) +static cairo_surface_t * +tree_node_get_surface (TreeNode *node, + CajaFileIconFlags flags) { if (node->parent == NULL) { @@ -360,37 +364,37 @@ tree_node_get_pixbuf (TreeNode *node, } static gboolean -tree_node_update_pixbuf (TreeNode *node, - GdkPixbuf **pixbuf_storage, +tree_node_update_surface (TreeNode *node, + cairo_surface_t **surface_storage, CajaFileIconFlags flags) { - GdkPixbuf *pixbuf; + cairo_surface_t *surface; - if (*pixbuf_storage == NULL) + if (*surface_storage == NULL) { return FALSE; } - pixbuf = tree_node_get_pixbuf (node, flags); - if (pixbuf == *pixbuf_storage) + surface = tree_node_get_surface (node, flags); + if (surface == *surface_storage) { - g_object_unref (pixbuf); + cairo_surface_destroy (surface); return FALSE; } - g_object_unref (*pixbuf_storage); - *pixbuf_storage = pixbuf; + cairo_surface_destroy (*surface_storage); + *surface_storage = surface; return TRUE; } static gboolean -tree_node_update_closed_pixbuf (TreeNode *node) +tree_node_update_closed_surface (TreeNode *node) { - return tree_node_update_pixbuf (node, &node->closed_pixbuf, 0); + return tree_node_update_surface (node, &node->closed_surface, 0); } static gboolean -tree_node_update_open_pixbuf (TreeNode *node) +tree_node_update_open_surface (TreeNode *node) { - return tree_node_update_pixbuf (node, &node->open_pixbuf, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER); + return tree_node_update_surface (node, &node->open_surface, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER); } static gboolean @@ -418,24 +422,24 @@ tree_node_update_display_name (TreeNode *node) return TRUE; } -static GdkPixbuf * -tree_node_get_closed_pixbuf (TreeNode *node) +static cairo_surface_t * +tree_node_get_closed_surface (TreeNode *node) { - if (node->closed_pixbuf == NULL) + if (node->closed_surface == NULL) { - node->closed_pixbuf = tree_node_get_pixbuf (node, 0); + node->closed_surface = tree_node_get_surface (node, 0); } - return node->closed_pixbuf; + return node->closed_surface; } -static GdkPixbuf * -tree_node_get_open_pixbuf (TreeNode *node) +static cairo_surface_t * +tree_node_get_open_surface (TreeNode *node) { - if (node->open_pixbuf == NULL) + if (node->open_surface == NULL) { - node->open_pixbuf = tree_node_get_pixbuf (node, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER); + node->open_surface = tree_node_get_surface (node, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER); } - return node->open_pixbuf; + return node->open_surface; } static const char * @@ -882,8 +886,8 @@ update_node_without_reporting (FMTreeModel *model, TreeNode *node) } changed |= tree_node_update_display_name (node); - changed |= tree_node_update_closed_pixbuf (node); - changed |= tree_node_update_open_pixbuf (node); + changed |= tree_node_update_closed_surface (node); + changed |= tree_node_update_open_surface (node); return changed; } @@ -1204,10 +1208,10 @@ fm_tree_model_get_column_type (GtkTreeModel *model, int index) { case FM_TREE_MODEL_DISPLAY_NAME_COLUMN: return G_TYPE_STRING; - case FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN: - return GDK_TYPE_PIXBUF; - case FM_TREE_MODEL_OPEN_PIXBUF_COLUMN: - return GDK_TYPE_PIXBUF; + case FM_TREE_MODEL_CLOSED_SURFACE_COLUMN: + return CAIRO_GOBJECT_TYPE_SURFACE; + case FM_TREE_MODEL_OPEN_SURFACE_COLUMN: + return CAIRO_GOBJECT_TYPE_SURFACE; case FM_TREE_MODEL_FONT_STYLE_COLUMN: return PANGO_TYPE_STYLE; default: @@ -1364,13 +1368,13 @@ fm_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GVa g_value_set_string (value, tree_node_get_display_name (node)); } break; - case FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN: - g_value_init (value, GDK_TYPE_PIXBUF); - g_value_set_object (value, node == NULL ? NULL : tree_node_get_closed_pixbuf (node)); + case FM_TREE_MODEL_CLOSED_SURFACE_COLUMN: + g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE); + g_value_set_boxed (value, node == NULL ? NULL : tree_node_get_closed_surface (node)); break; - case FM_TREE_MODEL_OPEN_PIXBUF_COLUMN: - g_value_init (value, GDK_TYPE_PIXBUF); - g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node)); + case FM_TREE_MODEL_OPEN_SURFACE_COLUMN: + g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE); + g_value_set_boxed (value, node == NULL ? NULL : tree_node_get_open_surface (node)); break; case FM_TREE_MODEL_FONT_STYLE_COLUMN: g_value_init (value, PANGO_TYPE_STYLE); diff --git a/src/file-manager/fm-tree-model.h b/src/file-manager/fm-tree-model.h index 2e459392..a5d05862 100644 --- a/src/file-manager/fm-tree-model.h +++ b/src/file-manager/fm-tree-model.h @@ -47,8 +47,8 @@ enum { FM_TREE_MODEL_DISPLAY_NAME_COLUMN, - FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, - FM_TREE_MODEL_OPEN_PIXBUF_COLUMN, + FM_TREE_MODEL_CLOSED_SURFACE_COLUMN, + FM_TREE_MODEL_OPEN_SURFACE_COLUMN, FM_TREE_MODEL_FONT_STYLE_COLUMN, FM_TREE_MODEL_NUM_COLUMNS }; diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index 643ae185..5d4e2b7a 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -39,6 +39,7 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <gio/gio.h> +#include <cairo-gobject.h> #include <libcaja-private/caja-clipboard.h> #include <libcaja-private/caja-clipboard-monitor.h> #include <libcaja-private/caja-desktop-icon-file.h> @@ -1482,9 +1483,7 @@ create_tree (FMTreeView *view) cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, - "pixbuf", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, - "pixbuf_expander_closed", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, - "pixbuf_expander_open", FM_TREE_MODEL_OPEN_PIXBUF_COLUMN, + "surface", FM_TREE_MODEL_CLOSED_SURFACE_COLUMN, NULL); cell = gtk_cell_renderer_text_new (); |