reverse previous changes
[claws.git] / src / mainwindow.c
index b138095226cbeb2eb9de6edc3b865ce9244a4a1f..0d9c9663df5715628f75ee3481e6faff29425c0c 100644 (file)
@@ -203,7 +203,9 @@ static void toggle_toolbar_cb        (MainWindow    *mainwin,
 static void toggle_statusbar_cb         (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action);
+static void separate_widget_cb (GtkCheckMenuItem *checkitem,
+                                guint action,
+                                GtkWidget *widget);
 
 static void addressbook_open_cb        (MainWindow     *mainwin,
                                 guint           action,
@@ -536,6 +538,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Summary/_Sort/Sort by _from"),   NULL, sort_summary_cb, SORT_BY_FROM, NULL},
        {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
        {N_("/_Summary/_Sort/Sort by sco_re"),  NULL, sort_summary_cb, SORT_BY_SCORE, NULL},
+       {N_("/_Summary/_Sort/Sort by _label"),  NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
        {N_("/_Summary/_Sort/---"),             NULL, NULL, 0, "<Separator>"},
        {N_("/_Summary/_Sort/_Attract by subject"),
                                                NULL, attract_by_subject_cb, 0, NULL},
@@ -568,7 +571,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
 
        {N_("/_Help"),                          NULL, NULL, 0, "<LastBranch>"},
        {N_("/_Help/_Manual"),                  NULL, NULL, 0, "<Branch>"},
-       {N_("/_Help/_Manual/_English"),         NULL, NULL, MANUAL_LANG_EN, NULL},
+       {N_("/_Help/_Manual/_English"),         NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
        {N_("/_Help/_Manual/_Japanese"),        NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
        {N_("/_Help/---"),                      NULL, NULL, 0, "<Separator>"},
        {N_("/_Help/_About"),                   NULL, about_show, 0, NULL}
@@ -591,8 +594,8 @@ MainWindow *main_window_create(SeparateType type)
        SummaryView *summaryview;
        MessageView *messageview;
        GdkColormap *colormap;
-       GdkColor color[5];
-       gboolean success[5];
+       GdkColor color[4];
+       gboolean success[4];
        guint n_menu_entries;
        GtkItemFactory *ifactory;
        GtkWidget *ac_menu;
@@ -699,14 +702,11 @@ MainWindow *main_window_create(SeparateType type)
        summaryview->color_dim.red = summaryview->color_dim.green =
                summaryview->color_dim.blue = COLOR_DIM;
 
-       summaryview->color_normal.red = summaryview->color_normal.green =
-               summaryview->color_normal.blue = 0;
-
        folderview->color_new.red = (guint16)55000;
        folderview->color_new.green = folderview->color_new.blue = 15000;
 
-       folderview->color_normal.red = folderview->color_normal.green =
-               folderview->color_normal.blue = 0;
+       gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
+                                      &folderview->color_op);
 
        summaryview->color_important.red = 0;
        summaryview->color_marked.green = 0;
@@ -714,13 +714,12 @@ MainWindow *main_window_create(SeparateType type)
 
        color[0] = summaryview->color_marked;
        color[1] = summaryview->color_dim;
-       color[2] = summaryview->color_normal;
-       color[3] = folderview->color_new;
-       color[4] = folderview->color_normal;
+       color[2] = folderview->color_new;
+       color[3] = folderview->color_op;
 
        colormap = gdk_window_get_colormap(window->window);
-       gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
-       for (i = 0; i < 5; i++) {
+       gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
+       for (i = 0; i < 4; i++) {
                if (success[i] == FALSE)
                        g_warning(_("MainWindow: color allocation %d failed\n"), i);
        }
@@ -775,15 +774,14 @@ MainWindow *main_window_create(SeparateType type)
        gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
                                           GUINT_TO_POINTER(SEPARATE_MESSAGE));
 
-       /*
+
        menu_set_sensitive(ifactory, "/Summary/Thread view",
                           prefs_common.enable_thread ? FALSE : TRUE);
        menu_set_sensitive(ifactory, "/Summary/Unthread view",
                           prefs_common.enable_thread ? TRUE : FALSE);
-       */
-       main_window_set_thread_option(mainwin);
+       
+       /*main_window_set_thread_option(mainwin);*/
 
-       menu_set_sensitive(ifactory, "/Help/Manual/English", FALSE);
 
        /* set account selection menu */
        ac_menu = gtk_item_factory_get_widget
@@ -807,17 +805,6 @@ MainWindow *main_window_create(SeparateType type)
        header_window_init(mainwin->headerwin);
        log_window_init(mainwin->logwin);
 
-       {
-               GtkStyle *newstyle;
-
-               gtk_widget_ensure_style(folderview->ctree);
-               newstyle = gtk_widget_get_style(folderview->ctree);
-               newstyle = gtk_style_copy(newstyle);
-               gtk_widget_set_style(summaryview->ctree, newstyle);
-               gtk_widget_ensure_style(summaryview->ctree);
-               gtk_widget_realize(summaryview->ctree);
-       }
-
        mainwin->cursor_count = 0;
 
        if (!watch_cursor)
@@ -1068,12 +1055,10 @@ void main_window_add_mailbox(MainWindow *mainwin)
                g_free(path);
                return;
        }
-
        if (!strcmp(path, "Mail"))
                folder = folder_new(F_MH, _("Mailbox"), path);
        else
                folder = folder_new(F_MH, g_basename(path), path);
-
        g_free(path);
 
        if (folder->create_tree(folder) < 0) {
@@ -1177,8 +1162,8 @@ void main_window_set_menu_sensitive(MainWindow *mainwin, gint selection)
        menu_set_sensitive(ifactory, "/Message/Reply", sens);
        menu_set_sensitive(ifactory, "/Message/Reply to sender", sens);
        menu_set_sensitive(ifactory, "/Message/Reply to all", sens);
-       menu_set_sensitive(ifactory, "/Message/Forward", sens);
-       menu_set_sensitive(ifactory, "/Message/Forward as attachment", sens);
+       menu_set_sensitive(ifactory, "/Message/Forward", TRUE);
+       menu_set_sensitive(ifactory, "/Message/Forward as attachment", TRUE);
        menu_set_sensitive(ifactory, "/Message/Open in new window", sens);
        menu_set_sensitive(ifactory, "/Message/Show all header", sens);
        menu_set_sensitive(ifactory, "/Message/View source", sens);
@@ -1233,6 +1218,7 @@ void main_window_popup(MainWindow *mainwin)
        y %= sy; if (y < 0) y += sy;
        gdk_window_move(mainwin->window->window, x, y);
        gdk_window_raise(mainwin->window->window);
+       gdk_window_show(mainwin->window->window);
 
        debug_print("window position: x = %d, y = %d\n", x, y);
 
@@ -1268,6 +1254,7 @@ void main_window_popup(MainWindow *mainwin)
                gdk_window_raise(widget->window);
                break;
        default:
+               break;
        }
 }
 
@@ -1574,7 +1561,7 @@ static void main_window_toolbar_create(MainWindow *mainwin,
        
        CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
        compose_mail_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                             _("Compose email"),
+                                             _("Email"),
                                              _("Compose an email message"),
                                              "New",
                                              icon_wid,
@@ -1585,7 +1572,7 @@ static void main_window_toolbar_create(MainWindow *mainwin,
 
        CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
        compose_news_btn_plain = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
-                                             _("Compose news"),
+                                             _("News"),
                                              _("Compose a news message"),
                                              "New",
                                              icon_wid,
@@ -1701,11 +1688,11 @@ static void main_window_toolbar_create(MainWindow *mainwin,
                mainwin);
 
        gtk_signal_connect(GTK_OBJECT(compose_mail_btn), "clicked",
-               GTK_SIGNAL_FUNC(toolbar_compose_cb),
+               GTK_SIGNAL_FUNC(toolbar_compose_mail_cb),
                mainwin);
 
        gtk_signal_connect(GTK_OBJECT(compose_news_btn), "clicked",
-               GTK_SIGNAL_FUNC(toolbar_compose_cb),
+               GTK_SIGNAL_FUNC(toolbar_compose_news_cb),
                mainwin);
 
        mainwin->toolbar         = toolbar;
@@ -2099,7 +2086,8 @@ static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
        }
 }
 
-static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action)
+static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
+
 {
        MainWindow *mainwin;
        SeparateType type;
@@ -2164,7 +2152,7 @@ static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                    && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
                        compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
                else
-                       compose_new(mainwin->summaryview->folder_item->folder->account);
+                       compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
        }
        else
                compose_new(NULL);
@@ -2180,16 +2168,21 @@ static void compose_mail_cb(MainWindow *mainwin, guint action,
        if (mainwin->summaryview->folder_item) {
                ac = mainwin->summaryview->folder_item->folder->account;
                if (ac && ac->protocol != A_NNTP) {
-                       compose_new(ac);
+                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
                        return;
                }
        }
 
+       if(cur_account && (cur_account->protocol != A_NNTP)) {
+               compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
+               return;
+       }
+
        list = account_get_list();
        for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
                ac = (PrefsAccount *) cur->data;
                if (ac->protocol != A_NNTP) {
-                       compose_new(ac);
+                       compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
                        return;
                }
        }
@@ -2223,6 +2216,7 @@ static void compose_news_cb(MainWindow *mainwin, guint action,
 
 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
+       GList  *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data
@@ -2250,10 +2244,21 @@ static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
                              TRUE, FALSE);
                break;
        case COMPOSE_FORWARD:
-               compose_forward(NULL, msginfo, FALSE);
-               break;
+               if (!sel->next) {
+                       compose_forward(NULL, msginfo, FALSE);
+                       break;
+               }
+               /* if (sel->next) FALL_THROUGH */
        case COMPOSE_FORWARD_AS_ATTACH:
-               compose_forward(NULL, msginfo, TRUE);
+               {
+                       GSList *msginfo_list = NULL;
+                       for ( ; sel != NULL; sel = sel->next)
+                               msginfo_list = g_slist_append(msginfo_list, 
+                                       gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
+                                               GTK_CTREE_NODE(sel->data)));
+                       compose_forward_multiple(NULL, msginfo_list);
+                       g_slist_free(msginfo_list);
+               }                       
                break;
        default:
                g_warning("reply_cb(): invalid action type: %d\n", action);
@@ -2329,7 +2334,7 @@ static void set_charset_cb(MainWindow *mainwin, guint action,
        debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
 }
 
-void main_window_set_thread_option(MainWindow *mainwin)
+/*void main_window_set_thread_option(MainWindow *mainwin)
 {
        GtkItemFactory *ifactory;
        gboolean no_item = FALSE;
@@ -2351,7 +2356,7 @@ void main_window_set_thread_option(MainWindow *mainwin)
                                           "/Summary/Thread view",   FALSE);
                        menu_set_sensitive(ifactory,
                                           "/Summary/Unthread view", TRUE);
-                       summary_thread_build(mainwin->summaryview);
+                       summary_thread_build(mainwin->summaryview, TRUE);
                }
                else {
                        menu_set_sensitive(ifactory,
@@ -2362,29 +2367,31 @@ void main_window_set_thread_option(MainWindow *mainwin)
                }
                prefs_folder_item_save_config(mainwin->summaryview->folder_item);
        }
-}
+}*/
 
 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
-       mainwin->summaryview->folder_item->prefs->enable_thread =
+       /*mainwin->summaryview->folder_item->prefs->enable_thread =
                !mainwin->summaryview->folder_item->prefs->enable_thread;
        main_window_set_thread_option(mainwin);
+        */
+
+        GtkItemFactory *ifactory;
+
+       ifactory = gtk_item_factory_from_widget(widget);
 
-       /*
        if (0 == action) {
-               summary_thread_build(mainwin->summaryview);
-               mainwin->summaryview->folder_item->prefs->enable_thread =
-                       TRUE;
+               summary_thread_build(mainwin->summaryview, FALSE);
+               prefs_common.enable_thread = TRUE;
                menu_set_sensitive(ifactory, "/Summary/Thread view",   FALSE);
                menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
        } else {
                summary_unthread(mainwin->summaryview);
-               mainwin->summaryview->folder_item->prefs->enable_thread =
-                       FALSE;
+               prefs_common.enable_thread = FALSE;
                menu_set_sensitive(ifactory, "/Summary/Thread view",   TRUE);
                menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
        }
-       */
+       
 }
 
 static void set_display_item_cb(MainWindow *mainwin, guint action,
@@ -2431,6 +2438,8 @@ static void update_summary_cb(MainWindow *mainwin, guint action,
        if (!mainwin->summaryview->folder_item) return;
        if (!folderview->opened) return;
 
+       folder_update_op_count();
+
        fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
                                            folderview->opened);
        if (!fitem) return;