* when pushing the delete toolbar button in the main window, or choosing
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sat, 7 Jul 2007 16:29:16 +0000 (16:29 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Sat, 7 Jul 2007 16:29:16 +0000 (16:29 +0000)
  the delete menu item, delete either message or folder, depending on the
  focus. the dimming rules already implemented this.

Fixes: NB#62765, NB#62748

pmo-trunk-r2625

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

index caf3ce7..29cfdec 100644 (file)
@@ -64,7 +64,7 @@ static const GtkActionEntry modest_action_entries [] = {
        { "EmailReply",       NULL,  N_("mcen_me_inbox_reply"),            NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_reply) },
        { "EmailReplyAll",    NULL,  N_("mcen_me_inbox_replytoall"),      NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_reply_all) },
        { "EmailForward",     NULL,  N_("mcen_me_inbox_forward"),          NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_forward) },
-       { "EmailDelete",      NULL,  N_("mcen_me_inbox_delete"),    NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_delete) },
+       { "EmailDelete",      NULL,  N_("mcen_me_inbox_delete"),    NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_delete_message_or_folder) },
        { "EmailContents",    NULL,  N_("mcen_me_inbox_retrieve_contents"), NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_retrieve_msg_contents) },
        { "EmailDetails",     NULL,  N_("mcen_me_inbox_messagedetails"),        NULL,      NULL,   G_CALLBACK (modest_ui_actions_on_details) },
        { "EmailPurgeAttachments", NULL, N_("mcen_me_inbox_remove_attachments"), NULL,  NULL,   G_CALLBACK (modest_ui_actions_remove_attachments) },
@@ -118,7 +118,7 @@ static const GtkActionEntry modest_action_entries [] = {
        { "ToolbarMessageForward",    MODEST_STOCK_FORWARD,     N_("mcen_me_inbox_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) }, */
-       { "ToolbarDeleteMessage",     MODEST_STOCK_DELETE,     N_("qgn_toolb_gene_deletebutton"),             NULL, NULL,  G_CALLBACK (modest_ui_actions_on_delete) },
+       { "ToolbarDeleteMessage",     MODEST_STOCK_DELETE,     N_("qgn_toolb_gene_deletebutton"),             NULL, NULL,  G_CALLBACK (modest_ui_actions_on_delete_message_or_folder) },
        { "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 },
        { "ToolbarMessageBack",       GTK_STOCK_GO_BACK,    N_("qgn_toolb_gene_back"),         NULL, NULL, G_CALLBACK (modest_ui_actions_on_prev) },
index 2aec465..8d5c01b 100644 (file)
@@ -247,7 +247,7 @@ static const GtkActionEntry modest_header_view_action_entries [] = {
        { "HeaderViewCSMCut",           NULL,  N_("mcen_me_inbox_cut"),         "<CTRL>X", NULL, G_CALLBACK (modest_ui_actions_on_cut) },
        { "HeaderViewCSMCopy",          NULL,  N_("mcen_me_inbox_copy"),        "<CTRL>C", NULL, G_CALLBACK (modest_ui_actions_on_copy) },
        { "HeaderViewCSMPaste",         NULL,  N_("mcen_me_inbox_paste"),       "<CTRL>V", NULL, G_CALLBACK (modest_ui_actions_on_paste) },
-       { "HeaderViewCSMDelete",        NULL,  N_("mcen_me_inbox_delete"),      NULL,      NULL, G_CALLBACK (modest_ui_actions_on_delete) },
+       { "HeaderViewCSMDelete",        NULL,  N_("mcen_me_inbox_delete"),      NULL,      NULL, G_CALLBACK (modest_ui_actions_on_delete_message) },
        { "HeaderViewCSMCancelSending", NULL,  N_("mcen_me_outbox_cancelsend"), NULL,      NULL, G_CALLBACK (modest_ui_actions_cancel_send) },
        { "HeaderViewCSMHelp",          NULL,  N_("mcen_me_inbox_help"),        NULL,      NULL, G_CALLBACK (modest_ui_actions_on_help) },
 };
index 4ea00fd..98f9d7e 100644 (file)
@@ -258,7 +258,7 @@ headers_action_delete (TnyHeader *header,
 }
 
 void
-modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win)
+modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
 {
        TnyList *header_list = NULL;
        TnyIterator *iter = NULL;
@@ -367,6 +367,38 @@ modest_ui_actions_on_delete (GtkAction *action, ModestWindow *win)
 }
 
 
+
+
+/* delete either message or folder, based on what has focus */
+void
+modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow *win)
+{
+       g_return_if_fail (MODEST_IS_WINDOW(win));
+       
+       /* Check first if the header view has the focus */
+       if (MODEST_IS_MAIN_WINDOW (win)) {
+               GtkWidget *w;
+
+               w = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                        MODEST_WIDGET_TYPE_HEADER_VIEW);
+               if (gtk_widget_is_focus (w)) {
+                       modest_ui_actions_on_delete_message (action, win);
+                       return;
+               }
+               
+               w = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
+                                                        MODEST_WIDGET_TYPE_FOLDER_VIEW);
+               if (gtk_widget_is_focus (w)) {
+                       modest_ui_actions_on_delete_folder (action, MODEST_MAIN_WINDOW(win));
+                       return;
+               }
+       }
+       g_warning ("BUG: delete toolbar button pressed with neither headerview nor folderview "
+                  "having focus");
+}
+
+
+
 void
 modest_ui_actions_on_quit (GtkAction *action, ModestWindow *win)
 {
index d8f14a8..91655be 100644 (file)
@@ -40,7 +40,9 @@ G_BEGIN_DECLS
 /* Menu & toolbar actions */
 void     modest_ui_actions_on_about         (GtkAction *action, ModestWindow *win);
 
-void     modest_ui_actions_on_delete        (GtkAction *action, ModestWindow *win);
+void     modest_ui_actions_on_delete_message     (GtkAction *action, ModestWindow *win);
+
+void     modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow *win);
 
 void     modest_ui_actions_on_quit          (GtkAction *action, ModestWindow *win);
 
index 8e2d313..e53a124 100644 (file)
@@ -56,7 +56,7 @@ static const GtkActionEntry modest_msg_edit_action_entries [] = {
        /* ACTIONS */
        { "ActionsNewMessage", NULL, N_("mcen_me_viewer_newemail"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_new_msg) },
        { "ActionsSaveToDrafts", NULL, N_("mcen_me_editor_save_as_draft"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_save_to_drafts) },
-       { "ActionsDelete", NULL, N_("mcen_me_inbox_delete"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_delete) },
+       { "ActionsDelete", NULL, N_("mcen_me_inbox_delete"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_delete_message) },
        { "ActionsSend", NULL, N_("mcen_me_editor_send"),  NULL, NULL,  G_CALLBACK (modest_ui_actions_on_send) },
 /*     { "ActionsFontColor", GTK_STOCK_SELECT_COLOR, N_("Color"), NULL, N_("Change text color"), G_CALLBACK (modest_ui_actions_on_select_editor_color)}, */
 /*     { "BackgroundColor", GTK_STOCK_SELECT_COLOR, N_("Background color"), NULL, N_("Change background color"), G_CALLBACK (modest_ui_actions_on_select_editor_background_color)}, */