[evolution/account-mgmt: 11/55] Adapt EContactEditor to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 11/55] Adapt EContactEditor to the new ESource API.
- Date: Mon, 28 May 2012 21:26:31 +0000 (UTC)
commit d2be878b19d99cfa191f9d51abadd7631d7eb77f
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 | 2 +
addressbook/gui/contact-editor/e-contact-editor.c | 27 +++++----
.../gui/contact-editor/e-contact-quick-add.c | 63 +++++++++++---------
.../gui/contact-editor/e-contact-quick-add.h | 13 +++-
4 files changed, 61 insertions(+), 44 deletions(-)
---
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index 49e95e8..3f5b1f6 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -232,6 +232,8 @@
</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="show-colors">False</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 af92ba2..131ca47 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -3094,13 +3094,10 @@ source_changed (ESourceComboBox *source_combo_box,
ESource *target_source;
ESource *source_source;
ESource *source;
- GtkWindow *parent;
source = e_source_combo_box_ref_active (source_combo_box);
g_return_if_fail (source != NULL);
- parent = eab_editor_get_window (EAB_EDITOR (editor));
-
if (editor->cancellable != NULL) {
g_cancellable_cancel (editor->cancellable);
g_object_unref (editor->cancellable);
@@ -3125,7 +3122,6 @@ source_changed (ESourceComboBox *source_combo_box,
e_client_utils_open_new (
source, E_CLIENT_SOURCE_TYPE_CONTACTS,
FALSE, editor->cancellable,
- e_client_utils_authenticate_handler, parent,
contact_editor_book_loaded_cb, g_object_ref (editor));
exit:
@@ -3581,7 +3577,12 @@ static void
real_save_contact (EContactEditor *ce,
gboolean should_close)
{
+ EShell *shell;
EditorCloseStruct *ecs;
+ ESourceRegistry *registry;
+
+ shell = eab_editor_get_shell (EAB_EDITOR (ce));
+ registry = e_shell_get_registry (shell);
ecs = g_new0 (EditorCloseStruct, 1);
ecs->ce = ce;
@@ -3595,17 +3596,17 @@ real_save_contact (EContactEditor *ce,
if (ce->source_client != ce->target_client) {
/* Two-step move; add to target, then remove from source */
eab_merging_book_add_contact (
- ce->target_client, ce->contact,
- contact_added_cb, ecs);
+ registry, ce->target_client,
+ ce->contact, contact_added_cb, ecs);
} else {
if (ce->is_new_contact)
eab_merging_book_add_contact (
- ce->target_client, ce->contact,
- contact_added_cb, ecs);
+ registry, ce->target_client,
+ ce->contact, contact_added_cb, ecs);
else if (ce->check_merge)
eab_merging_book_modify_contact (
- ce->target_client, ce->contact,
- contact_modified_cb, ecs);
+ registry, ce->target_client,
+ ce->contact, contact_modified_cb, ecs);
else
e_book_client_modify_contact (
ce->target_client, ce->contact, NULL,
@@ -3990,6 +3991,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
{
GtkBuilder *builder;
EShell *shell;
+ ESourceRegistry *registry;
GtkWidget *container;
GtkWidget *widget, *label;
GtkEntryCompletion *completion;
@@ -3997,6 +3999,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
/* FIXME The shell should be obtained
* through a constructor property. */
shell = e_shell_get_default ();
+ registry = e_shell_get_registry (shell);
e_contact_editor->name = e_contact_name_new ();
@@ -4049,8 +4052,8 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
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");
+ e_source_combo_box_set_registry (
+ E_SOURCE_COMBO_BOX (widget), registry);
g_signal_connect (
widget, "changed",
G_CALLBACK (source_changed), e_contact_editor);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 69b35b6..7172a60 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -32,6 +32,7 @@
#include <libebook/e-contact.h>
#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-combo-box.h>
+#include <libedataserver/e-source-address-book.h>
#include <addressbook/util/eab-book-util.h>
#include "e-contact-editor.h"
#include "e-contact-quick-add.h"
@@ -45,7 +46,7 @@ struct _QuickAdd {
gchar *vcard;
EContact *contact;
GCancellable *cancellable;
- ESourceList *source_list;
+ ESourceRegistry *registry;
ESource *source;
EContactQuickAddCallback cb;
@@ -61,10 +62,11 @@ struct _QuickAdd {
};
static QuickAdd *
-quick_add_new (void)
+quick_add_new (ESourceRegistry *registry)
{
QuickAdd *qa = g_new0 (QuickAdd, 1);
qa->contact = e_contact_new ();
+ qa->registry = g_object_ref (registry);
qa->refs = 1;
return qa;
}
@@ -79,12 +81,11 @@ quick_add_unref (QuickAdd *qa)
g_cancellable_cancel (qa->cancellable);
g_object_unref (qa->cancellable);
}
- if (qa->source_list != NULL)
- g_object_unref (qa->source_list);
g_free (qa->name);
g_free (qa->email);
g_free (qa->vcard);
g_object_unref (qa->contact);
+ g_object_unref (qa->registry);
g_free (qa);
}
}
@@ -156,7 +157,7 @@ merge_cb (GObject *source_object,
if (!e_client_is_readonly (client))
eab_merging_book_add_contact (
- E_BOOK_CLIENT (client),
+ qa->registry, E_BOOK_CLIENT (client),
qa->contact, NULL, NULL);
else
e_alert_run_dialog_for_args (
@@ -185,9 +186,7 @@ quick_add_merge_contact (QuickAdd *qa)
e_client_utils_open_new (
qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, qa->cancellable,
- e_client_utils_authenticate_handler, NULL,
- merge_cb, qa);
+ FALSE, qa->cancellable, merge_cb, qa);
}
/* Raise a contact editor with all fields editable,
@@ -313,7 +312,7 @@ ce_have_book (GObject *source_object,
g_return_if_fail (E_IS_CLIENT (client));
eab_merging_book_find_contact (
- E_BOOK_CLIENT (client),
+ qa->registry, E_BOOK_CLIENT (client),
qa->contact, ce_have_contact, qa);
}
@@ -329,9 +328,7 @@ edit_contact (QuickAdd *qa)
e_client_utils_open_new (
qa->source, E_CLIENT_SOURCE_TYPE_CONTACTS,
- FALSE, qa->cancellable,
- e_client_utils_authenticate_handler, NULL,
- ce_have_book, qa);
+ FALSE, qa->cancellable, ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
@@ -429,12 +426,12 @@ source_changed (ESourceComboBox *source_combo_box,
static GtkWidget *
build_quick_add_dialog (QuickAdd *qa)
{
- GConfClient *gconf_client;
GtkWidget *container;
GtkWidget *dialog;
GtkWidget *label;
GtkTable *table;
ESource *source;
+ const gchar *extension_name;
const gint xpad = 0, ypad = 0;
g_return_val_if_fail (qa != NULL, NULL);
@@ -475,16 +472,15 @@ build_quick_add_dialog (QuickAdd *qa)
gtk_widget_set_sensitive (qa->email_entry, FALSE);
}
- gconf_client = gconf_client_get_default ();
- qa->source_list = e_source_list_new_for_gconf (
- gconf_client, "/apps/evolution/addressbook/sources");
- source = e_source_list_peek_default_source (qa->source_list);
- g_object_unref (gconf_client);
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ source = e_source_registry_ref_default_address_book (qa->registry);
- qa->combo_box = e_source_combo_box_new (qa->source_list);
+ qa->combo_box = e_source_combo_box_new (qa->registry, extension_name);
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (qa->combo_box), source);
+ g_object_unref (source);
+
source_changed (E_SOURCE_COMBO_BOX (qa->combo_box), qa);
g_signal_connect (
qa->combo_box, "changed",
@@ -537,7 +533,8 @@ build_quick_add_dialog (QuickAdd *qa)
}
void
-e_contact_quick_add (const gchar *in_name,
+e_contact_quick_add (ESourceRegistry *registry,
+ const gchar *in_name,
const gchar *email,
EContactQuickAddCallback cb,
gpointer closure)
@@ -547,6 +544,8 @@ e_contact_quick_add (const gchar *in_name,
gchar *name = NULL;
gint len;
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+
/* We need to have *something* to work with. */
if (in_name == NULL && email == NULL) {
if (cb)
@@ -568,7 +567,7 @@ e_contact_quick_add (const gchar *in_name,
g_strstrip (name);
}
- qa = quick_add_new ();
+ qa = quick_add_new (registry);
qa->cb = cb;
qa->closure = closure;
if (name)
@@ -583,7 +582,8 @@ e_contact_quick_add (const gchar *in_name,
}
void
-e_contact_quick_add_free_form (const gchar *text,
+e_contact_quick_add_free_form (ESourceRegistry *registry,
+ const gchar *text,
EContactQuickAddCallback cb,
gpointer closure)
{
@@ -591,8 +591,10 @@ e_contact_quick_add_free_form (const gchar *text,
const gchar *last_at, *s;
gboolean in_quote;
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+
if (text == NULL) {
- e_contact_quick_add (NULL, NULL, cb, closure);
+ e_contact_quick_add (registry, NULL, NULL, cb, closure);
return;
}
@@ -656,13 +658,15 @@ e_contact_quick_add_free_form (const gchar *text,
g_strstrip (email);
}
- e_contact_quick_add (name, email, cb, closure);
+ e_contact_quick_add (registry, name, email, cb, closure);
+
g_free (name);
g_free (email);
}
void
-e_contact_quick_add_email (const gchar *email,
+e_contact_quick_add_email (ESourceRegistry *registry,
+ const gchar *email,
EContactQuickAddCallback cb,
gpointer closure)
{
@@ -684,14 +688,15 @@ e_contact_quick_add_email (const gchar *email,
addr = g_strdup (email);
}
- e_contact_quick_add (name, addr, cb, closure);
+ e_contact_quick_add (registry, name, addr, cb, closure);
g_free (name);
g_free (addr);
}
void
-e_contact_quick_add_vcard (const gchar *vcard,
+e_contact_quick_add_vcard (ESourceRegistry *registry,
+ const gchar *vcard,
EContactQuickAddCallback cb,
gpointer closure)
{
@@ -699,6 +704,8 @@ e_contact_quick_add_vcard (const gchar *vcard,
GtkWidget *dialog;
EContact *contact;
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+
/* We need to have *something* to work with. */
if (vcard == NULL) {
if (cb)
@@ -706,7 +713,7 @@ e_contact_quick_add_vcard (const gchar *vcard,
return;
}
- qa = quick_add_new ();
+ qa = quick_add_new (registry);
qa->cb = cb;
qa->closure = closure;
quick_add_set_vcard (qa, vcard);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h
index 861ddba..91e6401 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.h
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.h
@@ -24,21 +24,26 @@
#define __E_CONTACT_QUICK_ADD_H__
#include <libebook/e-contact.h>
+#include <libedataserver/e-source-registry.h>
typedef void (*EContactQuickAddCallback) (EContact *new_contact,
gpointer closure);
-void e_contact_quick_add (const gchar *name,
+void e_contact_quick_add (ESourceRegistry *registry,
+ const gchar *name,
const gchar *email,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_free_form (const gchar *text,
+void e_contact_quick_add_free_form (ESourceRegistry *registry,
+ const gchar *text,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_email (const gchar *email,
+void e_contact_quick_add_email (ESourceRegistry *registry,
+ const gchar *email,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_vcard (const gchar *vcard,
+void e_contact_quick_add_vcard (ESourceRegistry *registry,
+ const gchar *vcard,
EContactQuickAddCallback cb,
gpointer closure);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]