2011-04-10 [colin] 3.7.9cvs2
[claws.git] / src / mainwindow.c
index 5fabdb3e105294c27c45549e05f338ae3a09c6c8..6f1f3259ac0f56f9c90aadece95472357e9db65b 100644 (file)
@@ -1,6 +1,6 @@
 /*
    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
-   Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
+   Copyright (C) 1999-2011 Hiroyuki Yamamoto and 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
@@ -147,10 +147,8 @@ static void empty_trash_cb  (GtkAction     *action,
                                  gpointer       data);
 static void save_as_cb          (GtkAction     *action,
                                  gpointer       data);
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
 static void page_setup_cb       (GtkAction     *action,
                                  gpointer       data);
-#endif
 static void print_cb            (GtkAction     *action,
                                  gpointer       data);
 static void app_exit_cb                 (GtkAction     *action,
@@ -494,9 +492,7 @@ static GtkActionEntry mainwin_entries[] =
 
        {"File/SaveAs",                         NULL, N_("_Save as..."), "<control>S", NULL, G_CALLBACK(save_as_cb) },
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
        {"File/PageSetup",                      NULL, N_("Page setup..."), NULL, NULL, G_CALLBACK(page_setup_cb) },
-#endif
        {"File/Print",                          NULL, N_("_Print..."), "<control>P", NULL, G_CALLBACK(print_cb) },
        /* {"File/---",                         NULL, "---" }, */
        {"File/SynchroniseFolders",             NULL, N_("Synchronise folders"), "<control><shift>S", NULL, G_CALLBACK(sync_cb) }, 
@@ -647,8 +643,8 @@ static GtkActionEntry mainwin_entries[] =
        {"Message/Mark/UnwatchThread",          NULL, N_("Unwatch thread"), NULL, NULL, G_CALLBACK(unwatch_thread_cb) },
        /* separation */
 
-       {"Message/Mark/MarkSpam",               NULL, N_("Mark as spam"), NULL, NULL, G_CALLBACK(mark_as_spam_cb) },
-       {"Message/Mark/MarkHam",                NULL, N_("Mark as ham"), NULL, NULL, G_CALLBACK(mark_as_ham_cb) },
+       {"Message/Mark/MarkSpam",               NULL, N_("Mark as _spam"), NULL, NULL, G_CALLBACK(mark_as_spam_cb) },
+       {"Message/Mark/MarkHam",                NULL, N_("Mark as _ham"), NULL, NULL, G_CALLBACK(mark_as_ham_cb) },
        /* separation */
 
        {"Message/Mark/Lock",                   NULL, N_("Lock"), NULL, NULL, G_CALLBACK(lock_msgs_cb) },
@@ -828,6 +824,7 @@ static GtkRadioActionEntry mainwin_radio_enc_entries[] =
        ENC_ACTION("Japanese/"CS_ISO_2022_JP_2, C_ISO_2022_JP_2, "ISO-2022-JP-_2"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_EUC_JP, C_EUC_JP, "_EUC-JP"), /* RADIO set_charset_cb */
        ENC_ACTION("Japanese/"CS_SHIFT_JIS, C_SHIFT_JIS, "_Shift-JIS"), /* RADIO set_charset_cb */
+       ENC_ACTION("Chinese/"CS_GB18030, C_GB18030, "_GB18030"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_GB2312, C_GB2312, "_GB2312"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_GBK, C_GBK, "GB_K"), /* RADIO set_charset_cb */
        ENC_ACTION("Chinese/"CS_BIG5, C_BIG5, "_Big5-JP"), /* RADIO set_charset_cb */
@@ -1624,9 +1621,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "EmptyTrashes", "File/EmptyTrashes", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator4", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM)
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "PageSetup", "File/PageSetup", GTK_UI_MANAGER_MENUITEM)
-#endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "Separator5", "File/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/File", "OfflineMode", "File/OfflineMode", GTK_UI_MANAGER_MENUITEM)
@@ -1772,6 +1767,7 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Japanese", CS_SHIFT_JIS, "View/Encoding/Japanese/"CS_SHIFT_JIS, GTK_UI_MANAGER_MENUITEM)
 
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding", "Chinese", "View/Encoding/Chinese", GTK_UI_MANAGER_MENU)
+       MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB18030, "View/Encoding/Chinese/"CS_GB18030, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GB2312, "View/Encoding/Chinese/"CS_GB2312, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_GBK, "View/Encoding/Chinese/"CS_GBK, GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/View/Encoding/Chinese", CS_BIG5, "View/Encoding/Chinese/"CS_BIG5, GTK_UI_MANAGER_MENUITEM)
@@ -2016,8 +2012,6 @@ MainWindow *main_window_create()
        g_signal_connect(G_OBJECT(warning_btn), "button-press-event", 
                         G_CALLBACK(warning_icon_pressed),
                         (gpointer) mainwin);
-       g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
-                        G_CALLBACK(warning_visi_notify), mainwin);
        g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
                         G_CALLBACK(warning_visi_notify), mainwin);
        g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
@@ -2041,6 +2035,7 @@ MainWindow *main_window_create()
        online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
        offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
        online_switch = gtk_button_new ();
+       gtkut_widget_set_can_focus(online_switch, FALSE);
        CLAWS_SET_TIP(online_switch, 
                             _("You are online. Click the icon to go offline"));
        offline_switch = gtk_button_new ();
@@ -2060,7 +2055,7 @@ MainWindow *main_window_create()
 
        ac_button = gtk_button_new();
        CLAWS_SET_TIP(ac_button, _("Select account"));
