[balsa] Install extra mimetype icons in Balsa's data tree



commit 4400b65d2325e0446cbc45bcf0c250476c8caea7
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Apr 25 20:08:54 2017 -0400

    Install extra mimetype icons in Balsa's data tree
    
    renamed:    gnome-mime-application-pgp-signature.png -> application-pgp-signature.png
    renamed:    gnome-mime-application-pkcs7-mime.png -> application-pkcs7-mime.png
    renamed:    gnome-mime-application-pkcs7-signature.png -> application-pkcs7-signature.png
    renamed:    gnome-mime-application-x-pkcs7-signature.png -> application-x-pkcs7-signature.png
    renamed:    gnome-mime-message-disposition-notification.png -> message-disposition-notification.png
    renamed:    gnome-mime-message-external-body.png -> message-external-body.png
    renamed:    gnome-mime-message.png -> message.png
    renamed:    gnome-mime-multipart-alternative.png -> multipart-alternative.png
    renamed:    gnome-mime-multipart-encrypted.png -> multipart-encrypted.png
    renamed:    gnome-mime-multipart-signed.png -> multipart-signed.png
    renamed:    gnome-mime-multipart.png -> multipart.png
    
        * configure.ac: do not install them in Gtk's icon folder.
        * images/24x24/Makefile.am: we do not need the 22x22 - 24x24
              symlink.
        * images/Makefile.am: always install the extra mimetype icons.
        * images/mimetypes/Makefile.am: change the file names and the
              installation directory.
        * libbalsa/files.c (libbalsa_icon_finder): add Balsa's mimetypes
              directory to the default icon-theme search path and remove the
              "last resort" code.

 configure.ac                                       |   21 +------
 images/24x24/Makefile.am                           |   10 ---
 images/Makefile.am                                 |    4 -
 images/mimetypes/Makefile.am                       |   27 ++++-----
 ...signature.png => application-pgp-signature.png} |  Bin 2952 -> 2952 bytes
 ...n-pkcs7-mime.png => application-pkcs7-mime.png} |  Bin 4887 -> 4887 bytes
 ...gnature.png => application-pkcs7-signature.png} |  Bin 2968 -> 2968 bytes
 ...ature.png => application-x-pkcs7-signature.png} |  Bin 2968 -> 2968 bytes
 ...on.png => message-disposition-notification.png} |  Bin 3013 -> 3013 bytes
 ...external-body.png => message-external-body.png} |  Bin 3341 -> 3341 bytes
 .../{gnome-mime-message.png => message.png}        |  Bin 1936 -> 1936 bytes
 ...t-alternative.png => multipart-alternative.png} |  Bin 2365 -> 2365 bytes
 ...ipart-encrypted.png => multipart-encrypted.png} |  Bin 2649 -> 2649 bytes
 ...e-multipart-signed.png => multipart-signed.png} |  Bin 3793 -> 3793 bytes
 .../{gnome-mime-multipart.png => multipart.png}    |  Bin 2044 -> 2044 bytes
 libbalsa/files.c                                   |   61 +++++++-------------
 16 files changed, 37 insertions(+), 86 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 404b6b8..ea50351 100644
--- a/configure.ac
+++ b/configure.ac
@@ -797,25 +797,8 @@ if test "x$prefix" = "xNONE"; then
 fi
 CPPFLAGS="$CPPFLAGS -DBALSA_STD_PREFIX=\\\"${prefix}\\\""
 CPPFLAGS="$CPPFLAGS -DBALSA_DATA_PREFIX=\\\"${datadir}/balsa\\\""
-
-
-dnl ###########################################################################
-dnl determine the base folder for installing the extra icons
-dnl ###########################################################################
-
-AC_ARG_ENABLE(extra-mimeicons,
-        AC_HELP_STRING([--enable-extra-mimeicons],
-                       [Install extra MIME icons (needs write access to the gtk+ icon folder, 
default=yes)]),[
-       install_mimeicons=$enableval
-],[
-       install_mimeicons=yes
-])
-AM_CONDITIONAL([INSTALL_MIME_ICONS], [test $install_mimeicons = "yes"])
-HICOLOR_ICON_DIR=`$PKG_CONFIG --variable=prefix gtk+-3.0`/share/icons/hicolor
-AC_SUBST(HICOLOR_ICON_DIR)
-dnl however, we do not mess with the icon caches - it messes up more
-dnl things that it fixes, for eg. user installs, package builds etc.
-dnl AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache)
+BALSA_DATA_PREFIX="${datadir}/balsa"
+AC_SUBST(BALSA_DATA_PREFIX)
 
 dnl Documentation and Testing requirements for libnetclient
 
diff --git a/images/24x24/Makefile.am b/images/24x24/Makefile.am
index 0ceb002..4669c5c 100644
--- a/images/24x24/Makefile.am
+++ b/images/24x24/Makefile.am
@@ -34,13 +34,3 @@ EXTRA_DIST = $(extra_appicons_IMGS)
 
 extra_appiconsdir = $(BALSA_DATA_PREFIX)/hicolor/24x24/apps
 extra_appicons_DATA = $(extra_appicons_IMGS)
-
-
-# Note: this link must be created due to a bug in gtk which searches the
-# folder 22x22 instead of 24x24 for 24 pixel wide icons.
-# (see http://bugzilla.gnome.org/show_bug.cgi?id=166374)
-install-data-hook:
-       cd $(DESTDIR)$(BALSA_DATA_PREFIX)/hicolor; \
-       if ! test -e 22x22; then     \
-               $(LN_S) 24x24 22x22 ;  \
-       fi
diff --git a/images/Makefile.am b/images/Makefile.am
index 98a7b94..69aa69a 100644
--- a/images/Makefile.am
+++ b/images/Makefile.am
@@ -1,8 +1,4 @@
-if INSTALL_MIME_ICONS
 SUBDIRS = mimetypes 16x16 24x24
