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);