Merge branch 'master' of ssh+git://git.claws-mail.org/home/git/claws
[claws.git] / src / prefs_themes.c
index 295e2b3025ef543fccb2697aba50e4d691906d96..9f02566754f5cddd096bba87d2fbdacfddd649d5 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2003-2004 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ * Copyright (C) 2003-2012 Hiroyuki Yamamoto & 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * 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.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -45,6 +45,7 @@
 #include "mainwindow.h"
 #include "compose.h"
 #include "alertpanel.h"
+#include "addr_compl.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)
@@ -73,8 +74,7 @@ typedef struct _ThemesPage
        GtkWidget *btn_use;
        GtkWidget *btn_remove;
 
-       GdkPixmap *pixmaps[PREVIEW_ICONS];
-       GdkBitmap *masks[PREVIEW_ICONS];
+       GdkPixbuf *pixbufs[PREVIEW_ICONS];
 
        /* gchar     *theme_path; */
 } ThemesPage;
@@ -131,7 +131,6 @@ StockPixmap prefs_themes_icons[PREVIEW_ICONS] = {
 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);
@@ -139,9 +138,10 @@ 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 int prefs_themes_cmp_name(gconstpointer a, gconstpointer b);
 static void prefs_themes_free_names            (ThemesData *tdata);
 
-static void prefs_themes_set_themes_menu       (GtkOptionMenu *opmenu, const ThemesData *tdata);
+static void prefs_themes_set_themes_menu       (GtkComboBox *combo, const ThemesData *tdata);
 
 static gchar *prefs_themes_get_theme_stats     (const gchar *dirname);
 static gboolean prefs_themes_is_system_theme   (const gchar *dirname);
@@ -163,13 +163,15 @@ static void prefs_themes_file_stats(const gchar *filename, gpointer data)
        DirInfo    *di = (DirInfo *)data;
        gint        len;
        
-       if (0 == stat(filename, &s) && 0 != S_ISREG(s.st_mode)) {
+       if (0 == g_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] == '.')
+                       const gchar *extension = filename+(len-4);
+                       if (!strcmp(extension, ".xpm"))
+                               di->pixms++;
+                       else if (!strcmp(extension, ".png"))
                                di->pixms++;
                }
        }
@@ -185,10 +187,11 @@ static void prefs_themes_file_remove(const gchar *filename, gpointer data)
        
        base = g_path_get_basename(filename);
        if (TRUE == is_dir_exist(filename)) {
-               if (!((base[0] == '.') || (base[0] == '.' && base[1] == '.')))
-                       g_warning("prefs_themes_file_remove(): subdir in theme dir skipped.\n");
+               if (strcmp(base, ".") != 0 && strcmp(base, "..") != 0)
+                       g_warning("prefs_themes_file_remove(): subdir in theme dir skipped: '%s'.\n",
+                                               base);
        }
