New icons for LDAP static search
[claws.git] / src / stock_pixmap.c
index 3931a8da51cd96331e715952c51555aa9eea87b2..f76012c3f449f62a545df0ecf97c74f4d061217d 100644 (file)
@@ -60,6 +60,7 @@
 #include "pixmaps/replied.xpm"
 #include "pixmaps/close.xpm"
 #include "pixmaps/down_arrow.xpm"
+#include "pixmaps/up_arrow.xpm"
 #include "pixmaps/exec.xpm"
 #include "pixmaps/mail.xpm"
 #include "pixmaps/mail_attach.xpm"
 #include "pixmaps/unread.xpm"
 #include "pixmaps/vcard.xpm"
 #include "pixmaps/ignorethread.xpm"
+#include "pixmaps/work_online.xpm"
+#include "pixmaps/work_offline.xpm"
+#include "pixmaps/notice_warn.xpm"
+#include "pixmaps/notice_error.xpm"
+#include "pixmaps/notice_note.xpm"
+#include "pixmaps/quicksearch.xpm"
+#include "pixmaps/gpg_signed.xpm"
+#include "pixmaps/drafts_close.xpm"
+#include "pixmaps/drafts_open.xpm"
+#include "pixmaps/messageview_text.xpm"
+#include "pixmaps/mime_text_plain.xpm"
+#include "pixmaps/mime_text_html.xpm"
+#include "pixmaps/mime_application.xpm"
+#include "pixmaps/mime_application_octet_stream.xpm"
+#include "pixmaps/mime_image.xpm"
+#include "pixmaps/mime_audio.xpm"
+#include "pixmaps/mime_text_enriched.xpm"
+#include "pixmaps/mime_unknown.xpm"
+#include "pixmaps/mime_gpg_signed.xpm"
+#include "pixmaps/mime_gpg_passed.xpm"
+#include "pixmaps/mime_gpg_failed.xpm"
+#include "pixmaps/mime_gpg_unknown.xpm"
+#include "pixmaps/mime_gpg_expired.xpm"                  
+#include "pixmaps/address_search.xpm"
 
 typedef struct _StockPixmapData        StockPixmapData;
 
@@ -101,6 +126,7 @@ static StockPixmapData pixmaps[] =
 {
        {address_xpm                    , NULL, NULL, "address", "  "},
        {address_book_xpm               , NULL, NULL, "address_book", "  "},
+       {address_search_xpm             , NULL, NULL, "address_search", "  "},
        {book_xpm                               , NULL, NULL, "book", "  "},
        {category_xpm                   , NULL, NULL, "category", "  "},
        {checkbox_off_xpm               , NULL, NULL, "checkbox_off", "  "},
@@ -116,6 +142,7 @@ static StockPixmapData pixmaps[] =
        {dir_open_xpm                   , NULL, NULL, "dir_open", "  "},
        {dir_open_hrm_xpm               , NULL, NULL, "dir_open_hrm", "  "},
        {down_arrow_xpm                 , NULL, NULL, "down_arrow", "  "},
+       {up_arrow_xpm                   , NULL, NULL, "up_arrow", "  "},
        {mail_compose_xpm               , NULL, NULL, "edit_extern", "  "},
        {error_xpm                              , NULL, NULL, "error", "  "},
        {exec_xpm                               , NULL, NULL, "exec", "  "},
@@ -161,13 +188,36 @@ static StockPixmapData pixmaps[] =
        {outbox_hrm_xpm                 , NULL, NULL, "queue_close_hrm", "  "},
        {outbox_xpm                             , NULL, NULL, "queue_open", "  "},
        {outbox_hrm_xpm                 , NULL, NULL, "queue_open_hrm", "  "},
-       {sylpheed_logo_xpm              , NULL, NULL, "sylpheed_logo", "  "},
        {trash_xpm                              , NULL, NULL, "trash_open", "  "},
        {trash_hrm_xpm                  , NULL, NULL, "trash_open_hrm", "  "},
        {trash_xpm                              , NULL, NULL, "trash_close", "  "},
        {trash_hrm_xpm                  , NULL, NULL, "trash_close_hrm", "  "},
        {unread_xpm                             , NULL, NULL, "unread", "  "},
        {vcard_xpm                              , NULL, NULL, "vcard", "  "},
+       {work_online_xpm                        , NULL, NULL, "work_online", "  "},
+       {work_offline_xpm                       , NULL, NULL, "work_offline", "  "},
+       {notice_warn_xpm                        , NULL, NULL, "notice_warn",  "  "},
+       {notice_error_xpm                       , NULL, NULL, "notice_error",  "  "},
+       {notice_note_xpm                        , NULL, NULL, "notice_note",  "  "},
+       {quicksearch_xpm                        , NULL, NULL, "quicksearch",  "  "},
+       {gpg_signed_xpm                         , NULL, NULL, "gpg_signed", "  "},
+       {drafts_close_xpm                       , NULL, NULL, "drafts_close", "  "},
+       {drafts_open_xpm                        , NULL, NULL, "drafts_open", "  "},
+       {messageview_text_xpm                   , NULL, NULL, "messageview_text", "  "},
+       {mime_text_plain_xpm                    , NULL, NULL, "mime_text_plain", "  "},
+       {mime_text_html_xpm                     , NULL, NULL, "mime_text_html", "  "},
+       {mime_application_xpm                   , NULL, NULL, "mime_application", "  "},
+       {mime_application_octet_stream_xpm      , NULL, NULL, "mime_application_octet_stream", "  "},
+       {mime_image_xpm                         , NULL, NULL, "mime_image", "  "},
+       {mime_audio_xpm                         , NULL, NULL, "mime_audio", "  "},
+       {mime_text_enriched_xpm                 , NULL, NULL, "mime_text_enriched", "  "},
+       {mime_unknown_xpm                       , NULL, NULL, "mime_unknown", "  "},    
+       {mime_gpg_signed_xpm                    , NULL, NULL, "mime_gpg_signed", "  "},
+       {mime_gpg_passed_xpm                    , NULL, NULL, "mime_gpg_passed", "  "},
+       {mime_gpg_failed_xpm                    , NULL, NULL, "mime_gpg_failed", "  "}, 
+       {mime_gpg_unknown_xpm                   , NULL, NULL, "mime_gpg_unknown", "  "},
+       {mime_gpg_expired_xpm                   , NULL, NULL, "mime_gpg_expired", "  "},
+       {sylpheed_logo_xpm                      , NULL, NULL, "sylpheed_logo", "  "},
 };
 
 /* return newly constructed GtkPixmap from GdkPixmap */
