[evolution] Bug #553927 - Autoselect newly created accounts in the folder tree
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #553927 - Autoselect newly created accounts in the folder tree
- Date: Tue, 18 Feb 2014 15:31:16 +0000 (UTC)
commit ab50665557df261e7207c1b8a3bcf92eb005e869
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 18 16:31:09 2014 +0100
Bug #553927 - Autoselect newly created accounts in the folder tree
mail/e-mail-config-assistant.c | 47 ++++++++++++++++++++++++
mail/em-folder-tree.c | 79 ++++++++++++++++++++++++++++++++++++++++
mail/em-folder-tree.h | 3 ++
3 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/mail/e-mail-config-assistant.c b/mail/e-mail-config-assistant.c
index 6294494..e847493 100644
--- a/mail/e-mail-config-assistant.c
+++ b/mail/e-mail-config-assistant.c
@@ -22,6 +22,11 @@
#include <libebackend/libebackend.h>
+#include <shell/e-shell.h>
+#include <shell/e-shell-window.h>
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-sidebar.h>
+
#include <mail/e-mail-config-confirm-page.h>
#include <mail/e-mail-config-identity-page.h>
#include <mail/e-mail-config-lookup-page.h>
@@ -31,6 +36,8 @@
#include <mail/e-mail-config-summary-page.h>
#include <mail/e-mail-config-welcome-page.h>
+#include "em-folder-tree.h"
+
#define E_MAIL_CONFIG_ASSISTANT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_CONFIG_ASSISTANT, EMailConfigAssistantPrivate))
@@ -365,6 +372,40 @@ mail_config_assistant_provider_page_visible (GBinding *binding,
}
static void
+mail_config_assistant_select_account_node (const gchar *account_uid)
+{
+ EShell *shell;
+ EShellWindow *shell_window;
+ EShellView *shell_view;
+ EShellSidebar *shell_sidebar;
+ EMFolderTree *folder_tree = NULL;
+ GtkWindow *active_window;
+
+ g_return_if_fail (account_uid != NULL);
+
+ shell = e_shell_get_default ();
+ active_window = e_shell_get_active_window (shell);
+
+ if (!E_IS_SHELL_WINDOW (active_window))
+ return;
+
+ shell_window = E_SHELL_WINDOW (active_window);
+
+ if (g_strcmp0 (e_shell_window_get_active_view (shell_window), "mail") != 0)
+ return;
+
+ shell_view = e_shell_window_get_shell_view (shell_window, "mail");
+
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
+
+ em_folder_tree_select_store_when_added (folder_tree, account_uid);
+
+ g_object_unref (folder_tree);
+
+}
+
+static void
mail_config_assistant_close_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -396,6 +437,12 @@ mail_config_assistant_close_cb (GObject *object,
g_error_free (error);
} else {
+ ESource *account;
+
+ account = e_mail_config_assistant_get_account_source (assistant);
+ if (account)
+ mail_config_assistant_select_account_node (e_source_get_uid (account));
+
gtk_widget_destroy (GTK_WIDGET (assistant));
}
}
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index f4ba8b9..3a094e6 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -96,6 +96,7 @@ struct _EMFolderTreePrivate {
guint loading_row_id;
guint loaded_row_id;
+ guint row_changed_id;
GtkTreeRowReference *drag_row;
gboolean skip_double_click;
@@ -104,6 +105,8 @@ struct _EMFolderTreePrivate {
GtkWidget *selectable; /* an ESelectable, where to pass selectable calls */
+ gchar *select_store_uid_when_added;
+
/* Signal handler IDs */
gulong selection_changed_handler_id;
};
@@ -559,6 +562,44 @@ folder_tree_maybe_expand_row (EMFolderTreeModel *model,
}
static void
+folder_tree_row_changed_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ EMFolderTree *folder_tree)
+{
+ gboolean is_store = FALSE;
+ CamelService *service = NULL;
+
+ g_return_if_fail (EM_IS_FOLDER_TREE (folder_tree));
+
+ if (!folder_tree->priv->select_store_uid_when_added ||
+ gtk_tree_path_get_depth (path) != 1)
+ return;
+
+ gtk_tree_model_get (model, iter,
+ COL_OBJECT_CAMEL_STORE, &service,
+ COL_BOOL_IS_STORE, &is_store,
+ -1);
+
+ if (is_store && service &&
+ g_strcmp0 (folder_tree->priv->select_store_uid_when_added, camel_service_get_uid (service)) == 0)
{
+ GtkTreeSelection *selection;
+
+ g_free (folder_tree->priv->select_store_uid_when_added);
+ folder_tree->priv->select_store_uid_when_added = NULL;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree));
+
+ gtk_tree_selection_select_iter (selection, iter);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (folder_tree), path, NULL, FALSE);
+ folder_tree->priv->cursor_set = TRUE;
+ gtk_tree_view_expand_row (GTK_TREE_VIEW (folder_tree), path, FALSE);
+ }
+
+ g_clear_object (&service);
+}
+
+static void
folder_tree_clear_selected_list (EMFolderTree *folder_tree)
{
EMFolderTreePrivate *priv = folder_tree->priv;
@@ -1094,6 +1135,11 @@ folder_tree_dispose (GObject *object)
priv->loading_row_id = 0;
}
+ if (priv->row_changed_id != 0) {
+ g_signal_handler_disconnect (model, priv->row_changed_id);
+ priv->row_changed_id = 0;
+ }
+
if (priv->selection_changed_handler_id != 0) {
g_signal_handler_disconnect (selection, priv->selection_changed_handler_id);
priv->selection_changed_handler_id = 0;
@@ -1151,6 +1197,9 @@ folder_tree_finalize (GObject *object)
priv->select_uris_table = NULL;
}
+ g_free (priv->select_store_uid_when_added);
+ priv->select_store_uid_when_added = NULL;
+
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (em_folder_tree_parent_class)->finalize (object);
}
@@ -1185,6 +1234,12 @@ folder_tree_constructed (GObject *object)
G_CALLBACK (folder_tree_maybe_expand_row), object);
priv->loaded_row_id = handler_id;
+ /* Cannot attach to "row-inserted", because the row is inserted empty */
+ handler_id = g_signal_connect (
+ model, "row-changed",
+ G_CALLBACK (folder_tree_row_changed_cb), object);
+ priv->row_changed_id = handler_id;
+
handler_id = g_signal_connect_swapped (
selection, "changed",
G_CALLBACK (folder_tree_selection_changed_cb), object);
@@ -3650,3 +3705,27 @@ em_folder_tree_restore_state (EMFolderTree *folder_tree,
valid = gtk_tree_model_iter_next (tree_model, &iter);
}
}
+
+/**
+ * em_folder_tree_select_store_when_added:
+ * @folder_tree: an #EMFolderTree
+ * @store_uid: UID of a CamelStore to remember to select
+ *
+ * Instruct @folder_tree to select a CamelStore with UID @store_uid,
+ * if/when it is added to the tree. This is necessary, because
+ * the addition is done asynchronously.
+ *
+ * Since: 3.12
+ **/
+void
+em_folder_tree_select_store_when_added (EMFolderTree *folder_tree,
+ const gchar *store_uid)
+{
+ g_return_if_fail (EM_IS_FOLDER_TREE (folder_tree));
+
+ if (g_strcmp0 (store_uid, folder_tree->priv->select_store_uid_when_added) == 0)
+ return;
+
+ g_free (folder_tree->priv->select_store_uid_when_added);
+ folder_tree->priv->select_store_uid_when_added = g_strdup (store_uid);
+}
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index bd09cb0..0972888 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -141,6 +141,9 @@ void em_folder_tree_restore_state (EMFolderTree *folder_tree,
void em_folder_tree_set_selectable_widget
(EMFolderTree *folder_tree,
GtkWidget *selectable);
+void em_folder_tree_select_store_when_added
+ (EMFolderTree *folder_tree,
+ const gchar *store_uid);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]