aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2012-02-16 20:04:47 +0800
committerMilan Crha <mcrha@redhat.com>2012-02-16 20:05:55 +0800
commit3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6 (patch)
treefcfb53b4b1107aed1d38a08611a5b7abf9a9e9c6 /modules
parent02cbfd837abaf8ec1218cc97f7fed70cbd1fdf7e (diff)
downloadgsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar.gz
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar.bz2
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar.lz
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar.xz
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.tar.zst
gsoc2013-evolution-3ec164d12e61102c0e3ce5271d5cb6ad7be6e4a6.zip
Bug #668482 - Edit account properties from menu on folder store
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/e-mail-shell-backend.c149
-rw-r--r--modules/mail/e-mail-shell-backend.h12
-rw-r--r--modules/mail/e-mail-shell-view-actions.c42
-rw-r--r--modules/mail/e-mail-shell-view-actions.h2
-rw-r--r--modules/mail/e-mail-shell-view.c4
-rw-r--r--modules/mail/em-account-prefs.c75
6 files changed, 177 insertions, 107 deletions
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 68ed9c39bc..2012b25660 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -76,6 +76,7 @@ struct _EMailShellBackendPrivate {
gint mail_sync_in_progress;
guint mail_sync_source_id;
gpointer assistant; /* weak pointer, when adding new mail account */
+ gpointer editor; /* weak pointer, when editing a mail account */
};
static void mbox_create_preview_cb (GObject *preview, GtkWidget **preview_widget);
@@ -165,7 +166,6 @@ action_mail_account_new_cb (GtkAction *action,
{
EShell *shell;
EShellBackend *shell_backend;
- EMailShellBackend *backend;
g_return_if_fail (shell_window != NULL);
@@ -173,37 +173,9 @@ action_mail_account_new_cb (GtkAction *action,
shell_backend = e_shell_get_backend_by_name (shell, BACKEND_NAME);
g_return_if_fail (E_IS_MAIL_SHELL_BACKEND (shell_backend));
- backend = E_MAIL_SHELL_BACKEND (shell_backend);
- if (backend->priv->assistant) {
- gtk_window_present (GTK_WINDOW (backend->priv->assistant));
- } else {
- EMAccountEditor *emae;
- GtkWindow *parent = GTK_WINDOW (shell_window);
-
- if (!e_shell_get_express_mode (shell)) {
- /** @HookPoint-EMConfig: New Mail Account Assistant
- * @Id: org.gnome.evolution.mail.config.accountAssistant
- * @Type: E_CONFIG_ASSISTANT
- * @Class: org.gnome.evolution.mail.config:1.0
- * @Target: EMConfigTargetAccount
- *
- * The new mail account assistant.
- */
- emae = em_account_editor_new (
- NULL, EMAE_ASSISTANT, E_MAIL_BACKEND (backend),
- "org.gnome.evolution.mail.config.accountAssistant");
- e_config_create_window (
- E_CONFIG (emae->config), NULL,
- _("Evolution Account Assistant"));
- backend->priv->assistant = E_CONFIG (emae->config)->window;
- } else {
- backend->priv->assistant = mail_capplet_shell_new (0, TRUE, FALSE);
- }
-
- g_object_add_weak_pointer (G_OBJECT (backend->priv->assistant), &backend->priv->assistant);
- gtk_window_set_transient_for (GTK_WINDOW (backend->priv->assistant), parent);
- gtk_widget_show (backend->priv->assistant);
- }
+ e_mail_shell_backend_new_account (
+ E_MAIL_SHELL_BACKEND (shell_backend),
+ GTK_WINDOW (shell_window));
}
static void
@@ -641,6 +613,29 @@ mail_shell_backend_empty_trash_policy_decision (EMailBackend *backend)
}
static void
+mail_shell_backend_dispose (GObject *object)
+{
+ EMailShellBackendPrivate *priv;
+
+ priv = E_MAIL_SHELL_BACKEND (object)->priv;
+
+ if (priv->assistant != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->assistant), &priv->assistant);
+ priv->assistant = NULL;
+ }
+
+ if (priv->editor != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->editor), &priv->editor);
+ priv->editor = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_mail_shell_backend_parent_class)->dispose (object);
+}
+
+static void
e_mail_shell_backend_class_init (EMailShellBackendClass *class)
{
GObjectClass *object_class;
@@ -651,6 +646,7 @@ e_mail_shell_backend_class_init (EMailShellBackendClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->constructed = mail_shell_backend_constructed;
+ object_class->dispose = mail_shell_backend_dispose;
shell_backend_class = E_SHELL_BACKEND_CLASS (class);
shell_backend_class->shell_view_type = E_TYPE_MAIL_SHELL_VIEW;
@@ -689,6 +685,95 @@ e_mail_shell_backend_type_register (GTypeModule *type_module)
e_mail_shell_backend_register_type (type_module);
}
+void
+e_mail_shell_backend_new_account (EMailShellBackend *mail_shell_backend,
+ GtkWindow *parent)
+{
+ EMailShellBackendPrivate *priv;
+
+ g_return_if_fail (mail_shell_backend != NULL);
+ g_return_if_fail (E_IS_MAIL_SHELL_BACKEND (mail_shell_backend));
+
+ priv = mail_shell_backend->priv;
+
+ if (priv->assistant) {
+ gtk_window_present (GTK_WINDOW (priv->assistant));
+ } else {
+ EMAccountEditor *emae;
+ EShell *shell;
+
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (mail_shell_backend));
+
+ if (!e_shell_get_express_mode (shell)) {
+ /** @HookPoint-EMConfig: New Mail Account Assistant
+ * @Id: org.gnome.evolution.mail.config.accountAssistant
+ * @Type: E_CONFIG_ASSISTANT
+ * @Class: org.gnome.evolution.mail.config:1.0
+ * @Target: EMConfigTargetAccount
+ *
+ * The new mail account assistant.
+ */
+ emae = em_account_editor_new (
+ NULL, EMAE_ASSISTANT, E_MAIL_BACKEND (mail_shell_backend),
+ "org.gnome.evolution.mail.config.accountAssistant");
+ e_config_create_window (
+ E_CONFIG (emae->config), NULL,
+ _("Evolution Account Assistant"));
+ priv->assistant = E_CONFIG (emae->config)->window;
+ g_object_set_data_full (
+ G_OBJECT (priv->assistant), "AccountEditor",
+ emae, (GDestroyNotify) g_object_unref);
+ } else {
+ priv->assistant = mail_capplet_shell_new (0, TRUE, FALSE);
+ }
+
+ g_object_add_weak_pointer (G_OBJECT (priv->assistant), &priv->assistant);
+ gtk_window_set_transient_for (GTK_WINDOW (priv->assistant), parent);
+ gtk_widget_show (priv->assistant);
+ }
+}
+
+void
+e_mail_shell_backend_edit_account (EMailShellBackend *mail_shell_backend,
+ GtkWindow *parent,
+ EAccount *account)
+{
+ EMailShellBackendPrivate *priv;
+ EMAccountEditor *emae;
+
+ g_return_if_fail (mail_shell_backend != NULL);
+ g_return_if_fail (E_IS_MAIL_SHELL_BACKEND (mail_shell_backend));
+ g_return_if_fail (account != NULL);
+
+ priv = mail_shell_backend->priv;
+
+ if (priv->editor != NULL) {
+ gtk_window_present (GTK_WINDOW (priv->editor));
+ return;
+ }
+
+ /** @HookPoint-EMConfig: Mail Account Editor
+ * @Id: org.gnome.evolution.mail.config.accountEditor
+ * @Type: E_CONFIG_BOOK
+ * @Class: org.gnome.evolution.mail.config:1.0
+ * @Target: EMConfigTargetAccount
+ *
+ * The account editor window.
+ */
+ emae = em_account_editor_new (
+ account, EMAE_NOTEBOOK, E_MAIL_BACKEND (mail_shell_backend),
+ "org.gnome.evolution.mail.config.accountEditor");
+ e_config_create_window (
+ E_CONFIG (emae->config), parent, _("Account Editor"));
+ priv->editor = E_CONFIG (emae->config)->window;
+ g_object_set_data_full (
+ G_OBJECT (priv->editor), "AccountEditor",
+ emae, (GDestroyNotify) g_object_unref);
+
+ g_object_add_weak_pointer (G_OBJECT (priv->editor), &priv->editor);
+ gtk_widget_show (priv->editor);
+}
+
/******************* Code below here belongs elsewhere. *******************/
#include "filter/e-filter-option.h"
diff --git a/modules/mail/e-mail-shell-backend.h b/modules/mail/e-mail-shell-backend.h
index 9d9a8e1dad..c9c23d045d 100644
--- a/modules/mail/e-mail-shell-backend.h
+++ b/modules/mail/e-mail-shell-backend.h
@@ -22,6 +22,7 @@
#ifndef E_MAIL_SHELL_BACKEND_H
#define E_MAIL_SHELL_BACKEND_H
+#include <libedataserver/e-account.h>
#include <mail/e-mail-backend.h>
/* Standard GObject macros */
@@ -58,9 +59,14 @@ struct _EMailShellBackendClass {
EMailBackendClass parent_class;
};
-GType e_mail_shell_backend_get_type (void);
-void e_mail_shell_backend_type_register
- (GTypeModule *type_module);
+GType e_mail_shell_backend_get_type (void);
+void e_mail_shell_backend_type_register (GTypeModule *type_module);
+
+void e_mail_shell_backend_new_account (EMailShellBackend *mail_shell_backend,
+ GtkWindow *parent);
+void e_mail_shell_backend_edit_account (EMailShellBackend *mail_shell_backend,
+ GtkWindow *parent,
+ EAccount *account);
/* XXX Find a better place for this function. */
GSList * e_mail_labels_get_filter_options (void);
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index 407f17ef78..c5c51a715a 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -114,6 +114,37 @@ action_mail_account_disable_cb (GtkAction *action,
}
static void
+action_mail_account_properties_cb (GtkAction *action,
+ EMailShellView *mail_shell_view)
+{
+ EMailShellSidebar *mail_shell_sidebar;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
+ EShellBackend *shell_backend;
+ EMFolderTree *folder_tree;
+ CamelService *service;
+ CamelStore *store;
+ const gchar *uid;
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+
+ shell_view = E_SHELL_VIEW (mail_shell_view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell_window = e_shell_view_get_shell_window (shell_view);
+
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+ store = em_folder_tree_get_selected_store (folder_tree);
+ g_return_if_fail (store != NULL);
+
+ service = CAMEL_SERVICE (store);
+ uid = camel_service_get_uid (service);
+
+ e_mail_shell_backend_edit_account (E_MAIL_SHELL_BACKEND (shell_backend),
+ GTK_WINDOW (shell_window),
+ e_get_account_by_uid (uid));
+}
+
+static void
action_mail_create_search_folder_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
@@ -1158,6 +1189,13 @@ static GtkActionEntry mail_entries[] = {
N_("Permanently remove all the deleted messages from all folders"),
G_CALLBACK (action_mail_folder_expunge_cb) },
+ { "mail-account-properties",
+ GTK_STOCK_PROPERTIES,
+ N_("_Properties"),
+ NULL,
+ N_("Edit properties of this account"),
+ G_CALLBACK (action_mail_account_properties_cb) },
+
{ "mail-download",
NULL,
N_("_Download Messages for Offline Usage"),
@@ -1421,6 +1459,10 @@ static EPopupActionEntry mail_popup_entries[] = {
NULL,
"mail-account-expunge" },
+ { "mail-popup-account-properties",
+ NULL,
+ "mail-account-properties" },
+
{ "mail-popup-flush-outbox",
NULL,
"mail-flush-outbox" },
diff --git a/modules/mail/e-mail-shell-view-actions.h b/modules/mail/e-mail-shell-view-actions.h
index c6ca167e14..ac682b3563 100644
--- a/modules/mail/e-mail-shell-view-actions.h
+++ b/modules/mail/e-mail-shell-view-actions.h
@@ -29,6 +29,8 @@
E_SHELL_WINDOW_ACTION ((window), "mail-account-disable")
#define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_EXPUNGE(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-account-expunge")
+#define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_PROPERTIES(window) \
+ E_SHELL_WINDOW_ACTION ((window), "mail-account-properties")
#define E_SHELL_WINDOW_ACTION_MAIL_ADD_SENDER(window) \
E_SHELL_WINDOW_ACTION ((window), "mail-add-sender")
#define E_SHELL_WINDOW_ACTION_MAIL_CARET_MODE(window) \
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 9929d8ae0e..f0661cf524 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -952,6 +952,10 @@ mail_shell_view_update_actions (EShellView *shell_view)
sensitive = folder_is_trash;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (MAIL_ACCOUNT_PROPERTIES);
+ sensitive = account != NULL;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (MAIL_FLUSH_OUTBOX);
sensitive = folder_is_outbox;
gtk_action_set_sensitive (action, sensitive);
diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c
index c6b132ebbb..08434d1a20 100644
--- a/modules/mail/em-account-prefs.c
+++ b/modules/mail/em-account-prefs.c
@@ -30,6 +30,7 @@
#endif
#include "em-account-prefs.h"
+#include "e-mail-shell-backend.h"
#include <glib/gi18n.h>
@@ -54,8 +55,6 @@
struct _EMAccountPrefsPrivate {
EMailBackend *backend;
- gpointer assistant; /* weak pointer */
- gpointer editor; /* weak pointer */
};
enum {
@@ -142,18 +141,6 @@ account_prefs_dispose (GObject *object)
priv->backend = NULL;
}
- if (priv->assistant != NULL) {
- g_object_remove_weak_pointer (
- G_OBJECT (priv->assistant), &priv->assistant);
- priv->assistant = NULL;
- }
-
- if (priv->editor != NULL) {
- g_object_remove_weak_pointer (
- G_OBJECT (priv->editor), &priv->editor);
- priv->editor = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (em_account_prefs_parent_class)->dispose (object);
}
@@ -179,45 +166,14 @@ static void
account_prefs_add_account (EMailAccountManager *manager)
{
EMAccountPrefsPrivate *priv;
- EMAccountEditor *emae;
gpointer parent;
priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
- if (priv->assistant != NULL) {
- gtk_window_present (GTK_WINDOW (priv->assistant));
- return;
- }
-
parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
- if (!e_shell_get_express_mode (e_shell_get_default ())) {
- /** @HookPoint-EMConfig: New Mail Account Assistant
- * @Id: org.gnome.evolution.mail.config.accountAssistant
- * @Type: E_CONFIG_ASSISTANT
- * @Class: org.gnome.evolution.mail.config:1.0
- * @Target: EMConfigTargetAccount
- *
- * The new mail account assistant.
- */
- emae = em_account_editor_new (
- NULL, EMAE_ASSISTANT, priv->backend,
- "org.gnome.evolution.mail.config.accountAssistant");
- e_config_create_window (
- E_CONFIG (emae->config), NULL,
- _("Evolution Account Assistant"));
- priv->assistant = E_CONFIG (emae->config)->window;
- g_object_set_data_full (
- G_OBJECT (priv->assistant), "AccountEditor",
- emae, (GDestroyNotify) g_object_unref);
- } else {
- priv->assistant = mail_capplet_shell_new (0, TRUE, FALSE);
- }
-
- g_object_add_weak_pointer (G_OBJECT (priv->assistant), &priv->assistant);
- gtk_window_set_transient_for (GTK_WINDOW (priv->assistant), parent);
- gtk_widget_show (priv->assistant);
+ e_mail_shell_backend_new_account (E_MAIL_SHELL_BACKEND (priv->backend), parent);
}
static void
@@ -225,39 +181,14 @@ account_prefs_edit_account (EMailAccountManager *manager,
EAccount *account)
{
EMAccountPrefsPrivate *priv;
- EMAccountEditor *emae;
gpointer parent;
priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
- if (priv->editor != NULL) {
- gtk_window_present (GTK_WINDOW (priv->editor));
- return;
- }
-
parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
- /** @HookPoint-EMConfig: Mail Account Editor
- * @Id: org.gnome.evolution.mail.config.accountEditor
- * @Type: E_CONFIG_BOOK
- * @Class: org.gnome.evolution.mail.config:1.0
- * @Target: EMConfigTargetAccount
- *
- * The account editor window.
- */
- emae = em_account_editor_new (
- account, EMAE_NOTEBOOK, priv->backend,
- "org.gnome.evolution.mail.config.accountEditor");
- e_config_create_window (
- E_CONFIG (emae->config), parent, _("Account Editor"));
- priv->editor = E_CONFIG (emae->config)->window;
- g_object_set_data_full (
- G_OBJECT (priv->editor), "AccountEditor",
- emae, (GDestroyNotify) g_object_unref);
-
- g_object_add_weak_pointer (G_OBJECT (priv->editor), &priv->editor);
- gtk_widget_show (priv->editor);
+ e_mail_shell_backend_edit_account (E_MAIL_SHELL_BACKEND (priv->backend), parent, account);
}
static void