aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-21 06:33:11 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-21 07:05:55 +0800
commit9aa668aa6bf612673ad7e760b06fc62350be041e (patch)
tree0faa8c08a5452393069fc3fc716b1458ad9cad5a /mail
parent7333f12087eb0b0271ff272c6643909a7803510b (diff)
downloadgsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar.gz
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar.bz2
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar.lz
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar.xz
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.tar.zst
gsoc2013-evolution-9aa668aa6bf612673ad7e760b06fc62350be041e.zip
Bug 650587 - Hide Search Folder actions when Search Folders are disabled
Add an action group for Search Folders to EMailReader. The action group's visibility is bound to the "mail-enable-search-folders" setting, so that menu items related to Search Folders are hidden when Search Folders are disabled in GConf. Affected menu items are: Edit -> Search Folders Message -> Create Rule -> Search Folder from Subject... Message -> Create Rule -> Search Folder from Sender... Message -> Create Rule -> Search Folder from Recipients... Message -> Create Rule -> Search Folder from Mailing List... Search -> Create Search Folder From Search...
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-browser.c48
-rw-r--r--mail/e-mail-notebook-view.c3
-rw-r--r--mail/e-mail-paned-view.c3
-rw-r--r--mail/e-mail-reader.c84
-rw-r--r--mail/e-mail-reader.h1
5 files changed, 86 insertions, 53 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 6e0a18ff21..63bfb4d5b5 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -43,11 +43,13 @@
#define MAIL_BROWSER_GCONF_PREFIX "/apps/evolution/mail/mail_browser"
+#define ACTION_GROUP_STANDARD "action-group-standard"
+#define ACTION_GROUP_SEARCH_FOLDERS "action-group-search-folders"
+
struct _EMailBrowserPrivate {
EMailBackend *backend;
GtkUIManager *ui_manager;
EFocusTracker *focus_tracker;
- GtkActionGroup *action_group;
EMFormatHTMLDisplay *formatter;
GtkWidget *main_menu;
@@ -485,11 +487,6 @@ mail_browser_dispose (GObject *object)
priv->focus_tracker = NULL;
}
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
if (priv->formatter != NULL) {
g_object_unref (priv->formatter);
priv->formatter = NULL;
@@ -598,9 +595,11 @@ mail_browser_constructed (GObject *object)
web_view, "status-message",
G_CALLBACK (mail_browser_status_message_cb), object);
+ /* Add action groups before initializing the reader interface. */
+
e_mail_reader_init (reader, TRUE, TRUE);
- action_group = priv->action_group;
+ action_group = gtk_action_group_new (ACTION_GROUP_STANDARD);
gtk_action_group_set_translation_domain (action_group, domain);
gtk_action_group_add_actions (
action_group, mail_browser_entries,
@@ -610,6 +609,20 @@ mail_browser_constructed (GObject *object)
G_N_ELEMENTS (mail_browser_popup_entries));
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ /* For easy access. Takes ownership of the reference. */
+ g_object_set_data_full (
+ object, ACTION_GROUP_STANDARD,
+ action_group, (GDestroyNotify) g_object_unref);
+
+ action_group = gtk_action_group_new (ACTION_GROUP_SEARCH_FOLDERS);
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+
+ /* For easy access. Takes ownership of the reference. */
+ g_object_set_data_full (
+ object, ACTION_GROUP_SEARCH_FOLDERS,
+ action_group, (GDestroyNotify) g_object_unref);
+
e_ui_manager_add_ui_from_file (
E_UI_MANAGER (ui_manager), E_MAIL_READER_UI_DEFINITION);
e_ui_manager_add_ui_from_string (
@@ -628,13 +641,13 @@ mail_browser_constructed (GObject *object)
/* Configure an EFocusTracker to manage selection actions. */
focus_tracker = e_focus_tracker_new (GTK_WINDOW (object));
- action = gtk_action_group_get_action (action_group, "cut-clipboard");
+ action = e_mail_reader_get_action (reader, "cut-clipboard");
e_focus_tracker_set_cut_clipboard_action (focus_tracker, action);
- action = gtk_action_group_get_action (action_group, "copy-clipboard");
+ action = e_mail_reader_get_action (reader, "copy-clipboard");
e_focus_tracker_set_copy_clipboard_action (focus_tracker, action);
- action = gtk_action_group_get_action (action_group, "paste-clipboard");
+ action = e_mail_reader_get_action (reader, "paste-clipboard");
e_focus_tracker_set_paste_clipboard_action (focus_tracker, action);
- action = gtk_action_group_get_action (action_group, "select-all");
+ action = e_mail_reader_get_action (reader, "select-all");
e_focus_tracker_set_select_all_action (focus_tracker, action);
priv->focus_tracker = focus_tracker;
@@ -745,16 +758,20 @@ static GtkActionGroup *
mail_browser_get_action_group (EMailReader *reader,
EMailReaderActionGroup group)
{
- EMailBrowserPrivate *priv;
-
- priv = E_MAIL_BROWSER (reader)->priv;
+ const gchar *group_name;
switch (group) {
case E_MAIL_READER_ACTION_GROUP_STANDARD:
- return priv->action_group;
+ group_name = ACTION_GROUP_STANDARD;
+ break;
+ case E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS:
+ group_name = ACTION_GROUP_SEARCH_FOLDERS;
+ break;
default:
g_return_val_if_reached (NULL);
}
+
+ return g_object_get_data (G_OBJECT (reader), group_name);
}
static EAlertSink *
@@ -959,7 +976,6 @@ e_mail_browser_init (EMailBrowser *browser)
browser->priv = G_TYPE_INSTANCE_GET_PRIVATE (
browser, E_TYPE_MAIL_BROWSER, EMailBrowserPrivate);
- browser->priv->action_group = gtk_action_group_new ("mail-browser");
browser->priv->formatter = em_format_html_display_new ();
bridge = gconf_bridge_get ();
diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c
index d72016d608..74b9eadf2d 100644
--- a/mail/e-mail-notebook-view.c
+++ b/mail/e-mail-notebook-view.c
@@ -792,6 +792,9 @@ mail_notebook_view_get_action_group (EMailReader *reader,
case E_MAIL_READER_ACTION_GROUP_STANDARD:
group_name = "mail";
break;
+ case E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS:
+ group_name = "search-folders";
+ break;
default:
g_return_val_if_reached (NULL);
}
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index d95fca16c2..6d381009d6 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -382,6 +382,9 @@ mail_paned_view_get_action_group (EMailReader *reader,
case E_MAIL_READER_ACTION_GROUP_STANDARD:
group_name = "mail";
break;
+ case E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS:
+ group_name = "search-folders";
+ break;
default:
g_return_val_if_reached (NULL);
}
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 1697db9ab3..bbbcfabae1 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2108,34 +2108,6 @@ static GtkActionEntry mail_reader_entries[] = {
N_("Save selected messages as an mbox file"),
G_CALLBACK (action_mail_save_as_cb) },
- { "mail-search-folder-from-mailing-list",
- NULL,
- N_("Search Folder from Mailing _List..."),
- NULL,
- N_("Create a search folder for this mailing list"),
- G_CALLBACK (action_mail_search_folder_from_mailing_list_cb) },
-
- { "mail-search-folder-from-recipients",
- NULL,
- N_("Search Folder from Recipien_ts..."),
- NULL,
- N_("Create a search folder for these recipients"),
- G_CALLBACK (action_mail_search_folder_from_recipients_cb) },
-
- { "mail-search-folder-from-sender",
- NULL,
- N_("Search Folder from Sen_der..."),
- NULL,
- N_("Create a search folder for this sender"),
- G_CALLBACK (action_mail_search_folder_from_sender_cb) },
-
- { "mail-search-folder-from-subject",
- NULL,
- N_("Search Folder from S_ubject..."),
- NULL,
- N_("Create a search folder for this subject"),
- G_CALLBACK (action_mail_search_folder_from_subject_cb) },
-
{ "mail-show-source",
NULL,
N_("_Message Source"),
@@ -2237,6 +2209,37 @@ static GtkActionEntry mail_reader_entries[] = {
NULL }
};
+static GtkActionEntry mail_reader_search_folder_entries[] = {
+
+ { "mail-search-folder-from-mailing-list",
+ NULL,
+ N_("Search Folder from Mailing _List..."),
+ NULL,
+ N_("Create a search folder for this mailing list"),
+ G_CALLBACK (action_mail_search_folder_from_mailing_list_cb) },
+
+ { "mail-search-folder-from-recipients",
+ NULL,
+ N_("Search Folder from Recipien_ts..."),
+ NULL,
+ N_("Create a search folder for these recipients"),
+ G_CALLBACK (action_mail_search_folder_from_recipients_cb) },
+
+ { "mail-search-folder-from-sender",
+ NULL,
+ N_("Search Folder from Sen_der..."),
+ NULL,
+ N_("Create a search folder for this sender"),
+ G_CALLBACK (action_mail_search_folder_from_sender_cb) },
+
+ { "mail-search-folder-from-subject",
+ NULL,
+ N_("Search Folder from S_ubject..."),
+ NULL,
+ N_("Create a search folder for this subject"),
+ G_CALLBACK (action_mail_search_folder_from_subject_cb) },
+};
+
static EPopupActionEntry mail_reader_popup_entries[] = {
{ "mail-popup-copy",
@@ -3200,15 +3203,12 @@ mail_reader_update_actions (EMailReader *reader,
}
static void
-mail_reader_init_charset_actions (EMailReader *reader)
+mail_reader_init_charset_actions (EMailReader *reader,
+ GtkActionGroup *action_group)
{
- GtkActionGroup *action_group;
GtkRadioAction *default_action;
GSList *radio_group;
- action_group = e_mail_reader_get_action_group (
- reader, E_MAIL_READER_ACTION_GROUP_STANDARD);
-
radio_group = e_charset_add_radio_actions (
action_group, "mail-charset-", NULL,
G_CALLBACK (action_mail_charset_cb), reader);
@@ -3383,6 +3383,8 @@ e_mail_reader_init (EMailReader *reader,
if (!init_actions)
goto connect_signals;
+ /* Add the "standard" EMailReader actions. */
+
action_group = e_mail_reader_get_action_group (
reader, E_MAIL_READER_ACTION_GROUP_STANDARD);
@@ -3403,7 +3405,7 @@ e_mail_reader_init (EMailReader *reader,
gtk_action_group_add_action_with_accel (
action_group, GTK_ACTION (menu_tool_action), "<Control>f");
- /* Likewise the "mail-reply-group" action */
+ /* Likewise the "mail-reply-group" action. */
/* For Translators: "Group Reply" will reply either to a mailing list
(if possible and if that configuration option is enabled), or else
@@ -3424,8 +3426,6 @@ e_mail_reader_init (EMailReader *reader,
action_group, GTK_ACTION (menu_tool_action), "<Control>g");
/* Add the other actions the normal way. */
-
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (
action_group, mail_reader_entries,
G_N_ELEMENTS (mail_reader_entries), reader);
@@ -3436,7 +3436,17 @@ e_mail_reader_init (EMailReader *reader,
action_group, mail_reader_toggle_entries,
G_N_ELEMENTS (mail_reader_toggle_entries), reader);
- mail_reader_init_charset_actions (reader);
+ mail_reader_init_charset_actions (reader, action_group);
+
+ /* Add EMailReader actions for Search Folders. The action group
+ * should be made invisible if Search Folders are disabled. */
+
+ action_group = e_mail_reader_get_action_group (
+ reader, E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS);
+
+ gtk_action_group_add_actions (
+ action_group, mail_reader_search_folder_entries,
+ G_N_ELEMENTS (mail_reader_search_folder_entries), reader);
/* Bind GObject properties to GConf keys. */
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index ea6732a055..f4df175a67 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -62,6 +62,7 @@ typedef struct _EMailReaderInterface EMailReaderInterface;
typedef enum {
E_MAIL_READER_ACTION_GROUP_STANDARD,
+ E_MAIL_READER_ACTION_GROUP_SEARCH_FOLDERS,
E_MAIL_READER_NUM_ACTION_GROUPS
} EMailReaderActionGroup;