diff options
-rw-r--r-- | mail/e-mail-paned-view.c | 24 | ||||
-rw-r--r-- | mail/em-utils.c | 14 | ||||
-rw-r--r-- | mail/em-utils.h | 3 | ||||
-rw-r--r-- | mail/message-list.c | 25 | ||||
-rw-r--r-- | mail/message-list.h | 5 |
5 files changed, 31 insertions, 40 deletions
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index 33c8a6e98a..ef099197cd 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -142,24 +142,29 @@ mail_paned_view_message_list_built_cb (EMailView *view, if (message_list->cursor_uid != NULL) ; /* do nothing */ - else if (message_list->folder_uri == NULL) + else if (message_list->folder == NULL) ; /* do nothing */ else if (e_shell_window_get_safe_mode (shell_window)) e_shell_window_set_safe_mode (shell_window, FALSE); else { - const gchar *folder_uri; + CamelFolder *folder; const gchar *key; + gchar *folder_uri; gchar *group_name; gchar *uid; + folder = message_list->folder; + folder_uri = e_mail_folder_uri_from_folder (folder); + key = STATE_KEY_SELECTED_MESSAGE; - folder_uri = message_list->folder_uri; group_name = g_strdup_printf ("Folder %s", folder_uri); uid = g_key_file_get_string (key_file, group_name, key, NULL); g_free (group_name); + g_free (folder_uri); + /* Use selection fallbacks if UID is not found. */ message_list_select_uid (message_list, uid, TRUE); @@ -173,22 +178,25 @@ mail_paned_view_message_selected_cb (EMailView *view, MessageList *message_list) { EShellView *shell_view; + CamelFolder *folder; GKeyFile *key_file; - const gchar *folder_uri; const gchar *key; + gchar *folder_uri; gchar *group_name; - folder_uri = message_list->folder_uri; + folder = message_list->folder; /* This also gets triggered when selecting a store name on * the sidebar such as "On This Computer", in which case - * 'folder_uri' will be NULL. */ - if (folder_uri == NULL) + * 'folder' will be NULL. */ + if (folder == NULL) return; shell_view = e_mail_view_get_shell_view (view); key_file = e_shell_view_get_state_key_file (shell_view); + folder_uri = e_mail_folder_uri_from_folder (folder); + key = STATE_KEY_SELECTED_MESSAGE; group_name = g_strdup_printf ("Folder %s", folder_uri); @@ -199,7 +207,7 @@ mail_paned_view_message_selected_cb (EMailView *view, e_shell_view_set_state_dirty (shell_view); g_free (group_name); - + g_free (folder_uri); } static void diff --git a/mail/em-utils.c b/mail/em-utils.c index 61b5baabc1..9b21fda7ad 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -771,25 +771,27 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, /** * em_utils_selection_set_uidlist: * @selection_data: selection data - * @uri: + * @folder: * @uids: * * Sets a "x-uid-list" format selection data. - * - * FIXME: be nice if this could take a folder argument rather than uri **/ void em_utils_selection_set_uidlist (GtkSelectionData *selection_data, - const gchar *uri, + CamelFolder *folder, GPtrArray *uids) { GByteArray *array = g_byte_array_new (); GdkAtom target; + gchar *folder_uri; gint i; /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn\0" */ - g_byte_array_append (array, (guchar *)uri, strlen (uri)+1); + folder_uri = e_mail_folder_uri_from_folder (folder); + + g_byte_array_append ( + array, (guchar *) folder_uri, strlen (folder_uri) + 1); for (i=0; i<uids->len; i++) g_byte_array_append (array, uids->pdata[i], strlen (uids->pdata[i])+1); @@ -798,6 +800,8 @@ em_utils_selection_set_uidlist (GtkSelectionData *selection_data, gtk_selection_data_set ( selection_data, target, 8, array->data, array->len); g_byte_array_free (array, TRUE); + + g_free (folder_uri); } /** diff --git a/mail/em-utils.h b/mail/em-utils.h index 7f5adf3250..5ae9951a68 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -56,8 +56,7 @@ void em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folde void em_utils_selection_set_mailbox (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_mailbox (GtkSelectionData *data, CamelFolder *folder); void em_utils_selection_get_message (GtkSelectionData *data, CamelFolder *folder); -/* FIXME: be nice if these also worked on CamelFolder's, no easy way to get uri from folder yet tho */ -void em_utils_selection_set_uidlist (GtkSelectionData *data, const gchar *uri, GPtrArray *uids); +void em_utils_selection_set_uidlist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_uidlist (GtkSelectionData *data, EMailSession *session, CamelFolder *dest, gint move, GCancellable *cancellable, GError **error); void em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder); diff --git a/mail/message-list.c b/mail/message-list.c index 6c0b532286..99e83a28b6 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -99,7 +99,6 @@ struct _MLSelection { GPtrArray *uids; CamelFolder *folder; - gchar *folder_uri; }; struct _MessageListPrivate { @@ -527,8 +526,6 @@ clear_selection (MessageList *ml, struct _MLSelection *selection) g_object_unref (selection->folder); selection->folder = NULL; } - g_free (selection->folder_uri); - selection->folder_uri = NULL; } static ETreePath @@ -987,9 +984,7 @@ message_list_copy (MessageList *ml, gboolean cut) } p->clipboard.uids = uids; - p->clipboard.folder = ml->folder; - g_object_ref (p->clipboard.folder); - p->clipboard.folder_uri = g_strdup (ml->folder_uri); + p->clipboard.folder = g_object_ref (ml->folder); gtk_selection_owner_set (p->invisible, GDK_SELECTION_CLIPBOARD, gtk_get_current_event_time ()); } else { em_utils_uids_free (uids); @@ -2147,7 +2142,7 @@ ml_selection_get (GtkWidget *widget, GtkSelectionData *data, guint info, guint t } else { /* x-uid-list */ d(printf("setting x-uid-list selection for uids\n")); - em_utils_selection_set_uidlist (data, selection->folder_uri, selection->uids); + em_utils_selection_set_uidlist (data, selection->folder, selection->uids); } } @@ -2199,7 +2194,7 @@ ml_tree_drag_data_get (ETree *tree, gint row, ETreePath path, gint col, if (uids->len > 0) { switch (info) { case DND_X_UID_LIST: - em_utils_selection_set_uidlist (data, ml->folder_uri, uids); + em_utils_selection_set_uidlist (data, ml->folder, uids); break; case DND_TEXT_URI_LIST: em_utils_selection_set_urilist (data, ml->folder, uids); @@ -2648,9 +2643,6 @@ message_list_finalize (GObject *object) g_mutex_free (message_list->regen_lock); - g_free (message_list->folder_uri); - message_list->folder_uri = NULL; - clear_selection (message_list, &priv->clipboard); /* Chain up to parent's finalize() method. */ @@ -3819,17 +3811,6 @@ message_list_set_folder (MessageList *message_list, message_list->thread_tree = NULL; } - g_free (message_list->folder_uri); - message_list->folder_uri = NULL; - - /* XXX Not sure if MESSAGE_SELECTED signal handlers rely on - * folder_uri being set, so avoid temptation to move this - * logic down until verifying it's safe. */ - if (CAMEL_IS_FOLDER (folder)) { - const gchar *uri = camel_folder_get_uri (folder); - message_list->folder_uri = g_strdup (uri); - } - if (message_list->cursor_uid) { g_free (message_list->cursor_uid); message_list->cursor_uid = NULL; diff --git a/mail/message-list.h b/mail/message-list.h index 699c4ce47f..6223c49ad8 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -104,9 +104,8 @@ struct _MessageList { ETreePath tree_root; ETableExtras *extras; - /* The folder & matching uri */ - CamelFolder *folder; - gchar *folder_uri; + /* The folder being shown. */ + CamelFolder *folder; GHashTable *uid_nodemap; /* uid (from info) -> tree node mapping */ |