Fix some of the gdk_warnings
[claws.git] / src / mainwindow.c
index d74632e4b5f5a1fdb1b6379ed6d91b5f77e0d38c..d099b53fbc9819daefc1c7e4e67216b28777ffae 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..."),
@@ -725,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 */
@@ -769,8 +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);
+       /* link window to mainwin->window to avoid gdk warnings */
+       mainwin->window       = window;
+       
+       /* create toolbar */
        toolbar_create(mainwin, handlebox);
 
        /* vbox that contains body */
@@ -835,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;
@@ -888,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;
 
@@ -923,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
@@ -1133,7 +1140,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;
@@ -1271,7 +1278,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)
@@ -1410,10 +1417,6 @@ 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;
 
@@ -1421,6 +1424,10 @@ SensitiveCond main_window_get_current_state(MainWindow *mainwin)
                    || 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;
@@ -1458,7 +1465,7 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        SensitiveCond state;
        gboolean sensitive;
        GtkWidget *menuitem;
-       FolderItem *item;
+       SummaryView *summaryview;
        gchar *menu_path;
        gint i;
 
@@ -1466,18 +1473,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},
@@ -1547,46 +1555,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 {
@@ -1666,7 +1673,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) {
@@ -1776,6 +1783,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();
@@ -1855,7 +1867,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
@@ -2380,7 +2392,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,
@@ -2399,10 +2411,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; */
        }
 }