remove icons that will never be displayed
[claws.git] / src / stock_pixmap.c
index 986535cab99d95a7c3dbdfb40becbad8997c4989..429fb6146312a18aad9556dadbf16acb29f1e82e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2011 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
  *
  * 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
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <dirent.h>
 
+#include "config.h"
 #include "stock_pixmap.h"
 #include "gtkutils.h"
 #include "utils.h"
@@ -57,6 +58,7 @@
 #include "pixmaps/locked.xpm"
 #include "pixmaps/new.xpm"
 #include "pixmaps/replied.xpm"
+#include "pixmaps/replied_and_forwarded.xpm"
 #include "pixmaps/close.xpm"
 #include "pixmaps/down_arrow.xpm"
 #include "pixmaps/up_arrow.xpm"
@@ -84,6 +86,7 @@
 #include "pixmaps/queue_open.xpm"
 #include "pixmaps/queue_open_hrm.xpm"
 #include "pixmaps/claws-mail_icon.xpm"
+#include "pixmaps/claws-mail_compose_logo.xpm"
 #ifndef GENERIC_UMPC
 #include "pixmaps/claws-mail_logo.xpm"
 #else
 #include "pixmaps/privacy_failed.xpm"
 #include "pixmaps/privacy_unknown.xpm"
 #include "pixmaps/privacy_expired.xpm"
-#include "pixmaps/privacy_warn.xpm"                 
+#include "pixmaps/privacy_warn.xpm"
 #include "pixmaps/privacy_emblem_encrypted.xpm"
 #include "pixmaps/privacy_emblem_signed.xpm"
 #include "pixmaps/privacy_emblem_passed.xpm"
 #include "pixmaps/privacy_emblem_failed.xpm"
 #include "pixmaps/privacy_emblem_warn.xpm"
-#include "pixmaps/mime_message.xpm"                  
+#include "pixmaps/mime_message.xpm"
 #include "pixmaps/address_search.xpm"
 #include "pixmaps/check_spelling.xpm"
 
 #include "pixmaps/trash_hrm_mark.xpm"
 #include "pixmaps/drafts_close_mark.xpm"
 #include "pixmaps/drafts_open_mark.xpm"
-#include "pixmaps/dir_noselect.xpm"
+#include "pixmaps/dir_noselect_close.xpm"
+#include "pixmaps/dir_noselect_close_mark.xpm"
+#include "pixmaps/dir_noselect_open.xpm"
+#include "pixmaps/dir_subs_close_mark.xpm"
+#include "pixmaps/dir_subs_close.xpm"
+#include "pixmaps/dir_subs_open.xpm"
 #include "pixmaps/spam.xpm"
 #include "pixmaps/spam_btn.xpm"
 #include "pixmaps/ham_btn.xpm"
@@ -273,7 +281,7 @@ static StockPixmapData pixmaps[] =
        {interface_xpm                          , NULL, NULL, "interface", NULL},
        {jpilot_xpm                             , NULL, NULL, "jpilot", NULL},
        {key_xpm                                , NULL, NULL, "key", NULL},
-       {key_gpg_signed_xpm                     , NULL, NULL, "key_gpg_signed_xpm", NULL},
+       {key_gpg_signed_xpm                     , NULL, NULL, "key_gpg_signed", NULL},
        {ldap_xpm                               , NULL, NULL, "ldap", NULL},
        {linewrapcurrent_xpm                    , NULL, NULL, "linewrapcurrent", NULL},
        {linewrap_xpm                           , NULL, NULL, "linewrap", NULL},
@@ -304,6 +312,7 @@ static StockPixmapData pixmaps[] =
        {outbox_open_mark_xpm                   , NULL, NULL, "outbox_open_mark", NULL},
        {outbox_open_hrm_mark_xpm               , NULL, NULL, "outbox_open_hrm_mark", NULL},
        {replied_xpm                            , NULL, NULL, "replied", NULL},
+       {replied_and_forwarded_xpm      , NULL, NULL, "replied_and_forwarded", NULL},
        {paste_xpm                              , NULL, NULL, "paste", NULL},
        {preferences_xpm                        , NULL, NULL, "preferences", NULL},
        {properties_xpm                         , NULL, NULL, "properties", NULL},
@@ -367,12 +376,18 @@ static StockPixmapData pixmaps[] =
        {delete_btn_xpm                         , NULL, NULL, "delete_btn", NULL},
        {cancel_xpm                             , NULL, NULL, "cancel", NULL},
        {trash_btn_xpm                          , NULL, NULL, "trash_btn", NULL},
+       {claws_mail_compose_logo_xpm            , NULL, NULL, "claws_mail_compose_logo", NULL},
 #ifndef GENERIC_UMPC
        {claws_mail_logo_xpm                    , NULL, NULL, "claws_mail_logo", NULL},
 #else
        {claws_mail_logo_small_xpm              , NULL, NULL, "claws_mail_logo_small", NULL},
 #endif
-        {dir_noselect_xpm                       , NULL, NULL, "dir_noselect" , NULL},
+        {dir_noselect_close_xpm                 , NULL, NULL, "dir_noselect_close" , NULL},
+        {dir_noselect_close_mark_xpm            , NULL, NULL, "dir_noselect_close_mark" , NULL},
+        {dir_noselect_open_xpm                  , NULL, NULL, "dir_noselect_open" , NULL},
+        {dir_subs_close_mark_xpm                , NULL, NULL, "dir_subs_close_mark" , NULL},
+        {dir_subs_close_xpm                     , NULL, NULL, "dir_subs_close" , NULL},
+        {dir_subs_open_xpm                      , NULL, NULL, "dir_subs_open" , NULL},
         {spam_xpm                               , NULL, NULL, "spam" , NULL},
         {spam_btn_xpm                           , NULL, NULL, "spam_btn" , NULL},
         {ham_btn_xpm                            , NULL, NULL, "ham_btn" , NULL},
