* Fixed a bug when there was no header selected
authorSergio Villar Senin <svillar@igalia.com>
Fri, 4 May 2007 07:29:31 +0000 (07:29 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Fri, 4 May 2007 07:29:31 +0000 (07:29 +0000)
* The toggle folder button is now really a toggle action

pmo-trunk-r1756

src/maemo/modest-main-window-ui.h
src/maemo/modest-main-window.c
src/modest-ui-actions.c

index 7b481d8..c2aada5 100644 (file)
@@ -109,7 +109,7 @@ static const GtkActionEntry modest_action_entries [] = {
        { "ToolbarMessageReplyAll",   MODEST_STOCK_REPLY_ALL,     N_("qgn_toolb_messagin_replyall"),         NULL, NULL,  G_CALLBACK (modest_ui_actions_on_reply_all) },
        { "ToolbarMessageForward",    MODEST_STOCK_FORWARD,     N_("qgn_toolb_messagin_forward"),      NULL, NULL,  G_CALLBACK (modest_ui_actions_on_forward) },
        { "ToolbarSendReceive",       MODEST_STOCK_REFRESH,   N_("qgn_toolb_gene_refresh"),      NULL, NULL,  G_CALLBACK (modest_ui_actions_on_send_receive) },
-       { "ToolbarToggleView",        MODEST_STOCK_SPLIT_VIEW,      N_("gqn_toolb_rss_fldonoff"),                "<CTRL>t", NULL,  G_CALLBACK (modest_ui_actions_toggle_folders_view) },
+/*     { "ToolbarToggleView",        MODEST_STOCK_SPLIT_VIEW,      N_("gqn_toolb_rss_fldonoff"),                "<CTRL>t", NULL,  G_CALLBACK (modest_ui_actions_toggle_folders_view) }, */
        { "ToolbarDeleteMessage",     MODEST_STOCK_DELETE,     N_("qgn_toolb_gene_deletebutton"),             NULL, NULL,  G_CALLBACK (modest_ui_actions_on_delete) },
        { "ToolbarSort",     MODEST_STOCK_SORT,     N_("qgn_list_sort"),             NULL, NULL,  G_CALLBACK (modest_ui_actions_on_sort) },
        { "ToolbarFindInMessage",     GTK_STOCK_FIND,       N_("qgn_toolb_gene_find"),         NULL, NULL, NULL },
index 8cc493a..06c3d37 100644 (file)
@@ -161,6 +161,12 @@ static const GtkActionEntry modest_folder_view_action_entries [] = {
        { "FolderViewCSMHelp", NULL, N_("mcen_me_inbox_help"), NULL, NULL, NULL },
 };
 
+
+static const GtkToggleActionEntry modest_main_window_toggle_action_entries [] = {
+       { "ToolbarToggleView", MODEST_STOCK_SPLIT_VIEW, N_("gqn_toolb_rss_fldonoff"), "<CTRL>t", NULL, G_CALLBACK (modest_ui_actions_toggle_folders_view), FALSE },
+};
+
+
 /************************************************************************/
 
 GType
@@ -446,6 +452,11 @@ modest_main_window_new (void)
                                             G_N_ELEMENTS (modest_toggle_action_entries),
                                             self);
 
+       gtk_action_group_add_toggle_actions (action_group,
+                                            modest_main_window_toggle_action_entries,
+                                            G_N_ELEMENTS (modest_main_window_toggle_action_entries),
+                                            self);
+
        gtk_ui_manager_insert_action_group (parent_priv->ui_manager, action_group, 0);
        g_object_unref (action_group);
 
@@ -568,15 +579,21 @@ modest_main_window_set_style (ModestMainWindow *self,
                              ModestMainWindowStyle style)
 {
        ModestMainWindowPrivate *priv;
+       ModestWindowPrivate *parent_priv;
+       GtkAction *action;
 
        g_return_if_fail (MODEST_IS_MAIN_WINDOW (self));
 
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
 
        /* no change -> nothing to do */
        if (priv->style == style)
                return;
 
+       /* Get toggle button */
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/ToolbarToggleView");
+
        priv->style = style;
 
        switch (style) {
@@ -588,6 +605,10 @@ modest_main_window_set_style (ModestMainWindow *self,
                /* Reparent the contents widget to the main vbox */
                gtk_widget_reparent (priv->contents_widget, priv->main_vbox);
 
+               g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
+               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
+
                break;
        case MODEST_MAIN_WINDOW_STYLE_SPLIT:
                /* Remove header view */
@@ -597,6 +618,11 @@ modest_main_window_set_style (ModestMainWindow *self,
                /* Reparent the main paned */
                gtk_paned_add2 (GTK_PANED (priv->main_paned), priv->contents_widget);
                gtk_container_add (GTK_CONTAINER (priv->main_vbox), priv->main_paned);
+
+               g_signal_handlers_block_by_func (action, modest_ui_actions_toggle_folders_view, self);
+               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), FALSE);
+               g_signal_handlers_unblock_by_func (action, modest_ui_actions_toggle_folders_view, self);
+
                break;
        default:
                g_return_if_reached ();
index 0931689..2e65ece 100644 (file)
@@ -931,6 +931,10 @@ modest_ui_actions_on_header_selected (ModestHeaderView *header_view,
 {
        g_return_if_fail (MODEST_IS_MAIN_WINDOW(main_window));
 
+       /* If no header has been selected then exit */
+       if (!header)
+               return;
+
        /* Update Main window title */
        if (GTK_WIDGET_HAS_FOCUS (header_view)) {
                const gchar *subject = tny_header_get_subject (header);