give full control of display or non-display of Execute icon to Custom toolbar settings
[claws.git] / src / mainwindow.c
index f9d09a27d445fadafc7d41568025ace1a900718a..782bb2d0ac814eac144b2d1a58f28758a7a91160 100644 (file)
@@ -400,7 +400,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_File"),                          NULL, NULL, 0, "<Branch>"},
        {N_("/_File/_Add mailbox..."),          NULL, add_mailbox_cb, 0, NULL},
        {N_("/_File/_Add mbox mailbox..."),     NULL, add_mbox_cb, 0, NULL},
-       {N_("/_File/_Check for new mails in all folders"),
+       {N_("/_File/_Check for new messages in all folders"),
                                                NULL, update_folderview_cb, 0, NULL},
        {N_("/_File/_Folder"),                  NULL, NULL, 0, "<Branch>"},
        {N_("/_File/_Folder/Create _new folder..."),
@@ -622,7 +622,6 @@ static GtkItemFactoryEntry mainwin_entries[] =
 
        {N_("/_Tools"),                         NULL, NULL, 0, "<Branch>"},
        {N_("/_Tools/_Selective download..."),  "<alt>S", sel_download_cb, 0, NULL},
-       {N_("/_Tools/_Customize Toolbar"),               "<alt>C", prefs_toolbar_cb, 0, NULL},
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
        {N_("/_Tools/_Address book..."),        "<shift><control>A", addressbook_open_cb, 0, NULL},
        {N_("/_Tools/Add sender to address boo_k"),
@@ -656,6 +655,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
        {N_("/_Configuration/_Common preferences..."),
                                                NULL, prefs_common_open_cb, 0, NULL},
+       {N_("/_Configuration/C_ustom toolbar..."),
+                                               NULL, prefs_toolbar_cb, 0, NULL},
        {N_("/_Configuration/_Filter setting..."),
                                                NULL, prefs_filter_open_cb, 0, NULL},
        {N_("/_Configuration/_Scoring..."),
@@ -724,7 +725,7 @@ MainWindow *main_window_create(SeparateType type)
 
        static GdkGeometry geometry;
 
-       debug_print(_("Creating main window...\n"));
+       debug_print("Creating main window...\n");
        mainwin = g_new0(MainWindow, 1);
 
        /* main window */
@@ -768,10 +769,10 @@ MainWindow *main_window_create(SeparateType type)
        gtk_widget_show(handlebox);
        gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
 
-       /* create the popup menus for the reply buttons specials */
-       toolbar_popups_create(mainwin, window);
-                          
-       //main_window_toolbar_create(mainwin, handlebox);
+       /* link window to mainwin->window to avoid gdk warnings */
+       mainwin->window       = window;
+       
+       /* create toolbar */
        toolbar_create(mainwin, handlebox);
 
        /* vbox that contains body */
@@ -823,7 +824,7 @@ MainWindow *main_window_create(SeparateType type)
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
        mainwin->summaryview = summaryview = summary_create();
-       mainwin->messageview = messageview = messageview_create();
+       mainwin->messageview = messageview = messageview_create(mainwin);
        mainwin->logwin      = log_window_create();
 
        folderview->mainwin      = mainwin;
@@ -836,7 +837,6 @@ MainWindow *main_window_create(SeparateType type)
 
        messageview->mainwin     = mainwin;
 
-       mainwin->window       = window;
        mainwin->vbox         = vbox;
        mainwin->menubar      = menubar;
        mainwin->menu_factory = ifactory;
@@ -889,7 +889,7 @@ MainWindow *main_window_create(SeparateType type)
                        g_warning(_("MainWindow: color allocation %d failed\n"), i);
        }
 
-       debug_print(_("done.\n"));
+       debug_print("done.\n");
 
        messageview->visible = TRUE;
 
@@ -924,6 +924,12 @@ MainWindow *main_window_create(SeparateType type)
                (ifactory, "/View/Show or hide/Status bar");
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
                                       prefs_common.show_statusbar);
+       
+       gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
+       
+       if (prefs_common.show_searchbar)
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
+
 
        /* set account selection menu */
        ac_menu = gtk_item_factory_get_widget
@@ -1043,21 +1049,12 @@ void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
 
                /* pixmap themes */
                if (pixmap_theme_changed) {
-                       gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), 
-                                            GTK_WIDGET(mainwin->toolbar->toolbar));
-
-                       mainwin->toolbar->toolbar = NULL;
-                       toolbar_create(mainwin, mainwin->handlebox);
+                       toolbar_update();
                        set_toolbar_style(mainwin);
                        folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
                        summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
                }
                
