2008-01-09 [colin] 3.2.0cvs34
[claws.git] / src / wizard.c
index 9a9aada7ef182d6d3198d8f66f997d301210e227..1b4322975d3c83be35880a2da0ba5d3217a853b8 100644 (file)
 #include "setup.h"
 #include "folder.h"
 #include "alertpanel.h"
-#ifdef USE_OPENSSL                     
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
 #include "ssl.h"
 #endif
 #include "prefs_common.h"
+#include "combobox.h"
 
 #ifdef MAEMO
 #include <libgnomevfs/gnome-vfs-volume.h>
@@ -116,7 +117,7 @@ typedef struct
        GtkWidget *recv_imap_subdir;
        GtkWidget *subsonly_checkbtn;
        GtkWidget *no_imap_warning;
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        GtkWidget *smtp_use_ssl;
        GtkWidget *recv_use_ssl;
        GtkWidget *smtp_use_tls;
@@ -451,6 +452,15 @@ static void initialize_fonts(WizardWindow *wizard)
                prefs_common.normalfont = new;
        }
        g_free(tmp);
+
+       tmp = g_strdup(prefs_common.boldfont);
+       if (strrchr(tmp, ' ')) {
+               *(strrchr(tmp, ' ')) = '\0';
+               new = g_strdup_printf("%s %d", tmp, size);
+               g_free(prefs_common.boldfont);
+               prefs_common.boldfont = new;
+       }
+       g_free(tmp);
 }
 
 #define XFACE "+}Axz@~a,-Yx?0Ysa|q}CLRH=89Y]\"')DSX^<6p\"d)'81yx5%G#u^o*7JG&[aPU0h1Ux.vb2yIjH83{5`/bVo|~nn/i83vE^E)qk-4W)_E.4Y=D*qvf/,Ci_=P<iY<M6"
@@ -571,18 +581,14 @@ static gboolean wizard_write_config(WizardWindow *wizard)
        static gboolean mailbox_ok = FALSE;
        PrefsAccount *prefs_account = prefs_account_new();
        GList *account_list = NULL;
-       GtkWidget *menu, *menuitem;
        gchar *smtp_server, *recv_server;
        gint smtp_port, recv_port;
-#ifdef USE_OPENSSL                     
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        SSLType smtp_ssl_type, recv_ssl_type;
 #endif
 
-       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
-       menuitem = gtk_menu_get_active(GTK_MENU(menu));
-       prefs_account->protocol = GPOINTER_TO_INT
-                       (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
-       
+       prefs_account->protocol = combobox_get_active_data(
+                                       GTK_COMBO_BOX(wizard->recv_type));
        
        if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 && 
            !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
@@ -752,7 +758,7 @@ static gboolean wizard_write_config(WizardWindow *wizard)
                prefs_account->use_smtp_auth = TRUE;
        }
 
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        smtp_ssl_type = SSL_NONE;
        recv_ssl_type = SSL_NONE;       
 
@@ -909,8 +915,7 @@ static void wizard_email_changed(GtkWidget *widget, gpointer data)
        WizardWindow *wizard = (WizardWindow *)data;
        RecvProtocol protocol;
        gchar *text;
-       protocol = GPOINTER_TO_INT
-               (g_object_get_data(G_OBJECT(wizard->recv_type), MENU_VAL_ID));
+       protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
        
        text = get_default_server(wizard, "smtp");
        gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
@@ -1090,10 +1095,10 @@ static GtkWidget* mailbox_page (WizardWindow * wizard)
                _("on internal memory"));
        wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
                GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
-               _("on /media/mmc1"));
+               _("on external memory card"));
        wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
                GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
-               _("on /media/mmc2"));
+               _("on internal memory card"));
                
        g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
                         G_CALLBACK(data_root_changed), wizard);
@@ -1121,6 +1126,8 @@ static GtkWidget* mailbox_page (WizardWindow * wizard)
        if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
            || strcmp(mount_path, MMC2_PATH)) {
                gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
+       } else {
+               gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
        }
        g_free(mount_path);
        