-       else if (0 != unlink(filename)) {
+       else if (0 != claws_unlink(filename)) {
                (*status) = g_strdup(filename);
        }
        g_free(base);
@@ -204,8 +207,9 @@ static void prefs_themes_file_install(const gchar *filename, gpointer data)
        
        base = g_path_get_basename(filename);
        if (TRUE == is_dir_exist(filename)) {
-               if (!((base[0] == '.') || (base[0] == '.' && base[1] == '.')))
-                       g_warning("prefs_themes_file_install(): subdir in theme dir skipped.\n");
+               if (strcmp(base, ".") != 0 && strcmp(base, "..") !=0 )
+                       g_warning("prefs_themes_file_install(): subdir in theme dir skipped: '%s'.\n",
+                                               base);
        }
        else {
                gchar *fulldest;
@@ -225,11 +229,11 @@ static void prefs_themes_foreach_file(const gchar *dirname, const FileFunc func,
        struct dirent *d;
        DIR           *dp;
 
-       g_return_if_fail(dirname != NULL);
-       g_return_if_fail(func != NULL);
+       cm_return_if_fail(dirname != NULL);
+       cm_return_if_fail(func != NULL);
        
        if ((dp = opendir(dirname)) == NULL) {
-               debug_print("directory %s not found", dirname);
+               debug_print("directory %s not found\n", dirname);
                return;
        }
 
@@ -243,61 +247,90 @@ static void prefs_themes_foreach_file(const gchar *dirname, const FileFunc func,
                (*func)(fullentry, data);
                
                g_free(fullentry);
-       }       
+       }
+       closedir(dp);
 }
 
 static gboolean prefs_themes_is_system_theme(const gchar *dirname)
 {
        gint len;
-       
-       g_return_val_if_fail(dirname != NULL, FALSE);
+       gchar *system_theme_dir;
+       gboolean is_sys = FALSE;
+
+       cm_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;
+       system_theme_dir = stock_pixmap_get_system_theme_dir_for_theme(NULL);
+       len = strlen(system_theme_dir);
+       if (strlen(dirname) > len && 0 == strncmp(dirname, system_theme_dir, len))
+               is_sys = TRUE;
        
-       return FALSE;
+       g_free(system_theme_dir);
+
+       return is_sys;
 }
 
-static void prefs_themes_set_themes_menu(GtkOptionMenu *opmenu, const ThemesData *tdata)
+static void prefs_themes_set_themes_menu(GtkComboBox *combo, const ThemesData *tdata)
 {
+       GtkListStore *store;
+       GtkTreeIter iter;
        GList     *themes = tdata->names;
-       GtkWidget *menu;
-       GtkWidget *item;
        gint       i = 0, active = 0;
+       GList     *sorted_list = NULL;
 
-       g_return_if_fail(opmenu != NULL);
-       
-       gtk_option_menu_remove_menu(opmenu);
+       cm_return_if_fail(combo != NULL);
+
+       /* sort theme data list by data name */
+       while (themes != NULL) {
+               ThemeName *tname = (ThemeName *)(themes->data);
+
+               sorted_list = g_list_insert_sorted(sorted_list, (gpointer)(tname),
+                                                  (GCompareFunc)prefs_themes_cmp_name);
+
+               themes = g_list_next(themes);
+       }
+
+       store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
        
-       menu = gtk_menu_new ();
+       /* feed gtk_menu w/ sorted themes names */
+       themes = sorted_list;
        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);
-               g_signal_connect(G_OBJECT(item), "activate",
-                                G_CALLBACK(prefs_themes_menu_item_activated_cb),
-                                tname->item->data);
-               gtk_menu_append(GTK_MENU(menu), item);
-
-               if (tdata->displayed != NULL && tdata->displayed == tpath)
+
+               gtk_list_store_append(store, &iter);
+               gtk_list_store_set(store, &iter,
+                                  0, tname->name,
+                                  1, tname->item->data, -1);
+
+               if (tdata->displayed != NULL && !strcmp2(tdata->displayed,tpath))
                        active = i;
+               ++i;
 
                themes = g_list_next(themes);
-               ++i;
        }
-       
-       gtk_menu_set_active(GTK_MENU(menu), active);
-       gtk_option_menu_set_menu (opmenu, menu);
+
+       g_list_free(sorted_list);
+
+       g_signal_connect(G_OBJECT(combo), "changed",
+                        G_CALLBACK(prefs_themes_menu_item_activated_cb),
+                        NULL);
+
+       gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store));
+       gtk_combo_box_set_active(combo, active);
+}
+
+static int prefs_themes_cmp_name(gconstpointer a_p, gconstpointer b_p)
+{
+       /* compare two ThemeData structures by their name attribute */
+       return strcmp2((gchar *)(((ThemeName*)a_p)->name),
+                                       (gchar *)(((ThemeName*)b_p)->name));
 }
 
 static void prefs_themes_get_themes_and_names(ThemesData *tdata)
 {
        GList *tpaths;
        
-       g_return_if_fail(tdata != NULL);
+       cm_return_if_fail(tdata != NULL);
        
        if (tdata->themes != NULL)
                stock_pixmap_themes_list_free(tdata->themes);
@@ -318,6 +351,9 @@ static void prefs_themes_get_themes_and_names(ThemesData *tdata)
                name->item = tpaths;
                        
                tdata->names = g_list_append(tdata->names, name);
+               if (!strcmp2(tpaths->data, prefs_common.pixmap_theme_path)) {
+                       tdata->displayed = (gchar *)tpaths->data;
+               }
                tpaths = g_list_next(tpaths);
                g_free(sname);  
        }
@@ -334,7 +370,7 @@ void prefs_themes_init(void)
        path[1] = _("Themes");
        path[2] = NULL;
 
-       debug_print("Creating prefereces for themes...\n");
+       debug_print("Creating preferences for themes...\n");
        
        tdata = g_new0(ThemesData, 1);
        prefs_themes_data = tdata;
