Load SVG files the deprecated way
[claws.git] / src / stock_pixmap.c
index 702b45c624b8bf91b919b3c2cf5358e59079f09b..947b2e6088de8f4f900b96b3db904ba4c36af531 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "defs.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "claws-features.h"
+#endif
+
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <librsvg/rsvg.h>
 #include <string.h>
 #include <dirent.h>
 
-#include "config.h"
+#include "defs.h"
 #include "stock_pixmap.h"
 #include "gtkutils.h"
 #include "utils.h"
 #include "pixmaps/mime_message.xpm"
 #include "pixmaps/address_search.xpm"
 #include "pixmaps/check_spelling.xpm"
-
 #include "pixmaps/dir_close.xpm"
 #include "pixmaps/dir_close_hrm.xpm"
 #include "pixmaps/dir_open.xpm"
 #include "pixmaps/trash_open.xpm"
 #include "pixmaps/trash_close.xpm"
 #include "pixmaps/delete_btn.xpm"
+#include "pixmaps/delete_dup_btn.xpm"
 #include "pixmaps/cancel.xpm"
 #include "pixmaps/trash_btn.xpm"
 #include "pixmaps/trash_open_hrm.xpm"
@@ -402,6 +407,7 @@ static StockPixmapData pixmaps[] =
     {claws_mail_icon_64_xpm           , NULL, NULL, "claws_mail_icon_64", NULL, NULL},
     {read_xpm                         , NULL, NULL, "read", NULL, NULL},
     {delete_btn_xpm                   , NULL, NULL, "delete_btn", NULL, NULL},
+    {delete_dup_btn_xpm               , NULL, NULL, "delete_dup_btn", NULL, NULL},
     {cancel_xpm                       , NULL, NULL, "cancel", NULL, NULL},
     {trash_btn_xpm                    , NULL, NULL, "trash_btn", NULL, NULL},
     {claws_mail_compose_logo_xpm      , NULL, NULL, "claws_mail_compose_logo", NULL, NULL},
@@ -459,12 +465,28 @@ static StockPixmapData pixmaps[] =
     {empty_xpm                        , NULL, NULL, "empty", NULL, NULL}
 };
 
+/* Supported theme extensions */
+static const char *extension[] = {
+       ".png",
+       ".xpm",
+#ifdef HAVE_SVG
+       ".svg",
+#endif
+       NULL
+};
+
+/* return current supported extensions */
+const char **stock_pixmap_theme_extensions(void)
+{
+       return extension;
+}
+
 /* return newly constructed GtkPixmap from GdkPixmap */
 GtkWidget *stock_pixmap_widget(StockPixmap icon)
 {
        GdkPixbuf *pixbuf;
 
-       cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
+       cm_return_val_if_fail(icon < N_STOCK_PIXMAPS, NULL);
 
        if (stock_pixbuf_gdk(icon, &pixbuf) != -1)
                return gtk_image_new_from_pixbuf(pixbuf);
@@ -478,14 +500,13 @@ GtkWidget *stock_pixmap_widget(StockPixmap icon)
 gint stock_pixbuf_gdk(StockPixmap icon, GdkPixbuf **pixbuf)
 {
        StockPixmapData *pix_d;
-       static const char *extension[]={".png", ".xpm", NULL};
        int i = 0;
        gboolean theme_changed = FALSE;
 
        if (pixbuf)
                *pixbuf = NULL;
 
-       cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
+       cm_return_val_if_fail(icon < N_STOCK_PIXMAPS, -1);
 
        pix_d = &pixmaps[icon];
 
@@ -509,7 +530,15 @@ try_next_extension:
                                                             NULL);
                                if (is_file_exist(icon_file_name)) {
                                        GError *err = NULL;
+#ifdef HAVE_SVG
+                                       if (!strncmp(extension[i], ".svg", 4)) {
+                                               pix = rsvg_pixbuf_from_file(icon_file_name, &err);
+                                       } else {
+                                               pix = gdk_pixbuf_new_from_file(icon_file_name, &err);
+                                       }
+#else
                                        pix = gdk_pixbuf_new_from_file(icon_file_name, &err);
+#endif
                                        if (err) g_error_free(err);
                                }
                                if (pix) {
@@ -555,7 +584,6 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
        gchar *fullentry;
        GDir *dp;
        GError *error = NULL;
-       static const char *extension[]={".png", ".xpm", NULL};
 
        if ((dp = g_dir_open(dirname, 0, &error)) == NULL) {
                debug_print("skipping theme scan, dir %s could not be opened: %s (%d)\n",
@@ -635,7 +663,7 @@ void stock_pixmap_themes_list_free(GList *list)
 
 gchar *stock_pixmap_get_name (StockPixmap icon)
 {
-       if (icon < 0 || icon >= N_STOCK_PIXMAPS)
+       if (icon >= N_STOCK_PIXMAPS)
                return NULL;
 
        return pixmaps[icon].file;