aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-12-13 00:26:16 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-12-13 00:26:16 +0800
commit159b10f3d9df51f2bde9172ddb532ac76ab044ac (patch)
tree1005d6ab1433d9d0001f5cb8eadaef9a2b831e24 /mail
parenta2ce61bbf1ad2c38fbff8ee7485ba2b3cbdf58ef (diff)
downloadgsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar.gz
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar.bz2
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar.lz
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar.xz
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.tar.zst
gsoc2013-evolution-159b10f3d9df51f2bde9172ddb532ac76ab044ac.zip
Get rid of the ETable #ifdef's - we won't ever be using ETable.
2002-12-12 Jeffrey Stedfast <fejj@ximian.com> * mail-accounts.c (account_delete_clicked): Get rid of the ETable #ifdef's - we won't ever be using ETable. (account_default_clicked): Same. (account_able_clicked): Here too. (mail_accounts_load): And here. (mail_accounts_treeview_new): Renamed from etable_new since we won't ever be using an etable. (mail_accounts_tab_construct): And finally here. svn path=/trunk/; revision=19104
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog11
-rw-r--r--mail/mail-accounts.c346
2 files changed, 112 insertions, 245 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index dc2c8f52a9..8e8a3fca00 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,14 @@
+2002-12-12 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-accounts.c (account_delete_clicked): Get rid of the ETable
+ #ifdef's - we won't ever be using ETable.
+ (account_default_clicked): Same.
+ (account_able_clicked): Here too.
+ (mail_accounts_load): And here.
+ (mail_accounts_treeview_new): Renamed from etable_new since we
+ won't ever be using an etable.
+ (mail_accounts_tab_construct): And finally here.
+
2002-12-12 Not Zed <NotZed@Ximian.com>
* folder-browser.c (my_folder_browser_init): cast a-warning a-way.
diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c
index 2d2a70f9ab..a10b987a8c 100644
--- a/mail/mail-accounts.c
+++ b/mail/mail-accounts.c
@@ -27,13 +27,6 @@
#include "mail-accounts.h"
-#define USE_ETABLE 0
-
-#ifdef USE_ETABLE
-#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>
-#endif
#include <camel/camel-url.h>
#include <gtk/gtkliststore.h>
@@ -178,21 +171,14 @@ account_edit_clicked (GtkButton *button, gpointer user_data)
if (prefs->editor == NULL) {
MailConfigAccount *account = NULL;
-#if USE_ETABLE
- int row;
-
- row = e_table_get_cursor_row (prefs->table);
- if (row >=0)
- account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
-#else
GtkTreeSelection *selection;
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);
-#endif
+ 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 *window;
@@ -212,44 +198,38 @@ account_delete_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
const MailConfigAccount *account = NULL;
- GtkDialog *confirm;
- GtkButton *tmp;
- const GSList *list;
- int ans;
-
-#if USE_ETABLE
- int row;
-
- row = e_table_get_cursor_row (prefs->table);
- if (row >=0)
- account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
-#else
+ GtkWidget *confirm, *button;
GtkTreeSelection *selection;
GtkTreeModel *model;
+ const GSList *list;
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);
-#endif
+ 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);
+
/* make sure we have a valid account selected and that we aren't editing anything... */
if (account == NULL || prefs->editor != NULL)
return;
-
- confirm = (GtkDialog *)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?"));
- tmp = (GtkButton *)gtk_button_new_from_stock(GTK_STOCK_YES);
- gtk_button_set_label(tmp, _("Delete"));
- gtk_dialog_add_action_widget(confirm, (GtkWidget *)tmp, GTK_RESPONSE_YES);
- tmp = (GtkButton *)gtk_button_new_from_stock(GTK_STOCK_NO);
- gtk_button_set_label(tmp, _("Don't delete"));
- gtk_dialog_add_action_widget(confirm, (GtkWidget *)tmp, GTK_RESPONSE_NO);
- ans = gtk_dialog_run(confirm);
- gtk_widget_destroy((GtkWidget *)confirm);
- g_object_unref(confirm);
-
+
+ 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 = gtk_button_new_from_stock (GTK_STOCK_YES);
+ gtk_button_set_label ((GtkButton *) button, _("Delete"));
+ gtk_dialog_add_action_widget ((GtkDialog *) confirm, button, GTK_RESPONSE_YES);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_NO);
+ gtk_button_set_label ((GtkButton *) button, _("Don't delete"));
+ gtk_dialog_add_action_widget ((GtkDialog *) confirm, button, GTK_RESPONSE_NO);
+
+ ans = gtk_dialog_run ((GtkDialog *) confirm);
+ gtk_widget_destroy (confirm);
+ g_object_unref (confirm);
+
if (ans == GTK_RESPONSE_YES) {
int len;
@@ -264,19 +244,11 @@ account_delete_clicked (GtkButton *button, gpointer user_data)
mail_autoreceive_setup ();
-#if USE_ETABLE
- e_table_memory_store_remove (E_TABLE_MEMORY_STORE (prefs->model), row);
-#else
- gtk_list_store_remove((GtkListStore *)model, &iter);
-#endif
+ gtk_list_store_remove ((GtkListStore *) model, &iter);
len = list ? g_slist_length ((GSList *) list) : 0;
if (len > 0) {
-#if USE_ETABLE
- e_table_set_cursor_row (prefs->table, row >= len ? len - 1 : row);
-#else
- gtk_tree_selection_select_iter(selection, &iter);
-#endif
+ 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);
@@ -291,23 +263,15 @@ account_default_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
const MailConfigAccount *account = NULL;
- int row;
-
-#if USE_ETABLE
- row = e_table_get_cursor_row (prefs->table);
- if (row >= 0)
- account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
-
-#else
GtkTreeSelection *selection;
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);
-#endif
-
+ 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 (account) {
mail_config_set_default_account (account);
@@ -322,26 +286,17 @@ account_able_clicked (GtkButton *button, gpointer user_data)
{
MailAccountsTab *prefs = user_data;
const MailConfigAccount *account = NULL;
-#if USE_ETABLE
- int row;
-
- row = e_table_get_cursor_row (prefs->table);
- if (row >= 0) {
- account = e_table_memory_get_data (E_TABLE_MEMORY (prefs->model), row);
- account->source->enabled = !account->source->enabled;
- }
-#else
GtkTreeSelection *selection;
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);
+
+ 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->source->enabled = !account->source->enabled;
- gtk_list_store_set((GtkListStore *)model, &iter, 0, account->source->enabled, -1);
+ gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->source->enabled, -1);
}
-#endif
+
if (account) {
/* if the account got disabled, remove it from the
folder-tree, otherwise add it to the folder-tree */
@@ -351,62 +306,28 @@ account_able_clicked (GtkButton *button, gpointer user_data)
else
mail_remove_storage_by_uri (account->source->url);
}
+
mail_autoreceive_setup ();
mail_config_write ();
}
}
-#if USE_ETABLE
-static void
-account_cursor_change (ETable *table, int row, gpointer user_data)
-{
- MailAccountsTab *prefs = user_data;
-
- if (row >= 0) {
- const MailConfigAccount *account;
-
- 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"));
-
- 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 (ETable *table, int row, int col, GdkEvent *event, gpointer user_data)
-{
- account_edit_clicked (NULL, user_data);
-}
-#else
static void
account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs)
{
+ const MailConfigAccount *account;
GtkTreeModel *model;
GtkTreeIter iter;
- const MailConfigAccount *account;
int state;
-
- state = gtk_tree_selection_get_selected(selection, &model, &iter);
+
+ state = gtk_tree_selection_get_selected (selection, &model, &iter);
if (state) {
- gtk_tree_model_get(model, &iter, 3, &account, -1);
+ gtk_tree_model_get (model, &iter, 3, &account, -1);
if (account->source && account->source->enabled)
- gtk_button_set_label(prefs->mail_able, _("Disable"));
+ gtk_button_set_label (prefs->mail_able, _("Disable"));
else
- gtk_button_set_label(prefs->mail_able, _("Enable"));
+ gtk_button_set_label (prefs->mail_able, _("Enable"));
/* FIXME: how do we get double clicks?? */
#warning "how to get double-clicks from gtktreeview"
/*if (event && event->type == GDK_2BUTTON_PRESS)
@@ -414,36 +335,27 @@ account_cursor_change (GtkTreeSelection *selection, MailAccountsTab *prefs)
} else {
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)
{
+ const MailConfigAccount *default_account;
+ GtkListStore *model;
const GSList *node;
+ GtkTreeIter iter;
+ char *name, *val;
int row = 0;
-#if USE_ETABLE
- e_table_memory_freeze (E_TABLE_MEMORY (prefs->model));
+ model = (GtkListStore *) gtk_tree_view_get_model (prefs->table);
+ gtk_list_store_clear (model);
- e_table_memory_store_clear (E_TABLE_MEMORY_STORE (prefs->model));
-#else
- GtkTreeIter iter;
- GtkListStore *model;
- const MailConfigAccount *default_account;
- char *name, *val;
-
- model = (GtkListStore *)gtk_tree_view_get_model(prefs->table);
- gtk_list_store_clear(model);
-
default_account = mail_config_get_default_account ();
-#endif
node = mail_config_get_accounts ();
while (node) {
@@ -454,31 +366,22 @@ mail_accounts_load (MailAccountsTab *prefs)
url = account->source && account->source->url ? camel_url_new (account->source->url, NULL) : 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"));
-
- e_table_memory_set_data (E_TABLE_MEMORY (prefs->model), row, (gpointer) account);
-#else
- gtk_list_store_append(model, &iter);
+ gtk_list_store_append (model, &iter);
if (account == default_account) {
/* translators: default account indicator */
- name = val = g_strdup_printf("%s %s", account->name, _("[Default]"));
+ name = val = g_strdup_printf ("%s %s", account->name, _("[Default]"));
} else {
val = account->name;
name = NULL;
}
-
- gtk_list_store_set(model, &iter,
- 0, account->source->enabled,
- 1, val,
- 2, url && url->protocol ? url->protocol : (char *) _("None"),
- 3, account,
- -1);
- g_free(name);
-#endif
+
+ gtk_list_store_set (model, &iter,
+ 0, account->source->enabled,
+ 1, val,
+ 2, url && url->protocol ? url->protocol : (char *) _("None"),
+ 3, account,
+ -1);
+ g_free (name);
if (url)
camel_url_free (url);
@@ -486,88 +389,54 @@ mail_accounts_load (MailAccountsTab *prefs)
node = node->next;
row++;
}
-
-#if USE_ETABLE
- e_table_memory_thaw (E_TABLE_MEMORY (prefs->model));
-#endif
}
-GtkWidget *mail_accounts_etable_new (char *widget_name, char *string1, char *string2,
- int int1, int int2);
+GtkWidget *mail_accounts_treeview_new (char *widget_name, char *string1, char *string2,
+ int int1, int int2);
-#if USE_ETABLE
GtkWidget *
-mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int int1, int int2)
-{
- 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,
- };
-
- extras = e_table_extras_new ();
-
- 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 = e_table_memory_store_new (columns);
-
- 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)
+mail_accounts_treeview_new (char *widget_name, char *string1, char *string2, int int1, int int2)
{
GtkWidget *table, *scrolled;
- char *titles[3];
- GtkListStore *model;
- GtkCellRenderer *renderer;
GtkTreeSelection *selection;
-
+ GtkCellRenderer *renderer;
+ GtkListStore *model;
+ char *titles[3];
+
scrolled = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-
- 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"),
- gtk_cell_renderer_toggle_new(),
- "active", 0,
- NULL);
- 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);
+
+ 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"),
+ gtk_cell_renderer_toggle_new (),
+ "active", 0,
+ NULL);
+ 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);
-
+ gtk_tree_view_set_headers_visible ((GtkTreeView *) table, TRUE);
+
/* FIXME: column auto-resize? */
/* Is this needed?
gtk_tree_view_column_set_alignment(gtk_tree_view_get_column(prefs->table, 0), 1.0);*/
-
+
gtk_container_add (GTK_CONTAINER (scrolled), table);
- g_object_set_data(G_OBJECT(scrolled), "table", table);
+ g_object_set_data ((GObject *) scrolled, "table", table);
gtk_widget_show (scrolled);
gtk_widget_show (table);
return scrolled;
}
-#endif
static void
mail_accounts_tab_construct (MailAccountsTab *prefs)
@@ -589,39 +458,26 @@ mail_accounts_tab_construct (MailAccountsTab *prefs)
widget = glade_xml_get_widget (gui, "etableMailAccounts");
-#if USE_ETABLE
- prefs->table = e_table_scrolled_get_table (E_TABLE_SCROLLED (widget));
- prefs->model = prefs->table->model;
-
- g_signal_connect((prefs->table), "cursor_change",
- account_cursor_change, prefs);
-
- g_signal_connect((prefs->table), "double_click",
- account_double_click, prefs);
+ prefs->table = GTK_TREE_VIEW (g_object_get_data ((GObject *) widget, "table"));
+ g_signal_connect (gtk_tree_view_get_selection (prefs->table),
+ "changed", G_CALLBACK (account_cursor_change), prefs);
mail_accounts_load (prefs);
-#else
- prefs->table = GTK_TREE_VIEW (g_object_get_data(G_OBJECT(widget), "table"));
- g_signal_connect(gtk_tree_view_get_selection(prefs->table),
- "changed", G_CALLBACK(account_cursor_change), prefs);
-
- mail_accounts_load (prefs);
-#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);
-
+ 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);
+ 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);
+ g_signal_connect (prefs->mail_delete, "clicked", G_CALLBACK (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);
+ g_signal_connect (prefs->mail_default, "clicked", G_CALLBACK (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);
+ g_signal_connect (prefs->mail_able, "clicked", G_CALLBACK (account_able_clicked), prefs);
}