redesign, move, fix icon theme selector
authorPaul Mangan <paul@claws-mail.org>
Tue, 30 Dec 2003 08:59:01 +0000 (08:59 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 30 Dec 2003 08:59:01 +0000 (08:59 +0000)
ChangeLog.claws
configure.ac
po/POTFILES.in
src/Makefile.am
src/common/defs.h
src/main.c
src/prefs_common.c
src/prefs_themes.c [new file with mode: 0644]
src/prefs_themes.h [new file with mode: 0644]
src/stock_pixmap.c
src/summaryview.c

index 9b18e53..0e68310 100644 (file)
@@ -1,3 +1,24 @@
+2003-12-30 [paul]      0.9.8claws13
+
+       * po/POTFILES.in
+         src/common/defs.h
+         src/Makefile.am
+         src/main.c
+         src/prefs_common.c
+         src/prefs_themes.[ch] ** NEW FILES **
+               redesign and move Icon Theme selector to
+               the new prefs window
+         
+       * src/stock_pixmap.c
+               fix the old bug where icons are not always
+               updated when changing themes
+       
+       * src/summaryview.c
+               fix bug where the icons on the title row
+               of the summary view were not updated
+       
+       all patches submitted by Ricardo Mones Lastra
+
 2003-12-30 [hoa]       0.9.8claws12
 
        * src/folder.c
index 6c0ee4b..2fe465d 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=12
+EXTRA_VERSION=13
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 779799f..491d85a 100644 (file)
@@ -89,6 +89,7 @@ src/prefs_matcher.c
 src/prefs_spelling.c
 src/prefs_summary_column.c
 src/prefs_template.c
+src/prefs_themes.c
 src/prefs_toolbar.c
 src/privacy.c
 src/procmsg.c
index 11fd541..d0184a8 100644 (file)
@@ -90,6 +90,7 @@ sylpheed_SOURCES = \
        prefs_gtk.c \
        prefs_matcher.c \
        prefs_spelling.c \
+       prefs_themes.c \
        prefs_summary_column.c \
        prefs_template.c \
        prefs_toolbar.c \
@@ -215,6 +216,7 @@ sylpheedinclude_HEADERS = \
        prefs_gtk.h \
        prefs_matcher.h \
        prefs_spelling.h \
+       prefs_themes.h \
        prefs_summary_column.h \
        prefs_template.h \
        prefs_toolbar.h \
index 5e24b3b..ef25b24 100644 (file)
@@ -71,6 +71,8 @@
 #define SYLDOC_FAQ_HTML_INDEX  "/faq/faq.html"
 #define CLAWS_FAQ_URI          "http://sylpheed-claws.sourceforge.net/phpwiki/index.php"
 #define CLAWS_BUGZILLA_URI     "http://www.thewildbeast.co.uk/sylpheed-claws/bugzilla/enter_bug.cgi"
+#define CLAWS_THEMES_URI       "http://sylpheed-claws.sourceforge.net/themes.php"
+#define THEMEINFO_FILE         ".sylpheed_themeinfo"
 #define FOLDER_LIST            "folderlist.xml"
 #define CACHE_FILE             ".sylpheed_cache"
 #define MARK_FILE              ".sylpheed_mark"
index 033d1c3..479e374 100644 (file)
@@ -53,6 +53,7 @@
 #include "prefs_actions.h"
 #include "prefs_fonts.h"
 #include "prefs_spelling.h"
+#include "prefs_themes.h"
 #include "prefs_display_header.h"
 #include "account.h"
 #include "procmsg.h"
@@ -250,7 +251,7 @@ int main(int argc, char *argv[])
        sgpgme_init();
        pgpmime_init();
 #endif
-
+       prefs_themes_init();
        prefs_fonts_init();
 #ifdef USE_ASPELL
        gtkaspell_checkers_init();
@@ -428,7 +429,7 @@ static void exit_sylpheed(MainWindow *mainwin)
        pgpmime_done();
        sgpgme_done();
 #endif
-
+       prefs_themes_done();
        prefs_fonts_done();
 #ifdef USE_ASPELL       
        prefs_spelling_done();
index 64dad09..e6e3ffe 100644 (file)
@@ -181,8 +181,6 @@ static struct Interface {
        GtkWidget *checkbtn_openinbox;
        GtkWidget *checkbtn_immedexec;
        GtkWidget *optmenu_nextunreadmsgdialog;
-       GtkWidget *entry_pixmap_theme;
-       GtkWidget *combo_pixmap_theme;
 } interface;
 
 static struct Other {
@@ -715,7 +713,7 @@ static PrefParam param[] = {
 
        {"pixmap_theme_path", DEFAULT_PIXMAP_THEME, 
         &prefs_common.pixmap_theme_path, P_STRING,
-        &interface.entry_pixmap_theme, prefs_set_data_from_entry, prefs_set_entry},
+        NULL, NULL, NULL},
 
        {"hover_timeout", "500", &prefs_common.hover_timeout, P_INT,
         NULL, NULL, NULL},
@@ -2140,12 +2138,6 @@ static void prefs_interface_create(void)
        GtkWidget *hbox_nextunreadmsgdialog;
        GtkWidget *optmenu_nextunreadmsgdialog;
 
-       GtkWidget *frame_pixmap_theme;
-       GtkWidget *vbox_pixmap_theme;
-       GtkWidget *entry_pixmap_theme;
-       GtkWidget *combo_pixmap_theme;
-       GList *avail_pixmap_themes = NULL;
-
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
@@ -2227,23 +2219,6 @@ static void prefs_interface_create(void)
        gtk_signal_connect (GTK_OBJECT (button_keybind), "clicked",
                            GTK_SIGNAL_FUNC (prefs_keybind_select), NULL);
 
-       PACK_FRAME(vbox1, frame_pixmap_theme, _("Icon theme"));
-       
-       vbox_pixmap_theme = gtk_vbox_new(FALSE, 0);
-       gtk_widget_show(vbox_pixmap_theme);
-       gtk_container_add(GTK_CONTAINER(frame_pixmap_theme), vbox_pixmap_theme);
-       gtk_container_set_border_width(GTK_CONTAINER(vbox_pixmap_theme), 8);
-       avail_pixmap_themes = stock_pixmap_themes_list_new(); 
-       combo_pixmap_theme = gtk_combo_new ();
-       gtk_widget_show (combo_pixmap_theme);
-       gtk_box_pack_start (GTK_BOX (vbox_pixmap_theme), combo_pixmap_theme, TRUE, TRUE, 0);
-       gtk_combo_set_popdown_strings(GTK_COMBO(combo_pixmap_theme), avail_pixmap_themes);
-       entry_pixmap_theme = GTK_COMBO (combo_pixmap_theme)->entry;
-
-       stock_pixmap_themes_list_free(avail_pixmap_themes);
-
        /* interface.checkbtn_emacs          = checkbtn_emacs; */
        interface.checkbtn_always_show_msg    = checkbtn_always_show_msg;
        interface.checkbtn_openunread         = checkbtn_openunread;
@@ -2252,8 +2227,6 @@ static void prefs_interface_create(void)
        interface.checkbtn_openinbox          = checkbtn_openinbox;
        interface.checkbtn_immedexec          = checkbtn_immedexec;
        interface.optmenu_nextunreadmsgdialog = optmenu_nextunreadmsgdialog;
-       interface.combo_pixmap_theme          = combo_pixmap_theme;
-       interface.entry_pixmap_theme          = entry_pixmap_theme;
 }
 
 static void prefs_other_create(void)
@@ -3616,37 +3589,11 @@ static void prefs_common_ok(void)
 
 static void prefs_common_apply(void)
 {
-       gchar *entry_pixmap_theme_str;
-       gboolean update_pixmap_theme;
        gchar *backup_theme_path;
        MainWindow *mainwindow;
-       
-       entry_pixmap_theme_str = gtk_entry_get_text(GTK_ENTRY(interface.entry_pixmap_theme));
-       if (entry_pixmap_theme_str && 
-               (strcmp(prefs_common.pixmap_theme_path, entry_pixmap_theme_str) != 0) )
-               update_pixmap_theme = TRUE;
-       else
-               update_pixmap_theme = FALSE;
-
-       /*!< FIXME: prefs_set_data_from_dialog() clears and frees all strings, 
-        * but prefs_common.pixmap_theme_path is stored in the StockPixmapData
-        * in stock_pixmap.c::pixmaps[].icon_path, and used when reflecting
-        * the pixmap changes. Work around by saving the old one and freeing 
-        * it later. */
-       backup_theme_path = prefs_common.pixmap_theme_path;
-       prefs_common.pixmap_theme_path = g_strdup(backup_theme_path);
+
        prefs_set_data_from_dialog(param);
        sock_set_io_timeout(prefs_common.io_timeout_secs);
-       
-       if (update_pixmap_theme) {
-               main_window_reflect_prefs_all_real(TRUE);
-               compose_reflect_prefs_pixmap_theme();
-       } else
-               main_window_reflect_prefs_all_real(FALSE);
-
-       /*!< FIXME: Now it's safe to delete the backup path */
-       g_free(backup_theme_path);
-
        prefs_common_save_config();
 
        mainwindow = mainwindow_get_mainwindow();
diff --git a/src/prefs_themes.c b/src/prefs_themes.c
new file mode 100644 (file)
index 0000000..12f3c13
--- /dev/null
@@ -0,0 +1,1030 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003 Hiroyuki Yamamoto & the Sylpheed-Claws 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "defs.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "intl.h"
+#include "utils.h"
+#include "prefs_common.h"
+#include "prefs_gtk.h"
+
+#include "gtk/gtkutils.h"
+#include "gtk/prefswindow.h"
+#include "gtk/filesel.h"
+
+#include "stock_pixmap.h"
+#include "mainwindow.h"
+#include "compose.h"
+#include "alertpanel.h"
+
+#define IS_CURRENT_THEME(path)  (strcmp(prefs_common.pixmap_theme_path, path) == 0)
+#define IS_INTERNAL_THEME(path) (strcmp(DEFAULT_PIXMAP_THEME, path) == 0)
+#define IS_SYSTEM_THEME(path)   (prefs_themes_is_system_theme(path))
+
+#define PREVIEW_ICONS 7
+
+typedef struct _ThemesPage
+{
+       PrefsPage page;
+
+       GtkWidget *window;              /* do not modify */
+
+       GtkWidget *op_menu;
+       GtkWidget *btn_install;
+       GtkWidget *btn_more;
+       GtkWidget *global;
+
+       GtkWidget *name;
+       GtkWidget *author;
+       GtkWidget *url;
+       GtkWidget *status;
+       
+       GtkWidget *icons[PREVIEW_ICONS];
+       
+       GtkWidget *btn_use;
+       GtkWidget *btn_remove;
+
+       GdkPixmap *pixmaps[PREVIEW_ICONS];
+       GdkBitmap *masks[PREVIEW_ICONS];
+
+       /* gchar     *theme_path; */
+} ThemesPage;
+
+typedef struct _ThemeInfo
+{
+       gchar *name;
+       gchar *author;
+       gchar *url;
+       gchar *status;
+} ThemeInfo;
+
+typedef struct _ThemeName
+{
+       gchar *name;
+       GList *item;
+} ThemeName;
+
+typedef struct _ThemesData
+{
+       GList      *themes;
+       GList      *names;
+       gchar      *displayed;
+       ThemesPage *page;
+} ThemesData;
+
+typedef void (*FileFunc) (const gchar *filename, gpointer data);
+
+typedef struct _DirInfo {
+       gint bytes;
+       gint files;
+       gint pixms;
+} DirInfo;
+
+typedef struct _CopyInfo {
+       gchar *dest;
+       gchar *status;
+} CopyInfo;
+
+static ThemesData *prefs_themes_data;
+
+StockPixmap prefs_themes_icons[PREVIEW_ICONS] = { 
+       STOCK_PIXMAP_MAIL,
+       STOCK_PIXMAP_MAIL_RECEIVE, 
+       STOCK_PIXMAP_DOWN_ARROW, 
+       STOCK_PIXMAP_MAIL_SEND_QUEUE, 
+       STOCK_PIXMAP_BOOK, 
+       STOCK_PIXMAP_MIME_TEXT_HTML, 
+       STOCK_PIXMAP_PRIVACY_PASSED
+};
+
+
+
+static void prefs_themes_btn_use_clicked_cb    (GtkWidget *widget, gpointer data);
+static void prefs_themes_btn_remove_clicked_cb (GtkWidget *widget, gpointer data);
+static void prefs_themes_btn_install_clicked_cb        (GtkWidget *widget, gpointer data);
+static void prefs_themes_btn_more_clicked_cb   (GtkWidget *widget, gpointer data);
+static void prefs_themes_menu_item_activated_cb        (GtkWidget *widget, gpointer data);
+
+static void prefs_themes_update_buttons                (const ThemesData *tdata);
+static void prefs_themes_display_global_stats  (const ThemesData *tdata);
+static void prefs_themes_get_theme_info         (ThemesData *tdata);
+static void prefs_themes_display_theme_info     (ThemesData *tdata, const ThemeInfo *info);
+static void prefs_themes_get_themes_and_names  (ThemesData *tdata);
+static void prefs_themes_free_names            (ThemesData *tdata);
+
+static void prefs_themes_set_themes_menu       (GtkOptionMenu *opmenu, const ThemesData *tdata);
+
+static gchar *prefs_themes_get_theme_stats     (const gchar *dirname);
+static gboolean prefs_themes_is_system_theme   (const gchar *dirname);
+
+static void prefs_themes_create_widget          (PrefsPage *page, GtkWindow *window, gpointer data);
+static void prefs_themes_destroy_widget         (PrefsPage *page);
+static void prefs_themes_save                   (PrefsPage *page);
+
+static void prefs_themes_foreach_file          (const gchar *dirname, const FileFunc func, gpointer data);
+static void prefs_themes_file_stats            (const gchar *filename, gpointer data);
+static void prefs_themes_file_remove           (const gchar *filename, gpointer data);
+static void prefs_themes_file_install          (const gchar *filename, gpointer data);
+
+
+
+static void prefs_themes_file_stats(const gchar *filename, gpointer data)
+{
+       struct stat s;
+       DirInfo    *di = (DirInfo *)data;
+       gint        len;
+       
+       if (0 == stat(filename, &s) && 0 != S_ISREG(s.st_mode)) {
+               di->bytes += s.st_size;
+               di->files++;
+               len = strlen(filename);
+               if (len > 4) {
+                       if (filename[len - 1] == 'm' && filename[len - 2] == 'p' &&
+                           filename[len - 3] == 'x' && filename[len - 4] == '.')
+                               di->pixms++;
+               }
+       }
+}
+       
+static void prefs_themes_file_remove(const gchar *filename, gpointer data)
+{
+       gchar **status = (gchar **)data;
+       gchar *name;
+       
+       if ((*status) != NULL)
+               return;
+       
+       name = g_basename(filename);
+       if (TRUE == is_dir_exist(filename)) {
+               if (!((name[0] == '.') || (name[0] == '.' && name[1] == '.')))
+                       g_warning("prefs_themes_file_remove(): subdir in theme dir skipped.\n");
+       }
+       else if (0 != unlink(filename)) {
+               (*status) = g_strdup(filename);
+       }
+}
+
+static void prefs_themes_file_install(const gchar *filename, gpointer data)
+{
+       CopyInfo *ci = (CopyInfo *)data;
+       gchar *name;
+       
+       if (ci->status != NULL)
+               return;
+       
+       name = g_basename(filename);
+       if (TRUE == is_dir_exist(filename)) {
+               if (!((name[0] == '.') || (name[0] == '.' && name[1] == '.')))
+                       g_warning("prefs_themes_file_install(): subdir in theme dir skipped.\n");
+       }
+       else {
+               gchar *fulldest;
+               
+               fulldest = g_strconcat(ci->dest, G_DIR_SEPARATOR_S, name, NULL);
+               
+               if (0 != copy_file(filename, fulldest, FALSE)) {
+                       ci->status = g_strdup(filename);
+               }
+               g_free(fulldest);
+       }
+}
+
+static void prefs_themes_foreach_file(const gchar *dirname, const FileFunc func, gpointer data)
+{
+       struct dirent *d;
+       DIR           *dp;
+
+       g_return_if_fail(dirname != NULL);
+       g_return_if_fail(func != NULL);
+       
+       if ((dp = opendir(dirname)) == NULL) {
+               debug_print("directory %s not found", dirname);
+               return;
+       }
+
+       while ((d = readdir(dp)) != NULL) {
+               gchar *entry;
+               gchar *fullentry;
+
+               entry     = d->d_name;
+               fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL);
+
+               (*func)(fullentry, data);
+               
+               g_free(fullentry);
+       }       
+}
+
+static gboolean prefs_themes_is_system_theme(const gchar *dirname)
+{
+       gint len;
+       
+       g_return_val_if_fail(dirname != NULL, FALSE);
+
+       len = strlen(PACKAGE_DATA_DIR);
+       if (strlen(dirname) > len && 0 == strncmp(dirname, PACKAGE_DATA_DIR, len))
+               return TRUE;
+       
+       return FALSE;
+}
+
+static void prefs_themes_set_themes_menu(GtkOptionMenu *opmenu, const ThemesData *tdata)
+{
+       GList     *themes = tdata->names;
+       GtkWidget *menu;
+       GtkWidget *item;
+       gint       i = 0, active = 0;
+
+       g_return_if_fail(opmenu != NULL);
+       
+       gtk_option_menu_remove_menu(opmenu);
+       
+       menu = gtk_menu_new ();
+       while (themes != NULL) {
+               ThemeName *tname = (ThemeName *)(themes->data);
+               gchar     *tpath = (gchar *)(tname->item->data);
+               
+               item = gtk_menu_item_new_with_label(tname->name);
+               gtk_widget_show(item);
+               gtk_signal_connect(GTK_OBJECT(item), "activate",
+                                  GTK_SIGNAL_FUNC(prefs_themes_menu_item_activated_cb),
+                                  tname->item->data);
+               gtk_menu_append(GTK_MENU(menu), item);
+
+               if (tdata->displayed != NULL && tdata->displayed == tpath)
+                       active = i;
+
+               themes = g_list_next(themes);
+               ++i;
+       }
+       
+       gtk_menu_set_active(GTK_MENU(menu), active);
+       gtk_option_menu_set_menu (opmenu, menu);
+}
+
+static void prefs_themes_get_themes_and_names(ThemesData *tdata)
+{
+       GList *tpaths;
+       
+       g_return_if_fail(tdata != NULL);
+       
+       if (tdata->themes != NULL)
+               stock_pixmap_themes_list_free(tdata->themes);
+       if (tdata->names != NULL)
+               prefs_themes_free_names(tdata);
+       
+       tdata->themes = stock_pixmap_themes_list_new();
+       
+       tpaths = tdata->themes;
+       while (tpaths != NULL) {
+               ThemeName *name = g_new0(ThemeName, 1);
+               gchar     *sname = g_basename((gchar *)(tpaths->data));
+               
+               if (IS_INTERNAL_THEME(sname))
+                       name->name = g_strdup(_("Default internal theme"));
+               else
+                       name->name = g_strdup(sname);
+               name->item = tpaths;
+                       
+               tdata->names = g_list_append(tdata->names, name);
+               tpaths = g_list_next(tpaths);
+       }       
+}
+
+void prefs_themes_init(void)
+{
+       ThemesData *tdata;
+       ThemesPage *page;
+       GList      *tpaths;
+
+       debug_print("Creating prefereces for themes...\n");
+       
+       tdata = g_new0(ThemesData, 1);
+       prefs_themes_data = tdata;
+
+       prefs_themes_get_themes_and_names(tdata);
+       
+       page = g_new0(ThemesPage, 1);
+       
+       page->page.path = _("Display/Themes");
+       page->page.create_widget = prefs_themes_create_widget;
+       page->page.destroy_widget = prefs_themes_destroy_widget;
+       page->page.save_page = prefs_themes_save;
+       page->page.weight = 15.0;
+       prefs_gtk_register_page((PrefsPage *) page);
+
+       tdata->page = page;
+
+       tpaths = g_list_first(tdata->themes);
+       tdata->displayed = (gchar *)(tpaths->data);
+}
+
+static void prefs_themes_free_names(ThemesData *tdata)
+{
+       GList *names;
+       
+       names = tdata->names;
+       while (names != NULL) {
+               ThemeName *tn = (ThemeName *)(names->data);
+               
+               tn->item = NULL;
+               g_free(tn->name);
+               g_free(tn);
+               
+               names = g_list_next(names);
+       }
+       g_list_free(names);
+       tdata->names = NULL;
+}
+
+void prefs_themes_done(void)
+{
+       ThemesData *tdata = prefs_themes_data;
+       GList      *n;
+
+       debug_print("Finished prefereces for themes.\n");
+       
+       stock_pixmap_themes_list_free(tdata->themes);
+       prefs_themes_free_names(tdata); 
+       g_free(tdata->page);
+       g_free(tdata);
+}
+
+static void prefs_themes_btn_use_clicked_cb(GtkWidget *widget, gpointer data)
+{
+       ThemesData *tdata = prefs_themes_data;
+       gchar      *theme_str;
+
+       theme_str = tdata->displayed;
+       
+       if (prefs_common.pixmap_theme_path != NULL)
+               g_free(prefs_common.pixmap_theme_path);
+       
+        prefs_common.pixmap_theme_path = g_strdup(theme_str);
+       
+        main_window_reflect_prefs_all_real(TRUE);
+        compose_reflect_prefs_pixmap_theme();
+       
+       prefs_themes_update_buttons(tdata);
+}
+
+static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
+{
+       ThemesData *tdata = prefs_themes_data;
+       gchar      *theme_str;
+       gchar      *alert_title = NULL;
+       AlertValue  val = 0;
+
+       theme_str = tdata->displayed;
+       
+       if (IS_SYSTEM_THEME(theme_str)) {
+               if (getuid() != 0) {
+                       alertpanel_error(_("Only root can remove system themes"));
+                       return;
+               }
+               alert_title = g_strdup_printf(_("Remove system theme '%s'"), 
+                                             g_basename(theme_str));
+       }
+       if (NULL == alert_title) {
+               alert_title = g_strdup_printf(_("Remove theme '%s'"), 
+                                             g_basename(theme_str));
+       }
+       val = alertpanel(alert_title,
+                        _("Are you sure you want to remove this theme?"),
+                        _("No"), _("Yes"), _("Cancel"));
+       g_free(alert_title);
+       if (G_ALERTALTERNATE == val) {
+               gchar *status = NULL;
+               
+               prefs_themes_foreach_file(theme_str, prefs_themes_file_remove, &status); 
+               if (0 != rmdir(theme_str)) {
+                       if (status != NULL) {
+                               alertpanel_error(_("File %s failed\nwhile removing theme."), status);
+                               g_free(status);
+                       }
+                       else
+                               alertpanel_error(_("Removing theme directory failed."));
+               }
+               else {  
+                       alertpanel_notice(_("Theme removed succesfully"));
+                       /* update interface back to first theme */
+                       prefs_themes_get_themes_and_names(tdata);
+                       prefs_themes_set_themes_menu(GTK_OPTION_MENU(tdata->page->op_menu), tdata);
+                       prefs_themes_display_global_stats(tdata);
+                       tdata->displayed = (gchar *)((g_list_first(tdata->themes))->data);
+                       prefs_themes_get_theme_info(tdata);
+               }
+       }
+}
+
+static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data)
+{
+       struct stat s;
+       gchar      *filename, *source;
+       gchar      *themeinfo, *themename;
+       gchar      *alert_title = NULL;
+       CopyInfo   *cinfo;
+       AlertValue  val = 0;
+       ThemesData *tdata = prefs_themes_data;
+       
+       filename = filesel_select_file(_("Select theme folder"), NULL);
+       if (filename == NULL) 
+               return;
+       
+       cinfo = g_new0(CopyInfo, 1);
+       source = g_dirname(filename);
+       themename = g_basename(source);
+       debug_print("Installing '%s' theme from %s\n", themename, filename);
+
+       themeinfo = g_strconcat(source, G_DIR_SEPARATOR_S, THEMEINFO_FILE, NULL);
+       alert_title = g_strdup_printf(_("Install theme '%s'"), themename);
+       if (file_exist(themeinfo, FALSE) == FALSE) {
+               val = alertpanel(alert_title,
+                                _("This folder doesn't seem to be a theme folder.\nInstall anyway?"),
+                                _("Yes"), _("No"), _("Cancel"));
+               if (G_ALERTDEFAULT != val)
+                       goto end_inst;
+       }
+       if (getuid() == 0) {
+               val = alertpanel(alert_title,
+                                _("Do you want to install theme for system's all users?"),
+                                _("Yes"), _("No"), _("Cancel"));
+               switch (val) {
+               case G_ALERTDEFAULT:
+                       cinfo->dest = g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
+                                                 PIXMAP_THEME_DIR, G_DIR_SEPARATOR_S, 
+                                                 themename, NULL);
+                       break;
+               case G_ALERTALTERNATE:
+                       break;
+               default:
+                       goto end_inst;
+               }
+       }
+       g_free(alert_title);
+       if (cinfo->dest == NULL) {
+               cinfo->dest = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, RC_DIR,
+                                         G_DIR_SEPARATOR_S, PIXMAP_THEME_DIR, G_DIR_SEPARATOR_S,
+                                         themename, NULL);
+       }
+       if (TRUE == is_dir_exist(cinfo->dest)) {
+               alertpanel_error(_("A theme with the same name is\nalready installed in this location"));
+               goto end_inst;
+       }
+       if (0 != make_dir_hier(cinfo->dest)) {
+               alertpanel_error(_("Couldn't create destination directory"));
+               goto end_inst;
+       }
+       prefs_themes_foreach_file(source, prefs_themes_file_install, cinfo);
+       if (cinfo->status == NULL) {
+               GList *insted;
+               
+               alertpanel_notice(_("Theme installed succesfully"));
+               /* update interface to show newly installed theme */
+               prefs_themes_get_themes_and_names(tdata);
+               insted = g_list_find_custom(tdata->themes, 
+                                           (gpointer)(cinfo->dest), 
+                                           (GCompareFunc)strcmp2);
+               tdata->displayed = (gchar *)(insted->data);
+               prefs_themes_set_themes_menu(GTK_OPTION_MENU(tdata->page->op_menu), tdata);
+               prefs_themes_display_global_stats(tdata);
+               prefs_themes_get_theme_info(tdata);     
+       }
+       else
+               alertpanel_error(_("File %s failed\nwhile installing theme."), cinfo->status);
+end_inst:
+       if (cinfo->dest != NULL) g_free(cinfo->dest);
+       g_free(source);
+       g_free(themeinfo);
+       g_free(cinfo);
+}
+
+static void prefs_themes_btn_more_clicked_cb(GtkWidget *widget, gpointer data)
+{
+       open_uri(CLAWS_THEMES_URI, prefs_common.uri_cmd);
+}
+
+static void prefs_themes_menu_item_activated_cb(GtkWidget *widget, gpointer data)
+{
+       ThemesData *tdata = prefs_themes_data;
+       gchar      *path = (gchar *)data;
+       
+       g_return_if_fail(path != NULL);
+       
+       tdata->displayed = path;
+       prefs_themes_get_theme_info(tdata);
+}
+
+static void prefs_themes_update_buttons(const ThemesData *tdata)
+{
+       ThemesPage *theme = tdata->page;
+       gboolean    can_rem, can_use;
+
+       can_use = !IS_CURRENT_THEME(tdata->displayed);
+       can_rem = can_use && !IS_INTERNAL_THEME(tdata->displayed);
+       
+       if (theme->btn_use != NULL)
+               gtk_widget_set_sensitive(theme->btn_use, can_use);
+       if (theme->btn_remove != NULL)
+               gtk_widget_set_sensitive(theme->btn_remove, can_rem);
+}
+
+static void prefs_themes_display_theme_info(ThemesData *tdata, const ThemeInfo *info)
+{
+       ThemesPage *theme = tdata->page;
+       gchar *save_prefs_path;
+       gint   i;
+       
+       gtk_label_set_text(GTK_LABEL(theme->name), info->name);
+       gtk_label_set_text(GTK_LABEL(theme->author), info->author);
+       gtk_label_set_text(GTK_LABEL(theme->url), info->url);   
+       gtk_label_set_text(GTK_LABEL(theme->status), info->status);
+
+       save_prefs_path = prefs_common.pixmap_theme_path;
+       prefs_common.pixmap_theme_path = tdata->displayed;
+       for (i = 0; i < PREVIEW_ICONS; ++i) {
+               stock_pixmap_gdk(theme->window, prefs_themes_icons[i], 
+                               &(theme->pixmaps[i]), &(theme->masks[i]));
+               gtk_pixmap_set(GTK_PIXMAP(theme->icons[i]),
+                               theme->pixmaps[i], theme->masks[i]);
+       }
+       prefs_common.pixmap_theme_path = save_prefs_path;
+
+       prefs_themes_update_buttons(tdata);
+}
+
+static void prefs_themes_display_global_stats(const ThemesData *tdata)
+{
+       ThemesPage *theme = tdata->page;
+       GList      *tnames = tdata->names;
+       gchar      *gstats;
+       gint        sys = 0;
+       gint        usr = 0;
+       gint        all = 0;
+
+       while (tnames != NULL) {
+               ThemeName *tname = (ThemeName *)(tnames->data);
+               gchar     *tpath = (gchar *)(tname->item->data);
+               
+               if (IS_SYSTEM_THEME(tpath)) 
+                       ++sys;
+               else if (!IS_INTERNAL_THEME(tpath)) 
+                       ++usr;
+               ++all;
+               tnames = g_list_next(tnames);
+       }
+
+       gstats = g_strdup_printf(_("%d themes available (%d user, %d system, 1 internal)"),
+                                all, usr, sys);
+       gtk_label_set_text(GTK_LABEL(theme->global), gstats);
+       g_free(gstats);
+}
+
+#define INFOFILE_LINE_LEN 80
+
+#define FGETS_INFOFILE_LINE() \
+       line[0] = '\0'; \
+       fgets(line, INFOFILE_LINE_LEN, finfo); \
+       if ((len = strlen(line)) > 0) { \
+               if (line[len - 1] == '\n') line[len - 1] = '\0'; \
+       } \
+       else { \
+               strcpy(line, _("Unknown")); \
+       }
+
+static void prefs_themes_get_theme_info(ThemesData *tdata)
+{
+       FILE  *finfo;
+       gchar *sinfo;
+       gchar *path;
+       gchar  line[INFOFILE_LINE_LEN];
+       gint   len;
+       ThemeInfo *info;
+       ThemesPage *theme = tdata->page;
+
+       g_return_if_fail(theme != NULL);
+       path = tdata->displayed;
+       g_return_if_fail(path != NULL);
+
+       debug_print("Getting theme info for %s\n", path);
+       
+       info = g_new0(ThemeInfo, 1);
+       
+       if (IS_INTERNAL_THEME(path)) {
+               info->name = g_strdup(_("Default internal theme"));
+               info->author = g_strdup(_("The Sylpheed Claws Team"));
+               info->url = g_strdup(HOMEPAGE_URI);
+               info->status = g_strdup_printf(_("Internal theme has %d icons"), N_STOCK_PIXMAPS);
+       }
+       else {
+               sinfo = g_strconcat(path, G_DIR_SEPARATOR_S, THEMEINFO_FILE, NULL);
+               finfo = fopen(sinfo, "r");
+               if (finfo == NULL) {
+                       info->name = g_strdup(_("No info file available for this theme"));
+                       info->author = g_strdup(_("Unknown"));
+                       info->url = g_strdup(_("Unknown"));
+               }
+               else {
+                       FGETS_INFOFILE_LINE()
+                       info->name = g_strdup(line);
+                       FGETS_INFOFILE_LINE()
+                       info->author = g_strdup(line);
+                       FGETS_INFOFILE_LINE()
+                       info->url = g_strdup(line);
+               
+                       fclose(finfo);
+               }
+               g_free(sinfo);
+
+               info->status = prefs_themes_get_theme_stats(path);
+               if (info->status == NULL) {
+                       info->status = g_strdup(_("Error: can't get theme status"));
+               }
+       }
+
+       prefs_themes_display_theme_info(tdata, info);
+
+       g_free(info->name);
+       g_free(info->author);
+       g_free(info->url);
+       g_free(info->status);
+       
+       g_free(info);
+}
+
+#undef FGETS_INFOFILE_LINE
+
+static gchar *prefs_themes_get_theme_stats(const gchar *dirname)
+{
+       gchar   *stats;
+       DirInfo *dinfo;
+
+       dinfo = g_new0(DirInfo, 1);
+       
+       prefs_themes_foreach_file(dirname, prefs_themes_file_stats, dinfo);
+       stats = g_strdup_printf(_("%d files (%d icons), size is %s"), 
+                               dinfo->files, dinfo->pixms, to_human_readable(dinfo->bytes));
+       
+       g_free(dinfo);
+       return stats;
+}
+
+/* BEGIN GLADE CODE */
+/* This is a dummy pixmap we use when a pixmap can't be found. */
+static char *dummy_pixmap_xpm[] = {
+       /* columns rows colors chars-per-pixel */
+       "1 1 1 1",
+       "  c None",
+       /* pixels */
+       " "
+};
+
+/* This is an internally used function to create pixmaps. */
+static GtkWidget* create_dummy_pixmap(GtkWidget *widget)
+{
+       GdkColormap *colormap;
+       GdkPixmap *gdkpixmap;
+       GdkBitmap *mask;
+       GtkWidget *pixmap;
+
+       colormap = gtk_widget_get_colormap (widget);
+       gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
+                       NULL, dummy_pixmap_xpm);
+       if (gdkpixmap == NULL)
+               g_error ("Couldn't create replacement pixmap.");
+       pixmap = gtk_pixmap_new (gdkpixmap, mask);
+       gdk_pixmap_unref (gdkpixmap);
+       gdk_bitmap_unref (mask);
+       return pixmap;
+}
+/* END GLADE CODE */
+
+/* glade generates some calls to a create_pixmap support function 
+ * we don't really need. */
+#define create_pixmap(widget,filename) create_dummy_pixmap(widget)
+
+static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpointer data)
+{
+       ThemesPage *prefs_themes = (ThemesPage *)page;
+       ThemesData *tdata = prefs_themes_data;
+       gchar *buf;
+       gint   i;
+       /* from gtk/about.c */
+       GtkStyle *style;
+       GdkColormap *cmap;
+       GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
+       gboolean success[2];
+
+       /* BEGIN GLADE EDITED CODE */
+       GtkWidget *vbox1;
+       GtkWidget *frame1;
+       GtkWidget *vbox2;
+       GtkWidget *hbox3;
+       GtkWidget *menu_themes;
+       GtkWidget *menu_themes_menu;
+       GtkWidget *glade_menuitem;
+       GtkWidget *btn_install;
+       GtkWidget *btn_more;
+       GtkWidget *label_global_status;
+       GtkWidget *frame_info;
+       GtkWidget *table1;
+       GtkWidget *label1;
+       GtkWidget *label2;
+       GtkWidget *label3;
+       GtkWidget *label_name;
+       GtkWidget *label_author;
+       GtkWidget *label_url;
+       GtkWidget *label4;
+       GtkWidget *label_status;
+       GtkWidget *frame_preview;
+       GtkWidget *hbox1;
+       GtkWidget *icon_1;
+       GtkWidget *icon_2;
+       GtkWidget *icon_3;
+       GtkWidget *icon_4;
+       GtkWidget *icon_5;
+       GtkWidget *icon_6;
+       GtkWidget *icon_7;
+       GtkWidget *frame_buttons;
+       GtkWidget *hbuttonbox1;
+       GtkWidget *btn_use;
+       GtkWidget *btn_remove;
+
+       vbox1 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox1);
+
+       frame1 = gtk_frame_new (_("Selector"));
+       gtk_widget_show (frame1);
+       gtk_box_pack_start (GTK_BOX (vbox1), frame1, TRUE, TRUE, 0);
+
+       vbox2 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox2);
+       gtk_container_add (GTK_CONTAINER (frame1), vbox2);
+
+       hbox3 = gtk_hbox_new (FALSE, 0);
+       gtk_widget_show (hbox3);
+       gtk_box_pack_start (GTK_BOX (vbox2), hbox3, TRUE, TRUE, 0);
+       gtk_container_set_border_width (GTK_CONTAINER (hbox3), 5);
+
+       menu_themes = gtk_option_menu_new ();
+       gtk_widget_show (menu_themes);
+       gtk_box_pack_start (GTK_BOX (hbox3), menu_themes, FALSE, FALSE, 0);
+       menu_themes_menu = gtk_menu_new ();
+       glade_menuitem = gtk_menu_item_new_with_label ("");
+       gtk_widget_show (glade_menuitem);
+       gtk_menu_append (GTK_MENU (menu_themes_menu), glade_menuitem);
+       gtk_option_menu_set_menu (GTK_OPTION_MENU (menu_themes), menu_themes_menu);
+
+       btn_install = gtk_button_new_with_label (_("Install new..."));
+       gtk_widget_show (btn_install);
+       gtk_box_pack_start (GTK_BOX (hbox3), btn_install, FALSE, FALSE, 0);
+       GTK_WIDGET_SET_FLAGS (btn_install, GTK_CAN_DEFAULT);
+
+       btn_more = gtk_button_new_with_label (_("Get more..."));
+       gtk_widget_show (btn_more);
+       gtk_box_pack_start (GTK_BOX (hbox3), btn_more, FALSE, FALSE, 0);
+       GTK_WIDGET_SET_FLAGS (btn_more, GTK_CAN_DEFAULT);
+       /* make it look like an uri */
+       gtk_button_set_relief(GTK_BUTTON(btn_more), GTK_RELIEF_NONE);
+       gtk_label_get(GTK_LABEL(GTK_BIN(btn_more)->child), &buf);
+       buf = g_strdup(buf);
+       for (i = 0; buf[i] != '\0'; buf[i++] = '_');
+       gtk_label_set_pattern(GTK_LABEL(GTK_BIN(btn_more)->child), buf);
+       g_free(buf);
+       cmap = gdk_window_get_colormap((mainwindow_get_mainwindow())->window->window);
+       gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
+       if (success[0] == TRUE && success[1] == TRUE) {
+               gtk_widget_ensure_style(GTK_BIN(btn_more)->child);
+               style = gtk_style_copy
+                       (gtk_widget_get_style(GTK_BIN(btn_more)->child));
+               style->fg[GTK_STATE_NORMAL]   = uri_color[0];
+               style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
+               style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
+               gtk_widget_set_style(GTK_BIN(btn_more)->child, style);
+       } else
+               g_warning("prefs_themes_create_widget(): color allocation failed.\n");
+
+
+       label_global_status = gtk_label_new ("");
+       gtk_widget_show (label_global_status);
+       gtk_box_pack_start (GTK_BOX (vbox2), label_global_status, FALSE, FALSE, 0);
+       gtk_label_set_justify (GTK_LABEL (label_global_status), GTK_JUSTIFY_LEFT);
+       gtk_misc_set_alignment (GTK_MISC (label_global_status), 0, 0.5);
+       gtk_misc_set_padding (GTK_MISC (label_global_status), 6, 0);
+
+       frame_info = gtk_frame_new (_("Information"));
+       gtk_widget_show (frame_info);
+       gtk_box_pack_start (GTK_BOX (vbox1), frame_info, TRUE, TRUE, 0);
+
+       table1 = gtk_table_new (4, 2, FALSE);
+       gtk_widget_show (table1);
+       gtk_container_add (GTK_CONTAINER (frame_info), table1);
+
+       label1 = gtk_label_new (_("Name: "));
+       gtk_widget_show (label1);
+       gtk_table_attach (GTK_TABLE (table1), label1, 0, 1, 0, 1,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 8, 2);
+       gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
+       gtk_misc_set_alignment (GTK_MISC (label1), 0, 0.5);
+
+       label2 = gtk_label_new (_("Author: "));
+       gtk_widget_show (label2);
+       gtk_table_attach (GTK_TABLE (table1), label2, 0, 1, 1, 2,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 8, 2);
+       gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT);
+       gtk_misc_set_alignment (GTK_MISC (label2), 0, 0.5);
+
+       label3 = gtk_label_new (_("URL:"));
+       gtk_widget_show (label3);
+       gtk_table_attach (GTK_TABLE (table1), label3, 0, 1, 2, 3,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 8, 2);
+       gtk_misc_set_alignment (GTK_MISC (label3), 0, 0.5);
+
+       label_name = gtk_label_new ("");
+       gtk_widget_show (label_name);
+       gtk_table_attach (GTK_TABLE (table1), label_name, 1, 2, 0, 1,
+                       (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                       (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment (GTK_MISC (label_name), 0, 0.5);
+
+       label_author = gtk_label_new ("");
+       gtk_widget_show (label_author);
+       gtk_table_attach (GTK_TABLE (table1), label_author, 1, 2, 1, 2,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment (GTK_MISC (label_author), 0, 0.5);
+
+       label_url = gtk_label_new ("");
+       gtk_widget_show (label_url);
+       gtk_table_attach (GTK_TABLE (table1), label_url, 1, 2, 2, 3,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment (GTK_MISC (label_url), 0, 0.5);
+
+       label4 = gtk_label_new (_("Status:"));
+       gtk_widget_show (label4);
+       gtk_table_attach (GTK_TABLE (table1), label4, 0, 1, 3, 4,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 8, 2);
+       gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
+
+       label_status = gtk_label_new ("");
+       gtk_widget_show (label_status);
+       gtk_table_attach (GTK_TABLE (table1), label_status, 1, 2, 3, 4,
+                       (GtkAttachOptions) (GTK_FILL),
+                       (GtkAttachOptions) (0), 0, 0);
+       gtk_misc_set_alignment (GTK_MISC (label_status), 0, 0.5);
+
+       frame_preview = gtk_frame_new (_("Preview"));
+       gtk_widget_show (frame_preview);
+       gtk_box_pack_start (GTK_BOX (vbox1), frame_preview, TRUE, TRUE, 0);
+
+       hbox1 = gtk_hbox_new (FALSE, 0);
+       gtk_widget_show (hbox1);
+       gtk_container_add (GTK_CONTAINER (frame_preview), hbox1);
+
+       icon_1 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_1);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_1, TRUE, TRUE, 2);
+       gtk_misc_set_padding (GTK_MISC (icon_1), 0, 5);
+
+       icon_2 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_2);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_2, TRUE, TRUE, 2);
+       gtk_misc_set_padding (GTK_MISC (icon_2), 0, 5);
+
+       icon_3 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_3);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_3, TRUE, TRUE, 2);
+       gtk_misc_set_padding (GTK_MISC (icon_3), 0, 5);
+
+       icon_4 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_4);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_4, TRUE, TRUE, 2);
+       gtk_misc_set_padding (GTK_MISC (icon_4), 0, 5);
+
+       icon_5 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_5);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_5, TRUE, TRUE, 2);
+       gtk_misc_set_padding (GTK_MISC (icon_5), 0, 5);
+
+       icon_6 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_6);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_6, TRUE, TRUE, 0);
+       gtk_misc_set_padding (GTK_MISC (icon_6), 0, 5);
+
+       icon_7 = create_pixmap (vbox1, NULL);
+       gtk_widget_show (icon_7);
+       gtk_box_pack_start (GTK_BOX (hbox1), icon_7, TRUE, TRUE, 0);
+       gtk_misc_set_padding (GTK_MISC (icon_7), 0, 5);
+
+       frame_buttons = gtk_frame_new (_("Actions"));
+       gtk_widget_show (frame_buttons);
+       gtk_box_pack_start (GTK_BOX (vbox1), frame_buttons, TRUE, TRUE, 0);
+
+       hbuttonbox1 = gtk_hbutton_box_new ();
+       gtk_widget_show (hbuttonbox1);
+       gtk_container_add (GTK_CONTAINER (frame_buttons), hbuttonbox1);
+       gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 5);
+       gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_START);
+       gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 5);
+       gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox1), 5, 0);
+
+       btn_use = gtk_button_new_with_label (_("Use this"));
+       gtk_widget_show (btn_use);
+       gtk_container_add (GTK_CONTAINER (hbuttonbox1), btn_use);
+       GTK_WIDGET_SET_FLAGS (btn_use, GTK_CAN_DEFAULT);
+
+       btn_remove = gtk_button_new_with_label (_("Remove"));
+       gtk_widget_show (btn_remove);
+       gtk_container_add (GTK_CONTAINER (hbuttonbox1), btn_remove);
+       GTK_WIDGET_SET_FLAGS (btn_remove, GTK_CAN_DEFAULT);
+
+       gtk_signal_connect(GTK_OBJECT (btn_use), "clicked",
+                       GTK_SIGNAL_FUNC (prefs_themes_btn_use_clicked_cb),
+                       NULL);
+       gtk_signal_connect(GTK_OBJECT(btn_remove), "clicked",
+                       GTK_SIGNAL_FUNC(prefs_themes_btn_remove_clicked_cb),
+                       NULL);
+       gtk_signal_connect(GTK_OBJECT(btn_install), "clicked",
+                       GTK_SIGNAL_FUNC(prefs_themes_btn_install_clicked_cb),
+                       NULL);
+       gtk_signal_connect(GTK_OBJECT(btn_more), "clicked",
+                       GTK_SIGNAL_FUNC(prefs_themes_btn_more_clicked_cb),
+                       NULL);
+
+       gtk_widget_grab_default (btn_use);
+       /* END GLADE EDITED CODE */
+
+       prefs_themes->window = GTK_WIDGET(window);
+       
+       prefs_themes->name   = label_name;
+       prefs_themes->author = label_author;
+       prefs_themes->url    = label_url;
+       prefs_themes->status = label_status;
+       prefs_themes->global = label_global_status;
+
+       prefs_themes->icons[0] = icon_1;
+       prefs_themes->icons[1] = icon_2;
+       prefs_themes->icons[2] = icon_3;
+       prefs_themes->icons[3] = icon_4;
+       prefs_themes->icons[4] = icon_5;
+       prefs_themes->icons[5] = icon_6;
+       prefs_themes->icons[6] = icon_7;
+       
+       prefs_themes->btn_use     = btn_use;
+       prefs_themes->btn_remove  = btn_remove;
+       prefs_themes->btn_install = btn_install;
+       prefs_themes->btn_more    = btn_more;
+
+       prefs_themes->op_menu     = menu_themes;
+
+       prefs_themes->page.widget = vbox1;
+
+       prefs_themes_set_themes_menu(GTK_OPTION_MENU(prefs_themes->op_menu), tdata);
+       
+       prefs_themes_get_theme_info(tdata);
+       prefs_themes_display_global_stats(tdata);
+}
+
+static void prefs_themes_destroy_widget(PrefsPage *page)
+{
+       /* ThemesPage *theme = (ThemesPage *)page; */
+}
+
+static void prefs_themes_save(PrefsPage *page)
+{
+       /* ThemesPage *theme = (ThemesPage *)page; */
+}
+
diff --git a/src/prefs_themes.h b/src/prefs_themes.h
new file mode 100644 (file)
index 0000000..c24bed7
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2003 Hiroyuki Yamamoto & the Sylpheed-Claws 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PREFS_THEMES_H
+#define PREFS_THEMES_H
+
+void prefs_themes_init(void);
+void prefs_themes_done(void);
+
+
+#endif /* PREFS_THEMES_H */
+
index cd5cd16..eb222df 100644 (file)
@@ -125,100 +125,100 @@ static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname);
 
 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", "  "},
