diff options
Diffstat (limited to 'plugins/mark-all-read/mark-all-read.c')
-rw-r--r-- | plugins/mark-all-read/mark-all-read.c | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c index e210af6547..dacb5e5685 100644 --- a/plugins/mark-all-read/mark-all-read.c +++ b/plugins/mark-all-read/mark-all-read.c @@ -28,20 +28,26 @@ #include <glib.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <e-util/e-config.h> -#include <mail/em-popup.h> +#include <e-util/e-plugin-ui.h> +#include <mail/em-folder-tree.h> #include <mail/mail-ops.h> #include <mail/mail-mt.h> #include <camel/camel-vee-folder.h> #include "e-util/e-error.h" +#include <shell/e-shell-sidebar.h> +#include <shell/e-shell-view.h> +#include <shell/e-shell-window.h> + #define PRIMARY_TEXT \ N_("Also mark messages in subfolders?") #define SECONDARY_TEXT \ N_("Do you want to mark messages as read in the current folder " \ "only, or in the current folder as well as all subfolders?") -void org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *target); +gboolean e_plugin_ui_init (GtkUIManager *ui_manager, + EShellView *shell_view); + static void mar_got_folder (gchar *uri, CamelFolder *folder, gpointer data); static void mar_all_sub_folders (CamelStore *store, CamelFolderInfo *fi, CamelException *ex); @@ -194,16 +200,6 @@ prompt_user (void) return response; } -void -org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *t) -{ - if (t->uri == NULL) { - return; - } - - mail_get_folder(t->uri, 0, mar_got_folder, NULL, mail_msg_unordered_push); -} - static void mark_all_as_read (CamelFolder *folder) { @@ -274,3 +270,50 @@ mar_all_sub_folders (CamelStore *store, CamelFolderInfo *fi, CamelException *ex) fi = fi->next; } } + +static void +action_mail_mark_read_recursive_cb (GtkAction *action, + EShellView *shell_view) +{ + EShellSidebar *shell_sidebar; + EMFolderTree *folder_tree; + const gchar *folder_uri; + + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL); + folder_uri = em_folder_tree_get_selected_uri (folder_tree); + g_return_if_fail (folder_uri != NULL); + + mail_get_folder ( + folder_uri, 0, mar_got_folder, NULL, mail_msg_unordered_push); + + g_object_unref (folder_tree); +} + +static GtkActionEntry entries[] = { + + { "mail-mark-read-recursive", + "mail-mark-read", + N_("Mark Me_ssages as Read"), + NULL, + NULL, /* XXX Add a tooltip! */ + G_CALLBACK (action_mail_mark_read_recursive_cb) } +}; + +gboolean +e_plugin_ui_init (GtkUIManager *ui_manager, + EShellView *shell_view) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "mail"); + + /* Add actions to the "mail" action group. */ + gtk_action_group_add_actions ( + action_group, entries, + G_N_ELEMENTS (entries), shell_view); + + return TRUE; +} |