2006-06-22 [colin] 2.3.1cvs13
[claws.git] / src / mainwindow.c
index 2984f4448a4d0e9f02bd296dfb3765deab5f1d2a..be7cee6ffffd73a1258c40b120913816bdce5688 100644 (file)
@@ -350,6 +350,9 @@ static void next_labeled_cb  (MainWindow    *mainwin,
 static void goto_folder_cb      (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
+static void goto_unread_folder_cb(MainWindow   *mainwin,
+                                 guint          action,
+                                 GtkWidget     *widget);
 
 static void copy_cb             (MainWindow    *mainwin,
                                  guint          action,
@@ -572,7 +575,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/_Go to/Next la_beled message"),
                                                NULL, next_labeled_cb, 0, NULL},
        {N_("/_View/_Go to/---"),               NULL, NULL, 0, "<Separator>"},
-       {N_("/_View/_Go to/Other _folder..."),  "G", goto_folder_cb, 0, NULL},
+       {N_("/_View/_Go to/Next unread _folder"),       "<shift>G", goto_unread_folder_cb, 0, NULL},
+       {N_("/_View/_Go to/_Other folder..."),  "G", goto_folder_cb, 0, NULL},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
 
 #define ENC_SEPARATOR \
@@ -1948,8 +1952,7 @@ void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
        g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
-                               (cur == 0 && total == 0) ? 0 :
-                               (gfloat)cur / (gfloat)total);
+                               (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
 }
 
 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
@@ -2124,12 +2127,12 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                                                 , M_INC_ACTIVE},
 
                {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
-               {"/Message/Reply"                 , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
-               {"/Message/Reply to"              , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
-               {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
+               {"/Message/Reply"                 , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+               {"/Message/Reply to"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+               {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
                {"/Message/Forward"               , M_HAVE_ACCOUNT|M_TARGET_EXIST},
                {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
-               {"/Message/Redirect"              , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Message/Redirect"              , M_HAVE_ACCOUNT|M_TARGET_EXIST},
                {"/Message/Move..."               , M_TARGET_EXIST|M_ALLOW_DELETE},
                {"/Message/Copy..."               , M_TARGET_EXIST|M_EXEC},
                {"/Message/Move to trash"         , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
@@ -2367,7 +2370,8 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
        buf = *buffer;
        
        if (buf == 0x00) {
-               url_decoded = 0x00;
+               *url_decoded = '\0';
+               *buffer = NULL;
                return;
        }
        /* Ignore spaces, comments  and tabs () */
@@ -2381,24 +2385,32 @@ static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
                for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
                buf++;
        }
-       else 
-               /* else, we finish parsing and ignore everything */
-               for (;buf != 0x00; buf++);
+       else  {
+               *buffer = NULL;
+               *url_decoded = '\0';
+               return;
+       }
        
        tmp[i]       = 0x00;
-       *url_decoded = 0x00;
+       *url_decoded = '\0';
+       *buffer = NULL;
        
        if (i == maxlen) {
-               for (;*buf != 0x00; buf++);
                return;
        }
        decode_uri (url_decoded, (const gchar *)tmp);
 
        /* Prepare the work for the next url in the list */
        /* after the closing bracket >, ignore space, comments and tabs */
-       for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
+       for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
                if (*buf == '(')
                        for (;*buf != ')' && *buf != 0x00; buf++);
+                       
+       if (!buf || !*buf) {
+               *buffer = NULL;
+               return;
+       }
+
        /* now first non space, non comment must be a comma */
        if (*buf != ',')
                for (;*buf != 0x00; buf++);
@@ -2904,19 +2916,28 @@ static void foldersort_cb(MainWindow *mainwin, guint action,
 static void import_mbox_cb(MainWindow *mainwin, guint action,
                           GtkWidget *widget)
 {
-       import_mbox(mainwin->summaryview->folder_item);
+       /* only notify if import has failed */
+       if (import_mbox(mainwin->summaryview->folder_item) == -1) {
+               alertpanel_error(_("Mbox import has failed."));
+       }
 }
 
 static void export_mbox_cb(MainWindow *mainwin, guint action,
                           GtkWidget *widget)
 {
-       export_mbox(mainwin->summaryview->folder_item);
+       /* only notify if export has failed */
+       if (export_mbox(mainwin->summaryview->folder_item) == -1) {
+               alertpanel_error(_("Export to mbox has failed."));
+       }
 }
 
 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
                                GtkWidget *widget)
 {
-       summaryview_export_mbox_list(mainwin->summaryview);
+       /* only notify if export has failed */
+       if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
+               alertpanel_error(_("Export to mbox has failed."));
+       }
 }
 
 static void empty_trash_cb(MainWindow *mainwin, guint action,
@@ -3492,6 +3513,12 @@ static void goto_folder_cb(MainWindow *mainwin, guint action,
                folderview_select(mainwin->folderview, to_folder);
 }
 
+static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
+                          GtkWidget *widget)
+{
+       folderview_select_next_unread(mainwin->folderview);
+}
+
 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        messageview_copy_clipboard(mainwin->messageview);
@@ -3501,11 +3528,11 @@ static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        MessageView *msgview = mainwin->messageview;
 
-       if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
-               summary_select_all(mainwin->summaryview);
-       else if (messageview_is_visible(msgview) &&
+       if (messageview_is_visible(msgview) &&
                 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
                messageview_select_all(mainwin->messageview);
+       else
+               summary_select_all(mainwin->summaryview);
 }
 
 static void select_thread_cb(MainWindow *mainwin, guint action,
@@ -3669,6 +3696,8 @@ static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focu
        SummaryView *summary;
 
        g_return_val_if_fail(data, FALSE);
+       if (!g_list_find(mainwin_list, data))
+               return TRUE;
        summary = ((MainWindow *)data)->summaryview;
        g_return_val_if_fail(summary, FALSE);