[gnome-software] Use GdkPixbuf to parse icns files



commit 7418e511c5420225afe8b73b5fa29bf921429391
Author: Richard Hughes <richard hughsie com>
Date:   Fri Mar 4 10:50:01 2016 +0000

    Use GdkPixbuf to parse icns files

 configure.ac                   |   21 ++--------
 contrib/gnome-software.spec.in |    1 -
 src/plugins/Makefile.am        |    2 +-
 src/plugins/gs-plugin-steam.c  |   80 ++--------------------------------------
 4 files changed, 10 insertions(+), 94 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ebcc34b..bd19941 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,23 +204,12 @@ AM_CONDITIONAL(HAVE_LIMBA, test x$enable_limba = xyes)
 # Steam
 AC_ARG_ENABLE(steam,
               [AS_HELP_STRING([--enable-steam],
-                              [enable steam support [default=auto]])],,
-              enable_steam=maybe)
-AS_IF([test "x$enable_steam" != "xno"], [
-    PKG_CHECK_MODULES(STEAM, libicns,
-                     [have_steam=yes],
-                      [have_steam=no])
-], [
-    have_steam=no
-])
-AS_IF([test "x$have_steam" = "xyes"], [
+                              [enable steam support [default=yes]])],,
+              enable_steam=yes)
+AS_IF([test "x$enable_steam" = "xyes"], [
     AC_DEFINE(HAVE_STEAM,1,[Build steam support])
-], [
-    AS_IF([test "x$enable_steam" = "xyes"], [
-          AC_MSG_ERROR([Steam support requested but 'steam' was not found])
-    ])
 ])
-AM_CONDITIONAL(HAVE_STEAM, test x$have_steam = xyes)
+AM_CONDITIONAL(HAVE_STEAM, test x$enable_steam = xyes)
 
 # this refers to the gnome-software plugin API version
 # this is not in any way related to a package or soname version
@@ -271,5 +260,5 @@ echo "
         Firmware support:          ${have_firmware}
         Limba support:             ${have_limba}
         XDG-APP support:           ${have_xdg_app}
-        Steam support:             ${have_steam}
+        Steam support:             ${enable_steam}
 "
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
index ff58e2c..8b7e866 100644
--- a/contrib/gnome-software.spec.in
+++ b/contrib/gnome-software.spec.in
@@ -28,7 +28,6 @@ BuildRequires: libnotify-devel
 BuildRequires: PackageKit-glib-devel >= 0.8.10
 BuildRequires: libsoup-devel
 BuildRequires: gnome-desktop3-devel
-BuildRequires: libicns-devel
 BuildRequires: gsettings-desktop-schemas-devel
 BuildRequires: libappstream-glib-devel
 BuildRequires: fwupd-devel
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 7d5d8e5..90e6f1f 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -142,7 +142,7 @@ endif
 
 if HAVE_STEAM
 libgs_plugin_steam_la_SOURCES = gs-plugin-steam.c
-libgs_plugin_steam_la_LIBADD = $(GS_PLUGIN_LIBS) $(STEAM_LIBS)
+libgs_plugin_steam_la_LIBADD = $(GS_PLUGIN_LIBS)
 libgs_plugin_steam_la_LDFLAGS = -module -avoid-version
 libgs_plugin_steam_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
 endif
diff --git a/src/plugins/gs-plugin-steam.c b/src/plugins/gs-plugin-steam.c
index 79964f7..cd11f1d 100644
--- a/src/plugins/gs-plugin-steam.c
+++ b/src/plugins/gs-plugin-steam.c
@@ -23,7 +23,6 @@
 
 #include <gs-plugin.h>
 #include <string.h>
-#include <icns.h>
 
 #include "gs-utils.h"
 
@@ -439,68 +438,6 @@ gs_plugin_steam_update_description (AsApp *app,
 }
 
 /**
- * gs_plugin_steam_new_pixbuf_from_icns:
- **/
-static GdkPixbuf *
-gs_plugin_steam_new_pixbuf_from_icns (const gchar *fn, GError **error)
-{
-       GdkPixbuf *pb = NULL;
-       FILE *datafile;
-       guint i;
-       icns_family_t *icon_family = NULL;
-       icns_image_t im;
-       int rc;
-       icns_type_t preference[] = {
-               ICNS_128X128_32BIT_DATA,
-               ICNS_256x256_32BIT_ARGB_DATA,
-               ICNS_48x48_32BIT_DATA,
-               0 };
-
-       /* open file */
-       datafile = fopen (fn, "rb");
-       rc = icns_read_family_from_file (datafile, &icon_family);
-       if (rc != 0) {
-               g_set_error (error, 1, 0, "Failed to read icon %s", fn);
-               return NULL;
-       }
-
-       /* libicns 'helpfully' frees the @arg */
-       im.imageData = NULL;
-
-       /* get the best sized icon */
-       for (i = 0; preference[i] != 0; i++) {
-               rc = icns_get_image32_with_mask_from_family (icon_family,
-                                                            preference[i],
-                                                            &im);
-               if (rc == 0) {
-                       gchar buf[5];
-                       icns_type_str (preference[i], buf);
-                       g_debug ("using ICNS %s for %s", buf, fn);
-                       break;
-               }
-       }
-       if (im.imageData == NULL) {
-               g_set_error (error, 1, 0, "Failed to get icon %s", fn);
-               return NULL;
-       }
-
-       /* create the pixbuf */
-       pb = gdk_pixbuf_new_from_data (im.imageData,
-                                      GDK_COLORSPACE_RGB,
-                                      TRUE,
-                                      im.imagePixelDepth,
-                                      im.imageWidth,
-                                      im.imageHeight,
-                                      im.imageWidth * im.imageChannels,
-                                      NULL, //??
-                                      NULL);
-       g_assert (pb != NULL);
-
-       fclose (datafile);
-       return pb;
-}
-
-/**
  * gs_plugin_steam_download_icon:
  **/
 static gboolean
@@ -540,19 +477,10 @@ gs_plugin_steam_download_icon (GsPlugin *plugin,
                        return FALSE;
        }
 
-       /* check the icns file is not just a png/ico/jpg file in disguise */
-       if (memcmp (data + 1, "\x89PNG", 4) == 0 ||
-           memcmp (data, "\x00\x00\x01\x00", 4) == 0 ||
-           memcmp (data, "\xff\xd8\xff", 3) == 0) {
-               g_debug ("using fallback for %s\n", cache_fn);
-               pb = gdk_pixbuf_new_from_file (cache_fn, error);
-               if (pb == NULL)
-                       return FALSE;
-       } else {
-               pb = gs_plugin_steam_new_pixbuf_from_icns (cache_fn, error);
-               if (pb == NULL)
-                       return FALSE;
-       }
+       /* load the icon as large as possible */
+       pb = gdk_pixbuf_new_from_file (cache_fn, error);
+       if (pb == NULL)
+               return FALSE;
 
        /* too small? */
        if (gdk_pixbuf_get_width (pb) < 48 ||


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]