[evolution] Bug #691134 - New contact lists always saved to a default book



commit 268b609f9d9bfab9a40fff87e82511710be7b511
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 8 22:14:26 2013 +0100

    Bug #691134 - New contact lists always saved to a default book

 .../contact-list-editor/e-contact-list-editor.c    |    2 +-
 modules/addressbook/e-book-shell-backend.c         |   36 ++++++++++++++++++--
 2 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index 8f0c878..f722210 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -946,7 +946,7 @@ contact_list_editor_source_menu_changed_cb (GtkWidget *widget)
 
 	if (!e_source_equal (client_source, active_source))
 		e_client_utils_open_new (
-			client_source, E_CLIENT_SOURCE_TYPE_CONTACTS,
+			active_source, E_CLIENT_SOURCE_TYPE_CONTACTS,
 			FALSE, NULL, contact_list_editor_book_loaded_cb,
 			g_object_ref (editor));
 
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 5dded83..3886c7f 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -33,6 +33,7 @@
 #include "shell/e-shell-window.h"
 
 #include "addressbook/gui/widgets/eab-gui-util.h"
+#include "addressbook/gui/widgets/e-addressbook-view.h"
 #include "addressbook/gui/contact-editor/e-contact-editor.h"
 #include "addressbook/gui/contact-editor/e-contact-quick-add.h"
 #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
@@ -40,6 +41,7 @@
 
 #include "autocompletion-config.h"
 
+#include "e-book-shell-content.h"
 #include "e-book-shell-migrate.h"
 #include "e-book-shell-settings.h"
 #include "e-book-shell-view.h"
@@ -171,7 +173,7 @@ action_contact_new_cb (GtkAction *action,
                        EShellWindow *shell_window)
 {
 	EShell *shell;
-	ESource *source;
+	ESource *source = NULL;
 	ESourceRegistry *registry;
 	const gchar *action_name;
 
@@ -179,8 +181,36 @@ action_contact_new_cb (GtkAction *action,
 
 	shell = e_shell_window_get_shell (shell_window);
 
-	registry = e_shell_get_registry (shell);
-	source = e_source_registry_ref_default_address_book (registry);
+	if (g_strcmp0 (e_shell_window_get_active_view (shell_window), "addressbook") == 0) {
+		EShellView *shell_view = e_shell_window_get_shell_view (shell_window, "addressbook");
+
+		if (shell_view && E_IS_BOOK_SHELL_VIEW (shell_view)) {
+			EBookShellContent *book_shell_content;
+			EAddressbookView *view;
+			EAddressbookModel *model;
+			EBookClient *book_client;
+
+			book_shell_content = NULL;
+			g_object_get (G_OBJECT (shell_view), "shell-content", &book_shell_content, NULL);
+			g_return_if_fail (book_shell_content != NULL);
+
+			view = e_book_shell_content_get_current_view (book_shell_content);
+			g_return_if_fail (view != NULL);
+
+			model = e_addressbook_view_get_model (view);
+			book_client = e_addressbook_model_get_client (model);
+			g_return_if_fail (book_client != NULL);
+
+			source = g_object_ref (e_client_get_source (E_CLIENT (book_client)));
+
+			g_object_unref (book_shell_content);
+		}
+	}
+
+	if (!source) {
+		registry = e_shell_get_registry (shell);
+		source = e_source_registry_ref_default_address_book (registry);
+	}
 
 	/* Use a callback function appropriate for the action. */
 	action_name = gtk_action_get_name (action);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]