diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-03-29 07:03:02 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-03-29 07:03:02 +0800 |
commit | f2724282525af3eae2f52badf8ecddd31a24db70 (patch) | |
tree | bea3ae8c520fcfd059f01fef25e018124a029095 | |
parent | 7fd8357af6b7e045c531d84ac561e0632d03aef4 (diff) | |
download | gsoc2013-evolution-f2724282525af3eae2f52badf8ecddd31a24db70.tar.gz gsoc2013-evolution-f2724282525af3eae2f52badf8ecddd31a24db70.tar.zst gsoc2013-evolution-f2724282525af3eae2f52badf8ecddd31a24db70.zip |
Use a GtkCList instead of an ETable, for some reason the etable was
2002-03-28 Jeffrey Stedfast <fejj@ximian.com>
* mail-accounts.c: Use a GtkCList instead of an ETable, for some
reason the etable was getting into some infinite resize loop or
something. I probably did something wrong but I can't figure out
what so I'm using a clist for now.
svn path=/trunk/; revision=16277
-rw-r--r-- | mail/ChangeLog | 7 | ||||
-rw-r--r-- | mail/mail-accounts.c | 180 | ||||
-rw-r--r-- | mail/mail-accounts.h | 4 | ||||
-rw-r--r-- | mail/mail-config.glade | 27 |
4 files changed, 183 insertions, 35 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 5c291b31a1..67a3c77463 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2002-03-28 Jeffrey Stedfast <fejj@ximian.com> + + * mail-accounts.c: Use a GtkCList instead of an ETable, for some + reason the etable was getting into some infinite resize loop or + something. I probably did something wrong but I can't figure out + what so I'm using a clist for now. + 2002-03-27 Ettore Perazzoli <ettore@ximian.com> * mail-accounts.c (mail_accounts_tab_construct): Use diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c index ccba207dfa..39458858de 100644 --- a/mail/mail-accounts.c +++ b/mail/mail-accounts.c @@ -30,8 +30,10 @@ #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 <bonobo/bonobo-generic-factory.h> @@ -42,15 +44,21 @@ #include "mail-account-editor.h" #include "mail-send-recv.h" +#include "art/mail-new.xpm" +#include "art/mail-read.xpm" + #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 (GtkObject *obj); static void mail_accounts_load (MailAccountsTab *tab); -static GdkPixbuf *pixbuf = NULL; +static GdkPixbuf *disabled_pixbuf = NULL; +static GdkPixbuf *enabled_pixbuf = NULL; static GtkVBoxClass *parent_class = NULL; @@ -90,7 +98,8 @@ mail_accounts_tab_class_init (MailAccountsTabClass *klass) /* setup static data */ - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) mark_xpm); + disabled_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) mail_new_xpm); + enabled_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) mail_read_xpm); } static void @@ -152,15 +161,22 @@ account_edit_clicked (GtkButton *button, gpointer user_data) if (prefs->editor == 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; window = gtk_widget_get_ancestor (GTK_WIDGET (prefs), GTK_TYPE_WINDOW); +#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), @@ -181,7 +197,11 @@ account_delete_clicked (GtkButton *button, gpointer user_data) 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 (row < 0 || prefs->editor != NULL) @@ -201,7 +221,11 @@ account_delete_clicked (GtkButton *button, gpointer user_data) 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->source && account->source->url && account->source->enabled) @@ -214,12 +238,20 @@ 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_clist_remove (prefs->table, row); +#endif len = list ? g_slist_length ((GSList *) list) : 0; if (len > 0) { 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); @@ -236,10 +268,18 @@ account_default_clicked (GtkButton *button, gpointer user_data) const MailConfigAccount *account; 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) { +#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); @@ -256,10 +296,19 @@ account_able_clicked (GtkButton *button, gpointer user_data) const MailConfigAccount *account; 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) { +#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 (account->source && account->source->url) { @@ -277,6 +326,7 @@ account_able_clicked (GtkButton *button, gpointer user_data) } } +#if USE_ETABLE static void account_cursor_change (ETable *table, int row, gpointer user_data) { @@ -310,6 +360,39 @@ account_double_click (ETable *table, int row, int col, GdkEvent *event, gpointer { account_edit_clicked (NULL, user_data); } +#else +static void +account_cursor_change (GtkCList *table, int row, int column, GdkEvent *event, gpointer user_data) +{ + 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_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->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)); + } +} +#endif + static void mail_accounts_load (MailAccountsTab *prefs) @@ -317,9 +400,15 @@ mail_accounts_load (MailAccountsTab *prefs) const GSList *node; int row = 0; +#if USE_ETABLE e_table_memory_freeze (E_TABLE_MEMORY (prefs->model)); e_table_memory_store_clear (E_TABLE_MEMORY_STORE (prefs->model)); +#else + gtk_clist_freeze (prefs->table); + + gtk_clist_clear (prefs->table); +#endif node = mail_config_get_accounts (); while (node) { @@ -330,31 +419,51 @@ 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 + { + char *text[3]; + + text[0] = NULL; + text[1] = e_utf8_to_gtk_string (GTK_WIDGET (prefs->table), account->name); + text[2] = url && url->protocol ? url->protocol : (char *) U_("None"); + + gtk_clist_insert (prefs->table, row, text); + + g_free (text[1]); + + gtk_clist_set_row_data (prefs->table, row, (gpointer) account); + } +#endif + if (url) camel_url_free (url); - e_table_memory_set_data (E_TABLE_MEMORY (prefs->model), row, (gpointer) account); - node = node->next; row++; } +#if USE_ETABLE e_table_memory_thaw (E_TABLE_MEMORY (prefs->model)); +#else + gtk_clist_thaw (prefs->table); +#endif } GtkWidget *mail_accounts_etable_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) { - ETable *etable; ETableModel *model; ETableExtras *extras; GdkPixbuf *images[2]; @@ -364,26 +473,50 @@ mail_accounts_etable_new (char *widget_name, char *string1, char *string2, int i E_TABLE_MEMORY_STORE_STRING, E_TABLE_MEMORY_STORE_TERMINATOR, }; - - return NULL; extras = e_table_extras_new (); - images[0] = NULL; /* disabled */ - images[1] = pixbuf; /* enabled */ + 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); - etable = (ETable *) e_table_new_from_spec_file (model, extras, EVOLUTION_ETSPECDIR "/mail-accounts.etspec", NULL); + 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]; + + scrolled = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + 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); - return (GtkWidget *) etable; + 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; + GtkWidget *toplevel, *widget; GladeXML *gui; gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "accounts_tab"); @@ -398,7 +531,10 @@ mail_accounts_tab_construct (MailAccountsTab *prefs) gtk_container_add (GTK_CONTAINER (prefs), toplevel); gtk_widget_unref (toplevel); - prefs->table = E_TABLE (glade_xml_get_widget (gui, "etableMailAccounts")); + 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; gtk_signal_connect (GTK_OBJECT (prefs->table), "cursor_change", @@ -408,6 +544,22 @@ mail_accounts_tab_construct (MailAccountsTab *prefs) account_double_click, prefs); mail_accounts_load (prefs); +#else + prefs->table = GTK_CLIST (gtk_object_get_data (GTK_OBJECT (widget), "table")); + + 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")); gtk_signal_connect (GTK_OBJECT (prefs->mail_add), "clicked", diff --git a/mail/mail-accounts.h b/mail/mail-accounts.h index 85fad77a2f..02b0fff58d 100644 --- a/mail/mail-accounts.h +++ b/mail/mail-accounts.h @@ -31,6 +31,7 @@ extern "C" { #include <gtk/gtkvbox.h> #include <gtk/gtkbutton.h> +#include <gtk/gtkclist.h> #include <glade/glade.h> #include <gal/e-table/e-table.h> @@ -59,8 +60,11 @@ struct _MailAccountsTab { GtkWidget *druid; GtkWidget *editor; + GtkCList *table; +#if 0 ETable *table; ETableModel *model; +#endif GtkButton *mail_add; GtkButton *mail_edit; diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 068844239b..2994e69a90 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -4321,32 +4321,17 @@ Quoted <spacing>0</spacing> <widget> - <class>GtkScrolledWindow</class> - <name>scrolledwindow44</name> - <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> - <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> - <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> - <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy> + <class>Custom</class> + <name>etableMailAccounts</name> + <creation_function>mail_accounts_etable_new</creation_function> + <int1>0</int1> + <int2>0</int2> + <last_modification_time>Thu, 28 Mar 2002 21:15:54 GMT</last_modification_time> <child> <padding>0</padding> <expand>True</expand> <fill>True</fill> </child> - - <widget> - <class>GtkViewport</class> - <name>viewport1</name> - <shadow_type>GTK_SHADOW_IN</shadow_type> - - <widget> - <class>Custom</class> - <name>etableMailAccounts</name> - <creation_function>mail_accounts_etable_new</creation_function> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Thu, 21 Mar 2002 19:16:13 GMT</last_modification_time> - </widget> - </widget> </widget> <widget> |