-               if (prefs_common.immediate_exec)
-                       gtk_widget_hide(mainwin->toolbar->exec_btn);
-               else
-                       gtk_widget_show(mainwin->toolbar->exec_btn);
-
                summary_redisplay_msg(mainwin->summaryview);
                headerview_set_visibility(mainwin->messageview->headerview,
                                          prefs_common.display_header_pane);
@@ -1138,7 +1135,7 @@ void main_window_separation_change(MainWindow *mainwin, SeparateType type)
        GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
        GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
 
-       debug_print(_("Changing window separation type from %d to %d\n"),
+       debug_print("Changing window separation type from %d to %d\n",
                    mainwin->type, type);
 
        if (mainwin->type == type) return;
@@ -1276,7 +1273,7 @@ void main_window_get_position(MainWindow *mainwin)
        prefs_common.mainwin_x = x;
        prefs_common.mainwin_y = y;
 
-       debug_print(_("window position: x = %d, y = %d\n"), x, y);
+       debug_print("window position: x = %d, y = %d\n", x, y);
 }
 
 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
@@ -1415,17 +1412,21 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                state |= M_MSG_EXIST;
        if (item && item->path && item->parent && !item->no_select) {
                state |= M_EXEC;
-               if (item->threaded)
-                       state |= M_THREADED;
-               else
-                       state |= M_UNTHREADED;  
                /*              if (item->folder->type != F_NEWS) */
                state |= M_ALLOW_DELETE;
 
+               if (prefs_common.immediate_exec == 0
+                   && mainwin->lock_count == 0)
+                       state |= M_DELAY_EXEC;
+
                if ((selection == SUMMARY_NONE && item->hide_read_msgs)
                    || selection != SUMMARY_NONE)
                        state |= M_HIDE_READ_MSG;       
        }               
+       if (mainwin->summaryview->threaded)
+               state |= M_THREADED;
+       else
+               state |= M_UNTHREADED;  
        if (selection == SUMMARY_SELECTED_SINGLE ||
            selection == SUMMARY_SELECTED_MULTIPLE)
                state |= M_TARGET_EXIST;
@@ -1463,7 +1464,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        SensitiveCond state;
        gboolean sensitive;
        GtkWidget *menuitem;
-       FolderItem *item;
+       SummaryView *summaryview;
        gchar *menu_path;
        gint i;
 
