aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-accounts.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-accounts.c')
-rw-r--r--mail/mail-accounts.c582
1 files changed, 326 insertions, 256 deletions
diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c
index fb06efd6ba..1ad5c066fa 100644
--- a/mail/mail-accounts.c
+++ b/mail/mail-accounts.c
@@ -27,10 +27,16 @@
#include "mail-accounts.h"
+#include <libgnomeui/gnome-stock.h>
+#include <libgnomeui/gnome-messagebox.h>
+#include <gal/e-table/e-table-memory-store.h>
+#include <gal/e-table/e-table-scrolled.h>
+#include <gal/e-table/e-cell-toggle.h>
+#include <gal/util/e-unicode-i18n.h>
+#include <gal/widgets/e-unicode.h>
#include <camel/camel-url.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtktreeselection.h>
+#include <bonobo/bonobo-generic-factory.h>
#include "mail.h"
#include "mail-config.h"
@@ -40,11 +46,11 @@
#include "art/mark.xpm"
+#define USE_ETABLE 0
static void mail_accounts_tab_class_init (MailAccountsTabClass *class);
static void mail_accounts_tab_init (MailAccountsTab *prefs);
-static void mail_accounts_tab_finalise (GObject *obj);
-static void mail_accounts_tab_destroy (GtkObject *object);
+static void mail_accounts_tab_finalise (GtkObject *obj);
static void mail_accounts_load (MailAccountsTab *tab);
@@ -57,23 +63,23 @@ static GtkVBoxClass *parent_class = NULL;
#define PREFS_WINDOW(prefs) GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW))
-GType
+GtkType
mail_accounts_tab_get_type (void)
{
- static GType type = 0;
+ static GtkType type = 0;
if (!type) {
- GTypeInfo type_info = {
- sizeof (MailAccountsTabClass),
- NULL, NULL,
- (GClassInitFunc) mail_accounts_tab_class_init,
- NULL, NULL,
+ GtkTypeInfo type_info = {
+ "MailAccountsTab",
sizeof (MailAccountsTab),
- 0,
- (GInstanceInitFunc) mail_accounts_tab_init,
+ sizeof (MailAccountsTabClass),
+ (GtkClassInitFunc) mail_accounts_tab_class_init,
+ (GtkObjectInitFunc) mail_accounts_tab_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL
};
- type = g_type_register_static (gtk_vbox_get_type (), "MailAccountsTab", &type_info, 0);
+ type = gtk_type_unique (gtk_vbox_get_type (), &type_info);
}
return type;
@@ -82,14 +88,14 @@ mail_accounts_tab_get_type (void)
static void
mail_accounts_tab_class_init (MailAccountsTabClass *klass)
{
- GtkObjectClass *gtk_object_class = (GtkObjectClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
+ GtkObjectClass *object_class;
- parent_class = g_type_class_ref (gtk_vbox_get_type ());
-
- gtk_object_class->destroy = mail_accounts_tab_destroy;
+ object_class = (GtkObjectClass *) klass;
+ parent_class = gtk_type_class (gtk_vbox_get_type ());
object_class->finalize = mail_accounts_tab_finalise;
+ /* override methods */
+
/* setup static data */
disabled_pixbuf = NULL;
@@ -106,71 +112,59 @@ mail_accounts_tab_init (MailAccountsTab *prefs)
}
static void
-mail_accounts_tab_destroy (GtkObject *obj)
-{
- MailAccountsTab *prefs = (MailAccountsTab *) obj;
-
- prefs->destroyed = TRUE;
-
- GTK_OBJECT_CLASS (parent_class)->destroy (obj);
-}
-
-static void
-mail_accounts_tab_finalise (GObject *obj)
+mail_accounts_tab_finalise (GtkObject *obj)
{
MailAccountsTab *prefs = (MailAccountsTab *) obj;
- g_object_unref (prefs->gui);
+ gtk_object_unref (GTK_OBJECT (prefs->gui));
gdk_pixmap_unref (prefs->mark_pixmap);
- g_object_unref (prefs->mark_bitmap);
+ gdk_bitmap_unref (prefs->mark_bitmap);
- G_OBJECT_CLASS (parent_class)->finalize (obj);
+ ((GtkObjectClass *)(parent_class))->finalize (obj);
}
static void
-account_add_finished (MailAccountsTab *prefs, GObject *deadbeef)
+account_add_finished (GtkWidget *widget, gpointer user_data)
{
/* Either Cancel or Finished was clicked in the druid so reload the accounts */
+ MailAccountsTab *prefs = user_data;
+
prefs->druid = NULL;
- if (!prefs->destroyed)
+ if (!GTK_OBJECT_DESTROYED (prefs))
mail_accounts_load (prefs);
- g_object_unref (prefs);
+ gtk_object_unref ((GtkObject *) prefs);
}
static void
account_add_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = (MailAccountsTab *) user_data;
- GtkWidget *parent;
if (prefs->druid == NULL) {
- prefs->druid = (GtkWidget *) mail_config_druid_new ();
-
- parent = gtk_widget_get_toplevel ((GtkWidget *) prefs);
- if (GTK_WIDGET_TOPLEVEL (parent))
- gtk_window_set_transient_for ((GtkWindow *) prefs->druid, (GtkWindow *) parent);
-
- g_object_weak_ref ((GObject *) prefs->druid,
- (GWeakNotify) account_add_finished, prefs);
+ prefs->druid = (GtkWidget *) mail_config_druid_new (prefs->shell);
+ gtk_signal_connect (GTK_OBJECT (prefs->druid), "destroy",
+ GTK_SIGNAL_FUNC (account_add_finished), prefs);
gtk_widget_show (prefs->druid);
- g_object_ref (prefs);
+ gtk_object_ref ((GtkObject *) prefs);
} else {
gdk_window_raise (prefs->druid->window);
}
}
static void
-account_edit_finished (MailAccountsTab *prefs, GObject *deadbeef)
+account_edit_finished (GtkWidget *widget, gpointer user_data)
{
+ MailAccountsTab *prefs = user_data;
+
prefs->editor = NULL;
- if (!prefs->destroyed)
+ if (!GTK_OBJECT_DESTROYED (prefs))
mail_accounts_load (prefs);
- g_object_unref (prefs);
+ gtk_object_unref ((GtkObject *) prefs);
}
static void
@@ -179,26 +173,29 @@ account_edit_clicked (GtkButton *button, gpointer user_data)
MailAccountsTab *prefs = (MailAccountsTab *) 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) {
- GtkWidget *parent;
-
- parent = gtk_widget_get_toplevel ((GtkWidget *) prefs);
- parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+ int row;
+#if USE_ETABLE
+ row = e_table_get_cursor_row (prefs->table);
+#else
+ row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1;
+#endif
+ if (row >= 0) {
+ MailConfigAccount *account;
+ GtkWidget *window;
- prefs->editor = (GtkWidget *) mail_account_editor_new (account, (GtkWindow *) parent, prefs);
+ window = gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW);
- g_object_weak_ref ((GObject *) prefs->editor, (GWeakNotify) account_edit_finished, prefs);
+#if USE_ETABLE
+ account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
+#else
+ account = gtk_clist_get_row_data (prefs->table, row);
+#endif
+ prefs->editor = (GtkWidget *) mail_account_editor_new (account, GTK_WINDOW (window), prefs);
+ gtk_signal_connect (GTK_OBJECT (prefs->editor), "destroy",
+ GTK_SIGNAL_FUNC (account_edit_finished),
+ prefs);
gtk_widget_show (prefs->editor);
- g_object_ref (prefs);
+ gtk_object_ref ((GtkObject *) prefs);
}
} else {
gdk_window_raise (prefs->editor->window);
@@ -209,60 +206,66 @@ static void
account_delete_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- EAccountList *accounts;
- GtkTreeModel *model;
- GtkWidget *confirm;
- GtkTreeIter iter;
- int ans;
-
- 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);
+ const MailConfigAccount *account;
+ GnomeDialog *confirm;
+ const GSList *list;
+ int row, ans;
+
+#if USE_ETABLE
+ row = e_table_get_cursor_row (prefs->table);
+#else
+ row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1;
+#endif
/* make sure we have a valid account selected and that we aren't editing anything... */
- if (account == NULL || prefs->editor != NULL)
+ if (row < 0 || prefs->editor != NULL)
return;
- confirm = gtk_message_dialog_new (PREFS_WINDOW (prefs),
- GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
- _("Are you sure you want to delete this account?"));
-
- button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_YES);
- gtk_button_set_label (button, _("Delete"));
- gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_YES);
- gtk_widget_show ((GtkWidget *) button);
-
- button = (GtkButton *) gtk_button_new_from_stock (GTK_STOCK_NO);
- gtk_button_set_label (button, _("Don't delete"));
- gtk_dialog_add_action_widget ((GtkDialog *) confirm, (GtkWidget *) button, GTK_RESPONSE_NO);
- gtk_widget_show ((GtkWidget *) button);
-
- ans = gtk_dialog_run ((GtkDialog *) confirm);
- gtk_widget_destroy (confirm);
-
- if (ans == GTK_RESPONSE_YES) {
- int len;
+ confirm = GNOME_DIALOG (gnome_message_box_new (_("Are you sure you want to delete this account?"),
+ GNOME_MESSAGE_BOX_QUESTION,
+ NULL));
+ gnome_dialog_append_button_with_pixmap (confirm, _("Delete"), GNOME_STOCK_BUTTON_YES);
+ gnome_dialog_append_button_with_pixmap (confirm, _("Don't delete"), GNOME_STOCK_BUTTON_NO);
+ gtk_window_set_policy (GTK_WINDOW (confirm), TRUE, TRUE, TRUE);
+ gtk_window_set_modal (GTK_WINDOW (confirm), TRUE);
+ gtk_window_set_title (GTK_WINDOW (confirm), _("Really delete account?"));
+ gnome_dialog_set_parent (confirm, PREFS_WINDOW (prefs));
+ ans = gnome_dialog_run_and_close (confirm);
+
+ if (ans == 0) {
+ int select, len;
+
+#if USE_ETABLE
+ account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
+#else
+ account = gtk_clist_get_row_data (prefs->table, row);
+#endif
/* remove it from the folder-tree in the shell */
- if (account->enabled && account->source && account->source->url)
+ if (account->source && account->source->url && account->source->enabled)
mail_remove_storage_by_uri (account->source->url);
/* remove it from the config file */
- mail_config_remove_account (account);
- accounts = mail_config_get_accounts ();
+ list = mail_config_remove_account ((MailConfigAccount *) account);
mail_config_write ();
mail_autoreceive_setup ();
- gtk_list_store_remove ((GtkListStore *) model, &iter);
+#if USE_ETABLE
+ e_table_memory_store_remove (E_TABLE_MEMORY_STORE (prefs->model), row);
+#else
+ gtk_clist_remove (prefs->table, row);
+#endif
- len = e_list_length ((EList *) accounts);
+ len = list ? g_slist_length ((GSList *) list) : 0;
if (len > 0) {
- gtk_tree_selection_select_iter (selection, &iter);
+ select = row >= len ? len - 1 : row;
+#if USE_ETABLE
+ e_table_set_cursor_row (prefs->table, select);
+#else
+ gtk_clist_select_row (prefs->table, select, 0);
+#endif
} else {
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), FALSE);
@@ -276,16 +279,22 @@ static void
account_default_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
- GtkTreeSelection *selection;
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ const MailConfigAccount *account;
+ int row;
- 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 USE_ETABLE
+ row = e_table_get_cursor_row (prefs->table);
+#else
+ row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1;
+#endif
- if (account) {
+ if (row >= 0) {
+#if USE_ETABLE
+ account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
+#else
+ account = gtk_clist_get_row_data (prefs->table, row);
+#endif
+
mail_config_set_default_account (account);
mail_config_write ();
@@ -298,222 +307,259 @@ static void
account_able_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
- 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);
- account->enabled = !account->enabled;
- gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1);
-
- gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable"));
- }
+ const MailConfigAccount *account;
+ int row;
- if (account) {
+#if USE_ETABLE
+ row = e_table_get_cursor_row (prefs->table);
+#else
+ row = prefs->table->selection ? GPOINTER_TO_INT (prefs->table->selection->data) : -1;
+#endif
+
+ if (row >= 0) {
+#if USE_ETABLE
+ account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
+#else
+ account = gtk_clist_get_row_data (prefs->table, row);
+#endif
+
+ account->source->enabled = !account->source->enabled;
+
/* if the account got disabled, remove it from the
folder-tree, otherwise add it to the folder-tree */
if (account->source->url) {
- if (account->enabled)
+ if (account->source->enabled)
mail_load_storage_by_uri (prefs->shell, account->source->url, account->name);
else
mail_remove_storage_by_uri (account->source->url);
}
+#if USE_ETABLE
+
+#else
+ if (account->source->enabled)
+ gtk_clist_set_pixmap (prefs->table, row, 0,
+ prefs->mark_pixmap,
+ prefs->mark_bitmap);
+ else
+ gtk_clist_set_pixmap (prefs->table, row, 0, NULL, NULL);
+
+ gtk_clist_select_row (prefs->table, row, 0);
+#endif
+
mail_autoreceive_setup ();
mail_config_write ();
}
}
+#if USE_ETABLE
static void
-account_able_toggled (GtkCellRendererToggle *renderer, char *arg1, gpointer user_data)
+account_cursor_change (ETable *table, int row, gpointer user_data)
{
MailAccountsTab *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);
- account->enabled = !account->enabled;
- gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1);
-
- if (gtk_tree_selection_iter_is_selected (selection, &iter))
- gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable"));
- }
-
- gtk_tree_path_free (path);
- if (account) {
- /* if the account got disabled, remove it from the
- folder-tree, otherwise add it to the folder-tree */
- if (account->source->url) {
- if (account->enabled)
- mail_load_storage_by_uri (prefs->shell, account->source->url, account->name);
- else
- mail_remove_storage_by_uri (account->source->url);
- }
+ if (row >= 0) {
+ const MailConfigAccount *account;
- mail_autoreceive_setup ();
+ account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
+ if (account->source && account->source->enabled)
+ gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Disable"));
+ else
+ gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Enable"));
- mail_config_write ();
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), TRUE);
+ } 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);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), FALSE);
+
+ gtk_widget_grab_focus (GTK_WIDGET (prefs->mail_add));
}
}
static void
-account_double_click (GtkTreeView *treeview, GtkTreePath *path,
- GtkTreeViewColumn *column, MailAccountsTab *prefs)
+account_double_click (ETable *table, int row, int col, GdkEvent *event, gpointer user_data)
{
- account_edit_clicked (NULL, prefs);
+ account_edit_clicked (NULL, user_data);
}
-
+#else
static void
-account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs)
+account_cursor_change (GtkCList *table, int row, int column, GdkEventButton *event, gpointer user_data)
{
- EAccount *account = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- int state;
-
- state = gtk_tree_selection_get_selected (selection, &model, &iter);
- if (state) {
- gtk_tree_model_get (model, &iter, 3, &account, -1);
- if (account->source && account->enabled)
- gtk_button_set_label (prefs->mail_able, _("Disable"));
+ MailAccountsTab *prefs = user_data;
+
+ if (row >= 0) {
+ const MailConfigAccount *account;
+
+ account = gtk_clist_get_row_data (prefs->table, row);
+ if (account->source && account->source->enabled)
+ gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Disable"));
else
- gtk_button_set_label (prefs->mail_able, _("Enable"));
+ gtk_label_set_text (GTK_LABEL (GTK_BIN (prefs->mail_able)->child), _("Enable"));
+
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), TRUE);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), TRUE);
+
+ if (event && event->type == GDK_2BUTTON_PRESS)
+ account_edit_clicked (NULL, user_data);
} 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);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), FALSE);
+
gtk_widget_grab_focus (GTK_WIDGET (prefs->mail_add));
}
-
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), state);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), state);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), state);
- gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), state);
}
+#endif
+
static void
mail_accounts_load (MailAccountsTab *prefs)
{
- EAccount *default_account;
- EAccountList *accounts;
- GtkListStore *model;
- GtkTreeIter iter;
- char *name, *val;
- EIterator *node;
+ const GSList *node;
int row = 0;
- model = (GtkListStore *) gtk_tree_view_get_model (prefs->table);
- gtk_list_store_clear (model);
+#if USE_ETABLE
+ e_table_memory_freeze (E_TABLE_MEMORY (prefs->model));
- default_account = mail_config_get_default_account ();
+ e_table_memory_store_clear (E_TABLE_MEMORY_STORE (prefs->model));
+#else
+ gtk_clist_freeze (prefs->table);
- accounts = mail_config_get_accounts ();
- node = e_list_get_iterator ((EList *) accounts);
- while (e_iterator_is_valid (node)) {
- EAccount *account;
+ gtk_clist_clear (prefs->table);
+#endif
+
+ node = mail_config_get_accounts ();
+ while (node) {
+ const MailConfigAccount *account;
CamelURL *url;
- account = (EAccount *) e_iterator_get (node);
+ account = node->data;
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;
- }
+#if USE_ETABLE
+ e_table_memory_store_insert_list (E_TABLE_MEMORY_STORE (prefs->model),
+ row, GINT_TO_POINTER (account->source->enabled),
+ account->name,
+ url && url->protocol ? url->protocol : U_("None"));
- gtk_list_store_set (model, &iter,
- 0, account->enabled,
- 1, val,
- 2, url && url->protocol ? url->protocol : (char *) _("None"),
- 3, account,
- -1);
- g_free (name);
+ e_table_memory_set_data (E_TABLE_MEMORY (prefs->model), row, (gpointer) account);
+#else
+ {
+ const MailConfigAccount *default_account;
+ char *str, *text[3];
+
+ default_account = mail_config_get_default_account ();
+
+ str = e_utf8_to_gtk_string (GTK_WIDGET (prefs->table), account->name);
+
+ text[0] = NULL;
+ text[1] = g_strdup_printf ("%s%s%s", str, account == default_account ? " " : "",
+ account == default_account ? _("[Default]") : "");
+ text[2] = url && url->protocol ? url->protocol : (char *) _("None");
+
+ gtk_clist_insert (prefs->table, row, text);
+
+ g_free (str);
+ g_free (text[1]);
+
+ if (account->source->enabled)
+ gtk_clist_set_pixmap (prefs->table, row, 0,
+ prefs->mark_pixmap,
+ prefs->mark_bitmap);
+
+ gtk_clist_set_row_data (prefs->table, row, (gpointer) account);
+ }
+#endif
if (url)
camel_url_free (url);
+ node = node->next;
row++;
-
- e_iterator_next (node);
}
- g_object_unref (node);
+#if USE_ETABLE
+ e_table_memory_thaw (E_TABLE_MEMORY (prefs->model));
+#else
+ gtk_clist_thaw (prefs->table);
+#endif
}
-GtkWidget *mail_accounts_treeview_new (char *widget_name, char *string1, char *string2,
- int int1, int int2);
+GtkWidget *mail_accounts_etable_new (char *widget_name, char *string1, char *string2,
+ int int1, int int2);
+#if USE_ETABLE
GtkWidget *
-mail_accounts_treeview_new (char *widget_name, char *string1, char *string2, int int1, int int2)
+mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int int1, int int2)
{
- GtkWidget *table, *scrolled;
- GtkTreeSelection *selection;
- GtkCellRenderer *renderer;
- GtkListStore *model;
+ ETableModel *model;
+ ETableExtras *extras;
+ GdkPixbuf *images[2];
+ ETableMemoryStoreColumnInfo columns[] = {
+ E_TABLE_MEMORY_STORE_INTEGER,
+ E_TABLE_MEMORY_STORE_STRING,
+ E_TABLE_MEMORY_STORE_STRING,
+ E_TABLE_MEMORY_STORE_TERMINATOR,
+ };
- 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);
+ extras = e_table_extras_new ();
- renderer = gtk_cell_renderer_toggle_new ();
- g_object_set ((GObject *) renderer, "activatable", TRUE, NULL);
+ images[0] = disabled_pixbuf; /* disabled */
+ images[1] = enabled_pixbuf; /* enabled */
+ e_table_extras_add_cell (extras, "render_able", e_cell_toggle_new (0, 2, images));
- 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);
- gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Enabled"),
- renderer, "active", 0, NULL);
+ model = e_table_memory_store_new (columns);
- g_object_set_data ((GObject *) scrolled, "renderer", renderer);
+ return e_table_scrolled_new_from_spec_file (model, extras, EVOLUTION_ETSPECDIR "/mail-accounts.etspec", NULL);
+}
+#else
+GtkWidget *
+mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int int1, int int2)
+{
+ GtkWidget *table, *scrolled;
+ char *titles[3];
- 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);
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- /* FIXME: column auto-resize? */
- /* Is this needed?
- gtk_tree_view_column_set_alignment (gtk_tree_view_get_column (prefs->table, 0), 1.0);*/
+ titles[0] = _("Enabled");
+ titles[1] = _("Account name");
+ titles[2] = _("Protocol");
+ table = gtk_clist_new_with_titles (3, titles);
+ gtk_clist_set_selection_mode (GTK_CLIST (table), GTK_SELECTION_SINGLE);
+ gtk_clist_column_titles_show (GTK_CLIST (table));
gtk_container_add (GTK_CONTAINER (scrolled), table);
- g_object_set_data ((GObject *) scrolled, "table", table);
+ gtk_object_set_data (GTK_OBJECT (scrolled), "table", table);
gtk_widget_show (scrolled);
gtk_widget_show (table);
return scrolled;
}
+#endif
static void
mail_accounts_tab_construct (MailAccountsTab *prefs)
{
GtkWidget *toplevel, *widget;
- GtkCellRenderer *renderer;
GladeXML *gui;
- gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "accounts_tab", NULL);
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "accounts_tab");
prefs->gui = gui;
/* get our toplevel widget */
@@ -527,30 +573,54 @@ mail_accounts_tab_construct (MailAccountsTab *prefs)
widget = glade_xml_get_widget (gui, "etableMailAccounts");
- prefs->table = (GtkTreeView *) g_object_get_data ((GObject *) widget, "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);
+#if USE_ETABLE
+ prefs->table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget));
+ prefs->model = prefs->table->model;
- renderer = g_object_get_data ((GObject *) widget, "renderer");
- g_signal_connect (renderer, "toggled", G_CALLBACK (account_able_toggled), prefs);
+ gtk_signal_connect (GTK_OBJECT (prefs->table), "cursor_change",
+ account_cursor_change, prefs);
+
+ gtk_signal_connect (GTK_OBJECT (prefs->table), "double_click",
+ account_double_click, prefs);
mail_accounts_load (prefs);
+#else
+ prefs->table = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (widget), "table"));
+ gtk_clist_set_column_justification (prefs->table, 0, GTK_JUSTIFY_RIGHT);
+
+ gtk_signal_connect (GTK_OBJECT (prefs->table), "select-row",
+ account_cursor_change, prefs);
+
+ mail_accounts_load (prefs);
+
+ {
+ int col;
+
+ for (col = 0; col < 3; col++) {
+ gtk_clist_set_column_auto_resize (prefs->table, col, TRUE);
+ }
+ }
+#endif
prefs->mail_add = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountAdd"));
- g_signal_connect (prefs->mail_add, "clicked", G_CALLBACK (account_add_clicked), prefs);
+ gtk_signal_connect (GTK_OBJECT (prefs->mail_add), "clicked",
+ 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);
+ gtk_signal_connect (GTK_OBJECT (prefs->mail_edit), "clicked",
+ 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);
+ gtk_signal_connect (GTK_OBJECT (prefs->mail_delete), "clicked",
+ account_delete_clicked, prefs);
prefs->mail_default = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountDefault"));
- g_signal_connect (prefs->mail_default, "clicked", G_CALLBACK (account_default_clicked), prefs);
+ gtk_signal_connect (GTK_OBJECT (prefs->mail_default), "clicked",
+ account_default_clicked, prefs);
prefs->mail_able = GTK_BUTTON (glade_xml_get_widget (gui, "cmdAccountAble"));
- g_signal_connect (prefs->mail_able, "clicked", G_CALLBACK (account_able_clicked), prefs);
+ gtk_signal_connect (GTK_OBJECT (prefs->mail_able), "clicked",
+ account_able_clicked, prefs);
}
@@ -559,7 +629,7 @@ mail_accounts_tab_new (GNOME_Evolution_Shell shell)
{
MailAccountsTab *new;
- new = (MailAccountsTab *) g_object_new (mail_accounts_tab_get_type (), NULL);
+ new = (MailAccountsTab *) gtk_type_new (mail_accounts_tab_get_type ());
mail_accounts_tab_construct (new);
new->shell = shell;