diff options
author | Not Zed <NotZed@Ximian.com> | 2002-09-11 12:27:23 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-09-11 12:27:23 +0800 |
commit | fd67fd43ea2c8e85f13f0f858d36d86f2af10e19 (patch) | |
tree | 4d216cc17ac4d45ca9f5e3d9dea0ad0d2b7d5571 /mail | |
parent | 4081a13ff156379ad380e0456881f707f1e67831 (diff) | |
download | gsoc2013-evolution-fd67fd43ea2c8e85f13f0f858d36d86f2af10e19.tar.gz gsoc2013-evolution-fd67fd43ea2c8e85f13f0f858d36d86f2af10e19.tar.zst gsoc2013-evolution-fd67fd43ea2c8e85f13f0f858d36d86f2af10e19.zip |
Handle file uri's too.
2002-09-11 Not Zed <NotZed@Ximian.com>
* component-factory.c (configure_folder_popup): Handle file uri's
too.
* mail-callbacks.c (configure_folder): clear message list before
calling configure folder.
(local_configure_done): completion callback to reset message list
when done.
* mail-local.c (mail_local_reconfigure_folder): changed args to
accept uri, and done callback.
(reconfigure_got_folder): moved code to callback which presents
the configure uri once we have the folder.
svn path=/trunk/; revision=18039
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 18 | ||||
-rw-r--r-- | mail/component-factory.c | 37 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 29 | ||||
-rw-r--r-- | mail/mail-local.c | 119 | ||||
-rw-r--r-- | mail/mail-local.h | 7 |
5 files changed, 130 insertions, 80 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 9539b16548..bbfde2b863 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,23 @@ +2002-09-11 Not Zed <NotZed@Ximian.com> + + * component-factory.c (configure_folder_popup): Handle file uri's + too. + + * mail-callbacks.c (configure_folder): clear message list before + calling configure folder. + (local_configure_done): completion callback to reset message list + when done. + + * mail-local.c (mail_local_reconfigure_folder): changed args to + accept uri, and done callback. + (reconfigure_got_folder): moved code to callback which presents + the configure uri once we have the folder. + 2002-09-10 Not Zed <NotZed@Ximian.com> + * component-factory.c: Handle file: as well as vfolder: uri's. + Pass both to the normal configure_folder callback. For #20849. + * folder-browser.c (got_folder): If we already have a folder, make sure we unref/unhook from it. Fixes a crash on exit. diff --git a/mail/component-factory.c b/mail/component-factory.c index fdef24dca8..3251a618f6 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -390,7 +390,17 @@ configure_folder_popup(BonoboUIComponent *component, void *user_data, const char { char *uri = user_data; - vfolder_edit_rule(uri); + + if (strncmp(uri, "vfolder:", 8) == 0) + vfolder_edit_rule(uri); + else { + FolderBrowser *fb = folder_browser_factory_get_browser(uri); + + if (fb) + configure_folder(component, fb, cname); + else + mail_local_reconfigure_folder(uri, NULL, NULL); + } } static void @@ -413,13 +423,12 @@ populate_folder_context_menu (EvolutionShellComponent *shell_component, /* FIXME: handle other types */ /* the unmatched test is a bit of a hack but it works */ - if (strncmp(physical_uri, "vfolder:", 8) != 0 - || strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) != NULL) - return; - - bonobo_ui_component_add_verb_full(uic, "ChangeFolderPropertiesPopUp", configure_folder_popup, g_strdup(physical_uri), g_free); - - bonobo_ui_component_set_translate (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER, popup_xml, NULL); + if ((strncmp(physical_uri, "vfolder:", 8) == 0 + && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL) + || strncmp(physical_uri, "file:", 5) == 0) { + bonobo_ui_component_add_verb_full(uic, "ChangeFolderPropertiesPopUp", configure_folder_popup, g_strdup(physical_uri), g_free); + bonobo_ui_component_set_translate (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER, popup_xml, NULL); + } } static void @@ -435,13 +444,11 @@ unpopulate_folder_context_menu (EvolutionShellComponent *shell_component, /* FIXME: handle other types */ /* the unmatched test is a bit of a hack but it works */ - if (strncmp(physical_uri, "vfolder:", 8) != 0 - || strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) != NULL) - return; - - bonobo_ui_component_rm (uic, - EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER "/ChangeFolderPropertiesPopUp", - NULL); + if ((strncmp(physical_uri, "vfolder:", 8) == 0 + && strstr(physical_uri, "#" CAMEL_UNMATCHED_NAME) == NULL) + || strncmp(physical_uri, "file:", 5) == 0) { + bonobo_ui_component_rm (uic, EVOLUTION_SHELL_COMPONENT_POPUP_PLACEHOLDER "/ChangeFolderPropertiesPopUp", NULL); + } } static char * diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index fc5c0f892c..571470ba3c 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -3292,6 +3292,23 @@ manage_subscriptions (BonoboUIComponent *uih, void *user_data, const char *path) /******************** End Subscription Dialog ***************************/ +static void +local_configure_done(const char *uri, CamelFolder *folder, void *data) +{ + FolderBrowser *fb = data; + + if (FOLDER_BROWSER_IS_DESTROYED (fb)) { + gtk_object_unref((GtkObject *)fb); + return; + } + + if (folder == NULL) + folder = fb->folder; + + message_list_set_folder(fb->message_list, folder, FALSE); + gtk_object_unref((GtkObject *)fb); +} + void configure_folder (BonoboUIComponent *uih, void *user_data, const char *path) { @@ -3300,10 +3317,14 @@ configure_folder (BonoboUIComponent *uih, void *user_data, const char *path) if (FOLDER_BROWSER_IS_DESTROYED (fb)) return; - if (fb->uri && strncmp (fb->uri, "vfolder:", 8) == 0) { - vfolder_edit_rule (fb->uri); - } else { - mail_local_reconfigure_folder (fb); + if (fb->uri) { + if (strncmp (fb->uri, "vfolder:", 8) == 0) { + vfolder_edit_rule (fb->uri); + } else { + message_list_set_folder(fb->message_list, NULL, FALSE); + gtk_object_ref((GtkObject *)fb); + mail_local_reconfigure_folder(fb->uri, local_configure_done, fb); + } } } diff --git a/mail/mail-local.c b/mail/mail-local.c index 7d9c034708..eba907e178 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -53,7 +53,6 @@ #include "mail.h" #include "mail-local.h" #include "mail-tools.h" -#include "folder-browser.h" #include "mail-mt.h" #include "mail-folder-cache.h" #include "mail-vfolder.h" @@ -1304,7 +1303,9 @@ mail_local_storage_startup (EvolutionShellClient *shellclient, const char *evolu struct _reconfigure_msg { struct _mail_msg msg; - FolderBrowser *fb; + char *uri; + CamelFolder *folder; + char *newtype; unsigned int index_body:1; GtkWidget *frame; @@ -1312,7 +1313,9 @@ struct _reconfigure_msg { GtkWidget *cancel; GtkWidget *check_index_body; GtkOptionMenu *optionlist; - CamelFolder *folder_out; + + void (*done)(const char *uri, CamelFolder *folder, void*data); + void *done_data; }; /* hash table of folders that the user has a reconfig-folder dialog for */ @@ -1324,7 +1327,7 @@ reconfigure_folder_describe (struct _mail_msg *mm, int done) struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm; return g_strdup_printf (_("Changing folder \"%s\" to \"%s\" format"), - m->fb->uri, + camel_folder_get_full_name (m->folder), m->newtype); } @@ -1332,25 +1335,10 @@ static void reconfigure_folder_reconfigure (struct _mail_msg *mm) { struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm; - CamelFolder *local_folder = NULL; - d(printf("reconfiguring folder: %s to type %s\n", m->fb->uri, m->newtype)); + d(printf("reconfiguring folder: %s to type %s\n", m->uri, m->newtype)); - if (strncmp (m->fb->uri, "file:", 5)) { - camel_exception_setv (&mm->ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("%s may not be reconfigured because it is not a local folder"), - m->fb->uri); - return; - } - - local_folder = mail_tool_uri_to_folder (m->fb->uri, 0, &mm->ex); - if (camel_exception_is_set (&mm->ex)) { - g_warning ("Can't resolve URI \"%s\" for reconfiguration!", m->fb->uri); - return; - } - - mail_local_folder_reconfigure (MAIL_LOCAL_FOLDER (local_folder), m->newtype, m->index_body, &mm->ex); - m->folder_out = local_folder; + mail_local_folder_reconfigure (MAIL_LOCAL_FOLDER (m->folder), m->newtype, m->index_body, &mm->ex); } static void @@ -1364,7 +1352,8 @@ reconfigure_folder_reconfigured (struct _mail_msg *mm) "you may need to repair it manually.")); } - message_list_set_folder (m->fb->message_list, m->folder_out, FALSE); + if (m->done) + m->done(m->uri, m->folder, m->done_data); } static void @@ -1373,16 +1362,16 @@ reconfigure_folder_free (struct _mail_msg *mm) struct _reconfigure_msg *m = (struct _reconfigure_msg *)mm; /* remove this folder from our hash since we are done with it */ - g_hash_table_remove (reconfigure_folder_hash, m->fb->folder); + g_hash_table_remove (reconfigure_folder_hash, m->folder); if (g_hash_table_size (reconfigure_folder_hash) == 0) { /* additional cleanup */ g_hash_table_destroy (reconfigure_folder_hash); reconfigure_folder_hash = NULL; } - if (m->folder_out) - camel_object_unref (CAMEL_OBJECT (m->folder_out)); - gtk_object_unref (GTK_OBJECT (m->fb)); + if (m->folder) + camel_object_unref (CAMEL_OBJECT (m->folder)); + g_free(m->uri); g_free (m->newtype); } @@ -1398,12 +1387,6 @@ reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m { if (button == 0) { GtkWidget *menu, *item; - - /* hack to clear the message list during update */ - /* we need to do this because the message list caches - * CamelMessageInfos from the old folder. */ - message_list_set_folder(m->fb->message_list, NULL, FALSE); - menu = gtk_option_menu_get_menu(m->optionlist); item = gtk_menu_get_active(GTK_MENU(menu)); m->newtype = g_strdup(gtk_object_get_data((GtkObject *)item, "type")); @@ -1414,68 +1397,70 @@ reconfigure_clicked (GnomeDialog *dialog, int button, struct _reconfigure_msg *m gtk_widget_set_sensitive (m->cancel, FALSE); e_thread_put (mail_thread_queued, (EMsg *)m); - } else + } else { + if (m->done) + m->done(m->uri, NULL, m->done_data); mail_msg_free ((struct _mail_msg *)m); + } if (button != -1) gnome_dialog_close (dialog); } -void -mail_local_reconfigure_folder (FolderBrowser *fb) +static void +reconfigure_got_folder(char *uri, CamelFolder *folder, void *data) { GladeXML *gui; GnomeDialog *gd; - struct _reconfigure_msg *m; + struct _reconfigure_msg *m = data; char *title; GList *p; GtkWidget *menu; char *currentformat; int index=0, history=0; - if (fb->folder == NULL) { + if (folder == NULL + || !MAIL_IS_LOCAL_FOLDER (folder)) { g_warning ("Trying to reconfigure nonexistant folder"); + /* error display ? */ + if (m->done) + m->done(uri, NULL, m->done_data); + mail_msg_free((struct _mail_msg *)m); return; } if (!reconfigure_folder_hash) reconfigure_folder_hash = g_hash_table_new (NULL, NULL); - if ((gd = g_hash_table_lookup (reconfigure_folder_hash, fb->folder))) { + if ((gd = g_hash_table_lookup (reconfigure_folder_hash, folder))) { gdk_window_raise (GTK_WIDGET (gd)->window); + if (m->done) + m->done(uri, NULL, m->done_data); + mail_msg_free((struct _mail_msg *)m); return; } - /* check if we can work on this folder */ - if (!MAIL_IS_LOCAL_FOLDER (fb->folder)) { - e_notice (NULL, GNOME_MESSAGE_BOX_WARNING, - _("You cannot change the format of a non-local folder.")); - return; - } - - m = mail_msg_new (&reconfigure_folder_op, NULL, sizeof (*m)); - gui = glade_xml_new (EVOLUTION_GLADEDIR "/local-config.glade", "dialog_format"); gd = (GnomeDialog *)glade_xml_get_widget (gui, "dialog_format"); title = g_strdup_printf (_("Reconfigure /%s"), - camel_folder_get_full_name (fb->folder)); + camel_folder_get_full_name (folder)); gtk_window_set_title (GTK_WINDOW (gd), title); g_free (title); - + + m->uri = g_strdup(uri); m->frame = glade_xml_get_widget (gui, "frame_format"); m->apply = glade_xml_get_widget (gui, "apply_format"); m->cancel = glade_xml_get_widget (gui, "cancel_format"); m->optionlist = (GtkOptionMenu *)glade_xml_get_widget (gui, "option_format"); m->check_index_body = glade_xml_get_widget (gui, "check_index_body"); m->newtype = NULL; - m->fb = fb; - m->folder_out = NULL; - gtk_object_ref (GTK_OBJECT (fb)); + m->folder = folder; + camel_object_ref(folder); /* dynamically create the folder type list from camel */ /* we assume the list is static and never freed */ - currentformat = MAIL_LOCAL_FOLDER (fb->folder)->meta->format; + currentformat = MAIL_LOCAL_FOLDER (folder)->meta->format; p = camel_session_list_providers(session, TRUE); menu = gtk_menu_new(); while (p) { @@ -1502,15 +1487,35 @@ mail_local_reconfigure_folder (FolderBrowser *fb) gtk_option_menu_remove_menu (GTK_OPTION_MENU(m->optionlist)); gtk_option_menu_set_menu (GTK_OPTION_MENU(m->optionlist), menu); gtk_option_menu_set_history(GTK_OPTION_MENU(m->optionlist), history); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (fb->folder)->meta->indexed); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m->check_index_body), MAIL_LOCAL_FOLDER (folder)->meta->indexed); gtk_label_set_text ((GtkLabel *)glade_xml_get_widget (gui, "label_format"), - MAIL_LOCAL_FOLDER (fb->folder)->meta->format); + MAIL_LOCAL_FOLDER (folder)->meta->format); gtk_signal_connect (GTK_OBJECT (gd), "clicked", reconfigure_clicked, m); gtk_object_unref (GTK_OBJECT (gui)); - g_hash_table_insert (reconfigure_folder_hash, (gpointer) fb->folder, (gpointer) gd); + g_hash_table_insert (reconfigure_folder_hash, (gpointer) folder, (gpointer) gd); - gnome_dialog_run (GNOME_DIALOG (gd)); + gtk_widget_show((GtkWidget *)gd); +} + +void +mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, CamelFolder *folder, void *data), void *done_data) +{ + struct _reconfigure_msg *m; + + if (strncmp(uri, "file:", 5) != 0) { + e_notice (NULL, GNOME_MESSAGE_BOX_WARNING, + _("You cannot change the format of a non-local folder.")); + if (done) + done(uri, NULL, done_data); + return; + } + + m = mail_msg_new (&reconfigure_folder_op, NULL, sizeof (*m)); + m->done = done; + m->done_data = done_data; + + mail_get_folder(uri, 0, reconfigure_got_folder, m, mail_thread_new); } diff --git a/mail/mail-local.h b/mail/mail-local.h index d1e4f3791d..d75356609c 100644 --- a/mail/mail-local.h +++ b/mail/mail-local.h @@ -27,11 +27,10 @@ #define _MAIL_LOCAL_H #include "evolution-shell-client.h" -#include "folder-browser.h" +#include <camel/camel-folder.h> -void mail_local_storage_startup (EvolutionShellClient *shellclient, - const char *evolution_path); +void mail_local_storage_startup (EvolutionShellClient *shellclient, const char *evolution_path); -void mail_local_reconfigure_folder (FolderBrowser *fb); +void mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, CamelFolder *folder, void *data), void *done_data); #endif |