[evolution/account-mgmt: 6/25] Adapt EContactEditor to the new ESource API.



commit 3a26527863d629c2b85167c9825ed3ef1a31b80a
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Dec 8 00:16:30 2010 -0500

    Adapt EContactEditor to the new ESource API.

 addressbook/gui/contact-editor/contact-editor.ui   |    1 +
 addressbook/gui/contact-editor/e-contact-editor.c  |    2 +-
 .../gui/contact-editor/e-contact-quick-add.c       |   37 ++++++++++++-------
 3 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 88c90c1..89f5e4d 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -231,6 +231,7 @@
                                 </child>
                                 <child>
                                   <object class="ESourceComboBox" type-func="e_source_combo_box_get_type" id="source-combo-box-source">
+                                    <property name="extension-name">Address Book</property>
                                     <property name="visible">True</property>
                                   </object>
                                   <packing>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 4ca2dd6..90bf3a6 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -25,6 +25,7 @@
 #include "eab-editor.h"
 #include "e-contact-editor.h"
 
+#include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <gtk/gtk.h>
@@ -3585,7 +3586,6 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
 	widget = e_builder_get_widget(e_contact_editor->builder, "button-categories");
 	g_signal_connect (widget, "clicked", G_CALLBACK (categories_clicked), e_contact_editor);
 	widget = e_builder_get_widget (e_contact_editor->builder, "source-combo-box-source");
-	e_util_set_source_combo_box_list (widget, "/apps/evolution/addressbook/sources");
 	g_signal_connect (widget, "changed", G_CALLBACK (source_changed), e_contact_editor);
 	label = e_builder_get_widget (e_contact_editor->builder, "where-label");
 	gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 032f4ac..bd6f856 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -27,6 +27,7 @@
 #include <glib/gi18n.h>
 #include <libebook/e-book.h>
 #include <libebook/e-contact.h>
+#include <libebook/e-source-address-book.h>
 #include <libedataserverui/e-source-combo-box.h>
 #include <addressbook/util/addressbook.h>
 #include <addressbook/util/eab-book-util.h>
@@ -129,10 +130,11 @@ merge_cb (EBook *book, const GError *error, gpointer closure)
 		if (e_book_is_writable (book))
 			eab_merging_book_add_contact (book, qa->contact, NULL, NULL);
 		else
-			e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
-						     "addressbook:error-read-only",
-						     e_source_peek_name (e_book_get_source (book)),
-						     NULL);
+			e_alert_run_dialog_for_args (
+				e_shell_get_active_window (NULL),
+				"addressbook:error-read-only",
+				e_source_get_name (e_book_get_source (book)),
+				NULL);
 
 		if (qa->cb)
 			qa->cb (qa->contact, qa->closure);
@@ -340,13 +342,13 @@ source_changed (ESourceComboBox *source_combo_box, QuickAdd *qa)
 static GtkWidget *
 build_quick_add_dialog (QuickAdd *qa)
 {
-	ESourceList *source_list;
-	GConfClient *gconf_client;
+	ESourceRegistry *registry;
 	GtkWidget *container;
 	GtkWidget *dialog;
 	GtkWidget *label;
 	GtkTable *table;
 	EBook *book;
+	const gchar *extension_name;
 	const gint xpad=0, ypad=0;
 
 	g_return_val_if_fail (qa != NULL, NULL);
@@ -385,16 +387,19 @@ build_quick_add_dialog (QuickAdd *qa)
 		gtk_widget_set_sensitive (qa->email_entry, FALSE);
 	}
 
-	gconf_client = gconf_client_get_default ();
-	source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources");
-	g_object_unref (gconf_client);
-	qa->combo_box = e_source_combo_box_new (source_list);
+	registry = e_source_registry_get_default ();
+	extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+
+	qa->combo_box = e_source_combo_box_new (registry, extension_name);
 	book = e_book_new_default_addressbook (NULL);
 	e_source_combo_box_set_active (
 		E_SOURCE_COMBO_BOX (qa->combo_box),
 		e_book_get_source (book));
 
 	if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
+		ESource *source;
+		GList *list;
+
 		/* this means the e_book_new_default_addressbook didn't find any "default" nor "system" source,
 		    and created new one for us. That is wrong, choose one from combo instead. */
 
@@ -403,8 +408,14 @@ build_quick_add_dialog (QuickAdd *qa)
 			book = NULL;
 		}
 
-		book = e_book_new (e_source_list_peek_source_any (source_list), NULL);
-		e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (qa->combo_box), e_book_get_source (book));
+		list = e_source_registry_list_sources (registry, extension_name);
+		source = (list != NULL) ? E_SOURCE (list->data) : NULL;
+
+		if (source != NULL) {
+			book = e_book_new (source, NULL);
+			e_source_combo_box_set_active (
+				E_SOURCE_COMBO_BOX (qa->combo_box), source);
+		}
 
 		if (!e_source_combo_box_get_active_uid (E_SOURCE_COMBO_BOX (qa->combo_box))) {
 			/* Does it failed again? What is going on? */
@@ -424,8 +435,6 @@ build_quick_add_dialog (QuickAdd *qa)
 		qa->combo_box, "changed",
 		G_CALLBACK (source_changed), qa);
 
-	g_object_unref (source_list);
-
 	table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
 	gtk_table_set_row_spacings (table, 6);
 	gtk_table_set_col_spacings (table, 12);



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