[evolution] I#657 - Cannot rename other than selected mail folder
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#657 - Cannot rename other than selected mail folder
- Date: Tue, 1 Sep 2020 13:43:45 +0000 (UTC)
commit a010c953a624fd4fdd2f8749e40646e4f58d3c58
Author: Milan Crha <mcrha redhat com>
Date: Tue Sep 1 15:42:31 2020 +0200
I#657 - Cannot rename other than selected mail folder
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/657
src/mail/em-folder-tree.c | 25 +++++++++++++-
src/modules/mail/e-mail-shell-view-actions.c | 8 +----
src/modules/mail/e-mail-shell-view-private.c | 50 ++++++++++++++++++++++++++--
src/modules/mail/e-mail-shell-view-private.h | 3 ++
src/modules/mail/e-mail-shell-view.c | 29 +---------------
5 files changed, 77 insertions(+), 38 deletions(-)
---
diff --git a/src/mail/em-folder-tree.c b/src/mail/em-folder-tree.c
index b4eab4f9f8..774db93358 100644
--- a/src/mail/em-folder-tree.c
+++ b/src/mail/em-folder-tree.c
@@ -130,6 +130,7 @@ enum {
enum {
FOLDER_ACTIVATED, /* aka double-clicked or user hit enter */
FOLDER_SELECTED,
+ FOLDER_RENAMED,
POPUP_EVENT,
HIDDEN_KEY_EVENT,
LAST_SIGNAL
@@ -723,13 +724,21 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree,
em_folder_tree_set_selected (folder_tree, folder_uri, FALSE);
g_free (folder_uri);
-exit:
+ exit:
+ g_signal_emit (folder_tree, signals[FOLDER_RENAMED], 0, FALSE, NULL);
+
g_free (old_name);
g_free (old_full_name);
g_free (new_full_name);
g_clear_object (&store);
}
+static void
+folder_tree_editing_canceled_cb (EMFolderTree *folder_tree)
+{
+ g_signal_emit (folder_tree, signals[FOLDER_RENAMED], 0, TRUE, NULL);
+}
+
static void
folder_tree_render_store_icon (GtkTreeViewColumn *column,
GtkCellRenderer *renderer,
@@ -1350,6 +1359,10 @@ folder_tree_constructed (GObject *object)
renderer, "edited",
G_CALLBACK (folder_tree_cell_edited_cb), object);
+ g_signal_connect_swapped (
+ renderer, "editing-canceled",
+ G_CALLBACK (folder_tree_editing_canceled_cb), object);
+
column = gtk_tree_view_column_new ();
gtk_tree_view_append_column (tree_view, column);
@@ -1701,6 +1714,16 @@ em_folder_tree_class_init (EMFolderTreeClass *class)
CAMEL_TYPE_STORE,
G_TYPE_STRING);
+ signals[FOLDER_RENAMED] = g_signal_new (
+ "folder-renamed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1,
+ G_TYPE_BOOLEAN);
+
signals[POPUP_EVENT] = g_signal_new (
"popup-event",
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/src/modules/mail/e-mail-shell-view-actions.c b/src/modules/mail/e-mail-shell-view-actions.c
index c7339f3a52..dd56b508e8 100644
--- a/src/modules/mail/e-mail-shell-view-actions.c
+++ b/src/modules/mail/e-mail-shell-view-actions.c
@@ -1055,13 +1055,7 @@ static void
action_mail_folder_rename_cb (GtkAction *action,
EMailShellView *mail_shell_view)
{
- EMailShellSidebar *mail_shell_sidebar;
- EMFolderTree *folder_tree;
-
- mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
- folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
-
- em_folder_tree_edit_selected (folder_tree);
+ e_mail_shell_view_rename_folder (mail_shell_view);
}
static void
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index e99b76a621..f9aabc10d5 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -184,8 +184,7 @@ exit:
}
static void
-mail_shell_view_folder_tree_selection_done_cb (EMailShellView *mail_shell_view,
- GtkWidget *menu)
+mail_shell_view_match_folder_tree_and_message_list_folder (EMailShellView *mail_shell_view)
{
EMailShellContent *mail_shell_content;
EMailShellSidebar *mail_shell_sidebar;
@@ -225,6 +224,16 @@ mail_shell_view_folder_tree_selection_done_cb (EMailShellView *mail_shell_view,
g_free (list_uri);
g_free (tree_uri);
+}
+
+static void
+mail_shell_view_folder_tree_selection_done_cb (EMailShellView *mail_shell_view,
+ GtkWidget *menu)
+{
+ if (!mail_shell_view->priv->ignore_folder_popup_selection_done)
+ mail_shell_view_match_folder_tree_and_message_list_folder (mail_shell_view);
+
+ mail_shell_view->priv->ignore_folder_popup_selection_done = FALSE;
/* Disconnect from the "selection-done" signal. */
g_signal_handlers_disconnect_by_func (
@@ -236,8 +245,12 @@ static void
mail_shell_view_folder_tree_popup_event_cb (EShellView *shell_view,
GdkEvent *button_event)
{
+ EMailShellView *mail_shell_view;
GtkWidget *menu;
+ mail_shell_view = E_MAIL_SHELL_VIEW (shell_view);
+ mail_shell_view->priv->ignore_folder_popup_selection_done = FALSE;
+
menu = e_shell_view_show_popup_menu (
shell_view, "/mail-folder-popup", button_event);
@@ -1525,3 +1538,36 @@ e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view)
GTK_MENU_TOOL_BUTTON (priv->send_receive_tool_item),
create_send_receive_submenu (mail_shell_view));
}
+
+static void
+mail_shell_view_folder_renamed_cb (EMFolderTree *folder_tree,
+ gboolean is_cancelled,
+ EMailShellView *mail_shell_view)
+{
+ g_return_if_fail (EM_IS_FOLDER_TREE (folder_tree));
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ mail_shell_view_match_folder_tree_and_message_list_folder (mail_shell_view);
+
+ g_signal_handlers_disconnect_by_func (folder_tree,
+ mail_shell_view_folder_renamed_cb, mail_shell_view);
+}
+
+void
+e_mail_shell_view_rename_folder (EMailShellView *mail_shell_view)
+{
+ EMailShellSidebar *mail_shell_sidebar;
+ EMFolderTree *folder_tree;
+
+ g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view));
+
+ mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar;
+ folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
+
+ em_folder_tree_edit_selected (folder_tree);
+
+ mail_shell_view->priv->ignore_folder_popup_selection_done = TRUE;
+
+ g_signal_connect_object (folder_tree, "folder-renamed",
+ G_CALLBACK (mail_shell_view_folder_renamed_cb), mail_shell_view, 0);
+}
diff --git a/src/modules/mail/e-mail-shell-view-private.h b/src/modules/mail/e-mail-shell-view-private.h
index 5d158c1244..3725b10a1d 100644
--- a/src/modules/mail/e-mail-shell-view-private.h
+++ b/src/modules/mail/e-mail-shell-view-private.h
@@ -137,6 +137,7 @@ struct _EMailShellViewPrivate {
GtkToolItem *send_receive_tool_separator;
gboolean vfolder_allow_expunge;
+ gboolean ignore_folder_popup_selection_done;
/* Selected UIDs for MAIL_FILTER_MESSAGE_THREAD filter */
GSList *selected_uids;
@@ -165,6 +166,8 @@ void e_mail_shell_view_update_send_receive_menus
(EMailShellView *mail_shell_view);
GDBusProxy * e_mail_shell_view_get_web_extension_proxy
(EMailShellView *mail_shell_view);
+void e_mail_shell_view_rename_folder
+ (EMailShellView *mail_shell_view);
G_END_DECLS
diff --git a/src/modules/mail/e-mail-shell-view.c b/src/modules/mail/e-mail-shell-view.c
index 1c2c3155f6..ae318c97f5 100644
--- a/src/modules/mail/e-mail-shell-view.c
+++ b/src/modules/mail/e-mail-shell-view.c
@@ -1414,7 +1414,6 @@ mail_shell_view_update_actions (EShellView *shell_view)
gboolean folder_is_virtual;
gboolean folder_has_unread = FALSE;
gboolean folder_has_unread_rec = FALSE;
- gboolean folder_tree_and_message_list_agree = TRUE;
gboolean store_is_builtin;
gboolean store_is_subscribable;
gboolean store_can_be_disabled;
@@ -1465,34 +1464,9 @@ mail_shell_view_update_actions (EShellView *shell_view)
if (em_folder_tree_get_selected (folder_tree, &store, &folder_name)) {
GtkTreeRowReference *reference;
- CamelFolder *folder;
folder_is_selected = TRUE;
- folder = e_mail_reader_ref_folder (reader);
-
- /* XXX If the user right-clicks on a folder other than what
- * the message list is showing, disable folder rename.
- * Between fetching the CamelFolder asynchronously and
- * knowing when NOT to move the folder tree selection
- * back to where it was to avoid cancelling the inline
- * folder tree editing, it's just too hairy to try to
- * get right. So we're punting. */
- if (folder != NULL) {
- gchar *uri1, *uri2;
-
- uri1 = e_mail_folder_uri_from_folder (folder);
- uri2 = e_mail_folder_uri_build (store, folder_name);
-
- folder_tree_and_message_list_agree =
- (g_strcmp0 (uri1, uri2) == 0);
-
- g_free (uri1);
- g_free (uri2);
-
- g_object_unref (folder);
- }
-
reference = em_folder_tree_model_get_row_reference (
model, store, folder_name);
if (reference != NULL) {
@@ -1585,8 +1559,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
action = ACTION (MAIL_FOLDER_RENAME);
sensitive =
folder_is_selected &&
- folder_can_be_deleted &&
- folder_tree_and_message_list_agree;
+ folder_can_be_deleted;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MAIL_FOLDER_SELECT_THREAD);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]