aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/contact-editor
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-02 03:30:14 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-03-02 07:16:07 +0800
commit4ff90f2bfd95337040616cae4b3bdddff033b5d6 (patch)
tree37d3acd7835e4366cc367dc904e43915c7c11f9b /addressbook/gui/contact-editor
parent977be20ced747224c0e08d565f961f0fa8d0baf8 (diff)
downloadgsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.gz
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.bz2
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.lz
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.xz
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.zst
gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.zip
Use EClientComboBox where appropriate.
Basically any place where we use both EClient and ESourceComboBox.
Diffstat (limited to 'addressbook/gui/contact-editor')
-rw-r--r--addressbook/gui/contact-editor/contact-editor.ui2
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c42
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c75
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.h10
4 files changed, 78 insertions, 51 deletions
diff --git a/addressbook/gui/contact-editor/contact-editor.ui b/addressbook/gui/contact-editor/contact-editor.ui
index b12c604f6a..f3a1848af1 100644
--- a/addressbook/gui/contact-editor/contact-editor.ui
+++ b/addressbook/gui/contact-editor/contact-editor.ui
@@ -234,7 +234,7 @@
</packing>
</child>
<child>
- <object class="ESourceComboBox" type-func="e_source_combo_box_get_type" id="source-combo-box-source">
+ <object class="EClientComboBox" type-func="e_client_combo_box_get_type" id="client-combo-box">
<property name="extension-name">Address Book</property>
<property name="show-colors">False</property>
<property name="visible">True</property>
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 0f3aef0739..0d994f8c49 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -686,7 +686,7 @@ fill_in_source_field (EContactEditor *editor)
return;
source_menu = e_builder_get_widget (
- editor->builder, "source-combo-box-source");
+ editor->builder, "client-combo-box");
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (source_menu),
@@ -3101,15 +3101,19 @@ init_all (EContactEditor *editor)
}
static void
-contact_editor_client_connect_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
+contact_editor_get_client_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ EClientComboBox *combo_box;
ConnectClosure *closure = user_data;
EClient *client;
GError *error = NULL;
- client = e_book_client_connect_finish (result, &error);
+ combo_box = E_CLIENT_COMBO_BOX (source_object);
+
+ client = e_client_combo_box_get_client_finish (
+ combo_box, result, &error);
/* Sanity check. */
g_return_if_fail (
@@ -3123,7 +3127,6 @@ contact_editor_client_connect_cb (GObject *source_object,
goto exit;
} else if (error != NULL) {
- GtkWidget *source_combo_box;
GtkWindow *parent;
parent = eab_editor_get_window (EAB_EDITOR (closure->editor));
@@ -3132,11 +3135,8 @@ contact_editor_client_connect_cb (GObject *source_object,
GTK_WIDGET (parent), NULL,
closure->source, error);
- source_combo_box = e_builder_get_widget (
- closure->editor->builder,
- "source-combo-box-source");
e_source_combo_box_set_active (
- E_SOURCE_COMBO_BOX (source_combo_box),
+ E_SOURCE_COMBO_BOX (combo_box),
closure->source);
g_error_free (error);
@@ -3153,7 +3153,7 @@ exit:
}
static void
-source_changed (ESourceComboBox *source_combo_box,
+source_changed (EClientComboBox *combo_box,
EContactEditor *editor)
{
ConnectClosure *closure;
@@ -3161,7 +3161,8 @@ source_changed (ESourceComboBox *source_combo_box,
ESource *source_source;
ESource *source;
- source = e_source_combo_box_ref_active (source_combo_box);
+ source = e_source_combo_box_ref_active (
+ E_SOURCE_COMBO_BOX (combo_box));
g_return_if_fail (source != NULL);
if (editor->cancellable != NULL) {
@@ -3189,9 +3190,10 @@ source_changed (ESourceComboBox *source_combo_box,
closure->editor = g_object_ref (editor);
closure->source = g_object_ref (source);
- e_book_client_connect (
- source, editor->cancellable,
- contact_editor_client_connect_cb,
+ e_client_combo_box_get_client (
+ combo_box, source,
+ editor->cancellable,
+ contact_editor_get_client_cb,
closure);
exit:
@@ -4062,7 +4064,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
{
GtkBuilder *builder;
EShell *shell;
- ESourceRegistry *registry;
+ EClientCache *client_cache;
GtkWidget *container;
GtkWidget *widget, *label;
GtkEntryCompletion *completion;
@@ -4070,7 +4072,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);
+ client_cache = e_shell_get_client_cache (shell);
e_contact_editor->name = e_contact_name_new ();
@@ -4122,9 +4124,9 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
widget, "clicked",
G_CALLBACK (categories_clicked), e_contact_editor);
widget = e_builder_get_widget (
- e_contact_editor->builder, "source-combo-box-source");
- e_source_combo_box_set_registry (
- E_SOURCE_COMBO_BOX (widget), registry);
+ e_contact_editor->builder, "client-combo-box");
+ e_client_combo_box_set_client_cache (
+ E_CLIENT_COMBO_BOX (widget), client_cache);
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 0bfa46b9a8..5814205c4d 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -41,7 +41,7 @@ struct _QuickAdd {
gchar *vcard;
EContact *contact;
GCancellable *cancellable;
- ESourceRegistry *registry;
+ EClientCache *client_cache;
ESource *source;
EContactQuickAddCallback cb;
@@ -57,11 +57,11 @@ struct _QuickAdd {
};
static QuickAdd *
-quick_add_new (ESourceRegistry *registry)
+quick_add_new (EClientCache *client_cache)
{
QuickAdd *qa = g_new0 (QuickAdd, 1);
qa->contact = e_contact_new ();
- qa->registry = g_object_ref (registry);
+ qa->client_cache = g_object_ref (client_cache);
qa->refs = 1;
return qa;
}
@@ -80,7 +80,7 @@ quick_add_unref (QuickAdd *qa)
g_free (qa->email);
g_free (qa->vcard);
g_object_unref (qa->contact);
- g_object_unref (qa->registry);
+ g_object_unref (qa->client_cache);
g_free (qa);
}
}
@@ -128,7 +128,8 @@ merge_cb (GObject *source_object,
EClient *client;
GError *error = NULL;
- client = e_book_client_connect_finish (result, &error);
+ client = e_client_cache_get_client_finish (
+ E_CLIENT_CACHE (source_object), result, &error);
/* Sanity check. */
g_return_if_fail (
@@ -151,11 +152,17 @@ merge_cb (GObject *source_object,
return;
}
- if (!e_client_is_readonly (client))
+ if (!e_client_is_readonly (client)) {
+ ESourceRegistry *registry;
+
+ registry = e_client_cache_ref_registry (qa->client_cache);
+
eab_merging_book_add_contact (
- qa->registry, E_BOOK_CLIENT (client),
+ registry, E_BOOK_CLIENT (client),
qa->contact, NULL, NULL);
- else {
+
+ g_object_unref (registry);
+ } else {
ESource *source = e_client_get_source (client);
e_alert_run_dialog_for_args (
@@ -183,7 +190,10 @@ quick_add_merge_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_book_client_connect (qa->source, qa->cancellable, merge_cb, qa);
+ e_client_cache_get_client (
+ qa->client_cache, qa->source,
+ E_SOURCE_EXTENSION_ADDRESS_BOOK,
+ qa->cancellable, merge_cb, qa);
}
/* Raise a contact editor with all fields editable,
@@ -283,9 +293,11 @@ ce_have_book (GObject *source_object,
{
QuickAdd *qa = user_data;
EClient *client;
+ ESourceRegistry *registry;
GError *error = NULL;
- client = e_book_client_connect_finish (result, &error);
+ client = e_client_cache_get_client_finish (
+ E_CLIENT_CACHE (source_object), result, &error);
/* Sanity check. */
g_return_if_fail (
@@ -307,9 +319,13 @@ ce_have_book (GObject *source_object,
return;
}
+ registry = e_client_cache_ref_registry (qa->client_cache);
+
eab_merging_book_find_contact (
- qa->registry, E_BOOK_CLIENT (client),
+ registry, E_BOOK_CLIENT (client),
qa->contact, ce_have_contact, qa);
+
+ g_object_unref (registry);
}
static void
@@ -322,7 +338,10 @@ edit_contact (QuickAdd *qa)
qa->cancellable = g_cancellable_new ();
- e_book_client_connect (qa->source, qa->cancellable, ce_have_book, qa);
+ e_client_cache_get_client (
+ qa->client_cache, qa->source,
+ E_SOURCE_EXTENSION_ADDRESS_BOOK,
+ qa->cancellable, ce_have_book, qa);
}
#define QUICK_ADD_RESPONSE_EDIT_FULL 2
@@ -425,6 +444,7 @@ build_quick_add_dialog (QuickAdd *qa)
GtkWidget *label;
GtkTable *table;
ESource *source;
+ ESourceRegistry *registry;
const gchar *extension_name;
const gint xpad = 0, ypad = 0;
@@ -467,9 +487,12 @@ build_quick_add_dialog (QuickAdd *qa)
}
extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
- source = e_source_registry_ref_default_address_book (qa->registry);
+ registry = e_client_cache_ref_registry (qa->client_cache);
+ source = e_source_registry_ref_default_address_book (registry);
+ g_object_unref (registry);
- qa->combo_box = e_source_combo_box_new (qa->registry, extension_name);
+ qa->combo_box = e_client_combo_box_new (
+ qa->client_cache, extension_name);
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (qa->combo_box), source);
@@ -533,7 +556,7 @@ build_quick_add_dialog (QuickAdd *qa)
}
void
-e_contact_quick_add (ESourceRegistry *registry,
+e_contact_quick_add (EClientCache *client_cache,
const gchar *in_name,
const gchar *email,
EContactQuickAddCallback cb,
@@ -544,7 +567,7 @@ e_contact_quick_add (ESourceRegistry *registry,
gchar *name = NULL;
gint len;
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (E_IS_CLIENT_CACHE (client_cache));
/* We need to have *something* to work with. */
if (in_name == NULL && email == NULL) {
@@ -567,7 +590,7 @@ e_contact_quick_add (ESourceRegistry *registry,
g_strstrip (name);
}
- qa = quick_add_new (registry);
+ qa = quick_add_new (client_cache);
qa->cb = cb;
qa->closure = closure;
if (name)
@@ -582,7 +605,7 @@ e_contact_quick_add (ESourceRegistry *registry,
}
void
-e_contact_quick_add_free_form (ESourceRegistry *registry,
+e_contact_quick_add_free_form (EClientCache *client_cache,
const gchar *text,
EContactQuickAddCallback cb,
gpointer closure)
@@ -591,10 +614,10 @@ e_contact_quick_add_free_form (ESourceRegistry *registry,
const gchar *last_at, *s;
gboolean in_quote;
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (E_IS_CLIENT_CACHE (client_cache));
if (text == NULL) {
- e_contact_quick_add (registry, NULL, NULL, cb, closure);
+ e_contact_quick_add (client_cache, NULL, NULL, cb, closure);
return;
}
@@ -658,14 +681,14 @@ e_contact_quick_add_free_form (ESourceRegistry *registry,
g_strstrip (email);
}
- e_contact_quick_add (registry, name, email, cb, closure);
+ e_contact_quick_add (client_cache, name, email, cb, closure);
g_free (name);
g_free (email);
}
void
-e_contact_quick_add_email (ESourceRegistry *registry,
+e_contact_quick_add_email (EClientCache *client_cache,
const gchar *email,
EContactQuickAddCallback cb,
gpointer closure)
@@ -688,14 +711,14 @@ e_contact_quick_add_email (ESourceRegistry *registry,
addr = g_strdup (email);
}
- e_contact_quick_add (registry, name, addr, cb, closure);
+ e_contact_quick_add (client_cache, name, addr, cb, closure);
g_free (name);
g_free (addr);
}
void
-e_contact_quick_add_vcard (ESourceRegistry *registry,
+e_contact_quick_add_vcard (EClientCache *client_cache,
const gchar *vcard,
EContactQuickAddCallback cb,
gpointer closure)
@@ -704,7 +727,7 @@ e_contact_quick_add_vcard (ESourceRegistry *registry,
GtkWidget *dialog;
EContact *contact;
- g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (E_IS_CLIENT_CACHE (client_cache));
/* We need to have *something* to work with. */
if (vcard == NULL) {
@@ -713,7 +736,7 @@ e_contact_quick_add_vcard (ESourceRegistry *registry,
return;
}
- qa = quick_add_new (registry);
+ qa = quick_add_new (client_cache);
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 cd5d8ba44c..abc94fddb7 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.h
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.h
@@ -25,23 +25,25 @@
#include <libebook/libebook.h>
+#include <e-util/e-util.h>
+
typedef void (*EContactQuickAddCallback) (EContact *new_contact,
gpointer closure);
-void e_contact_quick_add (ESourceRegistry *registry,
+void e_contact_quick_add (EClientCache *client_cache,
const gchar *name,
const gchar *email,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_free_form (ESourceRegistry *registry,
+void e_contact_quick_add_free_form (EClientCache *client_cache,
const gchar *text,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_email (ESourceRegistry *registry,
+void e_contact_quick_add_email (EClientCache *client_cache,
const gchar *email,
EContactQuickAddCallback cb,
gpointer closure);
-void e_contact_quick_add_vcard (ESourceRegistry *registry,
+void e_contact_quick_add_vcard (EClientCache *client_cache,
const gchar *vcard,
EContactQuickAddCallback cb,
gpointer closure);