@@ -347,13 +383,14 @@ void prefs_themes_init(void)
        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;
+       page->page.weight = 130.0;
        prefs_gtk_register_page((PrefsPage *) page);
 
        tdata->page = page;
 
        tpaths = g_list_first(tdata->themes);
-       tdata->displayed = (gchar *)(tpaths->data);
+       if (tdata->displayed == NULL)
+               tdata->displayed = (gchar *)(tpaths->data);
 }
 
 static void prefs_themes_free_names(ThemesData *tdata)
@@ -370,7 +407,7 @@ static void prefs_themes_free_names(ThemesData *tdata)
                
                names = g_list_next(names);
        }
-       g_list_free(names);
+       g_list_free(tdata->names);
        tdata->names = NULL;
 }
 
@@ -378,10 +415,10 @@ void prefs_themes_done(void)
 {
        ThemesData *tdata = prefs_themes_data;
 
-       debug_print("Finished prefereces for themes.\n");
+       debug_print("Finished preferences for themes.\n");
        
        stock_pixmap_themes_list_free(tdata->themes);
-       prefs_themes_free_names(tdata); 
+       prefs_themes_free_names(tdata); 
        g_free(tdata->page);
        g_free(tdata);
 }
@@ -392,15 +429,15 @@ static void prefs_themes_btn_use_clicked_cb(GtkWidget *widget, gpointer data)
        gchar      *theme_str;
 
        theme_str = tdata->displayed;
-       
-       if (prefs_common.pixmap_theme_path != NULL)
-               g_free(prefs_common.pixmap_theme_path);
-       
+
+       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();
-       
+       addrcompl_reflect_prefs_pixmap_theme();
+
        prefs_themes_update_buttons(tdata);
 }
 