-       GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
+       gtkut_widget_set_can_focus(ac_button, FALSE);
        gtk_widget_set_size_request(ac_button, -1, 0);
        gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
        g_signal_connect(G_OBJECT(ac_button), "button_press_event",
@@ -2255,7 +2250,9 @@ MainWindow *main_window_create()
        ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
        
 #ifndef GENERIC_UMPC
+#ifdef G_OS_UNIX
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
+#endif
 #endif
 
        g_signal_connect(G_OBJECT(window), "window_state_event",
@@ -2403,7 +2400,7 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        toolbar_update(TOOLBAR_MAIN, mainwin);
                        messageview_reflect_prefs_pixmap_theme();
                        compose_reflect_prefs_pixmap_theme();
-                       folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
+                       folderview_reinit_fonts(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
                        foldersel_reflect_prefs_pixmap_theme();
                        addressbook_reflect_prefs_pixmap_theme();
@@ -2469,7 +2466,7 @@ void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
        }
        mainwindow_colorlabel_menu_create(mainwin, TRUE);
        summary_reflect_prefs_custom_colors(mainwin->summaryview);
-
+       folderview_reinit_fonts(mainwin->folderview);
 }
 
 static gint tags_tag = 0;
@@ -2816,7 +2813,7 @@ void main_window_toggle_message_view(MainWindow *mainwin)
        SummaryView *summaryview = mainwin->summaryview;
        GtkWidget *ppaned = NULL;
        GtkWidget *container = NULL;
-       
+
        switch (prefs_common.layout_mode) {
        case NORMAL_LAYOUT:
        case VERTICAL_LAYOUT:
@@ -2965,7 +2962,7 @@ void main_window_progress_off(MainWindow *mainwin)
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
 }
 
-static gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
+gboolean main_window_empty_trash(MainWindow *mainwin, gboolean confirm, gboolean for_quit)
 {
        if (confirm && procmsg_have_trashed_mails_fast()) {
                AlertValue val;
@@ -3567,14 +3564,17 @@ void main_window_popup(MainWindow *mainwin)
 {
        static gboolean first_start = TRUE;
 
-       if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
+       if (!gtkut_widget_get_visible(GTK_WIDGET(mainwin->window)))
                main_window_show(mainwin);
 
        if (prefs_common.mainwin_maximised)
                gtk_window_maximize(GTK_WINDOW(mainwin->window));
 
        if (first_start) {
+#ifdef G_OS_UNIX
                gtk_window_deiconify(GTK_WINDOW(mainwin->window));
+               gtkut_window_popup(mainwin->window);
+#endif
                first_start = FALSE;
        } else {
                gtkut_window_popup(mainwin->window);
@@ -4000,7 +4000,6 @@ static void print_cb(GtkAction *action, gpointer data)
        summary_print(mainwin->summaryview);
 }
 
-#if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
 static void page_setup_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
@@ -4010,7 +4009,6 @@ static void page_setup_cb(GtkAction *action, gpointer data)
 
        printing_page_setup(win);
 }
-#endif
 
 static void app_exit_cb(GtkAction *action, gpointer data)
 {
@@ -4097,14 +4095,17 @@ static void toggle_col_headers_cb(GtkAction *gaction, gpointer data)
        MainWindow *mainwin = (MainWindow *)data;
        FolderView *folderview = mainwin->folderview;
        SummaryView *summaryview = mainwin->summaryview;
+       MimeView *mimeview = mainwin->messageview->mimeview;
 
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (gaction))) {
                gtk_cmclist_column_titles_show(GTK_CMCLIST(folderview->ctree));
                gtk_cmclist_column_titles_show(GTK_CMCLIST(summaryview->ctree));
+               gtk_cmclist_column_titles_show(GTK_CMCLIST(mimeview->ctree));
                prefs_common.show_col_headers = TRUE;
        } else {
                gtk_cmclist_column_titles_hide(GTK_CMCLIST(folderview->ctree));
                gtk_cmclist_column_titles_hide(GTK_CMCLIST(summaryview->ctree));
+               gtk_cmclist_column_titles_hide(GTK_CMCLIST(mimeview->ctree));           
                prefs_common.show_col_headers = FALSE;
        }
 }
@@ -4236,8 +4237,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                if(have_connectivity)
                        mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
-               if(have_connectivity)
-                       imap_disconnect_all();
+               imap_disconnect_all(have_connectivity);
                hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        } else {
                /*go online */
@@ -4799,7 +4799,7 @@ static void allsel_cb(GtkAction *action, gpointer data)
        MessageView *msgview = mainwin->messageview;
 
        if (messageview_is_visible(msgview) &&
-                (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
+                (gtkut_widget_has_focus(msgview->mimeview->textview->text)))
                messageview_select_all(mainwin->messageview);
        else
                summary_select_all(mainwin->summaryview);
@@ -5002,6 +5002,9 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
        if (!r)
                r = write_w32_registry_dword ("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
                                "EditFlags", 2);
+       if (!r)
+               r = write_w32_registry_string ("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto", 
+                               "FriendlyTypeName", "Claws-Mail URL");
        if (!r)
                r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail\\Protocols\\mailto\\DefaultIcon", 
                                "", binary_icon);
@@ -5021,6 +5024,9 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
        if (!r)
                r = write_w32_registry_dword ("HKCU", "Software\\Classes\\mailto", 
                                "EditFlags", 2);
+       if (!r)
+               r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto", 
+                               "FriendlyTypeName", "Claws-Mail URL");
        if (!r)
                r = write_w32_registry_string("HKCU", "Software\\Classes\\mailto\\DefaultIcon", 
                                "", binary_icon);