Custom Toolbar 1
[claws.git] / src / stock_pixmap.c
index 126fbac448d397a66d258bc0dbbab56915eae9ca..927969beaf5ed168256a7df5ce6d739bd4278c75 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"
 
 typedef struct _StockPixmapData        StockPixmapData;
 
@@ -116,6 +122,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", "  "},
@@ -168,6 +175,11 @@ static StockPixmapData pixmaps[] =
        {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",  "  "},
 };
 
 /* return newly constructed GtkPixmap from GdkPixmap */
@@ -243,17 +255,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) {
+               FILE_OP_ERROR(dirname, "opendir");
                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)) {
@@ -266,14 +280,14 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
                                        *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)
@@ -310,3 +324,22 @@ 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;
+}
+