[gnome-control-center/wip/background: 2/2] background: Frame the thumbnails
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/background: 2/2] background: Frame the thumbnails
- Date: Thu, 30 Jan 2014 10:01:49 +0000 (UTC)
commit 8b763ca9ff01f3cd58bf119fcad36ddad9b231be
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Jan 30 09:04:24 2014 +0100
background: Frame the thumbnails
https://bugzilla.gnome.org/show_bug.cgi?id=708943
configure.ac | 2 +-
panels/background/Makefile.am | 3 +-
panels/background/background.gresource.xml | 1 +
panels/background/bg-pictures-source.c | 45 ++++++++++++++++++++++++++--
panels/background/thumbnail-frame.png | Bin 0 -> 482 bytes
5 files changed, 46 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3991b20..ad699e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,7 +113,7 @@ COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
gio-unix-2.0
gsettings-desktop-schemas >= $SCHEMAS_REQUIRED_VERSION"
-LIBGD_INIT([_view-common notification main-toolbar stack static])
+LIBGD_INIT([gtk-hacks _view-common notification main-toolbar stack static])
PKG_CHECK_MODULES(LIBLANGUAGE, $COMMON_MODULES gnome-desktop-3.0 fontconfig)
PKG_CHECK_MODULES(LIBSHORTCUTS, $COMMON_MODULES x11)
diff --git a/panels/background/Makefile.am b/panels/background/Makefile.am
index 58e39aa..b651b60 100644
--- a/panels/background/Makefile.am
+++ b/panels/background/Makefile.am
@@ -10,6 +10,7 @@ dist_slideshowemblem_DATA = slideshow-emblem.svg
INCLUDES = \
$(PANEL_CFLAGS) \
$(BACKGROUND_PANEL_CFLAGS) \
+ -I$(top_srcdir)/libgd \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DDATADIR="\"$(datadir)\"" \
-DGNOME_DESKTOP_USE_UNSTABLE_API \
@@ -40,7 +41,7 @@ libbackground_chooser_la_SOURCES = \
bg-colors-source.c \
bg-colors-source.h
-libbackground_chooser_la_LIBADD = $(PANEL_LIBS) $(BACKGROUND_PANEL_LIBS)
+libbackground_chooser_la_LIBADD = $(PANEL_LIBS) $(BACKGROUND_PANEL_LIBS) $(top_builddir)/libgd/libgd.la
libbackground_la_SOURCES = \
cc-background-panel.c \
diff --git a/panels/background/background.gresource.xml b/panels/background/background.gresource.xml
index e8e4ff3..00d6bc4 100644
--- a/panels/background/background.gresource.xml
+++ b/panels/background/background.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/control-center/background">
<file preprocess="xml-stripblanks">background.ui</file>
+ <file preprocess="to-pixdata">thumbnail-frame.png</file>
</gresource>
</gresources>
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 9b86c87..7333230 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <gio/gio.h>
+#include <libgd/gd.h>
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include <gdesktop-enums.h>
@@ -166,13 +167,19 @@ picture_scaled (GObject *source_object,
BgPicturesSource *bg_source;
CcBackgroundItem *item;
GError *error = NULL;
+ GdkPixbuf *framed_pixbuf = NULL;
GdkPixbuf *pixbuf = NULL;
+ GtkBorder border;
const char *software;
const char *uri;
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeRowReference *row_ref;
GtkListStore *store;
+ gint16 x_border;
+ gint16 y_border;
+ int height;
+ int width;
item = g_object_get_data (source_object, "item");
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
@@ -207,12 +214,24 @@ picture_scaled (GObject *source_object,
cc_background_item_load (item, NULL);
+ height = gdk_pixbuf_get_height (pixbuf);
+ width = gdk_pixbuf_get_width (pixbuf);
+ x_border = (gint16) (THUMBNAIL_WIDTH - width) / 2 + 2;
+ y_border = (gint16) (THUMBNAIL_HEIGHT - height) / 2 + 2;
+
+ border.left = border.right = x_border;
+ border.bottom = border.top = y_border;
+ framed_pixbuf = gd_embed_image_in_frame (pixbuf,
+
"resource:///org/gnome/control-center/background/thumbnail-frame.png",
+ &border,
+ &border);
+
row_ref = g_object_get_data (G_OBJECT (item), "row-ref");
if (row_ref == NULL)
{
/* insert the item into the liststore if it did not exist */
gtk_list_store_insert_with_values (store, NULL, -1,
- 0, pixbuf,
+ 0, framed_pixbuf,
1, item,
-1);
}
@@ -223,7 +242,7 @@ picture_scaled (GObject *source_object,
{
/* otherwise update the thumbnail */
gtk_list_store_set (store, &iter,
- 0, pixbuf,
+ 0, framed_pixbuf,
-1);
}
}
@@ -234,6 +253,7 @@ picture_scaled (GObject *source_object,
out:
+ g_clear_object (&framed_pixbuf);
g_clear_object (&pixbuf);
}
@@ -306,7 +326,9 @@ add_single_file (BgPicturesSource *bg_source,
const gchar *content_type;
CcBackgroundItem *item = NULL;
GError *error = NULL;
+ GdkPixbuf *framed_pixbuf = NULL;
GdkPixbuf *pixbuf = NULL;
+ GtkBorder border;
GtkIconInfo *icon_info = NULL;
GtkIconTheme *theme;
GtkListStore *store;
@@ -315,7 +337,11 @@ add_single_file (BgPicturesSource *bg_source,
GtkTreeRowReference *row_ref;
char *uri = NULL;
gboolean retval = FALSE;
+ gint16 x_border;
+ gint16 y_border;
guint64 mtime;
+ int height;
+ int width;
/* find png and jpeg files */
content_type = g_file_info_get_content_type (info);
@@ -361,11 +387,23 @@ add_single_file (BgPicturesSource *bg_source,
goto read_file;
}
+ height = gdk_pixbuf_get_height (pixbuf);
+ width = gdk_pixbuf_get_width (pixbuf);
+ x_border = (gint16) (THUMBNAIL_WIDTH - width) / 2 + 2;
+ y_border = (gint16) (THUMBNAIL_HEIGHT - height) / 2 + 2;
+
+ border.left = border.right = x_border;
+ border.bottom = border.top = y_border;
+ framed_pixbuf = gd_embed_image_in_frame (pixbuf,
+
"resource:///org/gnome/control-center/background/thumbnail-frame.png",
+ &border,
+ &border);
+
store = bg_source_get_liststore (BG_SOURCE (bg_source));
/* insert the item into the liststore */
gtk_list_store_insert_with_values (store, &iter, -1,
- 0, pixbuf,
+ 0, framed_pixbuf,
1, item,
-1);
@@ -384,6 +422,7 @@ add_single_file (BgPicturesSource *bg_source,
out:
gtk_tree_path_free (path);
+ g_clear_object (&framed_pixbuf);
g_clear_object (&pixbuf);
g_clear_object (&icon_info);
g_clear_object (&item);
diff --git a/panels/background/thumbnail-frame.png b/panels/background/thumbnail-frame.png
new file mode 100644
index 0000000..674b648
Binary files /dev/null and b/panels/background/thumbnail-frame.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]