24 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #define _BG_MIN_SIZE 20
29 #define _EMBLEM_MIN_SIZE 8
42 GIcon *icon, *retval = NULL;
43 cairo_surface_t *surface;
45 GtkStyleContext *style;
54 total_size = base_size / 2;
58 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, total_size, total_size);
59 cr = cairo_create (surface);
61 style = gtk_style_context_new ();
63 path = gtk_widget_path_new ();
64 gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
65 gtk_style_context_set_path (style, path);
66 gtk_widget_path_unref (path);
68 gtk_style_context_add_class (style,
"documents-icon-bg");
70 gtk_render_background (style, cr, (total_size - bg_size) / 2, (total_size - bg_size) / 2, bg_size, bg_size);
72 symbolic_name = g_strconcat (name,
"-symbolic", NULL);
73 icon = g_themed_icon_new_with_default_fallbacks (symbolic_name);
74 g_free (symbolic_name);
76 theme = gtk_icon_theme_get_default();
77 info = gtk_icon_theme_lookup_by_gicon (theme, icon, emblem_size,
78 GTK_ICON_LOOKUP_FORCE_SIZE);
79 g_object_unref (icon);
84 pixbuf = gtk_icon_info_load_symbolic_for_context (info, style, NULL, NULL);
85 g_object_unref (info);
90 gtk_render_icon (style, cr, pixbuf, (total_size - emblem_size) / 2, (total_size - emblem_size) / 2);
91 g_object_unref (pixbuf);
93 retval = G_ICON (gdk_pixbuf_get_from_surface (surface, 0, 0, total_size, total_size));
96 g_object_unref (style);
97 cairo_surface_destroy (surface);
114 const gchar *frame_image_url,
115 GtkBorder *slice_width,
116 GtkBorder *border_width)
118 cairo_surface_t *surface;
120 int source_width, source_height;
121 int dest_width, dest_height;
123 GtkCssProvider *provider;
124 GtkStyleContext *context;
125 GError *error = NULL;
129 source_width = cairo_image_surface_get_width (source_image);
130 source_height = cairo_image_surface_get_height (source_image);
132 dest_width = source_width + border_width->left + border_width->right;
133 dest_height = source_height + border_width->top + border_width->bottom;
135 css_str = g_strdup_printf (
".embedded-image { border-image: url(\"%s\") %d %d %d %d / %dpx %dpx %dpx %dpx }",
137 slice_width->top, slice_width->right, slice_width->bottom, slice_width->left,
138 border_width->top, border_width->right, border_width->bottom, border_width->left);
139 provider = gtk_css_provider_new ();
140 gtk_css_provider_load_from_data (provider, css_str, -1, &error);
144 g_warning (
"Unable to create the thumbnail frame image: %s", error->message);
145 g_error_free (error);
148 return cairo_surface_reference (source_image);
151 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dest_width, dest_height);
152 cr = cairo_create (surface);
154 context = gtk_style_context_new ();
155 path = gtk_widget_path_new ();
156 gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
158 gtk_style_context_set_path (context, path);
159 gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), 600);
161 gtk_render_icon_surface (context, cr,
163 border_width->left, border_width->top);
165 gtk_style_context_save (context);
166 gtk_style_context_add_class (context,
"embedded-image");
168 gtk_render_frame (context, cr,
170 dest_width, dest_height);
172 gtk_style_context_restore (context);
175 gtk_widget_path_unref (path);
176 g_object_unref (provider);
177 g_object_unref (context);