perform a sync to bring in Hiro's separate view implementation
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Tue, 11 Jun 2002 21:46:03 +0000 (21:46 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Tue, 11 Jun 2002 21:46:03 +0000 (21:46 +0000)
ChangeLog.claws
configure.in
src/mainwindow.c
src/messageview.c
src/messageview.h
src/summary_search.c
src/summaryview.c
src/summaryview.h

index 261adbe29806778e4e719b2127f8c619759c74e1..916cb12ad8bb940c636f60ae20bf1828ef6d9dbc 100644 (file)
@@ -1,3 +1,13 @@
+2002-06-11 [alfons]    0.7.6claws40
+
+       * src/messageview.[ch]
+       * src/summaryview.[ch]
+       * src/summary_search.c
+       * src/mainwindow.c
+               perform a sync to bring in Hiro's separate view implementation 
+
+               (NOTE: may still be buggy; 0.7.6claws39 marked as LAST_STABLE)
+
 2002-06-11 [paul]      0.7.6claws39
        
        * src/prefs_account.c
index dc61ed5b39f9835016a91cfe1a9fef11c8bd3fe2..2390cc5583dfe6eda2fa915b99f431bc1de83bad 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws39
+EXTRA_VERSION=claws40
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 36a7e4ffb50fa663fdf12a8475f880c5f3b5580e..1a6d46ef57a25c83e200b6e66db581ec0c9c964f 100644 (file)
@@ -250,12 +250,9 @@ static void toggle_expand_summaryview_cb    (MainWindow    *mainwin,
 static void toggle_expand_messageview_cb        (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-static void toggle_work_offline_cb      (MainWindow    *mainwin,
+static void separate_widget_cb  (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
-static void separate_widget_cb (GtkCheckMenuItem *checkitem,
-                                guint action,
-                                GtkWidget *widget);
 
 static void addressbook_open_cb        (MainWindow     *mainwin,
                                 guint           action,
@@ -446,6 +443,7 @@ static void prefs_template_open_cb  (MainWindow     *mainwin,
 static void prefs_actions_open_cb      (MainWindow     *mainwin,
                                         guint           action,
                                         GtkWidget      *widget);
+
 static void new_account_cb      (MainWindow    *mainwin,
                                  guint          action,
                                  GtkWidget     *widget);
@@ -481,6 +479,8 @@ static void key_pressed (GtkWidget *widget,
 
 static void set_toolbar_style(MainWindow *mainwin);
 
+static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
+
 static void addr_harvest_cb     ( MainWindow  *mainwin,
                                   guint       action,
                                   GtkWidget   *widget );
@@ -489,7 +489,7 @@ static void addr_harvest_msg_cb      ( MainWindow  *mainwin,
                                   guint       action,
                                   GtkWidget   *widget );
 
-#define  SEPARATE_ACTION  667
+#define  SEPARATE_ACTION 500 
 
 static GtkItemFactoryEntry mainwin_entries[] =
 {
@@ -510,6 +510,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_File/_Save as..."),              "<control>S", save_as_cb, 0, NULL},
        {N_("/_File/_Print..."),                NULL, print_cb, 0, NULL},
        {N_("/_File/---"),                      NULL, NULL, 0, "<Separator>"},
+       /* {N_("/_File/_Close"),                "<alt>W", app_exit_cb, 0, NULL}, */
        {N_("/_File/E_xit"),                    "<control>Q", app_exit_cb, 0, NULL},
 
        {N_("/_Edit"),                          NULL, NULL, 0, "<Branch>"},
@@ -522,6 +523,10 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_Edit/_Search folder..."),        "<shift><control>F", search_cb, 1, NULL},
        {N_("/_View"),                          NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Show or hi_de"),            NULL, NULL, 0, "<Branch>"},
+       {N_("/_View/Show or hi_de/_Folder tree"),
+                                               NULL, toggle_folder_cb, 0, "<ToggleItem>"},
+       {N_("/_View/Show or hi_de/_Message view"),
+                                               "V", toggle_message_cb, 0, "<ToggleItem>"},
        {N_("/_View/Show or hi_de/_Toolbar"),
                                                NULL, NULL, 0, "<Branch>"},
        {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
@@ -535,8 +540,8 @@ static GtkItemFactoryEntry mainwin_entries[] =
        {N_("/_View/Show or hi_de/Status _bar"),
                                                NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
-       {N_("/_View/Separate _Folder Tree"),    NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER,  "<ToggleItem>"},
-       {N_("/_View/Separate _Message View"),   NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
+       {N_("/_View/Separate f_older tree"),    NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
+       {N_("/_View/Separate m_essage view"),   NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
        {N_("/_View/E_xpand Summary View"),     "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
        {N_("/_View/Ex_pand Message View"),     "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
        {N_("/_View/---"),                      NULL, NULL, 0, "<Separator>"},
@@ -1029,6 +1034,8 @@ MainWindow *main_window_create(SeparateType type)
 
        debug_print(_("done.\n"));
 
+       messageview->visible = TRUE;
+
        main_window_set_widgets(mainwin, type);
 
        /* set menu items */
@@ -1061,33 +1068,6 @@ 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);
-#if 0 /* FIXED SEPARATE WINDOWS */
-       /* Message view and Folder tree are always shown at startup
-        * make that in the menu visible */
-       menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-       menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
-#endif 
-       /* set the check of the SEPARATE_xxx menu items. we also need the main window
-        * as a property and pass the action type to the callback */
-       menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
-       g_assert(menuitem);
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
-       gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
-       gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
-                                          GUINT_TO_POINTER(SEPARATE_FOLDER));
-
-       menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
-       g_assert(menuitem);
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
-       gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
-       gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb), 
-                                          GUINT_TO_POINTER(SEPARATE_MESSAGE));
-       
-       menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
-       gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
-                                               mainwin);
 
        /* set account selection menu */
        ac_menu = gtk_item_factory_get_widget
@@ -1341,6 +1321,62 @@ void main_window_separation_change(MainWindow *mainwin, SeparateType type)
        gtk_widget_unref(message_wid);
 }
 
+void main_window_toggle_message_view(MainWindow *mainwin)
+{
+       SummaryView *summaryview = mainwin->summaryview;
+       union CompositeWin *cwin = &mainwin->win;
+       GtkWidget *vpaned = NULL;
+       GtkWidget *container = NULL;
+       GtkWidget *msgwin = NULL;
+
+       switch (mainwin->type) {
+       case SEPARATE_NONE:
+               vpaned = cwin->sep_none.vpaned;
+               container = cwin->sep_none.hpaned;
+               break;
+       case SEPARATE_FOLDER:
+               vpaned = cwin->sep_folder.vpaned;
+               container = mainwin->vbox_body;
+               break;
+       case SEPARATE_MESSAGE:
+               msgwin = mainwin->win.sep_message.messagewin;
+               break;
+       case SEPARATE_BOTH:
+               msgwin = mainwin->win.sep_both.messagewin;
+               break;
+       }
+
+       if (msgwin) {
+               if (GTK_WIDGET_VISIBLE(msgwin)) {
+                       gtk_widget_hide(msgwin);
+                       mainwin->messageview->visible = FALSE;
+                       summaryview->displayed = NULL;
+               } else {
+                       gtk_widget_show(msgwin);
+                       mainwin->messageview->visible = TRUE;
+               }
+       } else if (vpaned->parent != NULL) {
+               mainwin->messageview->visible = FALSE;
+               summaryview->displayed = NULL;
+               gtk_widget_ref(vpaned);
+               gtkut_container_remove(GTK_CONTAINER(container), vpaned);
+               gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
+               gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
+                             GTK_ARROW_UP, GTK_SHADOW_OUT);
+       } else {
+               mainwin->messageview->visible = TRUE;
+               gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
+               gtk_container_add(GTK_CONTAINER(container), vpaned);
+               gtk_widget_unref(vpaned);
+               gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
+                             GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+       }
+
+       main_window_set_menu_sensitive(mainwin);
+
+       gtk_widget_grab_focus(summaryview->ctree);
+}
+
 void main_window_get_size(MainWindow *mainwin)
 {
        GtkAllocation *allocation;
@@ -1349,7 +1385,9 @@ void main_window_get_size(MainWindow *mainwin)
 
        prefs_common.summaryview_width  = allocation->width;
 
-       if (mainwin->summaryview->msg_is_toggled_on)
+       if ((mainwin->type == SEPARATE_NONE ||
+            mainwin->type == SEPARATE_FOLDER) &&
+           messageview_is_visible(mainwin->messageview))
                prefs_common.summaryview_height = allocation->height;
 
        prefs_common.mainview_width     = allocation->width;
@@ -1718,6 +1756,9 @@ void main_window_set_menu_sensitive(MainWindow *mainwin)
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
 }
 
+       SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
+                             messageview_is_visible(mainwin->messageview));
+
        item = mainwin->summaryview->folder_item;
        menu_path = "/View/Sort/Don't sort";
        if (item) {
@@ -1885,7 +1926,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                               GTK_WIDGET_PTR(mainwin->folderview));
 
                vpaned = gtk_vpaned_new();
-               if (mainwin->summaryview->msg_is_toggled_on) {
+               if (messageview_is_visible(mainwin->messageview)) {
                        gtk_paned_add2(GTK_PANED(hpaned), vpaned);
                        gtk_paned_add1(GTK_PANED(vpaned),
                                       GTK_WIDGET_PTR(mainwin->summaryview));
@@ -1907,19 +1948,12 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                                     prefs_common.mainwin_height);
                gtk_widget_show_all(vpaned);
 
-               menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
-               menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
-               menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
-               menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
-               menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
-               
                mainwin->win.sep_none.hpaned = hpaned;
                mainwin->win.sep_none.vpaned = vpaned;
                break;
        case SEPARATE_FOLDER:
                vpaned = gtk_vpaned_new();
-               if (mainwin->summaryview->msg_is_toggled_on) {
+               if (messageview_is_visible(mainwin->messageview)) {
                        gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
                                           TRUE, TRUE, 0);
                        gtk_paned_add1(GTK_PANED(vpaned),
@@ -1945,9 +1979,6 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                gtk_container_add(GTK_CONTAINER(folderwin),
                                  GTK_WIDGET_PTR(mainwin->folderview));
 
-               menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
-               menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
-               
                mainwin->win.sep_folder.folderwin = folderwin;
                mainwin->win.sep_folder.vpaned    = vpaned;
 
@@ -1971,12 +2002,7 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                gtk_widget_show_all(hpaned);
                gtk_container_add(GTK_CONTAINER(messagewin),
                                  GTK_WIDGET_PTR(mainwin->messageview));
-       
-               menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
-               menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
-               menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
-               menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
-               
+
                mainwin->win.sep_message.messagewin = messagewin;
                mainwin->win.sep_message.hpaned     = hpaned;
 
@@ -1997,9 +2023,6 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
                gtk_container_add(GTK_CONTAINER(messagewin),
                                  GTK_WIDGET_PTR(mainwin->messageview));
 
-               menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
-               menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
-       
                mainwin->win.sep_both.folderwin = folderwin;
                mainwin->win.sep_both.messagewin = messagewin;
 
@@ -2010,8 +2033,10 @@ static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
 
        mainwin->type = type;
 
+       mainwin->messageview->visible = TRUE;
        ifactory = gtk_item_factory_from_widget(mainwin->menubar);
 
+       /* toggle menu state */
        menuitem = gtk_item_factory_get_item
                (ifactory, "/View/Show or hide/Folder tree");
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
@@ -2533,7 +2558,7 @@ static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
 
        ifactory = gtk_item_factory_from_widget(mainwin->menubar);
        menuitem = gtk_item_factory_get_item
-               (ifactory, "/View/Expand Summary View");
+               (ifactory, "/View/Show or hide/Folder tree");
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
 
        return TRUE;
@@ -2545,10 +2570,10 @@ static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
        MainWindow *mainwin = (MainWindow *)data;
        GtkItemFactory *ifactory;
        GtkWidget *menuitem;
-
+       
        ifactory = gtk_item_factory_from_widget(mainwin->menubar);
        menuitem = gtk_item_factory_get_item
-               (ifactory, "/View/Expand Message View");
+               (ifactory, "/View/Show or hide/Message view");
        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
 
        return TRUE;
@@ -2678,39 +2703,37 @@ static void toggle_message_cb(MainWindow *mainwin, guint action,
 
        active = GTK_CHECK_MENU_ITEM(widget)->active;
 
-       switch (mainwin->type) {
-       case SEPARATE_NONE:
-       case SEPARATE_FOLDER:
-               break;
-       case SEPARATE_MESSAGE:
-               if (active)
-                       gtk_widget_show(mainwin->win.sep_message.messagewin);
-               else
-                       gtk_widget_hide(mainwin->win.sep_message.messagewin);
-               break;
-       case SEPARATE_BOTH:
-               if (active)
-                       gtk_widget_show(mainwin->win.sep_both.messagewin);
-               else
-                       gtk_widget_hide(mainwin->win.sep_both.messagewin);
-               break;
-       }
+       if (active != messageview_is_visible(mainwin->messageview))
+               summary_toggle_view(mainwin->summaryview);
 }
 
 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
                              GtkWidget *widget)
 {
-/*     activate_compose_button(mainwin, (ToolbarStyle)action, 
-                       mainwin->compose_btn_type);
-       set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
-       set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
-       set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
-       set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
-       
+       switch ((ToolbarStyle)action) {
+       case TOOLBAR_NONE:
+               gtk_widget_hide(mainwin->handlebox);
+       case TOOLBAR_ICON:
+               gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
+                                     GTK_TOOLBAR_ICONS);
+               break;
+       case TOOLBAR_TEXT:
+               gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
+                                     GTK_TOOLBAR_TEXT);
+               break;
+       case TOOLBAR_BOTH:
+               gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
+                                     GTK_TOOLBAR_BOTH);
+               break;
+       }
+
+       if (action != TOOLBAR_NONE) {
+               gtk_widget_show(mainwin->handlebox);
+               gtk_widget_queue_resize(mainwin->handlebox);
+       }
+
        mainwin->toolbar_style = (ToolbarStyle)action;
        prefs_common.toolbar_style = (ToolbarStyle)action;
-       
-       set_toolbar_style(mainwin);
 }
 
 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
@@ -2725,14 +2748,32 @@ static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
        }
 }
 
+static void separate_widget_cb(MainWindow *mainwin, guint action,
+                              GtkWidget *widget)
+{
+       SeparateType type;
+
+       if (GTK_CHECK_MENU_ITEM(widget)->active)
+               type = mainwin->type | action;
+       else
+               type = mainwin->type & ~action;
+
+       main_window_separation_change(mainwin, type);
+
+       prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
+       prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
+}
+
 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action,    GtkWidget *widget)
 {
-       summary_toggle_view_real(mainwin->summaryview);
+       summary_toggle_view(mainwin->summaryview);
 }
 
 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
-       messageview_toggle_view_real(mainwin->messageview);
+#if 0
+       messageview_toggle_view(mainwin->messageview);
+#endif
 }
 
 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
@@ -2775,22 +2816,6 @@ static void online_switch_clicked (GtkButton *btn, gpointer data)
        }
 }
 
-static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
-{
-       MainWindow *mainwin;
-       SeparateType type;
-
-       if (GTK_CHECK_MENU_ITEM(widget)->active)
-               type = mainwin->type | action;
-       else
-               type = mainwin->type & ~action;
-
-       main_window_separation_change(mainwin, type);
-
-       prefs_common.sep_folder = (type & SEPARATE_FOLDER)  != 0;
-       prefs_common.sep_msg    = (type & SEPARATE_MESSAGE) != 0;
-}
-
 static void addressbook_open_cb(MainWindow *mainwin, guint action,
                                GtkWidget *widget)
 {
@@ -3189,19 +3214,19 @@ static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 
 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 (mainwin->summaryview->msg_is_toggled_on && (
-                GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text) ||
-                GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->ctree) ||
-                GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->notebook) ||
-                GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->textview->text)))
+       else if (messageview_is_visible(msgview) &&
+                (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
+                 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
                messageview_select_all(mainwin->messageview);
 }
 
 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
-       if (mainwin->summaryview->msg_is_toggled_on)
+       if (messageview_is_visible(mainwin->summaryview->messageview))
                summary_select_thread(mainwin->summaryview);
 }
 
@@ -3337,7 +3362,7 @@ static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkState
        
        if (!mainwin) return;
                
-       gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
+       gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_arrow), GTK_WIDGET_IS_SENSITIVE(widget));
 }
 
 #define BREAK_ON_MODIFIER_KEY() \
index 72ab34eec79d1e8e0f90bfe5083c21dd4c8eeef3..10696cf2cdbc10542c0efd2025a1c750cb4ec87c 100644 (file)
@@ -58,7 +58,6 @@ static void messageview_size_allocate_cb(GtkWidget    *widget,
 static void key_pressed                        (GtkWidget      *widget,
                                         GdkEventKey    *event,
                                         MessageView    *messageview);
-static void messageview_toggle_view(MessageView *messageview);
 
 MessageView *messageview_create(void)
 {
@@ -139,6 +138,7 @@ MessageView *messageview_create_with_new_window(void)
 
        msgview->new_window = TRUE;
        msgview->window = window;
+       msgview->visible = TRUE;
 
        messageview_init(msgview);
 
@@ -569,6 +569,11 @@ GtkWidget *messageview_get_text_widget(MessageView *messageview)
        return messageview->textview->text;
 }
 
+gboolean messageview_is_visible(MessageView *messageview)
+{
+       return messageview->visible;
+}
+
 static void messageview_destroy_cb(GtkWidget *widget, MessageView *messageview)
 {
        messageview_destroy(messageview);
index 01d8b08dcdcf87328cc7f15e4a36e00d99595b36..0be16f5e681ca1937916e9319395d5f547c5fb2b 100644 (file)
@@ -52,6 +52,8 @@ struct _MessageView
        MimeView *mimeview;
 
        MainWindow *mainwin;
+
+       gboolean visible;
 };
 
 MessageView *messageview_create                        (void);
@@ -79,4 +81,6 @@ gboolean messageview_search_string_backward   (MessageView    *messageview,
 
 GtkWidget *messageview_get_text_widget         (MessageView    *messageview);
 
+gboolean messageview_is_visible                        (MessageView    *messageview);
+
 #endif /* __MESSAGEVIEW_H__ */
index 60e517d618dd821f2bd1b9fa9ec2be5d915c0b36..0f9cc6b39f83654c41eb36514ed64d5e3c03a8fd 100644 (file)
@@ -44,6 +44,7 @@
 #include "main.h"
 #include "summary_search.h"
 #include "summaryview.h"
+#include "messageview.h"
 #include "mainwindow.h"
 #include "utils.h"
 #include "gtkutils.h"
@@ -354,7 +355,8 @@ static void summary_search_execute(GtkButton *button, gpointer data)
                        if (search_all)
                                gtk_ctree_select(ctree, node);
                        else {
-                               if (summaryview->msg_is_toggled_on) {
+                               if (messageview_is_visible
+                                       (summaryview->messageview)) {
                                        summary_unlock(summaryview);
                                        summary_select_node
                                                (summaryview, node, TRUE, TRUE);
index 20a0f63efa733e30f455bda2e6b44bed654286a6..bff0597fa96c128adeaf8f3fa49aae2f2a007e42 100644 (file)
@@ -267,11 +267,10 @@ static void summary_colorlabel_menu_create(SummaryView    *summaryview);
 
 static GtkWidget *summary_ctree_create (SummaryView    *summaryview);
 
-static void summary_toggle_view(SummaryView *summarview);
-
 /* callback functions */
-static void summary_toggle_view_cb     (GtkWidget      *widget,
-                                        gpointer       data);                                   
+static void summary_toggle_pressed     (GtkWidget              *eventbox,
+                                        GdkEventButton         *event,
+                                        SummaryView            *summaryview);
 static void summary_button_pressed     (GtkWidget              *ctree,
                                         GdkEventButton         *event,
                                         SummaryView            *summaryview);
@@ -469,8 +468,8 @@ SummaryView *summary_create(void)
        GtkWidget *statlabel_select;
        GtkWidget *statlabel_msgs;
        GtkWidget *hbox_spc;
-       GtkWidget *toggle_view_btn;
-       GtkWidget *toggle_view_arrow;
+       GtkWidget *toggle_eventbox;
+       GtkWidget *toggle_arrow;
        GtkWidget *popupmenu;
        GtkItemFactory *popupfactory;
        gint n_entries;
@@ -509,14 +508,14 @@ SummaryView *summary_create(void)
        statlabel_select = gtk_label_new("");
        gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_select, FALSE, FALSE, 12);
 
-       /* toggle view buttons */
-       toggle_view_btn = gtk_button_new();
-       gtk_box_pack_end(GTK_BOX(hbox), toggle_view_btn, FALSE, FALSE, 0);
-       gtk_button_set_relief(GTK_BUTTON(toggle_view_btn), GTK_RELIEF_NONE);
-       toggle_view_arrow=gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-       gtk_container_add(GTK_CONTAINER(toggle_view_btn), toggle_view_arrow);
-       gtk_signal_connect(GTK_OBJECT(toggle_view_btn), "clicked",
-                               GTK_SIGNAL_FUNC(summary_toggle_view_cb), summaryview);
+       /* toggle view button */
+       toggle_eventbox = gtk_event_box_new();
+       gtk_box_pack_end(GTK_BOX(hbox), toggle_eventbox, FALSE, FALSE, 4);
+       toggle_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+       gtk_container_add(GTK_CONTAINER(toggle_eventbox), toggle_arrow);
+       gtk_signal_connect(GTK_OBJECT(toggle_eventbox), "button_press_event",
+                          GTK_SIGNAL_FUNC(summary_toggle_pressed),
+                          summaryview);
 
        statlabel_msgs = gtk_label_new("");
        gtk_box_pack_end(GTK_BOX(hbox), statlabel_msgs, FALSE, FALSE, 4);
@@ -539,11 +538,10 @@ SummaryView *summary_create(void)
        summaryview->statlabel_folder = statlabel_folder;
        summaryview->statlabel_select = statlabel_select;
        summaryview->statlabel_msgs = statlabel_msgs;
-       summaryview->toggle_view_btn = toggle_view_btn;
-       summaryview->toggle_view_arrow = toggle_view_arrow;
+       summaryview->toggle_eventbox = toggle_eventbox;
+       summaryview->toggle_arrow = toggle_arrow;
        summaryview->popupmenu = popupmenu;
        summaryview->popupfactory = popupfactory;
-       summaryview->msg_is_toggled_on = TRUE;
        summaryview->lock_count = 0;
 
        gtk_widget_show_all(vbox);
@@ -1356,8 +1354,7 @@ static GtkCTreeNode *summary_find_prev_msg(SummaryView *summaryview,
 
        for (; node != NULL; node = GTK_CTREE_NODE_PREV(node)) {
                msginfo = gtk_ctree_node_get_row_data(ctree, node);
-               if (!MSG_IS_DELETED(msginfo->flags))
-                       break;
+               if (!MSG_IS_DELETED(msginfo->flags)) break;
        }
 
        return node;
@@ -1377,8 +1374,7 @@ static GtkCTreeNode *summary_find_next_msg(SummaryView *summaryview,
 
        for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
                msginfo = gtk_ctree_node_get_row_data(ctree, node);
-               if (!MSG_IS_DELETED(msginfo->flags))
-                       break;
+               if (!MSG_IS_DELETED(msginfo->flags)) break;
        }
 
        return node;
@@ -2249,12 +2245,6 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
        text[col_pos[S_COL_NUMBER]] = itos(msginfo->msgnum);
        text[col_pos[S_COL_SIZE]]   = to_human_readable(msginfo->size);
 
-#if 0
-       text[col_pos[S_COL_SCORE]]  = itos_buf(col_score, msginfo->threadscore);
-#else
-       text[col_pos[S_COL_SCORE]]  = itos_buf(col_score, msginfo->score);
-#endif 
-
        if (msginfo->date_t) {
                procheader_date_get_localtime(date_modified,
                                              sizeof(date_modified),
@@ -2381,8 +2371,8 @@ static void summary_display_msg_full(SummaryView *summaryview,
                msgview = summaryview->messageview;
 
                summaryview->displayed = row;
-               if (!summaryview->msg_is_toggled_on)
-                       summary_toggle_view(summaryview);
+               if (!messageview_is_visible(msgview))
+                       main_window_toggle_message_view(summaryview->mainwin);
                messageview_show(msgview, msginfo, all_headers);
                if (msgview->type == MVIEW_TEXT ||
                    (msgview->type == MVIEW_MIME &&
@@ -2487,93 +2477,21 @@ void summary_step(SummaryView *summaryview, GtkScrollType type)
                }
        }
 
-       if (summaryview->msg_is_toggled_on)
+       if (messageview_is_visible(summaryview->messageview))
                summaryview->display_msg = TRUE;
 
        gtk_signal_emit_by_name(GTK_OBJECT(ctree), "scroll_vertical",
                                type, 0.0);
 }
 
-static void summary_toggle_view(SummaryView *summaryview)
-{
-       MainWindow *mainwin = summaryview->mainwin;
-       GtkItemFactory *ifactory;
-       
-       if (!mainwin) return;
-       
-       ifactory = gtk_item_factory_from_widget(mainwin->menubar);
-       menu_toggle_toggle(ifactory, "/View/Expand Summary View");
-}
-
-void summary_toggle_view_real(SummaryView *summaryview)
+void summary_toggle_view(SummaryView *summaryview)
 {
-       MainWindow *mainwin = summaryview->mainwin;
-       union CompositeWin *cwin = &mainwin->win;
-       GtkWidget *vpaned = NULL;
-       GtkWidget *container = NULL;
-       GtkWidget *toggle_view_btn;
-       GtkWidget *toggle_view_arrow;
-       GtkItemFactory *ifactory = gtk_item_factory_from_widget(mainwin->menubar);
-       
-       switch (mainwin->type) {
-       case SEPARATE_NONE:
-               vpaned = cwin->sep_none.vpaned;
-               container = cwin->sep_none.hpaned;
-               break;
-       case SEPARATE_FOLDER:
-               vpaned = cwin->sep_folder.vpaned;
-               container = mainwin->vbox_body;
-               break;
-       case SEPARATE_MESSAGE:
-       case SEPARATE_BOTH:
-               return;
-       }
-
-       if (vpaned->parent != NULL) {
-               summaryview->msg_is_toggled_on = FALSE;
-               summaryview->displayed = NULL;
-               gtk_widget_ref(vpaned);
-               gtkut_container_remove(GTK_CONTAINER(container), vpaned);
-               gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
-               
-               gtk_widget_destroy(summaryview->toggle_view_arrow);
-               gtk_widget_destroy(summaryview->toggle_view_btn);
-               
-               toggle_view_btn = gtk_button_new();
-               gtk_box_pack_end(GTK_BOX(summaryview->hbox), toggle_view_btn, FALSE, FALSE, 0);
-               gtk_box_reorder_child(GTK_BOX(summaryview->hbox), toggle_view_btn, 0);
-               gtk_button_set_relief(GTK_BUTTON(toggle_view_btn), GTK_RELIEF_NONE);
-               toggle_view_arrow=gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_OUT);
-               gtk_container_add(GTK_CONTAINER(toggle_view_btn), toggle_view_arrow);
-               gtk_signal_connect(GTK_OBJECT(toggle_view_btn), "clicked",
-                                       GTK_SIGNAL_FUNC(summary_toggle_view_cb), summaryview);
-               gtk_widget_show_all(toggle_view_btn);
-               menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
-       } else {
-               summaryview->msg_is_toggled_on = TRUE;
-               gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
-               gtk_container_add(GTK_CONTAINER(container), vpaned);
-               gtk_widget_unref(vpaned);
-               
-               gtk_widget_destroy(summaryview->toggle_view_arrow);
-               gtk_widget_destroy(summaryview->toggle_view_btn);
-               
-               toggle_view_btn = gtk_button_new();
-               gtk_box_pack_end(GTK_BOX(summaryview->hbox), toggle_view_btn, FALSE, FALSE, 0);
-               gtk_box_reorder_child(GTK_BOX(summaryview->hbox), toggle_view_btn, 0);
-               gtk_button_set_relief(GTK_BUTTON(toggle_view_btn), GTK_RELIEF_NONE);
-               toggle_view_arrow=gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
-               gtk_container_add(GTK_CONTAINER(toggle_view_btn), toggle_view_arrow);
-               gtk_signal_connect(GTK_OBJECT(toggle_view_btn), "clicked",
-                                       GTK_SIGNAL_FUNC(summary_toggle_view_cb), summaryview);
-               gtk_widget_show_all(toggle_view_btn);
-               menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
-       }
-
-       gtk_widget_grab_focus(summaryview->ctree);
-       
-       summaryview->toggle_view_btn = toggle_view_btn;
-       summaryview->toggle_view_arrow = toggle_view_arrow;
+       if (!messageview_is_visible(summaryview->messageview) &&
+           summaryview->selected)
+               summary_display_msg(summaryview,
+                                   summaryview->selected);
+       else
+               main_window_toggle_message_view(summaryview->mainwin);
 }
 
 static gboolean summary_search_unread_recursive(GtkCTree *ctree,
@@ -3052,9 +2970,10 @@ void summary_delete(SummaryView *summaryview)
                else if (sel_last && node == GTK_CTREE_NODE_PREV(sel_last))
                        summary_step(summaryview, GTK_SCROLL_STEP_BACKWARD);
                else
-                       summary_select_node(summaryview, node,
-                                           summaryview->msg_is_toggled_on,
-                                           FALSE);
+                       summary_select_node
+                               (summaryview, node,
+                                messageview_is_visible(summaryview->messageview),
+                                FALSE);
        }
 
        if (prefs_common.immediate_exec || item->stype == F_TRASH)
@@ -3131,6 +3050,7 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        CHANGE_FLAGS(msginfo);
        summary_set_row_marks(summaryview, row);
+
        debug_print(_("Message %s/%d is unmarked\n"),
                    msginfo->folder->path, msginfo->msgnum);
 }
@@ -3604,7 +3524,6 @@ static void summary_execute_delete(SummaryView *summaryview)
        GSList *cur;
 
        trash = summaryview->folder_item->folder->trash;
-
        if (summaryview->folder_item->folder->type == F_MH) {
                g_return_if_fail(trash != NULL);
        }
@@ -4550,7 +4469,6 @@ void summary_set_column_order(SummaryView *summaryview)
        guint selected_msgnum = summary_get_msgnum(summaryview, summaryview->selected);
        guint displayed_msgnum = summary_get_msgnum(summaryview, summaryview->displayed);
 
-       
        item = summaryview->folder_item;
 
        summary_lock(summaryview);
@@ -4583,18 +4501,14 @@ void summary_set_column_order(SummaryView *summaryview)
 }
 
 
-
 /* callback functions */
 
-static void summary_toggle_view_cb(GtkWidget *button,
-                                  gpointer data)
+static void summary_toggle_pressed(GtkWidget *eventbox, GdkEventButton *event,
+                                  SummaryView *summaryview)
 {
-       SummaryView *summaryview = (SummaryView *) data;
-       
-       if (!summaryview->msg_is_toggled_on && summaryview->selected)
-               summary_display_msg(summaryview, summaryview->selected);
-       else
-               summary_toggle_view(summaryview);
+       if (!event) return;
+
+       summary_toggle_view(summaryview);
 }
 
 static void summary_button_pressed(GtkWidget *ctree, GdkEventButton *event,
@@ -4610,7 +4524,7 @@ static void summary_button_pressed(GtkWidget *ctree, GdkEventButton *event,
                summaryview->display_msg = TRUE;
        } else if (event->button == 1) {
                if (!prefs_common.emulate_emacs &&
-                   summaryview->msg_is_toggled_on)
+                   messageview_is_visible(summaryview->messageview))
                        summaryview->display_msg = TRUE;
        }
 }
index 16610b7f75e25add5dd868d4675dc96d20036cfc..76c1680a7bf3a812f7dd24347f4977c897723e36 100644 (file)
@@ -88,8 +88,8 @@ struct _SummaryView
        GtkWidget *statlabel_folder;
        GtkWidget *statlabel_select;
        GtkWidget *statlabel_msgs;
-       GtkWidget *toggle_view_btn;
-       GtkWidget *toggle_view_arrow;
+       GtkWidget *toggle_eventbox;
+       GtkWidget *toggle_arrow;
        GtkWidget *popupmenu;
        GtkWidget *colorlabel_menu;
 
@@ -100,7 +100,6 @@ struct _SummaryView
        GtkCTreeNode *selected;
        GtkCTreeNode *displayed;
 
-       gboolean msg_is_toggled_on;
        gboolean display_msg;
 
        GdkColor color_important;
@@ -207,6 +206,7 @@ void summary_view_source      (SummaryView          *summaryview);
 void summary_reedit              (SummaryView          *summaryview);
 void summary_step                (SummaryView          *summaryview,
                                   GtkScrollType         type);
+void summary_toggle_view         (SummaryView          *summaryview);
 void summary_set_marks_selected          (SummaryView          *summaryview);
 
 void summary_move_selected_to    (SummaryView          *summaryview,