@@ -1471,18 +1472,19 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                gchar *const entry;
                SensitiveCond cond;
        } entry[] = {
-               {"/File/Add mailbox..."        , M_UNLOCKED},
-                {"/File/Add mbox mailbox..."   , M_UNLOCKED},
-               {"/File/Check for new mails in all folders", M_UNLOCKED},
-               {"/File/Folder"                , M_UNLOCKED},
-               {"/File/Import mbox file..."   , M_UNLOCKED},
-               {"/File/Export to mbox file...", M_UNLOCKED},
-               {"/File/Empty trash"           , M_UNLOCKED},
-               {"/File/Work offline"          , M_UNLOCKED},
+               {"/File/Add mailbox..."                       , M_UNLOCKED},
+                {"/File/Add mbox mailbox..."                         , M_UNLOCKED},
+               {"/File/Check for new messages in all folders", M_UNLOCKED},
+               {"/File/Folder"                               , M_UNLOCKED},
+               {"/File/Import mbox file..."                  , M_UNLOCKED},
+               {"/File/Export to mbox file..."               , M_UNLOCKED},
+               {"/File/Empty trash"                          , M_UNLOCKED},
+               {"/File/Work offline"                         , M_UNLOCKED},
+
                {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
                {"/File/Print..."  , M_TARGET_EXIST|M_UNLOCKED},
-               /* {"/File/Close", M_UNLOCKED}, */
-               {"/File/Exit" , M_UNLOCKED},
+               /* {"/File/Close"  , M_UNLOCKED}, */
+               {"/File/Exit"      , M_UNLOCKED},
 
                {"/Edit/Select thread"             , M_SINGLE_TARGET_EXIST},
                {"/View/Sort"                      , M_EXEC},
@@ -1526,7 +1528,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
                {"/Tools/Filter messages"           , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
                {"/Tools/Create filter rule"        , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
                {"/Tools/Actions"                   , M_TARGET_EXIST|M_UNLOCKED},
-               {"/Tools/Execute"                   , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
+               {"/Tools/Execute"                   , M_DELAY_EXEC},
                {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
 
                {"/Configuration", M_UNLOCKED},
@@ -1552,46 +1554,45 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
                              messageview_is_visible(mainwin->messageview));
 
-       item = mainwin->summaryview->folder_item;
+       summaryview = mainwin->summaryview;
        menu_path = "/View/Sort/Don't sort";
-       if (item) {
-               switch (item->sort_key) {
-               case SORT_BY_NUMBER:
-                       menu_path = "/View/Sort/by number"; break;
-               case SORT_BY_SIZE:
-                       menu_path = "/View/Sort/by size"; break;
-               case SORT_BY_DATE:
-                       menu_path = "/View/Sort/by date"; break;
-               case SORT_BY_FROM:
-                       menu_path = "/View/Sort/by from"; break;
-               case SORT_BY_SUBJECT:
-                       menu_path = "/View/Sort/by subject"; break;
-               case SORT_BY_LABEL:
-                       menu_path = "/View/Sort/by color label"; break;
-               case SORT_BY_MARK:
-                       menu_path = "/View/Sort/by mark"; break;
-               case SORT_BY_UNREAD:
-                       menu_path = "/View/Sort/by unread"; break;
-               case SORT_BY_MIME:
-                       menu_path = "/View/Sort/by attachment"; break;
-               case SORT_BY_SCORE:
-                       menu_path = "/View/Sort/by score"; break;
-               case SORT_BY_LOCKED:
-                       menu_path = "/View/Sort/by locked"; break;
-               case SORT_BY_NONE:
-               default:
-                       menu_path = "/View/Sort/Don't sort"; break;
-               }
+
+       switch (summaryview->sort_key) {
+       case SORT_BY_NUMBER:
+               menu_path = "/View/Sort/by number"; break;
+       case SORT_BY_SIZE:
+               menu_path = "/View/Sort/by size"; break;
+       case SORT_BY_DATE:
+               menu_path = "/View/Sort/by date"; break;
+       case SORT_BY_FROM:
+               menu_path = "/View/Sort/by from"; break;
+       case SORT_BY_SUBJECT:
+               menu_path = "/View/Sort/by subject"; break;
+       case SORT_BY_LABEL:
+               menu_path = "/View/Sort/by color label"; break;
+       case SORT_BY_MARK:
+               menu_path = "/View/Sort/by mark"; break;
+       case SORT_BY_UNREAD:
+               menu_path = "/View/Sort/by unread"; break;
+       case SORT_BY_MIME:
+               menu_path = "/View/Sort/by attachment"; break;
+       case SORT_BY_SCORE:
+               menu_path = "/View/Sort/by score"; break;
+       case SORT_BY_LOCKED:
+               menu_path = "/View/Sort/by locked"; break;
+       case SORT_BY_NONE:
+       default:
+               menu_path = "/View/Sort/Don't sort"; break;
        }
        SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
 
-       if (!item || item->sort_type == SORT_ASCENDING) {
+       if (summaryview->sort_type == SORT_ASCENDING) {
                SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
        } else {
                SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
        }
 
-       if (item && item->sort_key != SORT_BY_NONE) {
+       if (summaryview->sort_key != SORT_BY_NONE) {
                menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
                menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
        } else {
@@ -1671,7 +1672,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
        GtkItemFactory *ifactory = mainwin->menu_factory;
        GtkWidget *menuitem;
 
-       debug_print(_("Setting widgets..."));
+       debug_print("Setting widgets...");
 
        /* create separated window(s) if needed */
        if (type & SEPARATE_FOLDER) {
@@ -1781,6 +1782,11 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                mainwin->win.sep_folder.vpaned    = vpaned;
 
                gtk_widget_show_all(folderwin);
+               
+               /* CLAWS: previous "gtk_widget_show_all" makes noticeview
+                * lose track of its visibility state */
+               if (!noticeview_is_visible(mainwin->messageview->noticeview)) 
+                       gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
                break;
        case SEPARATE_MESSAGE:
                hpaned = gtk_hpaned_new();
@@ -1860,7 +1866,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
                                       ((type & SEPARATE_MESSAGE) != 0));
 
-       debug_print(_("done.\n"));
+       debug_print("done.\n");
 }
 
 #if 0
@@ -2385,7 +2391,7 @@ static void set_charset_cb(MainWindow *mainwin, guint action,
 
        summary_redisplay_msg(mainwin->summaryview);
 
-       debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
+       debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
 }
 
 static void hide_read_messages (MainWindow *mainwin, guint action,
@@ -2404,10 +2410,10 @@ static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 
        if (GTK_CHECK_MENU_ITEM(widget)->active) {
                summary_thread_build(mainwin->summaryview);
-               mainwin->summaryview->folder_item->threaded = TRUE;
+/*             mainwin->summaryview->folder_item->threaded = TRUE; */
        } else {
                summary_unthread(mainwin->summaryview);
-               mainwin->summaryview->folder_item->threaded = FALSE;
+/*             mainwin->summaryview->folder_item->threaded = FALSE; */
        }
 }