From 9344597f4c8e8b0c0cf7481ae04963c73a844035 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Wed, 4 Jul 2007 17:35:28 +0000 Subject: [PATCH] * src/maemo/modest-main-window.c: * Now proper Contextual menus for header view are shown, depending on the type of folder (drafts, sent, outbox, inbox...) (fixes NB#60352, NB#60355, NB#60356). pmo-trunk-r2577 --- src/maemo/modest-main-window.c | 76 +++++++++++++++++++++++++++++++- src/maemo/ui/modest-main-window-ui.xml | 5 +-- 2 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/maemo/modest-main-window.c b/src/maemo/modest-main-window.c index d7fa440..3c19dd0 100644 --- a/src/maemo/modest-main-window.c +++ b/src/maemo/modest-main-window.c @@ -50,6 +50,7 @@ #include "modest-main-window-ui-dimming.h" #include "modest-account-mgr.h" #include "modest-tny-account.h" +#include "modest-tny-folder.h" #include "modest-conf.h" #include #include "modest-tny-platform-factory.h" @@ -147,6 +148,11 @@ static gboolean on_header_view_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer userdata); +static void +modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, + TnyFolderStore *folder_store, + gboolean selected, + ModestMainWindow *main_window); /* list my signals */ enum { @@ -613,7 +619,7 @@ connect_signals (ModestMainWindow *self) g_signal_connect (G_OBJECT(priv->folder_view), "key-press-event", G_CALLBACK(on_inner_widgets_key_pressed), self); g_signal_connect (G_OBJECT(priv->folder_view), "folder_selection_changed", - G_CALLBACK(modest_ui_actions_on_folder_selection_changed), self); + G_CALLBACK(modest_main_window_on_folder_selection_changed), self); g_signal_connect (G_OBJECT(priv->folder_view), "folder-display-name-changed", G_CALLBACK(modest_ui_actions_on_folder_display_name_changed), self); g_signal_connect (G_OBJECT (priv->folder_view), "focus-in-event", @@ -2092,3 +2098,71 @@ on_header_view_focus_in (GtkWidget *widget, } return FALSE; } + +static void +modest_main_window_on_folder_selection_changed (ModestFolderView *folder_view, + TnyFolderStore *folder_store, + gboolean selected, + ModestMainWindow *main_window) +{ + ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (main_window); + GtkAction *action = NULL; + gboolean show_reply = TRUE; + gboolean show_forward = TRUE; + gboolean show_cancel_send = FALSE; + gboolean show_clipboard = TRUE; + gboolean show_delete = TRUE; + + if (selected) { + if (TNY_IS_ACCOUNT (folder_store)) { + show_reply = show_forward = show_cancel_send = show_clipboard = show_delete = FALSE; + } else if (TNY_IS_FOLDER (folder_store)) { + if (modest_tny_folder_is_local_folder (TNY_FOLDER (folder_store))) { + TnyFolderType folder_type = modest_tny_folder_get_local_folder_type ( + TNY_FOLDER (folder_store)); + switch (folder_type) { + case TNY_FOLDER_TYPE_DRAFTS: + show_clipboard = show_delete = TRUE; + show_reply = show_forward = show_cancel_send = FALSE; + break; + case TNY_FOLDER_TYPE_SENT: + show_forward = show_clipboard = show_delete = TRUE; + show_reply = show_cancel_send = FALSE; + break; + case TNY_FOLDER_TYPE_OUTBOX: + show_clipboard = show_delete = show_cancel_send = TRUE; + show_reply = show_forward = FALSE; + break; + default: + show_reply = show_forward = show_clipboard = show_delete = TRUE; + show_cancel_send = FALSE; + } + } else { + show_reply = show_forward = show_clipboard = show_delete = TRUE; + show_cancel_send = FALSE; + } + } + } + + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMReply"); + gtk_action_set_visible (action, show_reply); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMReplyAll"); + gtk_action_set_visible (action, show_reply); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMForward"); + gtk_action_set_visible (action, show_forward); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMCancelSending"); + gtk_action_set_visible (action, show_cancel_send); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMCut"); + gtk_action_set_visible (action, show_clipboard); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMCopy"); + gtk_action_set_visible (action, show_clipboard); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMPaste"); + gtk_action_set_visible (action, show_clipboard); + action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/HeaderViewCSM/HeaderViewCSMDelete"); + gtk_action_set_visible (action, show_delete); + + /* We finally call to the ui actions handler, after updating properly + * the header view CSM */ + modest_ui_actions_on_folder_selection_changed (folder_view, folder_store, selected, main_window); + +} diff --git a/src/maemo/ui/modest-main-window-ui.xml b/src/maemo/ui/modest-main-window-ui.xml index 3da4e20..ba59db6 100644 --- a/src/maemo/ui/modest-main-window-ui.xml +++ b/src/maemo/ui/modest-main-window-ui.xml @@ -115,20 +115,19 @@ - + - - + -- 1.7.9.5