[Xfce4-commits] [xfce/thunar] 02/02: Use GResource for thumbnail frame

noreply at xfce.org noreply at xfce.org
Sun Jun 3 00:41:10 CEST 2018


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 01854c4070196fe173fc1cd67b19c98fee0039ac
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sat Jun 2 19:35:31 2018 -0300

    Use GResource for thumbnail frame
    
    Also make it work again, the /.thumbnails/ path
    has changed to /.cache/thumbnails/
---
 .gitignore                      |  2 +-
 thunar/Makefile.am              | 42 ++++++++++++++++++++++-------------------
 thunar/thunar-icon-factory.c    | 26 +++++++++++++++++++++----
 thunar/thunar-thumbnail-frame.h | 31 ------------------------------
 thunar/thunar.gresource.xml     |  6 ++++++
 5 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3362ead..40ec2ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -108,10 +108,10 @@ thunar/thunar
 thunar/thunar-dbus-service-infos.[ch]
 thunar/thunar-fallback-icon.c
 thunar/thunar-thumbnail-cache-proxy.[ch]
-thunar/thunar-thumbnail-frame.c
 thunar/thunar-thumbnailer-manager-proxy.h
 thunar/thunar-thumbnailer-proxy.[ch]
 thunar/thunar-marshal.[ch]
+thunar/thunar-resources.[ch]
 thunar/Thunar
 thunar/core.*
 thunar/*.core
diff --git a/thunar/Makefile.am b/thunar/Makefile.am
index e27c95e..cd74726 100644
--- a/thunar/Makefile.am
+++ b/thunar/Makefile.am
@@ -22,22 +22,23 @@ bin_PROGRAMS =								\
 	thunar
 
 thunar_built_sources =							\
-	thunar-marshal.c						\
-	thunar-marshal.h						\
-	thunar-abstract-icon-view-ui.h					\
+	thunar-marshal.c							\
+	thunar-marshal.h							\
+	thunar-abstract-icon-view-ui.h				\
 	thunar-details-view-ui.h					\
 	thunar-launcher-ui.h						\
 	thunar-shortcuts-pane-ui.h					\
 	thunar-renamer-dialog-ui.h					\
 	thunar-standard-view-ui.h					\
-	thunar-thumbnail-frame.c					\
 	thunar-dbus-service-infos.h					\
 	thunar-dbus-service-infos.c					\
 	thunar-thumbnailer-proxy.c					\
 	thunar-thumbnailer-proxy.h					\
-	thunar-thumbnail-cache-proxy.h 					\
-	thunar-thumbnail-cache-proxy.c					\
-	thunar-window-ui.h
+	thunar-thumbnail-cache-proxy.h				\
+	thunar-thumbnail-cache-proxy.c				\
+	thunar-window-ui.h							\
+	thunar-resources.h							\
+	thunar-resources.c
 
 
 thunar_SOURCES =							\
@@ -200,7 +201,6 @@ thunar_SOURCES =							\
 	thunar-thumbnail-cache.h					\
 	thunar-thumbnailer.c						\
 	thunar-thumbnailer.h						\
-	thunar-thumbnail-frame.h					\
 	thunar-transfer-job.c						\
 	thunar-transfer-job.h						\
 	thunar-trash-action.c						\
@@ -298,9 +298,6 @@ thunar-thumbnailer-proxy.h thunar-thumbnailer-proxy.c: $(srcdir)/thunar-thumbnai
 thunar-thumbnail-cache-proxy.h thunar-thumbnail-cache-proxy.c: $(srcdir)/thunar-thumbnail-cache-dbus.xml Makefile
 	$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code thunar-thumbnail-cache-proxy $(srcdir)/thunar-thumbnail-cache-dbus.xml
 
-thunar-thumbnail-frame.c: $(srcdir)/thunar-thumbnail-frame.png Makefile
-	$(AM_V_GEN) (echo "#include <thunar/thunar-thumbnail-frame.h>" && gdk-pixbuf-csource --extern --raw --stream --name=thunar_thumbnail_frame $(srcdir)/thunar-thumbnail-frame.png) > thunar-thumbnail-frame.c
-
 thunar-abstract-icon-view-ui.h: Makefile $(srcdir)/thunar-abstract-icon-view-ui.xml
 	$(AM_V_GEN) exo-csource --strip-comments --strip-content --static --name=thunar_abstract_icon_view_ui $(srcdir)/thunar-abstract-icon-view-ui.xml > thunar-abstract-icon-view-ui.h
 
@@ -349,17 +346,24 @@ thunar-marshal.c: thunar-marshal.list Makefile
 		&& cp xgen-tmc thunar-marshal.c \
 		&& rm -f xgen-tmc \
 	)
+
+thunar-resources.c: thunar.gresource.xml
+	glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name thunar $(srcdir)/thunar.gresource.xml
+
+thunar-resources.h: thunar.gresource.xml
+	glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name thunar $(srcdir)/thunar.gresource.xml
 endif
 
 EXTRA_DIST =								\
-	thunar-abstract-icon-view-ui.xml				\
-	thunar-dbus-service-infos.xml					\
-	thunar-details-view-ui.xml					\
-	thunar-launcher-ui.xml						\
+	thunar-abstract-icon-view-ui.xml		\
+	thunar-dbus-service-infos.xml			\
+	thunar-details-view-ui.xml				\
+	thunar-launcher-ui.xml					\
 	thunar-marshal.list						\
-	thunar-renamer-dialog-ui.xml					\
-	thunar-standard-view-ui.xml					\
-	thunar-thumbnail-frame.png					\
-	thunar-window-ui.xml						\
+	thunar-renamer-dialog-ui.xml			\
+	thunar-standard-view-ui.xml				\
+	thunar-thumbnail-frame.png				\
+	thunar-window-ui.xml					\
 	thunar-settings							\
+	thunar.gresource.xml					\
 	$(desktop_in_files)
diff --git a/thunar/thunar-icon-factory.c b/thunar/thunar-icon-factory.c
index 6bc0847..b39f414 100644
--- a/thunar/thunar-icon-factory.c
+++ b/thunar/thunar-icon-factory.c
@@ -34,7 +34,6 @@
 #include <thunar/thunar-icon-factory.h>
 #include <thunar/thunar-preferences.h>
 #include <thunar/thunar-private.h>
-#include <thunar/thunar-thumbnail-frame.h>
 #include <thunar/thunar-util.h>
 
 
@@ -400,6 +399,26 @@ thumbnail_needs_frame (const GdkPixbuf *thumbnail,
 
 
 static GdkPixbuf*
+thunar_icon_factory_get_thumbnail_frame (void)
+{
+  GInputStream *stream;
+  static GdkPixbuf *frame = NULL;
+
+  if (G_LIKELY (frame != NULL))
+     return frame;
+
+  stream = g_resources_open_stream ("/org/xfce/thunar/thumbnail-frame.png", 0, NULL);
+  if (G_UNLIKELY (stream != NULL)) {
+    frame = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
+    g_object_unref (stream);
+  }
+
+  return frame;
+}
+
+
+
+static GdkPixbuf*
 thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
                                     const gchar       *path,
                                     gint               size)
@@ -424,7 +443,7 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
       /* check if we want to add a frame to the image (we really don't
        * want to do this for icons displayed in the details view).
        */
