[Xfce4-commits] [xfce/xfwm4] 09/32: Load default icon from icon theme

noreply at xfce.org noreply at xfce.org
Tue Dec 5 09:21:55 CET 2017


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

o   l   i   v   i   e   r       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/xfwm4.

commit 5b10f726c28c68d0ebc972754b08f5ea199d36b1
Author: Viktor Odintsev <zakhams at gmail.com>
Date:   Sun Jul 2 16:50:08 2017 +0300

    Load default icon from icon theme
---
 icons/48x48/Makefile.am                            |   3 +-
 icons/48x48/xfwm4-default.png                      | Bin 0 -> 667 bytes
 icons/scalable/Makefile.am                         |   3 +-
 .../scalable/xfwm4-default.svg                     |   0
 src/Makefile.am                                    |  14 --------
 src/default_icon.png                               | Bin 843 -> 0 bytes
 src/icons.c                                        |  36 ++++++++++-----------
 7 files changed, 21 insertions(+), 35 deletions(-)

diff --git a/icons/48x48/Makefile.am b/icons/48x48/Makefile.am
index d420d48..8d4c1c7 100644
--- a/icons/48x48/Makefile.am
+++ b/icons/48x48/Makefile.am
@@ -2,6 +2,7 @@ iconsdir = $(datadir)/icons/hicolor/48x48/apps
 icons_DATA =								\
 	wmtweaks.png							\
 	xfce4-workspaces.png						\
-	xfwm4.png
+	xfwm4.png							\
+	xfwm4-default.png
 
 EXTRA_DIST = $(icons_DATA)
diff --git a/icons/48x48/xfwm4-default.png b/icons/48x48/xfwm4-default.png
new file mode 100644
index 0000000..6bb8d0a
Binary files /dev/null and b/icons/48x48/xfwm4-default.png differ
diff --git a/icons/scalable/Makefile.am b/icons/scalable/Makefile.am
index 59b92ee..9c6acf9 100644
--- a/icons/scalable/Makefile.am
+++ b/icons/scalable/Makefile.am
@@ -2,7 +2,8 @@ appiconsdir = $(datadir)/icons/hicolor/scalable/apps
 appicons_DATA =								\
 	wmtweaks.svg							\
 	xfce4-workspaces.svg						\
-	xfwm4.svg
+	xfwm4.svg							\
+	xfwm4-default.svg
 
 actionsiconsdir = $(datadir)/icons/hicolor/scalable/actions
 actionsicons_DATA =							\
diff --git a/src/default_icon.svg b/icons/scalable/xfwm4-default.svg
similarity index 100%
rename from src/default_icon.svg
rename to icons/scalable/xfwm4-default.svg
diff --git a/src/Makefile.am b/src/Makefile.am
index 018cb36..8a6309e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,7 +21,6 @@ xfwm4_SOURCES =								\
 	hints.h								\
 	icons.c								\
 	icons.h								\
-	inline-default-icon.h						\
 	keyboard.c							\
 	keyboard.h							\
 	main.c								\
@@ -116,17 +115,4 @@ AM_CPPFLAGS = 								\
 	$(PLATFORM_CPPFLAGS)
 
 EXTRA_DIST = 								\
-	default_icon.png						\
-	default_icon.svg						\
 	gen-color-table.pl
-
-if MAINTAINER_MODE
-
-BUILT_SOURCES =								\
-	inline-default-icon.h
-
-inline-default-icon.h: $(srcdir)/default_icon.png
-	$(AM_V_GEN) gdk-pixbuf-csource --raw --build-list 		\
-	default_icon_data $(srcdir)/default_icon.png > inline-default-icon.h
-
-endif
diff --git a/src/default_icon.png b/src/default_icon.png
deleted file mode 100644
index 9b74d8d..0000000
Binary files a/src/default_icon.png and /dev/null differ
diff --git a/src/icons.c b/src/icons.c
index 1066f1e..1238d91 100644
--- a/src/icons.c
+++ b/src/icons.c
@@ -33,7 +33,6 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libxfce4util/libxfce4util.h>
 
-#include "inline-default-icon.h"
 #include "icons.h"
 #include "display.h"
 #include "screen.h"
@@ -70,34 +69,33 @@ downsize_ratio (guint *width, guint *height, guint dest_w, guint dest_h)
  * create a GdkPixbuf from inline data and scale it to a given size
  */
 static GdkPixbuf *
-inline_icon_at_size (const guint8 *data, guint width, guint height)
+default_icon_at_size (GdkScreen *screen, guint width, guint height)
 {
+    GtkIconTheme *icon_theme;
     GdkPixbuf *base;
+    GdkPixbuf *scaled;
 
-    base = gdk_pixbuf_new_from_inline (-1, data, FALSE, NULL);
+    icon_theme = gtk_icon_theme_get_for_screen (screen);
 
-    g_return_val_if_fail (base, NULL);
+    g_return_val_if_fail (icon_theme != NULL, NULL);
 
-    if ((width <= 0 || height <= 0) ||
-        ((guint) gdk_pixbuf_get_width (base) == width &&
-         (guint) gdk_pixbuf_get_height (base) == height))
+    if (width <= 0 || height <= 0)
     {
-        return base;
+        width = 160;
+        height = 160;
     }
-    else
-    {
-        GdkPixbuf *scaled;
-        guint w, h;
 
-        w = gdk_pixbuf_get_width (base);
-        h = gdk_pixbuf_get_height (base);
-        downsize_ratio (&w, &h, width, height);
-        scaled = gdk_pixbuf_scale_simple (base, w, h, GDK_INTERP_BILINEAR);
+    base = gtk_icon_theme_load_icon (icon_theme, "xfwm4-default",
+                                     MAX (width, height), 0, NULL);
 
+    if (base != NULL && width != height)
+    {
+        scaled = gdk_pixbuf_scale_simple (base, width, height, GDK_INTERP_BILINEAR);
         g_object_unref (G_OBJECT (base));
-
         return scaled;
     }
+
+    return base;
 }
 
 
@@ -573,7 +571,7 @@ getAppIcon (ScreenInfo *screen_info, Window window, guint width, guint height)
         }
     }
 
-    return inline_icon_at_size (default_icon_data, width, height);
+    return default_icon_at_size (screen_info->gscr, width, height);
 }
 
 GdkPixbuf *
@@ -606,7 +604,7 @@ getClientIcon (Client *c, guint width, guint height)
     }
     else
     {
-        app_content = inline_icon_at_size (default_icon_data, width, height);
+        app_content = default_icon_at_size (screen_info->gscr, width, height);
     }
 
     app_icon_width = (guint) gdk_pixbuf_get_width (app_content);

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


More information about the Xfce4-commits mailing list