@@ -417,7 +454,7 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
        tmp = g_path_get_basename(theme_str);
 
        if (IS_SYSTEM_THEME(theme_str)) {
-               if (getuid() != 0) {
+               if (!superuser_p()) {
                        alertpanel_error(_("Only root can remove system themes"));
                        return;
                }
@@ -431,8 +468,9 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
 
        val = alertpanel(alert_title,
                         _("Are you sure you want to remove this theme?"),
-                        _("No"), _("Yes"), _("Cancel"));
+                        GTK_STOCK_NO, GTK_STOCK_YES, NULL);
        g_free(alert_title);
+
        if (G_ALERTALTERNATE == val) {
                gchar *status = NULL;
                
@@ -446,16 +484,15 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
                                alertpanel_error(_("Removing theme directory failed."));
                }
                else {  
-                       alertpanel_notice(_("Theme removed succesfully"));
+                       alertpanel_notice(_("Theme removed successfully"));
                        /* 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_set_themes_menu(GTK_COMBO_BOX(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);
                }
        }
-       g_free(theme_str);
 }
 
 static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data)
@@ -486,21 +523,20 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
        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)
+                                GTK_STOCK_NO, GTK_STOCK_YES, NULL);
+               if (G_ALERTALTERNATE != val)
                        goto end_inst;
        }
-       if (getuid() == 0) {
+       if (superuser_p ()) {
                val = alertpanel(alert_title,
                                 _("Do you want to install theme for all users?"),
-                                _("Yes"), _("No"), _("Cancel"));
+                                GTK_STOCK_NO, GTK_STOCK_YES, NULL);
                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:
+                       cinfo->dest = stock_pixmap_get_system_theme_dir_for_theme(
+                                               themename);
+                       break;
+               case G_ALERTDEFAULT:
                        break;
                default:
                        goto end_inst;
@@ -508,16 +544,27 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
        }
        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,
+               cinfo->dest = g_strconcat(get_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;
+               AlertValue val = alertpanel_full(_("Theme exists"),
+                               _("A theme with the same name is\nalready installed in this location.\n\n"
+                                 "Do you want to replace it?"),
+                               GTK_STOCK_CANCEL, _("Overwrite"), NULL, FALSE,
+                               NULL, ALERT_WARNING, G_ALERTDEFAULT);
+               if (val == G_ALERTALTERNATE) {
+                       if (remove_dir_recursive(cinfo->dest) < 0) {
+                               alertpanel_error(_("Couldn't delete the old theme in %s."), cinfo->dest);
+                               goto end_inst;
+                       }
+               } else {
+                       goto end_inst;
+               }
        }
        if (0 != make_dir_hier(cinfo->dest)) {
-               alertpanel_error(_("Couldn't create destination directory"));
+               alertpanel_error(_("Couldn't create destination directory %s."), cinfo->dest);
                goto end_inst;
        }
        prefs_themes_foreach_file(source, prefs_themes_file_install, cinfo);
@@ -530,9 +577,9 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
                                            (gpointer)(cinfo->dest), 
                                            (GCompareFunc)strcmp2);
                if (NULL != insted) {
-                       alertpanel_notice(_("Theme installed succesfully"));
+                       alertpanel_notice(_("Theme installed successfully."));
                        tdata->displayed = (gchar *)(insted->data);
-                       prefs_themes_set_themes_menu(GTK_OPTION_MENU(tdata->page->op_menu), tdata);
+                       prefs_themes_set_themes_menu(GTK_COMBO_BOX(tdata->page->op_menu), tdata);
                        prefs_themes_display_global_stats(tdata);
                        prefs_themes_get_theme_info(tdata);
                }
@@ -542,7 +589,7 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
        else
                alertpanel_error(_("File %s failed\nwhile installing theme."), cinfo->status);
 end_inst:
-       if (cinfo->dest != NULL) g_free(cinfo->dest);
+       g_free(cinfo->dest);
        g_free(filename);
        g_free(source);
        g_free(themeinfo);
@@ -550,18 +597,18 @@ end_inst:
        g_free(themename);
 }
 
-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;
+       gchar      *path;
+       GtkTreeModel *model;
+       GtkTreeIter iter;
        
-       g_return_if_fail(path != NULL);
+       cm_return_if_fail(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter));
        
+       model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));                 
+       gtk_tree_model_get(model, &iter, 1, &path, -1); 
+
        tdata->displayed = path;
        prefs_themes_get_theme_info(tdata);
 }
@@ -592,6 +639,7 @@ static void prefs_themes_update_buttons(const ThemesData *tdata)
                tmpstr = g_strdup(text);                                \
                                                                        \
        gtk_label_set_text(GTK_LABEL(label), tmpstr);                   \
+       gtk_label_set_selectable(GTK_LABEL(label), TRUE);               \
        g_free(tmpstr);                                                 \
 }
 static void prefs_themes_display_theme_info(ThemesData *tdata, const ThemeInfo *info)
@@ -608,10 +656,10 @@ static void prefs_themes_display_theme_info(ThemesData *tdata, const ThemeInfo *
        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_image_set_from_pixmap(GTK_IMAGE(theme->icons[i]),
-                               theme->pixmaps[i], theme->masks[i]);
+               stock_pixbuf_gdk(theme->window, prefs_themes_icons[i], 
+                               &(theme->pixbufs[i]));
+               gtk_image_set_from_pixbuf(GTK_IMAGE(theme->icons[i]),
+                               theme->pixbufs[i]);
        }
        prefs_common.pixmap_theme_path = save_prefs_path;
 
@@ -652,8 +700,7 @@ static void prefs_themes_display_global_stats(const ThemesData *tdata)
 
 #define FGETS_INFOFILE_LINE() \
        line[0] = '\0'; \
-       fgets(line, INFOFILE_LINE_LEN, finfo); \
-       if ((len = strlen(line)) > 0) { \
+       if (fgets(line, INFOFILE_LINE_LEN, finfo) != NULL && (len = strlen(line)) > 0) { \
                if (line[len - 1] == '\n') line[len - 1] = '\0'; \
        } \
        else { \
@@ -670,9 +717,9 @@ static void prefs_themes_get_theme_info(ThemesData *tdata)
        ThemeInfo *info;
        ThemesPage *theme = tdata->page;
 
-       g_return_if_fail(theme != NULL);
+       cm_return_if_fail(theme != NULL);
        path = tdata->displayed;
-       g_return_if_fail(path != NULL);
+       cm_return_if_fail(path != NULL);
 
        debug_print("Getting theme info for %s\n", path);
        
@@ -680,13 +727,13 @@ static void prefs_themes_get_theme_info(ThemesData *tdata)
        
        if (IS_INTERNAL_THEME(path)) {
                info->name = g_strdup(_("Default internal theme"));
-               info->author = g_strdup(_("The Sylpheed Claws Team"));
+               info->author = g_strdup(_("The Claws Mail 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");
+               finfo = g_fopen(sinfo, "r");
                if (finfo == NULL) {
                        info->name = g_strdup(_("No info file available for this theme"));
                        info->author = g_strdup(_("Unknown"));
@@ -706,7 +753,7 @@ static void prefs_themes_get_theme_info(ThemesData *tdata)
 
                info->status = prefs_themes_get_theme_stats(path);
                if (info->status == NULL) {
-                       info->status = g_strdup(_("Error: can't get theme status"));
+                       info->status = g_strdup(_("Error: couldn't get theme status"));
                }
        }
 
@@ -731,65 +778,22 @@ static gchar *prefs_themes_get_theme_stats(const gchar *dirname)
        
        prefs_themes_foreach_file(dirname, prefs_themes_file_stats, dinfo);
        stats = g_strdup_printf(_("%d files (%d icons), size: %s"), 
-                               dinfo->files, dinfo->pixms, to_human_readable(dinfo->bytes));
+                               dinfo->files, dinfo->pixms, to_human_readable((goffset)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_image_new_from_pixmap(gdkpixmap, mask);
-       g_object_unref (gdkpixmap);
-       g_object_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];
 
        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;
@@ -816,59 +820,31 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        GtkWidget *hbuttonbox1;
        GtkWidget *btn_use;
        GtkWidget *btn_remove;
+       GtkCellRenderer *renderer;
 
-       vbox1 = gtk_vbox_new (FALSE, 0);
+       vbox1 = gtk_vbox_new (FALSE, VSPACING);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
        gtk_widget_show (vbox1);
 
-       PACK_FRAME (vbox1, frame1, _("Selector"));
-
-       vbox2 = gtk_vbox_new (FALSE, 0);
-       gtk_widget_show (vbox2);
-       gtk_container_add (GTK_CONTAINER (frame1), vbox2);
+       vbox2 = gtkut_get_options_frame(vbox1, &frame1, _("Selector"));
 
-       hbox3 = gtk_hbox_new (FALSE, 0);
+       hbox3 = gtk_hbox_new (FALSE, 5);
        gtk_widget_show (hbox3);
        gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
        gtk_container_set_border_width (GTK_CONTAINER (hbox3), 5);
 
-       menu_themes = gtk_option_menu_new ();
+       menu_themes = gtk_combo_box_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);
+       gtkut_widget_set_can_default (btn_install, TRUE);
 
-       btn_more = gtk_button_new_with_label (_("Get more..."));
+       btn_more = gtkut_get_link_btn((GtkWidget *)window, THEMES_URI, _("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);
@@ -947,37 +923,37 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        gtk_widget_show (hbox1);
        gtk_container_add (GTK_CONTAINER (frame_preview), hbox1);
 
-       icon_1 = create_pixmap (vbox1, NULL);
+       icon_1 = gtk_image_new();
        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);
+       icon_2 = gtk_image_new();
        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);
+       icon_3 = gtk_image_new();
        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);
+       icon_4 = gtk_image_new();
        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);
+       icon_5 = gtk_image_new();
        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);
+       icon_6 = gtk_image_new();
        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);
+       icon_7 = gtk_image_new();
        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);
@@ -989,18 +965,17 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        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);
+       gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 5);
 
        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);
+       gtkut_widget_set_can_default (btn_use, TRUE);
 
        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);
+       gtkut_widget_set_can_default (btn_remove, TRUE);
 
        g_signal_connect(G_OBJECT(btn_use), "clicked",
                         G_CALLBACK(prefs_themes_btn_use_clicked_cb),
@@ -1011,11 +986,6 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        g_signal_connect(G_OBJECT(btn_install), "clicked",
                         G_CALLBACK(prefs_themes_btn_install_clicked_cb),
                         NULL);
-       g_signal_connect(G_OBJECT(btn_more), "clicked",
-                        G_CALLBACK(prefs_themes_btn_more_clicked_cb),
-                        NULL);
-
-       gtk_widget_grab_default (btn_use);
 
        prefs_themes->window = GTK_WIDGET(window);
        
@@ -1041,8 +1011,12 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        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_set_themes_menu(GTK_COMBO_BOX(menu_themes), tdata);
+       renderer = gtk_cell_renderer_text_new();
+       gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(menu_themes), renderer, TRUE);
+       gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(menu_themes), renderer,
+                                       "text", 0, NULL);
        
        prefs_themes_get_theme_info(tdata);
        prefs_themes_display_global_stats(tdata);