aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-account-prefs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/em-account-prefs.c')
-rw-r--r--mail/em-account-prefs.c676
1 files changed, 213 insertions, 463 deletions
diff --git a/mail/em-account-prefs.c b/mail/em-account-prefs.c
index be431db9cc..82342de3c9 100644
--- a/mail/em-account-prefs.c
+++ b/mail/em-account-prefs.c
@@ -1,4 +1,6 @@
/*
+ * em-account-prefs.c
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -13,13 +15,17 @@
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
- * Authors:
- * Jeffrey Stedfast <fejj@ximian.com>
- *
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
+/* XXX EAccountManager handles all the user interface stuff. This subclass
+ * applies policies using mailer resources that EAccountManager does not
+ * have access to. The desire is to someday move account management
+ * completely out of the mailer, perhaps to evolution-data-server. */
+
+#include "em-account-prefs.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -28,550 +34,294 @@
#include <glib/gi18n.h>
-#include "mail-component.h"
-#include "mail-config.h"
-#include "mail-ops.h"
-#include "mail-send-recv.h"
-
-#include "libedataserver/e-account-list.h"
#include "e-util/e-error.h"
-#include "e-util/e-util-private.h"
-
-#include "em-account-prefs.h"
+#include "em-config.h"
#include "em-account-editor.h"
+#include "e-mail-shell-backend.h"
-static void em_account_prefs_class_init (EMAccountPrefsClass *class);
-static void em_account_prefs_init (EMAccountPrefs *prefs);
-static void em_account_prefs_finalise (GObject *obj);
-static void em_account_prefs_destroy (GtkObject *object);
-
-static void mail_accounts_load (EMAccountPrefs *prefs);
-
-
-static GtkVBoxClass *parent_class = NULL;
+#define EM_ACCOUNT_PREFS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), EM_TYPE_ACCOUNT_PREFS, EMAccountPrefsPrivate))
+struct _EMAccountPrefsPrivate {
+ gpointer druid; /* weak pointer */
+ gpointer editor; /* weak pointer */
+};
-#define PREFS_WINDOW(prefs) GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW))
+static gpointer parent_class;
-
-GType
-em_account_prefs_get_type (void)
+static void
+account_prefs_enable_account_cb (EAccountTreeView *tree_view)
{
- static GType type = 0;
+ EAccount *account;
- if (!type) {
- GTypeInfo type_info = {
- sizeof (EMAccountPrefsClass),
- NULL, NULL,
- (GClassInitFunc) em_account_prefs_class_init,
- NULL, NULL,
- sizeof (EMAccountPrefs),
- 0,
- (GInstanceInitFunc) em_account_prefs_init,
- };
-
- type = g_type_register_static (gtk_vbox_get_type (), "EMAccountPrefs", &type_info, 0);
- }
+ account = e_account_tree_view_get_selected (tree_view);
+ g_return_if_fail (account != NULL);
- return type;
+ e_mail_shell_backend_load_store_by_uri (
+ global_mail_shell_backend,
+ account->source->url, account->name);
}
static void
-em_account_prefs_class_init (EMAccountPrefsClass *klass)
+account_prefs_disable_account_cb (EAccountTreeView *tree_view)
{
- GtkObjectClass *gtk_object_class = (GtkObjectClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
-
- parent_class = g_type_class_ref (gtk_vbox_get_type ());
+ EAccountList *account_list;
+ EAccount *account;
+ gpointer parent;
+ gint response;
- gtk_object_class->destroy = em_account_prefs_destroy;
-
- object_class->finalize = em_account_prefs_finalise;
-}
+ account = e_account_tree_view_get_selected (tree_view);
+ g_return_if_fail (account != NULL);
-static void
-em_account_prefs_init (EMAccountPrefs *prefs)
-{
- prefs->druid = NULL;
- prefs->editor = NULL;
-}
+ account_list = e_account_tree_view_get_account_list (tree_view);
+ g_return_if_fail (account_list != NULL);
-static void
-em_account_prefs_destroy (GtkObject *obj)
-{
- EMAccountPrefs *prefs = (EMAccountPrefs *) obj;
+ if (!e_account_list_account_has_proxies (account_list, account))
+ return;
- prefs->destroyed = TRUE;
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (tree_view));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
- GTK_OBJECT_CLASS (parent_class)->destroy (obj);
-}
+ response = e_error_run (
+ parent, "mail:ask-delete-proxy-accounts", NULL);
-static void
-em_account_prefs_finalise (GObject *obj)
-{
- EMAccountPrefs *prefs = (EMAccountPrefs *) obj;
+ if (response != GTK_RESPONSE_YES) {
+ g_signal_stop_emission_by_name (tree_view, "disable-account");
+ return;
+ }
- g_object_unref (prefs->gui);
+ e_account_list_remove_account_proxies (account_list, account);
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ e_mail_shell_backend_remove_store_by_uri (
+ global_mail_shell_backend, account->source->url);
}
static void
-account_add_finished (EMAccountPrefs *prefs, GObject *deadbeef)
+account_prefs_add_account (EAccountManager *manager)
{
- /* Either Cancel or Finished was clicked in the druid so reload the accounts */
- prefs->druid = NULL;
+ EMAccountPrefsPrivate *priv;
+ EMAccountEditor *emae;
+ gpointer parent;
- if (!prefs->destroyed)
- mail_accounts_load (prefs);
+ priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
- g_object_unref (prefs);
-}
-
-#include "em-config.h"
-
-static void
-account_add_clicked (GtkButton *button, gpointer user_data)
-{
- EMAccountPrefs *prefs = (EMAccountPrefs *) user_data;
-
- if (prefs->druid == NULL) {
- EMAccountEditor *emae;
-
- /** @HookPoint-EMConfig: New Mail Account Druid
- * @Id: org.gnome.evolution.mail.config.accountDruid
- * @Type: E_CONFIG_DRUID
- * @Class: org.gnome.evolution.mail.config:1.0
- * @Target: EMConfigTargetAccount
- *
- * The new mail account druid.
- */
- emae = em_account_editor_new(NULL, EMAE_DRUID, "org.gnome.evolution.mail.config.accountDruid");
- prefs->druid = emae->editor;
-
- gtk_window_set_transient_for((GtkWindow *)prefs->druid, (GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)prefs));
- g_object_ref(prefs);
- /* rather nasty hack to reload the accounts, it should just listen to the e-account-list */
- g_object_weak_ref((GObject *) prefs->druid, (GWeakNotify) account_add_finished, prefs);
- gtk_widget_show(emae->editor);
- } else {
- gdk_window_raise (prefs->druid->window);
+ if (priv->druid != NULL) {
+ gtk_window_present (GTK_WINDOW (priv->druid));
+ return;
}
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ /** @HookPoint-EMConfig: New Mail Account Druid
+ * @Id: org.gnome.evolution.mail.config.accountDruid
+ * @Type: E_CONFIG_DRUID
+ * @Class: org.gnome.evolution.mail.config:1.0
+ * @Target: EMConfigTargetAccount
+ *
+ * The new mail account druid.
+ */
+ emae = em_account_editor_new (
+ NULL, EMAE_DRUID,
+ "org.gnome.evolution.mail.config.accountDruid");
+ priv->druid = emae->editor;
+
+ g_object_add_weak_pointer (G_OBJECT (priv->druid), &priv->druid);
+ gtk_window_set_transient_for (GTK_WINDOW (priv->druid), parent);
+ gtk_widget_show (priv->druid);
}
static void
-account_edit_finished (EMAccountPrefs *prefs, GObject *deadbeef)
+account_prefs_edit_account (EAccountManager *manager)
{
- prefs->editor = NULL;
-
- if (!prefs->destroyed)
- mail_accounts_load (prefs);
+ EMAccountPrefsPrivate *priv;
+ EMAccountEditor *emae;
+ EAccountTreeView *tree_view;
+ EAccountList *account_list;
+ EAccount *account;
+ gpointer parent;
- g_object_unref (prefs);
-}
+ priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
-static void
-account_edit_clicked (GtkButton *button, gpointer user_data)
-{
- EMAccountPrefs *prefs = (EMAccountPrefs *) user_data;
-
- if (prefs->editor == NULL) {
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- selection = gtk_tree_view_get_selection (prefs->table);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- gtk_tree_model_get (model, &iter, 3, &account, -1);
-
- if (account && !account->parent_uid && !mail_config_has_proxies (account)) {
- EMAccountEditor *emae;
-
- /** @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, "org.gnome.evolution.mail.config.accountEditor");
- prefs->editor = emae->editor;
-
- gtk_window_set_transient_for((GtkWindow *)prefs->editor, (GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)prefs));
- g_object_ref(prefs);
- /* rather nasty hack to reload the accounts, it should just listen to the e-account-list */
- g_object_weak_ref((GObject *)prefs->editor, (GWeakNotify) account_edit_finished, prefs);
- gtk_widget_show(emae->editor);
- }
- } else {
- gdk_window_raise (prefs->editor->window);
+ if (priv->editor != NULL) {
+ gtk_window_present (GTK_WINDOW (priv->editor));
+ return;
}
+
+ account_list = e_account_manager_get_account_list (manager);
+ tree_view = e_account_manager_get_tree_view (manager);
+ account = e_account_tree_view_get_selected (tree_view);
+ g_return_if_fail (account != NULL);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
+ parent = GTK_WIDGET_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,
+ "org.gnome.evolution.mail.config.accountEditor");
+ priv->editor = emae->editor;
+
+ g_object_add_weak_pointer (G_OBJECT (priv->editor), &priv->editor);
+ gtk_window_set_transient_for (GTK_WINDOW (priv->editor), parent);
+ gtk_widget_show (priv->editor);
}
static void
-account_delete_clicked (GtkButton *button, gpointer user_data)
+account_prefs_delete_account (EAccountManager *manager)
{
- EMAccountPrefs *prefs = user_data;
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- EAccountList *accounts;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gint ans;
- gboolean has_proxies = FALSE;
-
- selection = gtk_tree_view_get_selection (prefs->table);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- gtk_tree_model_get (model, &iter, 3, &account, -1);
-
- /* make sure we have a valid account selected and that we aren't editing anything... */
- if (account == NULL || prefs->editor != NULL)
+ EMAccountPrefsPrivate *priv;
+ EAccountTreeView *tree_view;
+ EAccountList *account_list;
+ EAccount *account;
+ gboolean has_proxies;
+ gpointer parent;
+ gint response;
+
+ priv = EM_ACCOUNT_PREFS_GET_PRIVATE (manager);
+
+ account_list = e_account_manager_get_account_list (manager);
+ tree_view = e_account_manager_get_tree_view (manager);
+ account = e_account_tree_view_get_selected (tree_view);
+ g_return_if_fail (account != NULL);
+
+ /* Make sure we aren't editing anything... */
+ if (priv->editor != NULL)
return;
- has_proxies = mail_config_has_proxies (account);
- ans = e_error_run(PREFS_WINDOW(prefs), has_proxies?"mail:ask-delete-account-with-proxies":"mail:ask-delete-account",NULL);
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (manager));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
- if (ans == GTK_RESPONSE_YES) {
- gint len;
+ has_proxies =
+ e_account_list_account_has_proxies (account_list, account);
- /* remove it from the folder-tree in the shell */
- if (account->enabled && account->source && account->source->url)
- mail_component_remove_store_by_uri (mail_component_peek (), account->source->url);
+ response = e_error_run (
+ parent, has_proxies ?
+ "mail:ask-delete-account-with-proxies" :
+ "mail:ask-delete-account", NULL);
- /* remove all the proxies account has created*/
- if (has_proxies)
- mail_config_remove_account_proxies (account);
-
- /* remove it from the config file */
- mail_config_remove_account (account);
- accounts = mail_config_get_accounts ();
-
- mail_config_write ();
-
- gtk_list_store_remove ((GtkListStore *) model, &iter);
-
- len = e_list_length ((EList *) accounts);
- if (len > 0) {
- if ( !gtk_list_store_iter_is_valid ((GtkListStore *) model, &iter))
- gtk_tree_model_get_iter_first (model, &iter);
-
- gtk_tree_selection_select_iter (selection, &iter);
- } else {
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), FALSE);
- }
+ if (response != GTK_RESPONSE_YES) {
+ g_signal_stop_emission_by_name (manager, "delete-account");
+ return;
}
-}
-static void
-account_default_clicked (GtkButton *button, gpointer user_data)
-{
- EMAccountPrefs *prefs = user_data;
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ /* Remove the account from the folder tree. */
+ if (account->enabled && account->source && account->source->url)
+ e_mail_shell_backend_remove_store_by_uri (
+ global_mail_shell_backend, account->source->url);
- selection = gtk_tree_view_get_selection (prefs->table);
- if (gtk_tree_selection_get_selected (selection, &model, &iter))
- gtk_tree_model_get (model, &iter, 3, &account, -1);
+ /* Remove all the proxies the account has created. */
+ if (has_proxies)
+ e_account_list_remove_account_proxies (account_list, account);
- if (account) {
- mail_config_set_default_account (account);
+ /* Remove it from the config file. */
+ e_account_list_remove (account_list, account);
- mail_config_write ();
-
- mail_accounts_load (prefs);
- }
+ e_account_list_save (account_list);
}
static void
-account_able_changed(EAccount *account)
+account_prefs_dispose (GObject *object)
{
- MailComponent *component = mail_component_peek ();
+ EMAccountPrefsPrivate *priv;
- /* FIXME: do this directly by listening to the mail accounts changed events in the relevant components */
+ priv = EM_ACCOUNT_PREFS_GET_PRIVATE (object);
- if (account->source->url) {
- if (account->enabled)
- mail_component_load_store_by_uri (component,
- account->source->url,
- account->name);
- else
- mail_component_remove_store_by_uri (component, account->source->url);
+ if (priv->druid != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->druid), &priv->druid);
+ priv->druid = NULL;
}
- mail_config_write ();
-}
-
-static void
-account_able_toggled (GtkCellRendererToggle *renderer, gchar *arg1, gpointer user_data)
-{
- EMAccountPrefs *prefs = user_data;
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- path = gtk_tree_path_new_from_string (arg1);
- model = gtk_tree_view_get_model (prefs->table);
- selection = gtk_tree_view_get_selection (prefs->table);
-
- if (gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_model_get (model, &iter, 3, &account, -1);
-
- if (mail_config_has_proxies (account)) {
- gint ans;
-
- ans = e_error_run(PREFS_WINDOW(prefs), "mail:ask-delete-proxy-accounts",NULL);
-
- if (ans == GTK_RESPONSE_NO) {
- gtk_tree_path_free (path);
- return;
- }
-
- mail_config_remove_account_proxies (account);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), 1);
- }
-
- account->enabled = !account->enabled;
- e_account_list_change(mail_config_get_accounts(), account);
- account_able_changed (account);
- gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1);
-
- /* let the rest of the application know it changed */
+ if (priv->editor != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->editor), &priv->editor);
+ priv->editor = NULL;
}
- gtk_tree_path_free (path);
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-account_double_click (GtkTreeView *treeview, GtkTreePath *path,
- GtkTreeViewColumn *column, EMAccountPrefs *prefs)
+account_prefs_class_init (EMAccountPrefsClass *class)
{
- account_edit_clicked (NULL, prefs);
-}
+ GObjectClass *object_class;
+ EAccountManagerClass *account_manager_class;
-static void
-account_cursor_change (GtkTreeSelection *selection, EMAccountPrefs *prefs)
-{
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- const gchar *url = NULL;
- gint state;
- EAccount *default_account;
- default_account = mail_config_get_default_account ();
-
- state = gconf_client_key_is_writable(mail_config_get_gconf_client(), "/apps/evolution/mail/accounts", NULL);
- if (state) {
- state = gtk_tree_selection_get_selected (selection, &model, &iter);
- if (state) {
- gtk_tree_model_get (model, &iter, 3, &account, -1);
- url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
- } else {
- gtk_widget_grab_focus (GTK_WIDGET (prefs->mail_add));
- }
- gtk_widget_set_sensitive (GTK_WIDGET (prefs), TRUE);
- } else {
- gtk_widget_set_sensitive (GTK_WIDGET (prefs), FALSE);
- }
-
- if( url != NULL )
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), !mail_config_has_proxies(account));
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMAccountPrefsPrivate));
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), state);
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = account_prefs_dispose;
- if(account == default_account)
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), FALSE);
- else
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), state);
+ account_manager_class = E_ACCOUNT_MANAGER_CLASS (class);
+ account_manager_class->add_account = account_prefs_add_account;
+ account_manager_class->edit_account = account_prefs_edit_account;
+ account_manager_class->delete_account = account_prefs_delete_account;
}
static void
-mail_accounts_load (EMAccountPrefs *prefs)
-{
- EAccount *default_account;
- EAccountList *accounts;
- GtkListStore *model;
- GtkTreeIter iter;
- gchar *name, *val;
- EIterator *node;
- gint row = 0;
- GtkTreeSelection *selection;
-
- model = (GtkListStore *) gtk_tree_view_get_model (prefs->table);
- gtk_list_store_clear (model);
-
- default_account = mail_config_get_default_account ();
-
- accounts = mail_config_get_accounts ();
- node = e_list_get_iterator ((EList *) accounts);
- selection = gtk_tree_view_get_selection(prefs->table);
-
- while (e_iterator_is_valid (node)) {
- EAccount *account;
- CamelURL *url;
-
- account = (EAccount *) e_iterator_get (node);
-
- if (!account->parent_uid) {
- url = account->source && account->source->url ? camel_url_new (account->source->url, NULL) : NULL;
-
- gtk_list_store_append (model, &iter);
- if (account == default_account) {
- /* translators: default account indicator */
- name = val = g_strdup_printf ("%s %s", account->name, _("[Default]"));
- } else {
- val = account->name;
- name = NULL;
- }
-
- gtk_list_store_set (model, &iter,
- 0, account->enabled,
- 1, val,
- 2, url && url->protocol ? url->protocol : (gchar *) _("None"),
- 3, account,
- -1);
- g_free (name);
-
- if (url)
- camel_url_free (url);
-
- /* select the first row by default */
- if (row == 0 && !prefs->changed)
- gtk_tree_selection_select_iter (selection, &iter);
- row++;
- }
-
- e_iterator_next (node);
- }
-
- g_object_unref (node);
-}
-
-
-
-GtkWidget *em_account_prefs_treeview_new (gchar *widget_name, gchar *string1, gchar *string2,
- gint int1, gint int2);
-
-GtkWidget *
-em_account_prefs_treeview_new (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2)
+account_prefs_init (EMAccountPrefs *prefs)
{
- GtkWidget *table, *scrolled;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkListStore *model;
-
- scrolled = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
-
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set ((GObject *) renderer, "activatable", TRUE, NULL);
-
- model = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
- table = gtk_tree_view_new_with_model ((GtkTreeModel *) model);
- g_object_unref (model);
- gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Enabled"),
- renderer, "active", 0, NULL);
-
- g_object_set_data ((GObject *) scrolled, "renderer", renderer);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Account name"),
- renderer, "text", 1, NULL);
- gtk_tree_view_insert_column_with_attributes ((GtkTreeView *)table, -1, _("Protocol"),
- renderer, "text", 2, NULL);
- selection = gtk_tree_view_get_selection ((GtkTreeView *) table);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- gtk_tree_view_set_headers_visible ((GtkTreeView *) table, TRUE);
- atk_object_set_name (gtk_widget_get_accessible (table), _("Mail Accounts"));
-
-
- /* FIXME: column auto-resize? */
- /* Is this needed?
- gtk_tree_view_column_set_alignment (gtk_tree_view_get_column (prefs->table, 0), 1.0);*/
+ EAccountManager *manager;
+ EAccountTreeView *tree_view;
- gtk_container_add (GTK_CONTAINER (scrolled), table);
+ prefs->priv = EM_ACCOUNT_PREFS_GET_PRIVATE (prefs);
- g_object_set_data ((GObject *) scrolled, "table", table);
+ manager = E_ACCOUNT_MANAGER (prefs);
+ tree_view = e_account_manager_get_tree_view (manager);
- gtk_widget_show (scrolled);
- gtk_widget_show (table);
+ g_signal_connect (
+ tree_view, "enable-account",
+ G_CALLBACK (account_prefs_enable_account_cb), NULL);
- return scrolled;
+ g_signal_connect (
+ tree_view, "disable-account",
+ G_CALLBACK (account_prefs_disable_account_cb), NULL);
}
-static void
-em_account_prefs_construct (EMAccountPrefs *prefs)
+GType
+em_account_prefs_get_type (void)
{
- GtkWidget *toplevel, *widget;
- GtkCellRenderer *renderer;
- GladeXML *gui;
- gchar *gladefile;
-
- gladefile = g_build_filename (EVOLUTION_GLADEDIR,
- "mail-config.glade",
- NULL);
- gui = glade_xml_new (gladefile, "accounts_tab", NULL);
- g_free (gladefile);
-
- prefs->gui = gui;
-
- /* get our toplevel widget */
- toplevel = glade_xml_get_widget (gui, "toplevel");
-
- /* reparent */
- g_object_ref (toplevel);
- gtk_container_remove (GTK_CONTAINER (toplevel->parent), toplevel);
- gtk_container_add (GTK_CONTAINER (prefs), toplevel);
- g_object_unref (toplevel);
-
- widget = glade_xml_get_widget (gui, "etableMailAccounts");
-
- prefs->table = (GtkTreeView *) g_object_get_data ((GObject *) widget, "table");
-
- renderer = g_object_get_data ((GObject *) widget, "renderer");
- g_signal_connect (renderer, "toggled", G_CALLBACK (account_able_toggled), prefs);
-
- prefs->changed = FALSE;
- mail_accounts_load (prefs);
- prefs->changed = TRUE;
-
- prefs->mail_add = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountAdd"));
- g_signal_connect (prefs->mail_add, "clicked", G_CALLBACK (account_add_clicked), prefs);
-
- prefs->mail_edit = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountEdit"));
- g_signal_connect (prefs->mail_edit, "clicked", G_CALLBACK (account_edit_clicked), prefs);
-
- prefs->mail_delete = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountDelete"));
- g_signal_connect (prefs->mail_delete, "clicked", G_CALLBACK (account_delete_clicked), prefs);
+ static GType type = 0;
- prefs->mail_default = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountDefault"));
- g_signal_connect (prefs->mail_default, "clicked", G_CALLBACK (account_default_clicked), prefs);
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EMAccountPrefsClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) account_prefs_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMAccountPrefs),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) account_prefs_init,
+ NULL /* value_table */
+ };
- g_signal_connect (gtk_tree_view_get_selection (prefs->table),
- "changed", G_CALLBACK (account_cursor_change), prefs);
- g_signal_connect (prefs->table, "row-activated", G_CALLBACK (account_double_click), prefs);
+ type = g_type_register_static (
+ E_TYPE_ACCOUNT_MANAGER, "EMAccountPrefs",
+ &type_info, 0);
+ }
- account_cursor_change(gtk_tree_view_get_selection(prefs->table), prefs);
+ return type;
}
GtkWidget *
-em_account_prefs_new (GNOME_Evolution_Shell shell)
+em_account_prefs_new (EAccountList *account_list)
{
- EMAccountPrefs *new;
-
- new = (EMAccountPrefs *) g_object_new (em_account_prefs_get_type (), NULL);
- em_account_prefs_construct (new);
- new->shell = shell;
+ g_return_val_if_fail (E_IS_ACCOUNT_LIST (account_list), NULL);
- return (GtkWidget *) new;
+ return g_object_new (
+ EM_TYPE_ACCOUNT_PREFS, "account-list", account_list, NULL);
}