2009-02-06 [colin] 3.7.0cvs54
[claws.git] / src / mainwindow.c
index a7b306f2915e14bb0e6ce4af1192d15ea805c264..43733dc8840eda95003e096746008be6508b6a92 100644 (file)
@@ -1,6 +1,6 @@
 /*
    Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
-   Copyright (C) 1999-2008 Hiroyuki Yamamoto and the Claws Mail team
+   Copyright (C) 1999-2009 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
@@ -81,6 +81,9 @@
 #include "imap.h"
 #include "socket.h"
 #include "printing.h"
+#ifdef G_OS_WIN32
+#include "w32lib.h"
+#endif
 
 #define AC_LABEL_WIDTH 240
 
@@ -626,7 +629,7 @@ static GtkActionEntry mainwin_entries[] =
        {"Message/CancelNews",                  NULL, N_("Cancel a news message"), NULL, NULL, G_CALLBACK(cancel_cb) },
        /*{"Message/---",                       NULL, "---" },*/
        
-       {"Message/Mark",                        NULL, "_Mark" },
+       {"Message/Mark",                        NULL, N_("_Mark") },
        {"Message/Mark/Mark",                   NULL, N_("_Mark"), "<shift>asterisk", NULL, G_CALLBACK(mark_cb) },
        {"Message/Mark/Unmark",                 NULL, N_("_Unmark"), "U", NULL, G_CALLBACK(unmark_cb) },
        {"Message/Mark/---",                    NULL, "---", NULL, NULL, NULL },
@@ -1309,9 +1312,13 @@ static gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
 
        switch (event->keyval) {
        case GDK_Q:             /* Quit */
+#ifndef MAEMO
                BREAK_ON_MODIFIER_KEY();
 
-               app_exit_cb(NULL, mainwin);
+               if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) {
+                       app_exit_cb(NULL, mainwin);
+               }
+#endif
                return FALSE;
        case GDK_space:
                BREAK_ON_MODIFIER_KEY();
@@ -1933,8 +1940,10 @@ MainWindow *main_window_create()
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Manual", "Help/Manual", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "FAQ", "Help/FAQ", GTK_UI_MANAGER_MENUITEM)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "IconLegend", "Help/IconLegend", GTK_UI_MANAGER_MENUITEM)
+#ifdef G_OS_WIN32
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator1", "Help/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "SetDefault", "Help/SetDefault", GTK_UI_MANAGER_MENUITEM)
+#endif
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "Separator2", "Help/---", GTK_UI_MANAGER_SEPARATOR)
        MENUITEM_ADDUI_MANAGER(mainwin->ui_manager, "/Menu/Help", "About", "Help/About", GTK_UI_MANAGER_MENUITEM)
 
@@ -2064,7 +2073,7 @@ MainWindow *main_window_create()
 #endif
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
-       mainwin->summaryview = summaryview = summary_create();
+       mainwin->summaryview = summaryview = summary_create(mainwin);
        mainwin->messageview = messageview = messageview_create(mainwin);
 
        /* init log instances data before creating log views */
@@ -2237,8 +2246,6 @@ MainWindow *main_window_create()
 
        ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
        
-/* FIXME       menu_connect_identical_items(); */
-
 #ifndef GENERIC_UMPC
        gtk_window_iconify(GTK_WINDOW(mainwin->window));
 #endif
@@ -2390,6 +2397,8 @@ static gboolean reflect_prefs_timeout_cb(gpointer data)
                        compose_reflect_prefs_pixmap_theme();
                        folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
+                       foldersel_reflect_prefs_pixmap_theme();
+                       addressbook_reflect_prefs_pixmap_theme();
 #ifndef GENERIC_UMPC
                        pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
                        gtk_container_remove(GTK_CONTAINER(mainwin->online_switch), 
@@ -2444,6 +2453,10 @@ void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
 
        /* clear items. get item pointers. */
        for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
+               g_signal_handlers_disconnect_matched
+                        (gtk_ui_manager_get_accel_group(mainwin->ui_manager), 
+                        G_SIGNAL_MATCH_DATA|G_SIGNAL_MATCH_FUNC,
+                        0, 0, NULL, mainwin_accel_changed_cb, cur->data);
                gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur->data), NULL);
        }
        mainwindow_colorlabel_menu_create(mainwin, TRUE);
@@ -3500,10 +3513,19 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
 static void mailing_list_compose (GtkWidget *w, gpointer *data)
 {
        const gchar *mailto;
+       PrefsAccount *account = NULL;
+       FolderItem   *folder_item = NULL;
 
        mailto = gtk_label_get_text(GTK_LABEL (gtk_bin_get_child(GTK_BIN((w)))));
+       if (mainwindow_get_mainwindow()) {
+               folder_item = mainwindow_get_mainwindow()->summaryview->folder_item;
+               if (folder_item && folder_item->prefs && folder_item->prefs->enable_default_account)
+                       account = account_find_from_id(folder_item->prefs->default_account);
+               if (folder_item && !account)
+                       account = account_find_from_item(folder_item);
+       }
        if (mailto)
-               compose_new(NULL, mailto+7, NULL);
+               compose_new_with_folderitem(account, folder_item, mailto+7);
 }
  
  static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
@@ -4175,7 +4197,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        MainWindow *mainwin;
        gboolean have_connectivity;
 
-#ifdef HAVE_NETWORKMANAGER
+#ifdef HAVE_NETWORKMANAGER_SUPPORT
        have_connectivity = networkmanager_is_online(NULL); 
 #else
        have_connectivity = TRUE;
@@ -4201,7 +4223,8 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                if(have_connectivity)
                        mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
-               imap_disconnect_all();
+               if(have_connectivity)
+                       imap_disconnect_all();
                hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        } else {
                /*go online */
@@ -4932,10 +4955,11 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
        binary_compose = g_strconcat(exename, " --compose %1", NULL);
        binary_run = g_strconcat(exename, NULL);
 
-       r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail", 
+       /* Try to set the Mail Start menu item to Claws. It may fail if we're not root; we don't care */
+       r = write_w32_registry_string("HKLM", "Software\\Clients\\Mail", 
                        "", "Claws Mail");
-       if (!r)
-               r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail", 
+       
+       r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail", 
                                "", "Claws Mail");
        if (!r)
                r = write_w32_registry_string("HKCU", "Software\\Clients\\Mail\\Claws Mail", 
@@ -4976,6 +5000,7 @@ static void set_default_client_cb(GtkAction *action, gpointer data)
                                "", binary_compose);
        
        if (!r) {
+               SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)"Software\\Clients\\Mail");
                alertpanel_notice(_("Claws Mail has been registered as default client."));
        } else {
                alertpanel_error(_("Can not register as default client: impossible to write to the registry."));