2007-01-15 [paul] 2.7.0cvs30
[claws.git] / src / mainwindow.c
index 8ca8964502ba1e9bed5b397a0bbbb778c2632841..3de1ec5e394cd205467046bac9c40db4ace9611a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
+ * Copyright (C) 1999-2007 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
@@ -390,6 +390,9 @@ static void allsel_cb                (MainWindow    *mainwin,
 static void select_thread_cb    (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void delete_thread_cb    (MainWindow    *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 
 static void create_filter_cb    (MainWindow    *mainwin,
                                  guint          action,
@@ -490,6 +493,7 @@ static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
 static void mainwindow_quicksearch             (MainWindow     *mainwin, 
                                                 guint           action, 
                                                 GtkWidget      *widget);
+static gboolean any_folder_want_synchronise(void);
 
 static GtkItemFactoryEntry mainwin_entries[] =
 {
@@ -519,6 +523,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Edit/_Copy"),                    "<control>C", copy_cb, 0, NULL},
        {N_("/_Edit/Select _all"),              "<control>A", allsel_cb, 0, NULL},
        {N_("/_Edit/Select _thread"),           NULL, select_thread_cb, 0, NULL},
+       {N_("/_Edit/_Delete thread"),           NULL, delete_thread_cb, 0, NULL},
        {N_("/_Edit/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_Edit/_Find in current message..."),
                                                "<control>F", search_cb, 0, NULL},
@@ -1792,6 +1797,7 @@ void main_window_set_account_menu(GList *account_list)
                main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
                main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
        }
+       hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
 }
 
 void main_window_set_account_menu_only_toolbar(GList *account_list)
@@ -2179,6 +2185,9 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
        if (cur_account)
                state |= M_HAVE_ACCOUNT;
        
+       if (any_folder_want_synchronise())
+               state |= M_WANT_SYNC;
+
        for ( ; account_list != NULL; account_list = account_list->next) {
                if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
                        state |= M_HAVE_NEWS_ACCOUNT;
@@ -2221,11 +2230,15 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        } entry[] = {
                {"/File/Save as...", M_TARGET_EXIST},
                {"/File/Print..."  , M_TARGET_EXIST},
+               {"/File/Synchronise folders", M_WANT_SYNC},
                {"/File/Exit"      , M_UNLOCKED},
 
                {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
+               {"/Edit/Delete thread"             , M_SINGLE_TARGET_EXIST},
                {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
 
+               {"/View/Set displayed columns/in Folder list..."
+                                                  , M_UNLOCKED}, 
                {"/View/Sort"                      , M_EXEC},
                {"/View/Thread view"               , M_EXEC},
                {"/View/Expand all threads"        , M_MSG_EXIST},
@@ -2486,15 +2499,17 @@ static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * li
                        item = NULL;
                        if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
                                item = gtk_menu_item_new_with_label ((url_decoded));
-                               gtk_signal_connect (GTK_OBJECT(item), "activate",
-                                               GTK_SIGNAL_FUNC(mailing_list_compose), NULL);
+                               g_signal_connect(G_OBJECT(item), "activate",
+                                                G_CALLBACK(mailing_list_compose),
+                                                NULL);
                        }
                        else if (!g_strncasecmp (url_decoded, "http:", 5) ||
                                 !g_strncasecmp (url_decoded, "https:",6)) {
 
                                item = gtk_menu_item_new_with_label ((url_decoded));
-                               gtk_signal_connect (GTK_OBJECT(item), "activate",
-                                               GTK_SIGNAL_FUNC(mailing_list_open_uri), NULL);
+                               g_signal_connect(G_OBJECT(item), "activate",
+                                                G_CALLBACK(mailing_list_open_uri),
+                                                NULL);
                        } 
                        if (item) {
                                gtk_menu_append (GTK_MENU(menu), item);
@@ -2693,7 +2708,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                
                folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
                gtk_window_set_title(GTK_WINDOW(folderwin),
-                                    _("Sylpheed-Claws - Folder View"));
+                                    _("Claws Mail - Folder View"));
 
                gtk_window_move(GTK_WINDOW(folderwin),
                                prefs_common.folderwin_x,
@@ -2729,7 +2744,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                
                messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
                gtk_window_set_title(GTK_WINDOW(messagewin),
-                                    _("Sylpheed-Claws - Message View"));
+                                    _("Claws Mail - Message View"));
                                     
                gtk_window_move(GTK_WINDOW(messagewin), 
                                prefs_common.main_msgwin_x,
@@ -3120,7 +3135,7 @@ static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        if (prefs_common.confirm_on_exit) {
-               if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
+               if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
                               GTK_STOCK_CANCEL, GTK_STOCK_QUIT,  NULL)
                    != G_ALERTALTERNATE)
                        return;
@@ -3140,8 +3155,7 @@ static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 
 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
-       prefs_common.show_searchbar = TRUE;
-       summaryview_activate_quicksearch(mainwin->summaryview);
+       summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
 }
 
 static void toggle_folder_cb(MainWindow *mainwin, guint action,
@@ -3249,23 +3263,27 @@ static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget
        main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
 }
 
-static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
+static gboolean any_folder_want_synchronise(void)
 {
        GList *folderlist = folder_get_list();
-       gboolean found = FALSE;
 
        /* see if there are synchronised folders */
        for (; folderlist; folderlist = folderlist->next) {
                Folder *folder = (Folder *)folderlist->data;
                if (folder_want_synchronise(folder)) {
-                       found = TRUE;
-                       break;
+                       return TRUE;
                }
        }
        
-       if (!found)
+       return FALSE;
+}
+
+static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
+{
+       
+       if (!any_folder_want_synchronise())
                return;
-               
+
        if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
                        _("Do you want to synchronise your folders now?"),
                        GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
@@ -3300,6 +3318,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                mainwindow_check_synchronise(mainwin, TRUE);
                prefs_common.work_offline = TRUE;
                imap_disconnect_all();
+               hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        } else {
                /*go online */
                if (!prefs_common.work_offline)
@@ -3310,6 +3329,7 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
                prefs_common.work_offline = FALSE;
                inc_autocheck_timer_set();
                refresh_resolvers();
+               hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
        }
 }
 
@@ -3630,7 +3650,10 @@ static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
 {
        struct DelDupsData data = {0, 0};
 
+       main_window_cursor_wait(mainwin);
        folder_func_to_all_folders(deldup_all, &data);
+       main_window_cursor_normal(mainwin);
+       
        alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
                                   "Deleted %d duplicate messages in %d folders.\n",
                                   data.dups),
@@ -3771,7 +3794,13 @@ static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 static void select_thread_cb(MainWindow *mainwin, guint action,
                             GtkWidget *widget)
 {
-       summary_select_thread(mainwin->summaryview);
+       summary_select_thread(mainwin->summaryview, FALSE);
+}
+
+static void delete_thread_cb(MainWindow *mainwin, guint action,
+                            GtkWidget *widget)
+{
+       summary_select_thread(mainwin->summaryview, TRUE);
 }
 
 static void create_filter_cb(MainWindow *mainwin, guint action,
@@ -4062,7 +4091,7 @@ void mainwindow_jump_to(const gchar *target)
                return;
                
        if (!mainwin) {
-               printf(_("not initialized\n"));
+               printf("not initialized\n");
                return;
        }
 
@@ -4074,7 +4103,7 @@ void mainwindow_jump_to(const gchar *target)
                *p = '\0';
 
        if ((item = folder_find_item_from_identifier(tmp))) {
-               printf(_("selecting folder '%s'\n"), tmp);
+               printf("selecting folder '%s'\n", tmp);
                folderview_select(mainwin->folderview, item);
                main_window_popup(mainwin);
                g_free(tmp);
@@ -4085,20 +4114,40 @@ void mainwindow_jump_to(const gchar *target)
        if (msg) {
                *msg++ = '\0';
                if ((item = folder_find_item_from_identifier(tmp))) {
-                       printf(_("selecting folder '%s'\n"), tmp);
+                       printf("selecting folder '%s'\n", tmp);
                        folderview_select(mainwin->folderview, item);
-               } 
+               } else {
+                       printf("'%s' not found\n", tmp);
+               }
                if (item && msg && atoi(msg)) {
-                       printf(_("selecting message %d\n"), atoi(msg));
+                       printf("selecting message %d\n", atoi(msg));
                        summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
                        summary_display_msg_selected(mainwin->summaryview, FALSE);
                        main_window_popup(mainwin);
                        g_free(tmp);
                        return;
-               } 
+               } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
+                       MsgInfo *msginfo = NULL;
+                       msg++;
+                       msg[strlen(msg)-1] = '\0';
+                       msginfo = folder_item_get_msginfo_by_msgid(item, msg);
+                       if (msginfo) {
+                               printf("selecting message %s\n", msg);
+                               summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
+                               summary_display_msg_selected(mainwin->summaryview, FALSE);
+                               main_window_popup(mainwin);
+                               g_free(tmp);
+                               procmsg_msginfo_free(msginfo);
+                               return;
+                       } else {
+                               printf("'%s' not found\n", msg);
+                       }
+               } else {
+                       printf("'%s' not found\n", msg);
+               }
+       } else {
+               printf("'%s' not found\n", tmp);
        }
        
-       printf("'%s' not found\n", tmp);
-       
        g_free(tmp);
 }