@@ -394,14 +409,13 @@ static StockPixmapData pixmaps[] =
 };
 
 /* return newly constructed GtkPixmap from GdkPixmap */
-GtkWidget *stock_pixmap_widget(GtkWidget *window, StockPixmap icon)
+GtkWidget *stock_pixmap_widget(StockPixmap icon)
 {
        GdkPixbuf *pixbuf;
 
-       cm_return_val_if_fail(window != NULL, NULL);
        cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
 
-       if (stock_pixbuf_gdk(window, icon, &pixbuf) != -1)
+       if (stock_pixbuf_gdk(icon, &pixbuf) != -1)
                return gtk_image_new_from_pixbuf(pixbuf);
        
        return NULL;
@@ -410,7 +424,7 @@ GtkWidget *stock_pixmap_widget(GtkWidget *window, StockPixmap icon)
 /*!
  *\brief       
  */
-gint stock_pixbuf_gdk(GtkWidget *window, StockPixmap icon, GdkPixbuf **pixbuf)
+gint stock_pixbuf_gdk(StockPixmap icon, GdkPixbuf **pixbuf)
 {
        StockPixmapData *pix_d;
        static const char *extension[]={".png", ".xpm", NULL};
@@ -486,20 +500,20 @@ try_next_extension:
 
 static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
 {
-       struct dirent *d;
-       DIR *dp;
+       const gchar *entry;
+       gchar *fullentry;
+       GDir *dp;
+       GError *error = NULL;
        static const char *extension[]={".png", ".xpm", NULL};
        
-       if ((dp = opendir(dirname)) == NULL) {
-               debug_print("dir %s not found, skipping theme scan", dirname?dirname:"(null)");
+       if ((dp = g_dir_open(dirname, 0, &error)) == NULL) {
+               debug_print("skipping theme scan, dir %s could not be opened: %s (%d)\n",
+                               dirname ? dirname : "(null)", error->message, error->code);
+               g_error_free(error);
                return;
        }
        
-       while ((d = readdir(dp)) != NULL) {
-               gchar *entry;
-               gchar *fullentry;
-
-               entry     = d->d_name;
+       while ((entry = g_dir_read_name(dp)) != NULL) {
                fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL);
                
                if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) {
@@ -522,7 +536,7 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
                } else 
                        g_free(fullentry);
        }
-       closedir(dp);
+       g_dir_close(dp);
 }
 
 gchar *stock_pixmap_get_system_theme_dir_for_theme(const gchar *theme)
@@ -534,7 +548,7 @@ gchar *stock_pixmap_get_system_theme_dir_for_theme(const gchar *theme)
        return g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
                           PIXMAP_THEME_DIR, sep, theme, NULL);
 #else
-       return g_strconcat(get_themes_dir(), sep, theme, NULL);
+       return g_strconcat(w32_get_themes_dir(), sep, theme, NULL);
 #endif
 }
 
@@ -751,7 +765,7 @@ static void pixmap_with_overlay_destroy_cb(GtkWidget *object, OverlayData *data)
  * \param border_x size of the border around the base icon (left and right)
  * \param border_y size of the border around the base icon (top and bottom)
  */
-GtkWidget *stock_pixmap_widget_with_overlay(GtkWidget *window, StockPixmap icon,
+GtkWidget *stock_pixmap_widget_with_overlay(StockPixmap icon,
                                            StockPixmap overlay, OverlayPosition pos,
                                            gint border_x, gint border_y)
 {
@@ -764,12 +778,14 @@ GtkWidget *stock_pixmap_widget_with_overlay(GtkWidget *window, StockPixmap icon,
        
        data = g_new0(OverlayData, 1);
 
-       stock_wid = stock_pixmap_widget(window, icon);
+       stock_wid = stock_pixmap_widget(icon);
        gtk_widget_get_requisition(stock_wid, &requisition);
 
+#if !GTK_CHECK_VERSION(3, 0, 0)
        if (gtk_image_get_storage_type(GTK_IMAGE(stock_wid)) == GTK_IMAGE_PIXMAP)
                data->is_pixmap = TRUE;
        else
+#endif
                data->is_pixmap = FALSE;
 
        if (data->is_pixmap) {
@@ -785,7 +801,7 @@ GtkWidget *stock_pixmap_widget_with_overlay(GtkWidget *window, StockPixmap icon,
                if (pos == OVERLAY_NONE) {
                        data->overlay_pixmap = NULL;
                } else {
-                       stock_wid = stock_pixmap_widget(window, overlay);
+                       stock_wid = stock_pixmap_widget(overlay);
                        cr = gdk_cairo_create(gtk_widget_get_window(stock_wid));
                        stock_pixmap = cairo_get_target(cr);
                        cairo_surface_reference(stock_pixmap);
@@ -807,7 +823,7 @@ GtkWidget *stock_pixmap_widget_with_overlay(GtkWidget *window, StockPixmap icon,
                if (pos == OVERLAY_NONE) {
                        data->overlay_pixmap = NULL;
                } else {
-                       stock_wid = stock_pixmap_widget(window, overlay);
+                       stock_wid = stock_pixmap_widget(overlay);
                        stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
                        g_object_ref(stock_pixbuf);
                        data->overlay_pixbuf = stock_pixbuf;