@@ -1230,7 +1237,7 @@ static GtkWidget* smtp_page (WizardWindow * wizard)
                gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);        
        gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->smtp_use_ssl = gtk_check_button_new_with_label(
@@ -1267,7 +1274,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_widget_show(wizard->recv_username_label);
                gtk_widget_show(wizard->recv_password_label);
                gtk_widget_hide(wizard->no_imap_warning);
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
                gtk_widget_show(wizard->recv_use_ssl);
                gtk_widget_show(wizard->recv_use_tls);
 #endif
@@ -1291,7 +1298,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_widget_show(wizard->recv_username_label);
                gtk_widget_show(wizard->recv_password_label);
                gtk_widget_hide(wizard->no_imap_warning);
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
                gtk_widget_show(wizard->recv_use_ssl);
                gtk_widget_show(wizard->recv_use_tls);
 #endif
@@ -1316,7 +1323,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                        gtk_widget_hide(wizard->mailbox_label);
                        gtk_widget_hide(wizard->mailbox_name);
                }
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
                gtk_widget_hide(wizard->recv_use_ssl);
                gtk_widget_hide(wizard->recv_use_tls);
 #endif
@@ -1334,7 +1341,7 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
                gtk_widget_hide(wizard->recv_password);
                gtk_widget_hide(wizard->recv_username_label);
                gtk_widget_hide(wizard->recv_password_label);
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
                gtk_widget_hide(wizard->recv_use_ssl);
                gtk_widget_hide(wizard->recv_use_tls);
 #endif
@@ -1346,12 +1353,10 @@ static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
        }
 }
 
-static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
+static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
 {
        WizardWindow *wizard = (WizardWindow *)data;
-       RecvProtocol protocol;
-       protocol = GPOINTER_TO_INT
-               (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
+       RecvProtocol protocol = combobox_get_active_data(combo);
 
        wizard_protocol_change(wizard, protocol);       
 }
@@ -1359,11 +1364,11 @@ static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
 static GtkWidget* recv_page (WizardWindow * wizard)
 {
        GtkWidget *table = gtk_table_new(1,1, FALSE);
-       GtkWidget *menu = gtk_menu_new();
-       GtkWidget *menuitem;
        GtkTooltips *tips = gtk_tooltips_new();
        GtkWidget *vbox;
        GtkWidget *hbox;
+       GtkListStore *store;
+       GtkTreeIter iter;
        gchar *text;
        gint index = 0;
 
@@ -1378,24 +1383,14 @@ static GtkWidget* recv_page (WizardWindow * wizard)
 
        hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-       wizard->recv_type = gtk_option_menu_new();
-       
-       MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3);
-       g_signal_connect(G_OBJECT(menuitem), "activate",
-                        G_CALLBACK(wizard_protocol_changed),
-                        wizard);
+       wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
+       store = GTK_LIST_STORE(gtk_combo_box_get_model(
+                       GTK_COMBO_BOX(wizard->recv_type)));
 
-       MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4);
-       g_signal_connect(G_OBJECT(menuitem), "activate",
-                        G_CALLBACK(wizard_protocol_changed),
-                        wizard);
-
-       MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL);
-       g_signal_connect(G_OBJECT(menuitem), "activate",
-                        G_CALLBACK(wizard_protocol_changed),
-                        wizard);
+       COMBOBOX_ADD(store, _("POP3"), A_POP3);
+       COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
+       COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
 
-       gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu);
        switch(tmpl.recvtype) {
        case A_POP3: 
                index = 0;
@@ -1409,7 +1404,10 @@ static GtkWidget* recv_page (WizardWindow * wizard)
        default:
                index = 0;
        }
-       gtk_option_menu_set_history(GTK_OPTION_MENU (wizard->recv_type), index);
+       gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
+       g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
+                        G_CALLBACK(wizard_protocol_changed),
+                        wizard);
        PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
                 wizard->recv_type);
 
@@ -1457,7 +1455,7 @@ static GtkWidget* recv_page (WizardWindow * wizard)
        gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
        
-#ifdef USE_OPENSSL
+#if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
        hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_use_ssl = gtk_check_button_new_with_label(
@@ -1509,13 +1507,10 @@ wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
 {
        WizardWindow * wizard = (WizardWindow *)data;
        int current_page, num_pages;
-       GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
-       GtkWidget *menuitem = gtk_menu_get_active(GTK_MENU(menu));
-       gint protocol = GPOINTER_TO_INT
-                       (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
        gboolean skip_mailbox_page = FALSE;
-       
 #ifndef MAEMO
+       gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
+
        if (protocol == A_IMAP4) {
                skip_mailbox_page = TRUE;
        }