-      needs_frame = (strstr (path, G_DIR_SEPARATOR_S ".thumbnails" G_DIR_SEPARATOR_S) != NULL)
+      needs_frame = (strstr (path, G_DIR_SEPARATOR_S ".cache/thumbnails" G_DIR_SEPARATOR_S) != NULL)
                  && (size >= 32) && thumbnail_needs_frame (pixbuf, width, height);
 
       /* be sure to make framed thumbnails fit into the size */
@@ -452,10 +471,9 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
       if (G_LIKELY (needs_frame))
         {
           /* add a frame to the thumbnail */
-          frame = gdk_pixbuf_new_from_inline (-1, thunar_thumbnail_frame, FALSE, NULL);
+          frame = thunar_icon_factory_get_thumbnail_frame ();
           tmp = exo_gdk_pixbuf_frame (pixbuf, frame, 4, 3, 5, 6);
           g_object_unref (G_OBJECT (pixbuf));
-          g_object_unref (G_OBJECT (frame));
           pixbuf = tmp;
         }
     }
diff --git a/thunar/thunar-thumbnail-frame.h b/thunar/thunar-thumbnail-frame.h
deleted file mode 100644
index 8ac8819..0000000
--- a/thunar/thunar-thumbnail-frame.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* vi:set et ai sw=2 sts=2 ts=2: */
-/*-
- * Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef __THUNAR_THUMBNAIL_FRAME_H__
-#define __THUNAR_THUMBNAIL_FRAME_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS;
-
-extern const guint8 thunar_thumbnail_frame[];
-
-G_END_DECLS;
-
-#endif /* !__THUNAR_THUMBNAIL_FRAME_H__ */
diff --git a/thunar/thunar.gresource.xml b/thunar/thunar.gresource.xml
new file mode 100644
index 0000000..1f521a4
--- /dev/null
+++ b/thunar/thunar.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/xfce/thunar">
+    <file compressed="true" alias="thumbnail-frame.png">thunar-thumbnail-frame.png</file>
+  </gresource>
+</gresources>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list