[gnome-photos] utils: Use libgd for framing and turn the asset into a resource
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] utils: Use libgd for framing and turn the asset into a resource
- Date: Mon, 10 Feb 2014 13:34:42 +0000 (UTC)
commit b09166df935d79c226fc2fa58bd2da2ffb243bf9
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Feb 7 14:34:27 2014 +0100
utils: Use libgd for framing and turn the asset into a resource
src/photos-base-item.c | 9 +++--
src/photos-utils.c | 78 ----------------------------------------------
src/photos-utils.h | 5 ---
src/photos.gresource.xml | 1 +
4 files changed, 6 insertions(+), 87 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 81d598d..8c06c6f 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -30,6 +30,7 @@
#include <gio/gio.h>
#include <glib.h>
#include <glib/gi18n.h>
+#include <libgd/gd.h>
#include <tracker-sparql.h>
#include "photos-base-item.h"
@@ -198,10 +199,10 @@ photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
GtkBorder *slice;
slice = photos_utils_get_thumbnail_frame_border ();
- priv->icon = photos_utils_embed_image_in_frame (icon,
- PACKAGE_ICONS_DIR "/thumbnail-frame.png",
- slice,
- slice);
+ priv->icon = gd_embed_image_in_frame (icon,
+ "resource:///org/gnome/photos/thumbnail-frame.png",
+ slice,
+ slice);
gtk_border_free (slice);
}
else
diff --git a/src/photos-utils.c b/src/photos-utils.c
index e5b028e..f44b725 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -280,84 +280,6 @@ photos_utils_dot_dir (void)
}
-GdkPixbuf *
-photos_utils_embed_image_in_frame (GdkPixbuf *source_image,
- const gchar *frame_image_path,
- GtkBorder *slice_width,
- GtkBorder *border_width)
-{
- GError *error = NULL;
- GdkPixbuf *ret_val;
- GtkCssProvider *provider;
- GtkStyleContext *context;
- GtkWidgetPath *path;
- cairo_surface_t *surface;
- cairo_t *cr;
- gchar *css_str;
- int dest_height;
- int dest_width;
- int source_height;
- int source_width;
-
- source_width = gdk_pixbuf_get_width (source_image);
- source_height = gdk_pixbuf_get_height (source_image);
-
- dest_width = source_width + border_width->left + border_width->right;
- dest_height = source_height + border_width->top + border_width->bottom;
-
- css_str = g_strdup_printf (".embedded-image { border-image: url(\"%s\") %d %d %d %d / %dpx %dpx %dpx %dpx
}",
- frame_image_path,
- slice_width->top, slice_width->right, slice_width->bottom, slice_width->left,
- border_width->top, border_width->right, border_width->bottom,
border_width->left);
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider, css_str, -1, &error);
-
- if (error != NULL)
- {
- g_warning ("Unable to create the thumbnail frame image: %s", error->message);
- g_error_free (error);
- g_free (css_str);
-
- return g_object_ref (source_image);
- }
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, dest_width, dest_height);
- cr = cairo_create (surface);
-
- context = gtk_style_context_new ();
- path = gtk_widget_path_new ();
- gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
-
- gtk_style_context_set_path (context, path);
- gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), 600);
-
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, "embedded-image");
-
- gtk_render_frame (context, cr,
- 0, 0,
- dest_width, dest_height);
-
- gtk_style_context_restore (context);
-
- gtk_render_icon (context, cr,
- source_image,
- border_width->left, border_width->top);
-
- ret_val = gdk_pixbuf_get_from_surface (surface, 0, 0, dest_width, dest_height);
-
- cairo_surface_destroy (surface);
- cairo_destroy (cr);
-
- gtk_widget_path_unref (path);
- g_object_unref (provider);
- g_object_unref (context);
- g_free (css_str);
-
- return ret_val;
-}
-
-
GQuark
photos_utils_error_quark (void)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index a244739..838b844 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -51,11 +51,6 @@ gboolean photos_utils_create_thumbnail (GFile *file, GCancell
const gchar *photos_utils_dot_dir (void);
-GdkPixbuf *photos_utils_embed_image_in_frame (GdkPixbuf *source_image,
- const gchar *frame_image_path,
- GtkBorder *slice_width,
- GtkBorder *border_width);
-
GQuark photos_utils_error_quark (void);
gchar *photos_utils_filename_strip_extension (const gchar *filename_with_extension);
diff --git a/src/photos.gresource.xml b/src/photos.gresource.xml
index 7fc55f2..c9f3c90 100644
--- a/src/photos.gresource.xml
+++ b/src/photos.gresource.xml
@@ -5,5 +5,6 @@
<file alias="dlna-renderers-dialog.ui" preprocess="xml-stripblanks"
compressed="true">photos-dlna-renderers-dialog.ui</file>
<file alias="preview-menu.ui" preprocess="xml-stripblanks"
compressed="true">photos-preview-menu.ui</file>
<file alias="selection-menu.ui" preprocess="xml-stripblanks"
compressed="true">photos-selection-menu.ui</file>
+ <file alias="thumbnail-frame.png" preprocess="to-pixdata">../data/thumbnail-frame.png</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]