diff options
Diffstat (limited to 'src/file-manager')
-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 |
4 files changed, 100 insertions, 97 deletions
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 46a8fd42..c18ddb6c 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -4404,7 +4404,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; @@ -4424,10 +4424,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); @@ -4902,12 +4902,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); @@ -4918,28 +4918,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 * @@ -4950,7 +4950,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), @@ -4966,11 +4966,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); } } @@ -5415,7 +5415,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; @@ -5433,11 +5433,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", @@ -5490,19 +5490,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); @@ -5661,7 +5661,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; @@ -5684,11 +5684,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", @@ -7584,17 +7584,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 96c465aa..e1846d83 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> @@ -1464,9 +1465,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 (); |