diff options
-rw-r--r-- | mail/ChangeLog | 31 | ||||
-rw-r--r-- | mail/Mail.idl | 2 | ||||
-rw-r--r-- | mail/mail-account-gui.c | 130 | ||||
-rw-r--r-- | mail/mail-account-gui.h | 8 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 34 | ||||
-rw-r--r-- | mail/mail-config.c | 30 | ||||
-rw-r--r-- | mail/mail-config.glade | 22 | ||||
-rw-r--r-- | mail/mail-config.h | 3 | ||||
-rw-r--r-- | mail/message-browser.c | 32 |
9 files changed, 122 insertions, 170 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 53657bf740..02a6cbd053 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,34 @@ +2002-04-04 Dan Winship <danw@ximian.com> + + * mail-account-gui.c (mail_account_gui_new): Make the drafts and + sent folder buttons be EvolutionFolderSelectorButtons. Remove the + code to deal with drafts_folder_name and sent_folder_name, since + they were only used to construct the button and aren't needed now. + (mail_account_gui_save): Remove drafts/sent name references. + (mail_account_gui_destroy): Likewise + (folder_selected): Handle the "selected" signal on the folder + selector button by updating the URI in the MailAccountGui. + (mail_account_gui_folder_selector_button_new): Glade custom widget + constructor. + + * mail-callbacks.c (transfer_msg): Update for + evolution_shell_client_user_select_folder change. + + * message-browser.c (transfer_msg): Likewise. (Sigh. Why is this + cut+pasted?) + + * mail-config.glade: Make the drafts/sent folder buttons custom + widgets. + + * mail-config.c (account_copy): Remove drafts/sent folder name + handling. + (account_destroy): Likewise. + (config_read): Likewise. + (mail_config_write): Likewise. + + * Mail.idl (MailConfig:Account): remove drafts_folder_name and + sent_folder_name. + 2002-04-03 Jeffrey Stedfast <fejj@ximian.com> * message-tag-followup.c (construct): Set the window title/icon diff --git a/mail/Mail.idl b/mail/Mail.idl index 239decd479..eedf2bcce8 100644 --- a/mail/Mail.idl +++ b/mail/Mail.idl @@ -63,9 +63,7 @@ module Evolution { Service source; Service transport; - string drafts_folder_name; string drafts_folder_uri; - string sent_folder_name; string sent_folder_uri; }; diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index f4d9927c6c..fac9966137 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -32,7 +32,7 @@ #include <gal/widgets/e-unicode.h> #include <gal/widgets/e-gui-utils.h> -#include "shell/evolution-shell-client.h" +#include "evolution-folder-selector-button.h" #include "mail-account-gui.h" #include "mail-session.h" #include "mail-send-recv.h" @@ -41,6 +41,7 @@ #define d(x) extern char *default_drafts_folder_uri, *default_sent_folder_uri; +extern EvolutionShellClient *global_shell_client; static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, MailConfigService *service); static void service_changed (GtkEntry *entry, gpointer user_data); @@ -858,61 +859,27 @@ extract_values (MailAccountGuiService *source, GHashTable *extra_config, CamelUR } -extern EvolutionShellClient *global_shell_client; - static void -set_folder_picker_label (GtkButton *button, const char *name) +folder_selected (EvolutionFolderSelectorButton *button, + GNOME_Evolution_Folder *corba_folder, + gpointer user_data) { - char *string; + char **folder_name = user_data; - string = e_utf8_to_gtk_string (GTK_WIDGET (button), name); - gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), string); - g_free (string); + g_free (*folder_name); + *folder_name = g_strdup (corba_folder->physicalUri); } -static char * -basename_from_uri (const char *uri) -{ - const char *base; - - base = strrchr (uri, '/'); - g_assert (base != NULL); - - /* translate the basename: fixes bug #7160 */ - if (!strncmp (uri, "evolution:/local", 16)) - return g_strdup (_(base + 1)); - else - return g_strdup (base + 1); -} +GtkWidget *mail_account_gui_folder_selector_button_new (char *widget_name, char *string1, char *string2, int int1, int int2); -static void -folder_picker_clicked (GtkButton *button, gpointer user_data) +GtkWidget * +mail_account_gui_folder_selector_button_new (char *widget_name, + char *string1, char *string2, + int int1, int int2) { - MailAccountGuiFolder *folder = user_data; - const char *allowed_types[] = { "mail", NULL }; - char *physical_uri, *evolution_uri; - - physical_uri = evolution_uri = NULL; - evolution_shell_client_user_select_folder ( - global_shell_client, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (button))), - _("Select Folder"), folder->uri, - allowed_types, &evolution_uri, &physical_uri); - if (!physical_uri || !*physical_uri) { - g_free (physical_uri); - g_free (evolution_uri); - return; - } - - g_free (folder->uri); - folder->uri = physical_uri; - g_free (folder->name); - folder->name = basename_from_uri (evolution_uri); - g_free (evolution_uri); - set_folder_picker_label (button, folder->name); + return (GtkWidget *)gtk_type_new (EVOLUTION_TYPE_FOLDER_SELECTOR_BUTTON); } - static gboolean setup_service (MailAccountGuiService *gsvc, MailConfigService *service) { @@ -1405,6 +1372,7 @@ MailAccountGui * mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog) { MailAccountGui *gui; + const char *allowed_types[] = { "mail", NULL }; gui = g_new0 (MailAccountGui, 1); gui->account = account; @@ -1487,29 +1455,31 @@ mail_account_gui_new (MailConfigAccount *account, MailAccountsTab *dialog) /* Drafts folder */ gui->drafts_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "drafts_button")); - gtk_signal_connect (GTK_OBJECT (gui->drafts_folder_button), "clicked", - GTK_SIGNAL_FUNC (folder_picker_clicked), &gui->drafts_folder); - if (account->drafts_folder_uri) { - gui->drafts_folder.uri = g_strdup (account->drafts_folder_uri); - gui->drafts_folder.name = g_strdup (account->drafts_folder_name); - } else { - gui->drafts_folder.uri = g_strdup (default_drafts_folder_uri); - gui->drafts_folder.name = g_strdup (strrchr (default_drafts_folder_uri, '/') + 1); - } - set_folder_picker_label (gui->drafts_folder_button, gui->drafts_folder.name); + gtk_signal_connect (GTK_OBJECT (gui->drafts_folder_button), "selected", + GTK_SIGNAL_FUNC (folder_selected), &gui->drafts_folder_uri); + if (account->drafts_folder_uri) + gui->drafts_folder_uri = g_strdup (account->drafts_folder_uri); + else + gui->drafts_folder_uri = g_strdup (default_drafts_folder_uri); + evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (gui->drafts_folder_button), + global_shell_client, + _("Select Folder"), + gui->drafts_folder_uri, + allowed_types); /* Sent folder */ gui->sent_folder_button = GTK_BUTTON (glade_xml_get_widget (gui->xml, "sent_button")); - gtk_signal_connect (GTK_OBJECT (gui->sent_folder_button), "clicked", - GTK_SIGNAL_FUNC (folder_picker_clicked), &gui->sent_folder); - if (account->sent_folder_uri) { - gui->sent_folder.uri = g_strdup (account->sent_folder_uri); - gui->sent_folder.name = g_strdup (account->sent_folder_name); - } else { - gui->sent_folder.uri = g_strdup (default_sent_folder_uri); - gui->sent_folder.name = g_strdup (strrchr (default_sent_folder_uri, '/') + 1); - } - set_folder_picker_label (gui->sent_folder_button, gui->sent_folder.name); + gtk_signal_connect (GTK_OBJECT (gui->sent_folder_button), "selected", + GTK_SIGNAL_FUNC (folder_selected), &gui->sent_folder_uri); + if (account->sent_folder_uri) + gui->sent_folder_uri = g_strdup (account->sent_folder_uri); + else + gui->sent_folder_uri = g_strdup (default_sent_folder_uri); + evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (gui->sent_folder_button), + global_shell_client, + _("Select Folder"), + gui->sent_folder_uri, + allowed_types); /* Always Cc */ gui->always_cc = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui->xml, "always_cc")); @@ -1882,17 +1852,13 @@ mail_account_gui_save (MailAccountGui *gui) save_service (&gui->transport, NULL, account->transport); /* Check to make sure that the Drafts folder uri is "valid" before assigning it */ - url = source_url && gui->drafts_folder.uri ? camel_url_new (gui->drafts_folder.uri, NULL) : NULL; - if (mail_config_get_account_by_source_url (gui->drafts_folder.uri) || + url = source_url && gui->drafts_folder_uri ? camel_url_new (gui->drafts_folder_uri, NULL) : NULL; + if (mail_config_get_account_by_source_url (gui->drafts_folder_uri) || (url && provider->url_equal (source_url, url))) { - g_free (account->drafts_folder_name); - account->drafts_folder_name = g_strdup (gui->drafts_folder.name); g_free (account->drafts_folder_uri); - account->drafts_folder_uri = g_strdup (gui->drafts_folder.uri); + account->drafts_folder_uri = g_strdup (gui->drafts_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - g_free (account->drafts_folder_name); - account->drafts_folder_name = basename_from_uri (default_drafts_folder_uri); g_free (account->drafts_folder_uri); account->drafts_folder_uri = g_strdup (default_drafts_folder_uri); } @@ -1901,17 +1867,13 @@ mail_account_gui_save (MailAccountGui *gui) camel_url_free (url); /* Check to make sure that the Sent folder uri is "valid" before assigning it */ - url = source_url && gui->sent_folder.uri ? camel_url_new (gui->sent_folder.uri, NULL) : NULL; - if (mail_config_get_account_by_source_url (gui->sent_folder.uri) || + url = source_url && gui->sent_folder_uri ? camel_url_new (gui->sent_folder_uri, NULL) : NULL; + if (mail_config_get_account_by_source_url (gui->sent_folder_uri) || (url && provider->url_equal (source_url, url))) { - g_free (account->sent_folder_name); - account->sent_folder_name = g_strdup (gui->sent_folder.name); g_free (account->sent_folder_uri); - account->sent_folder_uri = g_strdup (gui->sent_folder.uri); + account->sent_folder_uri = g_strdup (gui->sent_folder_uri); } else { /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */ - g_free (account->sent_folder_name); - account->sent_folder_name = basename_from_uri (default_sent_folder_uri); g_free (account->sent_folder_uri); account->sent_folder_uri = g_strdup (default_sent_folder_uri); } @@ -1958,9 +1920,7 @@ mail_account_gui_destroy (MailAccountGui *gui) gtk_object_unref (GTK_OBJECT (gui->xml)); if (gui->extra_config) g_hash_table_destroy (gui->extra_config); - g_free (gui->drafts_folder.name); - g_free (gui->drafts_folder.uri); - g_free (gui->sent_folder.name); - g_free (gui->sent_folder.uri); + g_free (gui->drafts_folder_uri); + g_free (gui->sent_folder_uri); g_free (gui); } diff --git a/mail/mail-account-gui.h b/mail/mail-account-gui.h index b62d9a1966..6a6735bf48 100644 --- a/mail/mail-account-gui.h +++ b/mail/mail-account-gui.h @@ -58,10 +58,6 @@ typedef struct { } MailAccountGuiService; typedef struct { - char *name, *uri; -} MailAccountGuiFolder; - -typedef struct { GtkWidget *top; MailConfigAccount *account; MailAccountsTab *dialog; @@ -102,9 +98,9 @@ typedef struct { /* special folders */ GtkButton *drafts_folder_button; - MailAccountGuiFolder drafts_folder; + char *drafts_folder_uri; GtkButton *sent_folder_button; - MailAccountGuiFolder sent_folder; + char *sent_folder_uri; /* always cc/bcc */ GtkToggleButton *always_cc; diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 2f4f6b695a..2f45924595 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -1410,38 +1410,35 @@ transfer_msg_done (gboolean ok, void *data) static void transfer_msg (FolderBrowser *fb, gboolean delete_from_source) { - const char *allowed_types[] = { "mail", "vtrash", NULL }; + static const char *allowed_types[] = { "mail", "vtrash", NULL }; extern EvolutionShellClient *global_shell_client; - char *uri, *physical, *path, *desc; - static char *last = NULL; + GNOME_Evolution_Folder *folder; + static char *last_uri = NULL; GPtrArray *uids; + char *desc; if (FOLDER_BROWSER_IS_DESTROYED (fb)) return; - if (last == NULL) - last = g_strdup (""); + if (last_uri == NULL) + last_uri = g_strdup (""); if (delete_from_source) desc = _("Move message(s) to"); else desc = _("Copy message(s) to"); - uri = NULL; - physical = NULL; evolution_shell_client_user_select_folder (global_shell_client, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (fb))), - desc, last, - allowed_types, &uri, &physical); - if (!uri) + desc, last_uri, allowed_types, + &folder); + if (!folder) return; - path = strchr (uri, '/'); - if (path && strcmp (last, path) != 0) { - g_free (last); - last = g_strdup_printf ("evolution:%s", path); + if (strcmp (last_uri, folder->evolutionUri) != 0) { + g_free (last_uri); + last_uri = g_strdup (folder->evolutionUri); } - g_free (uri); uids = g_ptr_array_new (); message_list_foreach (fb->message_list, enumerate_msg, uids); @@ -1449,12 +1446,13 @@ transfer_msg (FolderBrowser *fb, gboolean delete_from_source) if (delete_from_source) { gtk_object_ref (GTK_OBJECT (fb)); mail_transfer_messages (fb->folder, uids, delete_from_source, - physical, 0, transfer_msg_done, fb); + folder->physicalUri, 0, + transfer_msg_done, fb); } else { mail_transfer_messages (fb->folder, uids, delete_from_source, - physical, 0, NULL, NULL); + folder->physicalUri, 0, NULL, NULL); } - g_free(physical); + CORBA_free (folder); } void diff --git a/mail/mail-config.c b/mail/mail-config.c index 145f70868f..6e2963ad22 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -253,9 +253,7 @@ account_copy (const MailConfigAccount *account) new->source = service_copy (account->source); new->transport = service_copy (account->transport); - new->drafts_folder_name = g_strdup (account->drafts_folder_name); new->drafts_folder_uri = g_strdup (account->drafts_folder_uri); - new->sent_folder_name = g_strdup (account->sent_folder_name); new->sent_folder_uri = g_strdup (account->sent_folder_uri); new->always_cc = account->always_cc; @@ -286,9 +284,7 @@ account_destroy (MailConfigAccount *account) service_destroy (account->source); service_destroy (account->transport); - g_free (account->drafts_folder_name); g_free (account->drafts_folder_uri); - g_free (account->sent_folder_name); g_free (account->sent_folder_uri); g_free (account->cc_addrs); @@ -632,14 +628,6 @@ config_read (void) config->corrupt = TRUE; } - path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_name_%d", i); - val = bonobo_config_get_string (config->db, path, NULL); - g_free (path); - if (val && *val) - account->drafts_folder_name = val; - else - g_free (val); - path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_uri_%d", i); val = bonobo_config_get_string (config->db, path, NULL); g_free (path); @@ -648,14 +636,6 @@ config_read (void) else g_free (val); - path = g_strdup_printf ("/Mail/Accounts/account_sent_folder_name_%d", i); - val = bonobo_config_get_string (config->db, path, NULL); - g_free (path); - if (val && *val) - account->sent_folder_name = val; - else - g_free (val); - path = g_strdup_printf ("/Mail/Accounts/account_sent_folder_uri_%d", i); val = bonobo_config_get_string (config->db, path, NULL); g_free (path); @@ -1071,21 +1051,11 @@ mail_config_write (void) bonobo_config_set_string_wrapper (config->db, path, account->name, NULL); g_free (path); - path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_name_%d", i); - bonobo_config_set_string_wrapper (config->db, path, - account->drafts_folder_name, NULL); - g_free (path); - path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_uri_%d", i); bonobo_config_set_string_wrapper (config->db, path, account->drafts_folder_uri, NULL); g_free (path); - path = g_strdup_printf ("/Mail/Accounts/account_sent_folder_name_%d", i); - bonobo_config_set_string_wrapper (config->db, path, - account->sent_folder_name, NULL); - g_free (path); - path = g_strdup_printf ("/Mail/Accounts/account_sent_folder_uri_%d", i); bonobo_config_set_string_wrapper (config->db, path, account->sent_folder_uri, NULL); diff --git a/mail/mail-config.glade b/mail/mail-config.glade index 714d830c8e..12a33f4dd8 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -1917,11 +1917,12 @@ Kerberos </widget> <widget> - <class>GtkButton</class> + <class>Custom</class> <name>drafts_button</name> - <can_focus>True</can_focus> - <label>Drafts</label> - <relief>GTK_RELIEF_NORMAL</relief> + <creation_function>mail_account_gui_folder_selector_button_new</creation_function> + <int1>0</int1> + <int2>0</int2> + <last_modification_time>Wed, 03 Apr 2002 23:03:41 GMT</last_modification_time> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> @@ -1934,16 +1935,17 @@ Kerberos <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> - <yfill>False</yfill> + <yfill>True</yfill> </child> </widget> <widget> - <class>GtkButton</class> + <class>Custom</class> <name>sent_button</name> - <can_focus>True</can_focus> - <label>Sent</label> - <relief>GTK_RELIEF_NORMAL</relief> + <creation_function>mail_account_gui_folder_selector_button_new</creation_function> + <int1>0</int1> + <int2>0</int2> + <last_modification_time>Wed, 03 Apr 2002 23:03:59 GMT</last_modification_time> <child> <left_attach>1</left_attach> <right_attach>2</right_attach> @@ -1956,7 +1958,7 @@ Kerberos <xshrink>False</xshrink> <yshrink>False</yshrink> <xfill>True</xfill> - <yfill>False</yfill> + <yfill>True</yfill> </child> </widget> </widget> diff --git a/mail/mail-config.h b/mail/mail-config.h index 2556dadd6f..917924d025 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -67,8 +67,7 @@ typedef struct { MailConfigService *source; MailConfigService *transport; - char *drafts_folder_name, *drafts_folder_uri; - char *sent_folder_name, *sent_folder_uri; + char *drafts_folder_uri, *sent_folder_uri; gboolean always_cc; char *cc_addrs; diff --git a/mail/message-browser.c b/mail/message-browser.c index 76d60172f9..d644f9ae43 100644 --- a/mail/message-browser.c +++ b/mail/message-browser.c @@ -116,36 +116,33 @@ transfer_msg (MessageBrowser *mb, int del) { const char *allowed_types[] = { "mail", "vtrash", NULL }; extern EvolutionShellClient *global_shell_client; - char *uri, *physical, *path, *desc; - static char *last = NULL; + GNOME_Evolution_Folder *folder; + static char *last_uri = NULL; GPtrArray *uids; + char *desc; if (GTK_OBJECT_DESTROYED(mb)) return; - if (last == NULL) - last = g_strdup (""); + if (last_uri == NULL) + last_uri = g_strdup (""); if (del) desc = _("Move message(s) to"); else desc = _("Copy message(s) to"); - uri = NULL; - physical = NULL; evolution_shell_client_user_select_folder (global_shell_client, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (mb))), - desc, last, - allowed_types, &uri, &physical); - if (!uri) + desc, last_uri, allowed_types, + &folder); + if (!folder) return; - path = strchr (uri, '/'); - if (path && strcmp (last, path) != 0) { - g_free (last); - last = g_strdup_printf ("evolution:%s", path); + if (strcmp (last_uri, folder->evolutionUri) != 0) { + g_free (last_uri); + last_uri = g_strdup (folder->evolutionUri); } - g_free (uri); uids = g_ptr_array_new (); message_list_foreach (mb->fb->message_list, enumerate_msg, uids); @@ -153,12 +150,13 @@ transfer_msg (MessageBrowser *mb, int del) if (del) { gtk_object_ref (GTK_OBJECT (mb)); mail_transfer_messages (mb->fb->folder, uids, del, - physical, 0, transfer_msg_done, mb); + folder->physicalUri, 0, + transfer_msg_done, mb); } else { mail_transfer_messages (mb->fb->folder, uids, del, - physical, 0, NULL, NULL); + folder->physicalUri, 0, NULL, NULL); } - g_free(physical); + CORBA_free (folder); } |