@@ -179,8 +229,10 @@ GtkWidget *stock_pixmap_widget(GtkWidget *window, StockPixmap icon)
        g_return_val_if_fail(window != NULL, NULL);
        g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
 
-       stock_pixmap_gdk(window, icon, &pixmap, &mask);
-       return gtk_pixmap_new(pixmap, mask);
+       if (stock_pixmap_gdk(window, icon, &pixmap, &mask) != -1)
+               return gtk_pixmap_new(pixmap, mask);
+       
+       return NULL;
 }
 
 /* create GdkPixmap if it has not created yet */
@@ -209,7 +261,7 @@ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
                                                             pix_d->file,
                                                             ".xpm",
                                                             NULL);
-                               if (file_exist(icon_file_name, FALSE))
+                               if (is_file_exist(icon_file_name))
                                        PIXMAP_CREATE_FROM_FILE(window, pix, pix_d->mask, icon_file_name);
                                if (pix) 
                                        pix_d->icon_path = prefs_common.pixmap_theme_path;
@@ -241,17 +293,19 @@ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
 
 static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
 {
-       struct dirent **namelist;
-       int n;
-
-       if ((n = scandir(dirname, &namelist, 0, alphasort)) <= 0)
+       struct dirent *d;
+       DIR *dp;
+       
+       if ((dp = opendir(dirname)) == NULL) {
+               debug_print("dir %s not found, skipping theme scan", dirname);
                return;
-
-       while (n--) {
+       }
+       
+       while ((d = readdir(dp)) != NULL) {
                gchar *entry;
                gchar *fullentry;
 
-               entry     = namelist[n]->d_name;
+               entry     = d->d_name;
                fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL);
                
                if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) {
@@ -260,18 +314,18 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
                        
                        for (i = 0; i < N_STOCK_PIXMAPS; i++) {
                                filetoexist = g_strconcat(fullentry, G_DIR_SEPARATOR_S, pixmaps[i].file, ".xpm", NULL);
-                               if (file_exist(filetoexist, FALSE)) {
+                               if (is_file_exist(filetoexist)) {
                                        *list = g_list_append(*list, fullentry);
                                        break;
                                }
-                               g_free(filetoexist);
                        }
+                       g_free(filetoexist);
                        if (i == N_STOCK_PIXMAPS) 
                                g_free(fullentry);
-               }
-               g_free(namelist[n]);
+               } else 
+                       g_free(fullentry);
        }
-       g_free(namelist);
+       closedir(dp);
 }
 
 GList *stock_pixmap_themes_list_new(void)
@@ -292,7 +346,7 @@ GList *stock_pixmap_themes_list_new(void)
        
        stock_pixmap_find_themes_in_dir(&list, userthemes);
        stock_pixmap_find_themes_in_dir(&list, systemthemes);
-       
+
        g_free(userthemes);
        g_free(systemthemes);
        return list;
@@ -308,3 +362,21 @@ void stock_pixmap_themes_list_free(GList *list)
        g_list_free(list);              
 }
 
+gchar *stock_pixmap_get_name (StockPixmap icon)
+{
+       g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
+       
+       return pixmaps[icon].file;
+
+}
+
+StockPixmap stock_pixmap_get_icon (gchar *file)
+{
+       gint i;
+       
+       for (i = 0; i < N_STOCK_PIXMAPS; i++) {
+               if (strcmp (pixmaps[i].file, file) == 0)
+                       return i;
+       }
+       return -1;
+}