diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-03-02 03:30:14 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-03-02 07:16:07 +0800 |
commit | 4ff90f2bfd95337040616cae4b3bdddff033b5d6 (patch) | |
tree | 37d3acd7835e4366cc367dc904e43915c7c11f9b /addressbook | |
parent | 977be20ced747224c0e08d565f961f0fa8d0baf8 (diff) | |
download | gsoc2013-evolution-4ff90f2bfd95337040616cae4b3bdddff033b5d6.tar.gz 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')
6 files changed, 108 insertions, 76 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); diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.ui b/addressbook/gui/contact-list-editor/contact-list-editor.ui index eb301847de..d6a197877c 100644 --- a/addressbook/gui/contact-list-editor/contact-list-editor.ui +++ b/addressbook/gui/contact-list-editor/contact-list-editor.ui @@ -61,7 +61,7 @@ <property name="xalign">1</property> <property name="label" translatable="yes">_Where:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">source-combo-box</property> + <property name="mnemonic_widget">client-combo-box</property> </object> <packing> <property name="top_attach">1</property> @@ -82,7 +82,7 @@ </packing> </child> <child> - <object class="ESourceComboBox" type-func="e_source_combo_box_get_type" id="source-combo-box"> + <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-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 08c92d72d4..d7437d3cfb 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -61,6 +61,8 @@ CONTACT_LIST_EDITOR_WIDGET ((editor), "add-button") #define CONTACT_LIST_EDITOR_WIDGET_CHECK_BUTTON(editor) \ CONTACT_LIST_EDITOR_WIDGET ((editor), "check-button") +#define CONTACT_LIST_EDITOR_WIDGET_CLIENT_COMBO_BOX(editor) \ + CONTACT_LIST_EDITOR_WIDGET ((editor), "client-combo-box") #define CONTACT_LIST_EDITOR_WIDGET_DIALOG(editor) \ CONTACT_LIST_EDITOR_WIDGET ((editor), "dialog") #define CONTACT_LIST_EDITOR_WIDGET_EMAIL_ENTRY(editor) \ @@ -73,8 +75,6 @@ CONTACT_LIST_EDITOR_WIDGET ((editor), "ok-button") #define CONTACT_LIST_EDITOR_WIDGET_REMOVE_BUTTON(editor) \ CONTACT_LIST_EDITOR_WIDGET ((editor), "remove-button") -#define CONTACT_LIST_EDITOR_WIDGET_SOURCE_MENU(editor) \ - CONTACT_LIST_EDITOR_WIDGET ((editor), "source-combo-box") #define CONTACT_LIST_EDITOR_WIDGET_TREE_VIEW(editor) \ CONTACT_LIST_EDITOR_WIDGET ((editor), "tree-view") #define CONTACT_LIST_EDITOR_WIDGET_TOP_BUTTON(editor) \ @@ -189,7 +189,7 @@ contact_list_editor_update (EContactListEditor *editor) priv->allows_contact_lists); gtk_widget_set_sensitive ( - WIDGET (SOURCE_MENU), priv->is_new_list); + WIDGET (CLIENT_COMBO_BOX), priv->is_new_list); } static void @@ -318,19 +318,23 @@ contact_list_editor_add_email (EContactListEditor *editor, } static void -contact_list_editor_client_connect_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) +contact_list_editor_get_client_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) { ConnectClosure *closure = user_data; EContactListEditor *editor = closure->editor; + EClientComboBox *combo_box; EContactStore *contact_store; ENameSelectorEntry *entry; EClient *client; EBookClient *book_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 ( @@ -347,7 +351,7 @@ contact_list_editor_client_connect_cb (GObject *source_object, closure->source, error); e_source_combo_box_set_active ( - E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)), + E_SOURCE_COMBO_BOX (combo_box), closure->source); g_error_free (error); @@ -976,10 +980,10 @@ contact_list_editor_select_button_clicked_cb (GtkWidget *widget) } void -contact_list_editor_source_menu_changed_cb (GtkWidget *widget); +contact_list_editor_combo_box_changed_cb (GtkWidget *widget); void -contact_list_editor_source_menu_changed_cb (GtkWidget *widget) +contact_list_editor_combo_box_changed_cb (GtkWidget *widget) { ESourceComboBox *combo_box; EContactListEditor *editor; @@ -997,9 +1001,10 @@ contact_list_editor_source_menu_changed_cb (GtkWidget *widget) client_source = e_client_get_source (client); if (!e_source_equal (client_source, active_source)) - e_book_client_connect ( + e_client_combo_box_get_client ( + E_CLIENT_COMBO_BOX (widget), active_source, NULL, - contact_list_editor_client_connect_cb, + contact_list_editor_get_client_cb, g_object_ref (editor)); g_object_unref (active_source); @@ -1224,7 +1229,7 @@ static void setup_custom_widgets (EContactListEditor *editor) { EShell *shell; - ESourceRegistry *registry; + EClientCache *client_cache; GtkWidget *combo_box; ENameSelectorEntry *name_selector_entry; GtkWidget *old, *parent; @@ -1236,16 +1241,16 @@ setup_custom_widgets (EContactListEditor *editor) priv = E_CONTACT_LIST_EDITOR_GET_PRIVATE (editor); shell = eab_editor_get_shell (EAB_EDITOR (editor)); - registry = e_shell_get_registry (shell); + client_cache = e_shell_get_client_cache (shell); - combo_box = WIDGET (SOURCE_MENU); + combo_box = WIDGET (CLIENT_COMBO_BOX); - e_source_combo_box_set_registry ( - E_SOURCE_COMBO_BOX (combo_box), registry); + e_client_combo_box_set_client_cache ( + E_CLIENT_COMBO_BOX (combo_box), client_cache); g_signal_connect ( combo_box, "changed", G_CALLBACK ( - contact_list_editor_source_menu_changed_cb), NULL); + contact_list_editor_combo_box_changed_cb), NULL); old = CONTACT_LIST_EDITOR_WIDGET (editor, "email-entry"); g_return_if_fail (old != NULL); @@ -1407,7 +1412,7 @@ contact_list_editor_constructed (GObject *object) GtkCellRenderer *renderer; GtkTreeView *view; GtkTreeSelection *selection; - ESourceRegistry *registry; + EClientCache *client_cache; EShell *shell; editor = E_CONTACT_LIST_EDITOR (object); @@ -1417,7 +1422,7 @@ contact_list_editor_constructed (GObject *object) constructed (object); shell = eab_editor_get_shell (EAB_EDITOR (editor)); - registry = e_shell_get_registry (shell); + client_cache = e_shell_get_client_cache (shell); editor->priv->editable = TRUE; editor->priv->allows_contact_lists = TRUE; @@ -1456,7 +1461,7 @@ contact_list_editor_constructed (GObject *object) column, renderer, (GtkTreeCellDataFunc) contact_list_editor_render_destination, NULL, NULL); - editor->priv->name_selector = e_name_selector_new (registry); + editor->priv->name_selector = e_name_selector_new (client_cache); e_name_selector_model_add_section ( e_name_selector_peek_model (editor->priv->name_selector), @@ -1916,10 +1921,10 @@ e_contact_list_editor_set_contact (EContactListEditor *editor, if (priv->book_client != NULL) { e_source_combo_box_set_active ( - E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)), + E_SOURCE_COMBO_BOX (WIDGET (CLIENT_COMBO_BOX)), e_client_get_source (E_CLIENT (priv->book_client))); gtk_widget_set_sensitive ( - WIDGET (SOURCE_MENU), priv->is_new_list); + WIDGET (CLIENT_COMBO_BOX), priv->is_new_list); } priv->changed = FALSE; |