-else
-SUBDIRS = 16x16 24x24
-endif
 
 # balsa_logo.png used by About menu (small one).
 # balsa-logo.png used by the init-druid
diff --git a/images/mimetypes/Makefile.am b/images/mimetypes/Makefile.am
index d2311c1..3250f1a 100644
--- a/images/mimetypes/Makefile.am
+++ b/images/mimetypes/Makefile.am
@@ -1,19 +1,18 @@
-extramimetypes_IMGS = \
-       gnome-mime-application-pgp-signature.png        \
-       gnome-mime-application-pkcs7-mime.png   \
-       gnome-mime-application-pkcs7-signature.png      \
-       gnome-mime-application-x-pkcs7-signature.png    \
-       gnome-mime-message-disposition-notification.png \
-       gnome-mime-message-external-body.png    \
-       gnome-mime-message.png  \
-       gnome-mime-multipart-alternative.png    \
-       gnome-mime-multipart-encrypted.png      \
-       gnome-mime-multipart.png        \
-       gnome-mime-multipart-signed.png
+extramimetypes_IMGS =                          \
+       application-pgp-signature.png           \
+       application-pkcs7-mime.png              \
+       application-pkcs7-signature.png         \
+       application-x-pkcs7-signature.png       \
+       message-disposition-notification.png    \
+       message-external-body.png               \
+       message.png                             \
+       multipart-alternative.png               \
+       multipart-encrypted.png                 \
+       multipart.png                           \
+       multipart-signed.png
 
 
 EXTRA_DIST = $(extramimetypes_IMGS)
 
-extramimetypesdir = $(HICOLOR_ICON_DIR)/48x48/mimetypes
+extramimetypesdir = $(BALSA_DATA_PREFIX)/hicolor/48x48/mimetypes
 extramimetypes_DATA = $(extramimetypes_IMGS)
-
diff --git a/libbalsa/files.c b/libbalsa/files.c
index 330489e..6e104eb 100644
--- a/libbalsa/files.c
+++ b/libbalsa/files.c
@@ -132,6 +132,7 @@ libbalsa_icon_finder(GtkWidget         * widget,
     GdkPixbuf *pixbuf = NULL;
     gint width, height;
     GtkIconTheme *icon_theme;
+    GIcon *icon;
 
     if (!gtk_icon_size_lookup(size, &width, &height))
         width = 16;
@@ -141,15 +142,26 @@ libbalsa_icon_finder(GtkWidget         * widget,
     else if (for_file) {
         content_type = libbalsa_vfs_get_mime_type(for_file);
     } else
-       content_type = "application/octet-stream";
+        content_type = "application/octet-stream";
 
     /* ask GIO for the icon */
-    if ((icon_theme = gtk_icon_theme_get_default())) {
-        GIcon * icon = g_content_type_get_icon(content_type);
+    if ((icon_theme = gtk_icon_theme_get_default()) == NULL)
+        return NULL;
+
+    icon = g_content_type_get_icon(content_type);
 
-        if (icon != NULL && G_IS_THEMED_ICON(icon)) {
+    if (icon != NULL) {
+        if (G_IS_THEMED_ICON(icon)) {
             gint i;
             GStrv icon_names;
+            static gsize appended = 0;
+
+            if (g_once_init_enter(&appended)) {
+                gtk_icon_theme_append_search_path(icon_theme,
+                                                  BALSA_DATA_PREFIX
+                                                  "/hicolor/48x48/mimetypes");
+                g_once_init_leave(&appended, 1);
+            }
 
             g_object_get(G_OBJECT(icon), "names", &icon_names, NULL);
 
@@ -159,45 +171,16 @@ libbalsa_icon_finder(GtkWidget         * widget,
                         gtk_icon_theme_load_icon(icon_theme, icon_names[i], width,
                                                  GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
                 }
+                g_strfreev(icon_names);
             }
-
-            g_strfreev(icon_names);
-            g_object_unref(icon);
-
-            /* last resort: try gnome-mime-<base mime type> */
-            if (pixbuf == NULL) {
-                gchar * base_type_icon = g_strdup_printf("gnome-mime-%s", content_type);
-                gchar * slash = strchr(base_type_icon, '/');
-                gchar *hyphen;
-
-                if (slash)
-                    *slash = '-';
-
-                do {
-                    pixbuf = gtk_icon_theme_load_icon(icon_theme, base_type_icon,
-                                                      width, GTK_ICON_LOOKUP_FORCE_SIZE, NULL);
-                    if (pixbuf != NULL)
-                        break;
-
-                    if ((hyphen = strrchr(base_type_icon, '-')) != NULL) {
-                        *hyphen = '\0';
-                    }
-                } while (hyphen != NULL);
-
-                g_free(base_type_icon);
-            }
-
-            /* return if we found a proper pixbuf */
-           if (pixbuf) {
-               if (used_type)
-                   *used_type = g_strdup(content_type);
-               return pixbuf;
-           }
         }
+        g_object_unref(icon);
     }
 
-    /* load the pixbuf */
-    pixbuf = libbalsa_default_attachment_pixbuf(width);
+    if (pixbuf == NULL) {
+        /* load the default pixbuf */
+        pixbuf = libbalsa_default_attachment_pixbuf(width);
+    }
 
     if (used_type)
         *used_type = g_strdup(content_type);


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