-       {checkbox_on_xpm                        , NULL, NULL, "checkbox_on", "  "},
-       {check_spelling_xpm                     , NULL, NULL, "check_spelling", "  "},
-       {clip_xpm                               , NULL, NULL, "clip", "  "},
-       {clipkey_xpm                            , NULL, NULL, "clipkey", "  "},
-       {close_xpm                              , NULL, NULL, "close", "  "},
-       {complete_xpm                           , NULL, NULL, "complete", "  "},
-       {continue_xpm                           , NULL, NULL, "continue", "  "},
-       {deleted_xpm                            , NULL, NULL, "deleted", "  "},
-       {dir_close_xpm                          , NULL, NULL, "dir_close", "  "},
-       {dir_close_xpm                          , NULL, NULL, "dir_close_hrm", " "},
-       {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", "  "},
-       {forwarded_xpm                          , NULL, NULL, "forwarded", "  "},
-       {group_xpm                              , NULL, NULL, "group", "  "},
-       {ignorethread_xpm                       , NULL, NULL, "ignorethread", "  "},
-       {inbox_xpm                              , NULL, NULL, "inbox_close", "  "},
-       {inbox_hrm_xpm                          , NULL, NULL, "inbox_close_hrm", "  "},
-       {inbox_xpm                              , NULL, NULL, "inbox_open", "  "},
-       {inbox_hrm_xpm                          , NULL, NULL, "inbox_open_hrm", "  "},
-       {paste_xpm                              , NULL, NULL, "insert_file", "  "},
-       {interface_xpm                          , NULL, NULL, "interface", "  "},
-       {jpilot_xpm                             , NULL, NULL, "jpilot", "  "},
-       {key_xpm                                , NULL, NULL, "key", "  "},
-       {ldap_xpm                               , NULL, NULL, "ldap", "  "},
-       {linewrap_xpm                           , NULL, NULL, "linewrap", "  "},
-       {locked_xpm                             , NULL, NULL, "locked", "  "},
-       {mail_xpm                               , NULL, NULL, "mail", "  "},
-       {mail_attach_xpm                        , NULL, NULL, "mail_attach", "  "},
-       {mail_compose_xpm                       , NULL, NULL, "mail_compose", "  "},
-       {mail_forward_xpm                       , NULL, NULL, "mail_forward", "  "},
-       {mail_receive_xpm                       , NULL, NULL, "mail_receive", "  "},
-       {mail_receive_all_xpm                   , NULL, NULL, "mail_receive_all", "  "},
-       {mail_reply_xpm                         , NULL, NULL, "mail_reply", "  "},
-       {mail_reply_to_all_xpm                  , NULL, NULL, "mail_reply_to_all", "  "},
-       {mail_reply_to_author_xpm               , NULL, NULL, "mail_reply_to_author", "  "},
-       {mail_send_xpm                          , NULL, NULL, "mail_send", "  "},
-       {mail_send_queue_xpm                    , NULL, NULL, "mail_send_queue", "  "},
-       {mail_xpm                               , NULL, NULL, "mail_sign", "  "},
-       {mark_xpm                               , NULL, NULL, "mark", "  "},
-       {new_xpm                                , NULL, NULL, "new", "  "},
-       {news_compose_xpm                       , NULL, NULL, "news_compose", "  "},
-       {outbox_xpm                             , NULL, NULL, "outbox_close", "  "},
-       {outbox_hrm_xpm                         , NULL, NULL, "outbox_close_hrm", "  "},
-       {outbox_xpm                             , NULL, NULL, "outbox_open", "  "},
-       {outbox_hrm_xpm                         , NULL, NULL, "outbox_open_hrm", "  "},
-       {replied_xpm                            , NULL, NULL, "replied", "  "},
-       {paste_xpm                              , NULL, NULL, "paste", "  "},
-       {preferences_xpm                        , NULL, NULL, "preferences", "  "},
-       {properties_xpm                         , NULL, NULL, "properties", "  "},
-       {outbox_xpm                             , NULL, NULL, "queue_close", "  "},
-       {outbox_hrm_xpm                         , NULL, NULL, "queue_close_hrm", "  "},
-       {outbox_xpm                             , NULL, NULL, "queue_open", "  "},
-       {outbox_hrm_xpm                         , NULL, NULL, "queue_open_hrm", "  "},
-       {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", "  "},
-       {online_xpm                             , NULL, NULL, "online", "  "},
-       {offline_xpm                            , NULL, NULL, "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", "  "},
-       {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_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", "  "},    
-       {privacy_signed_xpm                     , NULL, NULL, "privacy_signed", "  "},
-       {privacy_passed_xpm                     , NULL, NULL, "privacy_passed", "  "},
-       {privacy_failed_xpm                     , NULL, NULL, "privacy_failed", "  "},  
-       {privacy_unknown_xpm                    , NULL, NULL, "privacy_unknown", "  "},
-       {privacy_expired_xpm                    , NULL, NULL, "privacy_expired", "  "},
-       {privacy_warn_xpm                       , NULL, NULL, "privacy_warn", "  "},
-       {mime_message_xpm                       , NULL, NULL, "mime_message", "  "},
-       {sylpheed_logo_xpm                      , NULL, NULL, "sylpheed_logo", "  "},
+       {address_xpm                            , NULL, NULL, "address", NULL},
+       {address_book_xpm                       , NULL, NULL, "address_book", NULL},
+       {address_search_xpm                     , NULL, NULL, "address_search", NULL},
+       {book_xpm                               , NULL, NULL, "book", NULL},
+       {category_xpm                           , NULL, NULL, "category", NULL},
+       {checkbox_off_xpm                       , NULL, NULL, "checkbox_off", NULL},
+       {checkbox_on_xpm                        , NULL, NULL, "checkbox_on", NULL},
+       {check_spelling_xpm                     , NULL, NULL, "check_spelling", NULL},
+       {clip_xpm                               , NULL, NULL, "clip", NULL},
+       {clipkey_xpm                            , NULL, NULL, "clipkey", NULL},
+       {close_xpm                              , NULL, NULL, "close", NULL},
+       {complete_xpm                           , NULL, NULL, "complete", NULL},
+       {continue_xpm                           , NULL, NULL, "continue", NULL},
+       {deleted_xpm                            , NULL, NULL, "deleted", NULL},
+       {dir_close_xpm                          , NULL, NULL, "dir_close", NULL},
+       {dir_close_xpm                          , NULL, NULL, "dir_close_hrm", NULL},
+       {dir_open_xpm                           , NULL, NULL, "dir_open", NULL},
+       {dir_open_hrm_xpm                       , NULL, NULL, "dir_open_hrm", NULL},
+       {down_arrow_xpm                         , NULL, NULL, "down_arrow", NULL},
+       {up_arrow_xpm                           , NULL, NULL, "up_arrow", NULL},
+       {mail_compose_xpm                       , NULL, NULL, "edit_extern", NULL},
+       {error_xpm                              , NULL, NULL, "error", NULL},
+       {exec_xpm                               , NULL, NULL, "exec", NULL},
+       {forwarded_xpm                          , NULL, NULL, "forwarded", NULL},
+       {group_xpm                              , NULL, NULL, "group", NULL},
+       {ignorethread_xpm                       , NULL, NULL, "ignorethread", NULL},
+       {inbox_xpm                              , NULL, NULL, "inbox_close", NULL},
+       {inbox_hrm_xpm                          , NULL, NULL, "inbox_close_hrm", NULL},
+       {inbox_xpm                              , NULL, NULL, "inbox_open", NULL},
+       {inbox_hrm_xpm                          , NULL, NULL, "inbox_open_hrm", NULL},
+       {paste_xpm                              , NULL, NULL, "insert_file", NULL},
+       {interface_xpm                          , NULL, NULL, "interface", NULL},
+       {jpilot_xpm                             , NULL, NULL, "jpilot", NULL},
+       {key_xpm                                , NULL, NULL, "key", NULL},
+       {ldap_xpm                               , NULL, NULL, "ldap", NULL},
+       {linewrap_xpm                           , NULL, NULL, "linewrap", NULL},
+       {locked_xpm                             , NULL, NULL, "locked", NULL},
+       {mail_xpm                               , NULL, NULL, "mail", NULL},
+       {mail_attach_xpm                        , NULL, NULL, "mail_attach", NULL},
+       {mail_compose_xpm                       , NULL, NULL, "mail_compose", NULL},
+       {mail_forward_xpm                       , NULL, NULL, "mail_forward", NULL},
+       {mail_receive_xpm                       , NULL, NULL, "mail_receive", NULL},
+       {mail_receive_all_xpm                   , NULL, NULL, "mail_receive_all", NULL},
+       {mail_reply_xpm                         , NULL, NULL, "mail_reply", NULL},
+       {mail_reply_to_all_xpm                  , NULL, NULL, "mail_reply_to_all", NULL},
+       {mail_reply_to_author_xpm               , NULL, NULL, "mail_reply_to_author", NULL},
+       {mail_send_xpm                          , NULL, NULL, "mail_send", NULL},
+       {mail_send_queue_xpm                    , NULL, NULL, "mail_send_queue", NULL},
+       {mail_xpm                               , NULL, NULL, "mail_sign", NULL},
+       {mark_xpm                               , NULL, NULL, "mark", NULL},
+       {new_xpm                                , NULL, NULL, "new", NULL},
+       {news_compose_xpm                       , NULL, NULL, "news_compose", NULL},
+       {outbox_xpm                             , NULL, NULL, "outbox_close", NULL},
+       {outbox_hrm_xpm                         , NULL, NULL, "outbox_close_hrm", NULL},
+       {outbox_xpm                             , NULL, NULL, "outbox_open", NULL},
+       {outbox_hrm_xpm                         , NULL, NULL, "outbox_open_hrm", NULL},
+       {replied_xpm                            , NULL, NULL, "replied", NULL},
+       {paste_xpm                              , NULL, NULL, "paste", NULL},
+       {preferences_xpm                        , NULL, NULL, "preferences", NULL},
+       {properties_xpm                         , NULL, NULL, "properties", NULL},
+       {outbox_xpm                             , NULL, NULL, "queue_close", NULL},
+       {outbox_hrm_xpm                         , NULL, NULL, "queue_close_hrm", NULL},
+       {outbox_xpm                             , NULL, NULL, "queue_open", NULL},
+       {outbox_hrm_xpm                         , NULL, NULL, "queue_open_hrm", NULL},
+       {trash_xpm                              , NULL, NULL, "trash_open", NULL},
+       {trash_hrm_xpm                          , NULL, NULL, "trash_open_hrm", NULL},
+       {trash_xpm                              , NULL, NULL, "trash_close", NULL},
+       {trash_hrm_xpm                          , NULL, NULL, "trash_close_hrm", NULL},
+       {unread_xpm                             , NULL, NULL, "unread", NULL},
+       {vcard_xpm                              , NULL, NULL, "vcard", NULL},
+       {online_xpm                             , NULL, NULL, "online", NULL},
+       {offline_xpm                            , NULL, NULL, "offline", NULL},
+       {notice_warn_xpm                        , NULL, NULL, "notice_warn",  NULL},
+       {notice_error_xpm                       , NULL, NULL, "notice_error",  NULL},
+       {notice_note_xpm                        , NULL, NULL, "notice_note",  NULL},
+       {quicksearch_xpm                        , NULL, NULL, "quicksearch",  NULL},
+       {gpg_signed_xpm                         , NULL, NULL, "gpg_signed", NULL},
+       {drafts_close_xpm                       , NULL, NULL, "drafts_close", NULL},
+       {drafts_open_xpm                        , NULL, NULL, "drafts_open", NULL},
+       {mime_text_plain_xpm                    , NULL, NULL, "mime_text_plain", NULL},
+       {mime_text_html_xpm                     , NULL, NULL, "mime_text_html", NULL},
+       {mime_application_xpm                   , NULL, NULL, "mime_application", NULL},
+       {mime_image_xpm                         , NULL, NULL, "mime_image", NULL},
+       {mime_audio_xpm                         , NULL, NULL, "mime_audio", NULL},
+       {mime_text_enriched_xpm                 , NULL, NULL, "mime_text_enriched", NULL},
+       {mime_unknown_xpm                       , NULL, NULL, "mime_unknown", NULL},    
+       {privacy_signed_xpm                     , NULL, NULL, "privacy_signed", NULL},
+       {privacy_passed_xpm                     , NULL, NULL, "privacy_passed", NULL},
+       {privacy_failed_xpm                     , NULL, NULL, "privacy_failed", NULL},  
+       {privacy_unknown_xpm                    , NULL, NULL, "privacy_unknown", NULL},
+       {privacy_expired_xpm                    , NULL, NULL, "privacy_expired", NULL},
+       {privacy_warn_xpm                       , NULL, NULL, "privacy_warn", NULL},
+       {mime_message_xpm                       , NULL, NULL, "mime_message", NULL},
+       {sylpheed_logo_xpm                      , NULL, NULL, "sylpheed_logo", NULL},
 };
 
 /* return newly constructed GtkPixmap from GdkPixmap */
@@ -250,7 +250,7 @@ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
 
        pix_d = &pixmaps[icon];
 
-       if (!pix_d->pixmap || (strcmp(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0)) {
+       if (!pix_d->pixmap || (strcmp2(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0)) {
                GdkPixmap *pix = NULL;
        
                if (strcmp(prefs_common.pixmap_theme_path, DEFAULT_PIXMAP_THEME) != 0) {
@@ -264,8 +264,10 @@ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
                                                             NULL);
                                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;
+                               if (pix) {
+                                       if (pix_d->icon_path != NULL) g_free(pix_d->icon_path);
+                                       pix_d->icon_path = g_strdup(prefs_common.pixmap_theme_path);
+                               }
                                g_free(icon_file_name);
                        } else {
                                /* even the path does not exist (deleted between two sessions), so
@@ -278,8 +280,10 @@ gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
 
        if (!pix_d->pixmap) {
                PIXMAP_CREATE(window, pix_d->pixmap, pix_d->mask, pix_d->data);
-               if (pix_d->pixmap) 
-                       pix_d->icon_path = DEFAULT_PIXMAP_THEME;        
+               if (pix_d->pixmap) {
+                       if (pix_d->icon_path != NULL) g_free(pix_d->icon_path);
+                       pix_d->icon_path = g_strdup(DEFAULT_PIXMAP_THEME);      
+               }
        }
 
        g_return_val_if_fail(pix_d->pixmap != NULL, -1);
index 8d1eac0..097078a 100644 (file)
@@ -5294,6 +5294,7 @@ void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview)
 
        folderview_unselect(summaryview->folderview);
        folderview_select(summaryview->folderview, summaryview->folder_item);
+       summary_set_column_titles(summaryview);
 }
 
 /*