diff options
author | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-08-02 13:10:51 +0800 |
---|---|---|
committer | Srinivasa Ragavan <sragavan@src.gnome.org> | 2007-08-02 13:10:51 +0800 |
commit | 0c7f584760ab79d65f52a40844c10fed1564f1f5 (patch) | |
tree | d752d831bb00ca230ba90aa6308097dfb478c0a1 | |
parent | 0afd0d160d45699d7856dfb8ea7b422083c67bee (diff) | |
download | gsoc2013-evolution-0c7f584760ab79d65f52a40844c10fed1564f1f5.tar.gz gsoc2013-evolution-0c7f584760ab79d65f52a40844c10fed1564f1f5.tar.zst gsoc2013-evolution-0c7f584760ab79d65f52a40844c10fed1564f1f5.zip |
Fix from Lucky to expand newly created folder
svn path=/trunk/; revision=33926
-rw-r--r-- | mail/ChangeLog | 17 | ||||
-rw-r--r-- | mail/em-folder-browser.c | 5 | ||||
-rw-r--r-- | mail/em-folder-selector.c | 6 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 29 | ||||
-rw-r--r-- | mail/em-folder-tree.h | 4 | ||||
-rw-r--r-- | mail/em-folder-utils.c | 40 | ||||
-rw-r--r-- | mail/em-folder-utils.h | 2 | ||||
-rw-r--r-- | mail/mail-component.c | 10 |
8 files changed, 78 insertions, 35 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 445e93f3d8..a878ab648e 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,20 @@ +2007-08-02 Srinivasa Ragavan <sragavan@novell.com> + + ** Fix for expanding newly created folders from Lucky + + * em-folder-browser.c: (emfb_folder_create): + * em-folder-selector.c: (emfs_response), + (em_folder_selector_set_selected), + (em_folder_selector_set_selected_list): + * em-folder-tree.c: (em_folder_tree_set_selected_list), + (emft_popup_new_folder), (em_folder_tree_set_selected): + * em-folder-tree.h: + * em-folder-utils.c: (new_folder_created_cb), + (emfu_popup_new_folder_response), (em_folder_utils_create_folder): + * em-folder-utils.h: + * mail-component.c: (impl_createView), (create_item), + (create_local_item_cb), (impl_requestCreateItem): + 2007-07-31 Veerapuram Varadhan <vvaradhan@novell.com> * em-format-html.c (efh_format_headers): Do not show the diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 58a694fb90..7af149fba5 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -1415,6 +1415,7 @@ emfb_folder_create(BonoboUIComponent *uid, void *data, const char *path) EMFolderBrowser *emfb = data; CamelFolderInfo *fi = NULL; CamelException ex; + EMFolderTree *tree = g_object_get_data (G_OBJECT (emfb), "foldertree"); camel_exception_init (&ex); @@ -1425,9 +1426,9 @@ emfb_folder_create(BonoboUIComponent *uid, void *data, const char *path) emfb->view.folder->full_name, CAMEL_STORE_FOLDER_INFO_FAST, &ex)) != NULL) - em_folder_utils_create_folder(fi); + em_folder_utils_create_folder(fi, tree); } else { - em_folder_utils_create_folder(NULL); + em_folder_utils_create_folder(NULL, tree); } diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c index 42453837fb..d93bbc3c1b 100644 --- a/mail/em-folder-selector.c +++ b/mail/em-folder-selector.c @@ -139,7 +139,7 @@ emfs_response (GtkWidget *dialog, int response, EMFolderSelector *emfs) if (response != EM_FOLDER_SELECTOR_RESPONSE_NEW) return; - em_folder_utils_create_folder(NULL); + em_folder_utils_create_folder(NULL, emfs->emft); g_signal_stop_emission_by_name (emfs, "response"); } @@ -282,13 +282,13 @@ em_folder_selector_create_new (EMFolderTree *emft, guint32 flags, const char *ti void em_folder_selector_set_selected (EMFolderSelector *emfs, const char *uri) { - em_folder_tree_set_selected (emfs->emft, uri); + em_folder_tree_set_selected (emfs->emft, uri, FALSE); } void em_folder_selector_set_selected_list (EMFolderSelector *emfs, GList *list) { - em_folder_tree_set_selected_list (emfs->emft, list); + em_folder_tree_set_selected_list (emfs->emft, list, FALSE); } const char * diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index e3eb4b8391..1e1a9f3f22 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -572,7 +572,7 @@ em_folder_tree_new (void) } /* NOTE: Removes and frees the selected uri structure */ -static void +static void emft_select_uri(EMFolderTree *emft, GtkTreePath *path, struct _selected_uri *u) { struct _EMFolderTreePrivate *priv = emft->priv; @@ -1602,13 +1602,14 @@ emft_clear_selected_list(EMFolderTree *emft) } void -em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list) +em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list, gboolean expand_only) { struct _EMFolderTreePrivate *priv = emft->priv; int id = 0; /* FIXME: need to remove any currently selected stuff? */ - emft_clear_selected_list(emft); + if (!expand_only) + emft_clear_selected_list(emft); for (;list;list = list->next) { struct _selected_uri *u = g_malloc0(sizeof(*u)); @@ -1621,9 +1622,11 @@ em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list) url = camel_url_new(u->uri, NULL); if (u->store == NULL || url == NULL) { - u->key = g_strdup_printf("dummy-%d:%s", id++, u->uri); - g_hash_table_insert(priv->select_uris_table, u->key, u); - priv->select_uris = g_slist_append(priv->select_uris, u); + if (!expand_only) { + u->key = g_strdup_printf("dummy-%d:%s", id++, u->uri); + g_hash_table_insert(priv->select_uris_table, u->key, u); + priv->select_uris = g_slist_append(priv->select_uris, u); + } } else { const char *path; char *expand_key, *end; @@ -1645,10 +1648,12 @@ em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list) else expand_key = g_strdup_printf ("local/%s", path); - u->key = g_strdup(expand_key); + if (!expand_only) { + u->key = g_strdup(expand_key); - g_hash_table_insert(priv->select_uris_table, u->key, u); - priv->select_uris = g_slist_append(priv->select_uris, u); + g_hash_table_insert(priv->select_uris_table, u->key, u); + priv->select_uris = g_slist_append(priv->select_uris, u); + } end = strrchr(expand_key, '/'); do { @@ -2011,7 +2016,7 @@ emft_popup_new_folder (EPopup *ep, EPopupItem *pitem, void *data) CamelFolderInfo *fi; if ((fi = em_folder_tree_get_selected_folder_info (emft)) != NULL) { - em_folder_utils_create_folder(fi); + em_folder_utils_create_folder(fi, emft); camel_folder_info_free(fi); } } @@ -2307,14 +2312,14 @@ emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft) } void -em_folder_tree_set_selected (EMFolderTree *emft, const char *uri) +em_folder_tree_set_selected (EMFolderTree *emft, const char *uri, gboolean expand_only) { GList *l = NULL; if (uri && uri[0]) l = g_list_append(l, (void *)uri); - em_folder_tree_set_selected_list(emft, l); + em_folder_tree_set_selected_list(emft, l, expand_only); g_list_free(l); } diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h index 5af8284ea7..e974224c01 100644 --- a/mail/em-folder-tree.h +++ b/mail/em-folder-tree.h @@ -78,11 +78,11 @@ void em_folder_tree_set_multiselect (EMFolderTree *emft, gboolean mode); void em_folder_tree_set_excluded(EMFolderTree *emft, guint32 flags); void em_folder_tree_set_excluded_func(EMFolderTree *emft, EMFTExcludeFunc exclude, void *data); -void em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list); +void em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list, gboolean expand_only); GList *em_folder_tree_get_selected_uris (EMFolderTree *emft); GList *em_folder_tree_get_selected_paths (EMFolderTree *emft); -void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri); +void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri, gboolean expand_only); void em_folder_tree_select_next_path (EMFolderTree *emft, gboolean skip_read_folders); void em_folder_tree_select_prev_path (EMFolderTree *emft, gboolean skip_read_folders); char *em_folder_tree_get_selected_uri (EMFolderTree *emft); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 43f7b83ae4..c795bb90f9 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -1,3 +1,4 @@ + /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Authors: Jeffrey Stedfast <fejj@ximian.com> @@ -573,6 +574,14 @@ struct _EMCreateFolder { void *user_data; }; +/* Temporary Structure to hold data to pass across function */ +struct _EMCreateFolderTempData +{ + EMFolderTree * emft; + EMFolderSelector * emfs; + char *uri; +}; + static char * emfu_create_folder__desc (struct _mail_msg *mm, int done) { @@ -660,12 +669,16 @@ emfu_create_folder_real (CamelStore *store, const char *full_name, void (* done) static void new_folder_created_cb (CamelFolderInfo *fi, void *user_data) { - EMFolderSelector *emfs = user_data; - - if (fi) - gtk_widget_destroy ((GtkWidget *) emfs); - - g_object_unref (emfs); + struct _EMCreateFolderTempData *emcftd=user_data; + if (fi){ + gtk_widget_destroy ((GtkWidget *) emcftd->emfs); + + /* Exapnding newly created folder */ + if (emcftd->emft) + em_folder_tree_set_selected ((EMFolderTree *) emcftd->emft, emcftd->uri, TRUE); + } + g_object_unref (emcftd->emfs); + g_free (emcftd); } static void @@ -675,6 +688,7 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, int response, gpointer d const char *uri, *path; CamelException ex; CamelStore *store; + struct _EMCreateFolderTempData *emcftd; if (response != GTK_RESPONSE_OK) { gtk_widget_destroy ((GtkWidget *) emfs); @@ -709,17 +723,23 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, int response, gpointer d vfolder_gui_add_rule(rule); gtk_widget_destroy((GtkWidget *)emfs); } else { + /* Temp data to pass to create_folder_real function */ + emcftd = (struct _EMCreateFolderTempData *) g_malloc(sizeof(struct _EMCreateFolderTempData)); + emcftd->emfs = emfs; + emcftd->uri = uri; + emcftd->emft = (EMFolderTree *) data; + g_object_ref (emfs); - emfu_create_folder_real (si->store, path, new_folder_created_cb, emfs); + emfu_create_folder_real (si->store, path, new_folder_created_cb, emcftd); } - + camel_object_unref (store); camel_exception_clear (&ex); } /* FIXME: these functions must be documented */ void -em_folder_utils_create_folder (CamelFolderInfo *folderinfo) { +em_folder_utils_create_folder (CamelFolderInfo *folderinfo, EMFolderTree *emft) { EMFolderTree *folder_tree; EMFolderTreeModel *model; GtkWidget *dialog; @@ -730,6 +750,6 @@ em_folder_utils_create_folder (CamelFolderInfo *folderinfo) { dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:")); if (folderinfo != NULL) em_folder_selector_set_selected ((EMFolderSelector *) dialog, folderinfo->uri); - g_signal_connect (dialog, "response", G_CALLBACK (emfu_popup_new_folder_response), folder_tree); + g_signal_connect (dialog, "response", G_CALLBACK (emfu_popup_new_folder_response), emft); gtk_widget_show (dialog); } diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h index c063e04759..d356aa37a8 100644 --- a/mail/em-folder-utils.h +++ b/mail/em-folder-utils.h @@ -33,6 +33,6 @@ void em_folder_utils_copy_folder (struct _CamelFolderInfo *folderinfo, int delet void em_folder_utils_delete_folder (struct _CamelFolder *folder); void em_folder_utils_rename_folder (struct _CamelFolder *folder); -void em_folder_utils_create_folder (struct _CamelFolderInfo *folderinfo); +void em_folder_utils_create_folder (struct _CamelFolderInfo *folderinfo, EMFolderTree * emft); #endif diff --git a/mail/mail-component.c b/mail/mail-component.c index 65f2a5a56b..b9b1e4247a 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -703,7 +703,7 @@ impl_createView (PortableServer_Servant servant, em_folder_tree_enable_drag_and_drop ((EMFolderTree *) tree_widget); if ((uri = em_folder_tree_model_get_selected (priv->model))) { - em_folder_tree_set_selected ((EMFolderTree *) tree_widget, uri); + em_folder_tree_set_selected ((EMFolderTree *) tree_widget, uri, FALSE); em_folder_view_set_folder_uri ((EMFolderView *) view_widget, uri); g_free (uri); } @@ -892,7 +892,7 @@ impl__get_userCreatableItems (PortableServer_Servant servant, CORBA_Environment } static int -create_item(const char *type, EMFolderTreeModel *model, const char *uri) +create_item(const char *type, EMFolderTreeModel *model, const char *uri, gpointer tree) { if (strcmp(type, "message") == 0) { if (!em_utils_check_user_can_send_mail(NULL)) @@ -900,7 +900,7 @@ create_item(const char *type, EMFolderTreeModel *model, const char *uri) em_utils_compose_new_message(uri); } else if (strcmp(type, "folder") == 0) { - em_folder_utils_create_folder(NULL); + em_folder_utils_create_folder(NULL, tree); } else return -1; @@ -913,7 +913,7 @@ create_local_item_cb(EUserCreatableItemsHandler *handler, const char *item_type_ EMFolderTree *tree = data; char *uri = em_folder_tree_get_selected_uri(tree); - create_item(item_type_name, em_folder_tree_get_model(tree), uri); + create_item(item_type_name, em_folder_tree_get_model(tree), uri, (gpointer) tree); g_free(uri); } @@ -924,7 +924,7 @@ impl_requestCreateItem (PortableServer_Servant servant, { MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant)); - if (create_item(item_type_name, mc->priv->model, NULL) == -1) { + if (create_item(item_type_name, mc->priv->model, NULL, NULL) == -1) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); } |