[evolution/account-mgmt: 13/48] Adapt addressbook/gui/widgets to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 13/48] Adapt addressbook/gui/widgets to the new ESource API.
- Date: Fri, 11 Nov 2011 01:26:29 +0000 (UTC)
commit cd807a7c273a069854dd012240e943c23a8cf035
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed Dec 8 00:16:09 2010 -0500
Adapt addressbook/gui/widgets to the new ESource API.
addressbook/gui/widgets/e-addressbook-model.c | 54 +++++++++++++++-
addressbook/gui/widgets/e-addressbook-model.h | 6 ++-
addressbook/gui/widgets/e-addressbook-selector.c | 65 +++++++++++---------
addressbook/gui/widgets/e-addressbook-selector.h | 3 +-
.../gui/widgets/e-addressbook-table-adapter.c | 10 +++-
addressbook/gui/widgets/e-addressbook-view.c | 41 +++++++++----
addressbook/gui/widgets/ea-minicard-view.c | 2 +-
addressbook/gui/widgets/eab-gui-util.c | 61 +++++++++----------
addressbook/gui/widgets/eab-gui-util.h | 7 ++-
9 files changed, 165 insertions(+), 84 deletions(-)
---
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index fa61c4e..3d37883 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -32,6 +32,7 @@
#include "eab-gui-util.h"
struct _EAddressbookModelPrivate {
+ ESourceRegistry *registry;
EBookClient *book_client;
gchar *query_str;
EBookClientView *client_view;
@@ -59,7 +60,8 @@ enum {
PROP_0,
PROP_CLIENT,
PROP_EDITABLE,
- PROP_QUERY
+ PROP_QUERY,
+ PROP_REGISTRY
};
enum {
@@ -449,6 +451,16 @@ remove_status_cb (gpointer data)
}
static void
+addressbook_model_set_registry (EAddressbookModel *model,
+ ESourceRegistry *registry)
+{
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
+ g_return_if_fail (model->priv->registry == NULL);
+
+ model->priv->registry = g_object_ref (registry);
+}
+
+static void
addressbook_model_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -472,6 +484,12 @@ addressbook_model_set_property (GObject *object,
E_ADDRESSBOOK_MODEL (object),
g_value_get_string (value));
return;
+
+ case PROP_REGISTRY:
+ addressbook_model_set_registry (
+ E_ADDRESSBOOK_MODEL (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -502,6 +520,12 @@ addressbook_model_get_property (GObject *object,
value, e_addressbook_model_get_query (
E_ADDRESSBOOK_MODEL (object)));
return;
+
+ case PROP_REGISTRY:
+ g_value_set_object (
+ value, e_addressbook_model_get_registry (
+ E_ADDRESSBOOK_MODEL (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -602,6 +626,18 @@ addressbook_model_class_init (EAddressbookModelClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (
+ object_class,
+ PROP_REGISTRY,
+ g_param_spec_object (
+ "registry",
+ "Registry",
+ "Data source registry",
+ E_TYPE_SOURCE_REGISTRY,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
signals[WRITABLE_STATUS] =
g_signal_new ("writable_status",
G_OBJECT_CLASS_TYPE (object_class),
@@ -741,9 +777,21 @@ e_addressbook_model_get_type (void)
}
EAddressbookModel *
-e_addressbook_model_new (void)
+e_addressbook_model_new (ESourceRegistry *registry)
{
- return g_object_new (E_TYPE_ADDRESSBOOK_MODEL, NULL);
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+ return g_object_new (
+ E_TYPE_ADDRESSBOOK_MODEL,
+ "registry", registry, NULL);
+}
+
+ESourceRegistry *
+e_addressbook_model_get_registry (EAddressbookModel *model)
+{
+ g_return_val_if_fail (E_IS_ADDRESSBOOK_MODEL (model), NULL);
+
+ return model->priv->registry;
}
EContact *
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 680352c..24c4302 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -24,6 +24,7 @@
#include <libebook/e-book-client.h>
#include <libebook/e-book-client-view.h>
#include <libebook/e-book-query.h>
+#include <libedataserver/e-source-registry.h>
/* Standard GObject macros */
#define E_TYPE_ADDRESSBOOK_MODEL \
@@ -83,7 +84,10 @@ struct _EAddressbookModelClass {
GType e_addressbook_model_get_type (void);
EAddressbookModel *
- e_addressbook_model_new (void);
+ e_addressbook_model_new (ESourceRegistry *registry);
+ESourceRegistry *
+ e_addressbook_model_get_registry
+ (EAddressbookModel *model);
/* Returns object with ref count of 1. */
EContact * e_addressbook_model_get_contact (EAddressbookModel *model,
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index 30bb889..cddf58c 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -24,6 +24,8 @@
#include "e-addressbook-selector.h"
+#include <libebook/e-source-address-book.h>
+
#include <e-util/e-selection.h>
#include <libedataserverui/e-client-utils.h>
@@ -37,6 +39,7 @@ struct _EAddressbookSelectorPrivate {
};
struct _MergeContext {
+ ESourceRegistry *registry;
EBookClient *source_client;
EBookClient *target_client;
@@ -76,13 +79,15 @@ merge_context_next (MergeContext *merge_context)
}
static MergeContext *
-merge_context_new (EBookClient *source_client,
+merge_context_new (ESourceRegistry *registry,
+ EBookClient *source_client,
EBookClient *target_client,
GSList *contact_list)
{
MergeContext *merge_context;
merge_context = g_slice_new0 (MergeContext);
+ merge_context->registry = g_object_ref (registry);
merge_context->source_client = source_client;
merge_context->target_client = target_client;
merge_context->remaining_contacts = contact_list;
@@ -94,6 +99,9 @@ merge_context_new (EBookClient *source_client,
static void
merge_context_free (MergeContext *merge_context)
{
+ if (merge_context->registry != NULL)
+ g_object_unref (merge_context->registry);
+
if (merge_context->source_client != NULL)
g_object_unref (merge_context->source_client);
@@ -154,6 +162,7 @@ addressbook_selector_merge_next_cb (EBookClient *book_client,
if (merge_context->remaining_contacts != NULL) {
merge_context_next (merge_context);
eab_merging_book_add_contact (
+ merge_context->registry,
merge_context->target_client,
merge_context->current_contact,
addressbook_selector_merge_next_cb, merge_context);
@@ -167,26 +176,13 @@ addressbook_selector_merge_next_cb (EBookClient *book_client,
static void
addressbook_selector_load_primary_source (ESourceSelector *selector)
{
- ESourceList *source_list;
- ESource *source = NULL;
- GSList *groups;
-
- source_list = e_source_selector_get_source_list (selector);
-
- /* Dig up the first source in the source list.
- * XXX libedataserver should provide API for this. */
- groups = e_source_list_peek_groups (source_list);
- while (groups != NULL) {
- ESourceGroup *source_group = groups->data;
- GSList *sources;
-
- sources = e_source_group_peek_sources (source_group);
- if (sources != NULL) {
- source = sources->data;
- break;
- }
-
- groups = g_slist_next (groups);
+ ESource *source;
+
+ source = e_source_selector_get_default_source (selector);
+ if (source == NULL) {
+ ESourceRegistry *registry;
+ registry = e_source_selector_get_registry (selector);
+ source = e_source_registry_lookup_by_uid (registry, "system");
}
if (source != NULL)
@@ -293,7 +289,7 @@ target_client_open_ready_cb (GObject *source_object,
}
eab_merging_book_add_contact (
- merge_context->target_client,
+ merge_context->registry, merge_context->target_client,
merge_context->current_contact,
addressbook_selector_merge_next_cb, merge_context);
}
@@ -309,6 +305,7 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
MergeContext *merge_context;
EAddressbookModel *model;
EBookClient *source_client = NULL;
+ ESourceRegistry *registry;
GSList *list;
const gchar *string;
gboolean remove_from_source;
@@ -319,26 +316,29 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
string = (const gchar *) gtk_selection_data_get_data (selection_data);
remove_from_source = (action == GDK_ACTION_MOVE);
+ model = e_addressbook_view_get_model (priv->current_view);
+ registry = e_addressbook_model_get_registry (model);
+
/* XXX Function assumes both out arguments are provided. All we
* care about is the contact list; source_client will be NULL. */
- eab_book_and_contact_list_from_string (string, &source_client, &list);
+ eab_book_and_contact_list_from_string (
+ registry, string, &source_client, &list);
if (source_client)
g_object_unref (source_client);
if (list == NULL)
return FALSE;
- model = e_addressbook_view_get_model (priv->current_view);
source_client = e_addressbook_model_get_client (model);
g_return_val_if_fail (E_IS_BOOK_CLIENT (source_client), FALSE);
- merge_context = merge_context_new (g_object_ref (source_client), NULL, list);
+ merge_context = merge_context_new (
+ registry, g_object_ref (source_client), NULL, list);
merge_context->remove_from_source = remove_from_source;
merge_context->pending_adds = TRUE;
e_client_utils_open_new (
destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, NULL,
target_client_open_ready_cb, merge_context);
return TRUE;
@@ -380,6 +380,12 @@ addressbook_selector_init (EAddressbookSelector *selector)
selector, E_TYPE_ADDRESSBOOK_SELECTOR,
EAddressbookSelectorPrivate);
+ e_source_selector_set_show_colors (
+ E_SOURCE_SELECTOR (selector), FALSE);
+
+ e_source_selector_set_show_toggles (
+ E_SOURCE_SELECTOR (selector), FALSE);
+
gtk_drag_dest_set (
GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL,
drag_types, G_N_ELEMENTS (drag_types),
@@ -416,13 +422,14 @@ e_addressbook_selector_get_type (void)
}
GtkWidget *
-e_addressbook_selector_new (ESourceList *source_list)
+e_addressbook_selector_new (ESourceRegistry *registry)
{
- g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL);
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
return g_object_new (
E_TYPE_ADDRESSBOOK_SELECTOR,
- "source-list", source_list, NULL);
+ "extension-name", E_SOURCE_EXTENSION_ADDRESS_BOOK,
+ "registry", registry, NULL);
}
EAddressbookView *
diff --git a/addressbook/gui/widgets/e-addressbook-selector.h b/addressbook/gui/widgets/e-addressbook-selector.h
index c0102cb..d4d6ad8 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.h
+++ b/addressbook/gui/widgets/e-addressbook-selector.h
@@ -21,7 +21,6 @@
#ifndef E_ADDRESSBOOK_SELECTOR_H
#define E_ADDRESSBOOK_SELECTOR_H
-#include <libedataserver/e-source-list.h>
#include <libedataserverui/e-source-selector.h>
#include "e-addressbook-view.h"
@@ -60,7 +59,7 @@ struct _EAddressbookSelectorClass {
};
GType e_addressbook_selector_get_type (void);
-GtkWidget * e_addressbook_selector_new (ESourceList *source_list);
+GtkWidget * e_addressbook_selector_new (ESourceRegistry *registry);
EAddressbookView *
e_addressbook_selector_get_current_view
(EAddressbookSelector *selector);
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index 463bdc7..b596d58 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -168,9 +168,11 @@ addressbook_set_value_at (ETableModel *etc,
EAddressbookTableAdapterPrivate *priv = adapter->priv;
if (e_addressbook_model_get_editable (priv->model)) {
+ ESourceRegistry *registry;
EBookClient *book_client;
EContact *contact;
+ registry = e_addressbook_model_get_registry (priv->model);
book_client = e_addressbook_model_get_client (priv->model);
if (col >= COLS || row >= e_addressbook_model_contact_count (priv->model))
@@ -194,7 +196,7 @@ addressbook_set_value_at (ETableModel *etc,
e_contact_set (contact, col, (gpointer) val);
eab_merging_book_modify_contact (
- book_client,
+ registry, book_client,
contact, contact_modified_cb, etc);
g_object_unref (contact);
@@ -221,6 +223,7 @@ addressbook_append_row (ETableModel *etm,
{
EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER (etm);
EAddressbookTableAdapterPrivate *priv = adapter->priv;
+ ESourceRegistry *registry;
EBookClient *book_client;
EContact *contact;
gint col;
@@ -232,8 +235,11 @@ addressbook_append_row (ETableModel *etm,
e_contact_set (contact, col, (gpointer) val);
}
+ registry = e_addressbook_model_get_registry (priv->model);
book_client = e_addressbook_model_get_client (priv->model);
- eab_merging_book_add_contact (book_client, contact, NULL, NULL);
+
+ eab_merging_book_add_contact (
+ registry, book_client, contact, NULL, NULL);
g_object_unref (contact);
}
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 9bda90a..204ea70 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -560,15 +560,24 @@ addressbook_view_constructed (GObject *object)
{
EAddressbookView *view = E_ADDRESSBOOK_VIEW (object);
GalViewInstance *view_instance;
+ EShell *shell;
EShellView *shell_view;
+ EShellBackend *shell_backend;
+ ESourceRegistry *registry;
ESource *source;
- gchar *uri;
+ const gchar *uid;
shell_view = e_addressbook_view_get_shell_view (view);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
+ shell = e_shell_backend_get_shell (shell_backend);
+ registry = e_shell_get_registry (shell);
+
source = e_addressbook_view_get_source (view);
- uri = e_source_get_uri (source);
+ uid = e_source_get_uid (source);
- view_instance = e_shell_view_new_view_instance (shell_view, uri);
+ view->priv->model = e_addressbook_model_new (registry);
+
+ view_instance = e_shell_view_new_view_instance (shell_view, uid);
g_signal_connect_swapped (
view_instance, "display-view",
G_CALLBACK (addressbook_view_display_view_cb), view);
@@ -579,8 +588,6 @@ addressbook_view_constructed (GObject *object)
* e_book_shell_content_get_current_view() returns the correct
* view in GalViewInstance::loaded signal handlers. */
- g_free (uri);
-
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (parent_class)->constructed (object);
}
@@ -687,6 +694,7 @@ addressbook_view_paste_clipboard (ESelectable *selectable)
EBookClient *book_client;
EAddressbookView *view;
EAddressbookModel *model;
+ ESourceRegistry *registry;
GtkClipboard *clipboard;
GSList *contact_list, *iter;
gchar *string;
@@ -698,6 +706,7 @@ addressbook_view_paste_clipboard (ESelectable *selectable)
return;
model = e_addressbook_view_get_model (view);
+ registry = e_addressbook_model_get_registry (model);
book_client = e_addressbook_model_get_client (model);
string = e_clipboard_wait_for_directory (clipboard);
@@ -707,7 +716,8 @@ addressbook_view_paste_clipboard (ESelectable *selectable)
for (iter = contact_list; iter != NULL; iter = iter->next) {
EContact *contact = iter->data;
- eab_merging_book_add_contact (book_client, contact, NULL, NULL);
+ eab_merging_book_add_contact (
+ registry, book_client, contact, NULL, NULL);
}
e_client_util_free_object_slist (contact_list);
@@ -845,8 +855,6 @@ addressbook_view_init (EAddressbookView *view)
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (
view, E_TYPE_ADDRESSBOOK_VIEW, EAddressbookViewPrivate);
- view->priv->model = e_addressbook_model_new ();
-
target_list = gtk_target_list_new (NULL, 0);
e_target_list_add_directory_targets (target_list, 0);
view->priv->copy_target_list = target_list;
@@ -1119,7 +1127,7 @@ folder_bar_message (EAddressbookView *view,
if (view->priv->source == NULL)
return;
- display_name = e_source_peek_name (view->priv->source);
+ display_name = e_source_get_display_name (view->priv->source);
e_shell_sidebar_set_primary_text (shell_sidebar, display_name);
e_shell_sidebar_set_secondary_text (shell_sidebar, message);
}
@@ -1144,16 +1152,18 @@ backend_died (EAddressbookView *view)
EAlertSink *alert_sink;
EAddressbookModel *model;
EBookClient *book_client;
+ ESource *source;
shell_view = e_addressbook_view_get_shell_view (view);
alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
model = e_addressbook_view_get_model (view);
book_client = e_addressbook_model_get_client (model);
+ source = e_client_get_source (E_CLIENT (book_client));
e_alert_submit (alert_sink,
"addressbook:backend-died",
- e_client_get_uri (E_CLIENT (book_client)), NULL);
+ e_source_get_display_name (source), NULL);
}
static void
@@ -1553,6 +1563,8 @@ all_contacts_ready_cb (GObject *source_object,
{
EBookClient *book_client = E_BOOK_CLIENT (source_object);
struct TransferContactsData *tcd = user_data;
+ EAddressbookModel *model;
+ ESourceRegistry *registry;
EShellView *shell_view;
EShellContent *shell_content;
EAlertSink *alert_sink;
@@ -1569,6 +1581,9 @@ all_contacts_ready_cb (GObject *source_object,
shell_content = e_shell_view_get_shell_content (shell_view);
alert_sink = E_ALERT_SINK (shell_content);
+ model = e_addressbook_view_get_model (tcd->view);
+ registry = e_addressbook_model_get_registry (model);
+
if (error) {
e_alert_submit (
alert_sink, "addressbook:search-error",
@@ -1576,7 +1591,7 @@ all_contacts_ready_cb (GObject *source_object,
g_error_free (error);
} else if (contacts) {
eab_transfer_contacts (
- book_client, contacts,
+ registry, book_client, contacts,
tcd->delete_from_source, alert_sink);
}
@@ -1590,7 +1605,9 @@ view_transfer_contacts (EAddressbookView *view,
gboolean all)
{
EBookClient *book_client;
+ ESourceRegistry *registry;
+ registry = e_addressbook_model_get_registry (view->priv->model);
book_client = e_addressbook_model_get_client (view->priv->model);
if (all) {
@@ -1622,7 +1639,7 @@ view_transfer_contacts (EAddressbookView *view,
contacts = e_addressbook_view_get_selected (view);
eab_transfer_contacts (
- book_client, contacts,
+ registry, book_client, contacts,
delete_from_source, alert_sink);
}
}
diff --git a/addressbook/gui/widgets/ea-minicard-view.c b/addressbook/gui/widgets/ea-minicard-view.c
index 6772a0b..65b20fe 100644
--- a/addressbook/gui/widgets/ea-minicard-view.c
+++ b/addressbook/gui/widgets/ea-minicard-view.c
@@ -165,7 +165,7 @@ ea_minicard_view_get_name (AtkObject *accessible)
g_object_get (card_view->adapter, "client", &book_client, NULL);
g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
source = e_client_get_source (E_CLIENT (book_client));
- display_name = e_source_peek_name (source);
+ display_name = e_source_get_display_name (source);
if (display_name == NULL)
display_name = "";
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index befc883..5391d9b 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -35,6 +35,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libebook/e-destination.h>
+#include <libebook/e-source-address-book.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserverui/e-client-utils.h>
#include <libedataserverui/e-source-selector.h>
@@ -107,12 +108,13 @@ eab_load_error_dialog (GtkWidget *parent,
ESource *source,
const GError *error)
{
- gchar *label_string, *label = NULL, *uri;
+ gchar *label_string, *label = NULL;
gboolean can_detail_error = TRUE;
+ const gchar *backend_name;
g_return_if_fail (source != NULL);
- uri = e_source_get_uri (source);
+ backend_name = e_source_get_backend_name (source);
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_OFFLINE_UNAVAILABLE)) {
can_detail_error = FALSE;
@@ -124,25 +126,16 @@ eab_load_error_dialog (GtkWidget *parent,
"download its contents.");
}
- else if (uri && g_str_has_prefix (uri, "local:")) {
+ else if (g_strcmp0 (backend_name, "local") == 0) {
const gchar *user_data_dir;
- const gchar *source_dir;
- gchar *mangled_source_dir;
+ const gchar *uid;
gchar *path;
+ uid = e_source_get_uid (source);
user_data_dir = e_get_user_data_dir ();
- source_dir = e_source_peek_relative_uri (source);
-
- if (!source_dir || !g_str_equal (source_dir, "system"))
- source_dir = e_source_peek_uid (source);
-
- /* Mangle the URI to not contain invalid characters. */
- mangled_source_dir = g_strdelimit (g_strdup (source_dir), ":/", '_');
path = g_build_filename (
- user_data_dir, "addressbook", mangled_source_dir, NULL);
-
- g_free (mangled_source_dir);
+ user_data_dir, "addressbook", uid, NULL);
label = g_strdup_printf (
_("This address book cannot be opened. Please check that the "
@@ -153,7 +146,7 @@ eab_load_error_dialog (GtkWidget *parent,
}
#ifndef HAVE_LDAP
- else if (uri && !strncmp (uri, "ldap:", 5)) {
+ else if (g_strcmp0 (backend_name, "ldap") == 0) {
/* special case for ldap: contact folders so we can tell the user about openldap */
can_detail_error = FALSE;
@@ -191,7 +184,6 @@ eab_load_error_dialog (GtkWidget *parent,
}
g_free (label);
- g_free (uri);
}
void
@@ -286,24 +278,24 @@ source_selection_changed_cb (ESourceSelector *selector,
}
ESource *
-eab_select_source (ESource *except_source,
+eab_select_source (ESourceRegistry *registry,
+ ESource *except_source,
const gchar *title,
const gchar *message,
const gchar *select_uid,
GtkWindow *parent)
{
ESource *source;
- ESourceList *source_list;
GtkWidget *content_area;
GtkWidget *dialog;
GtkWidget *ok_button;
/* GtkWidget *label; */
GtkWidget *selector;
GtkWidget *scrolled_window;
+ const gchar *extension_name;
gint response;
- if (!e_book_client_get_sources (&source_list, NULL))
- return NULL;
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
dialog = gtk_dialog_new_with_buttons (_("Select Address Book"), parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -316,18 +308,19 @@ eab_select_source (ESource *except_source,
/* label = gtk_label_new (message); */
- selector = e_source_selector_new (source_list);
- e_source_selector_show_selection (E_SOURCE_SELECTOR (selector), FALSE);
+ extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
+ selector = e_source_selector_new (registry, extension_name);
+ e_source_selector_set_show_toggles (
+ E_SOURCE_SELECTOR (selector), FALSE);
if (except_source)
g_object_set_data (
- G_OBJECT (ok_button), "except-source",
- e_source_list_peek_source_by_uid (source_list, e_source_peek_uid (except_source)));
+ G_OBJECT (ok_button), "except-source", except_source);
g_signal_connect (
selector, "primary_selection_changed",
G_CALLBACK (source_selection_changed_cb), ok_button);
if (select_uid) {
- source = e_source_list_peek_source_by_uid (source_list, select_uid);
+ source = e_source_registry_lookup_by_uid (registry, select_uid);
if (source)
e_source_selector_set_primary_selection (
E_SOURCE_SELECTOR (selector), source);
@@ -385,6 +378,7 @@ struct ContactCopyProcess_ {
GSList *contacts;
EBookClient *source;
EBookClient *destination;
+ ESourceRegistry *registry;
gboolean delete_from_source;
EAlertSink *alert_sink;
};
@@ -455,6 +449,7 @@ process_unref (ContactCopyProcess *process)
e_client_util_free_object_slist (process->contacts);
g_object_unref (process->source);
g_object_unref (process->destination);
+ g_object_unref (process->registry);
g_free (process);
}
}
@@ -499,7 +494,7 @@ do_copy (gpointer data,
process->count++;
eab_merging_book_add_contact (
- book_client,
+ process->registry, book_client,
contact, contact_added_cb, process);
}
@@ -535,7 +530,8 @@ exit:
}
void
-eab_transfer_contacts (EBookClient *source_client,
+eab_transfer_contacts (ESourceRegistry *registry,
+ EBookClient *source_client,
GSList *contacts /* adopted */,
gboolean delete_from_source,
EAlertSink *alert_sink)
@@ -547,6 +543,7 @@ eab_transfer_contacts (EBookClient *source_client,
gchar *desc;
GtkWindow *window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (alert_sink)));
+ g_return_if_fail (E_IS_SOURCE_REGISTRY (registry));
g_return_if_fail (E_IS_BOOK_CLIENT (source_client));
if (contacts == NULL)
@@ -570,14 +567,14 @@ eab_transfer_contacts (EBookClient *source_client,
source = e_client_get_source (E_CLIENT (source_client));
destination = eab_select_source (
- source, desc, NULL, last_uid, window);
+ registry, source, desc, NULL, last_uid, window);
if (!destination)
return;
- if (strcmp (last_uid, e_source_peek_uid (destination)) != 0) {
+ if (strcmp (last_uid, e_source_get_uid (destination)) != 0) {
g_free (last_uid);
- last_uid = g_strdup (e_source_peek_uid (destination));
+ last_uid = g_strdup (e_source_get_uid (destination));
}
process = g_new (ContactCopyProcess, 1);
@@ -586,12 +583,12 @@ eab_transfer_contacts (EBookClient *source_client,
process->source = g_object_ref (source_client);
process->contacts = contacts;
process->destination = NULL;
+ process->registry = g_object_ref (registry);
process->alert_sink = alert_sink;
process->delete_from_source = delete_from_source;
e_client_utils_open_new (
destination, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, window,
book_loaded_cb, process);
}
diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h
index 88a759b..d2638a7 100644
--- a/addressbook/gui/widgets/eab-gui-util.h
+++ b/addressbook/gui/widgets/eab-gui-util.h
@@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <libebook/e-book-client.h>
+#include <libedataserver/e-source-registry.h>
#include "e-util/e-alert-sink.h"
G_BEGIN_DECLS
@@ -40,12 +41,14 @@ void eab_load_error_dialog (GtkWidget *parent,
void eab_search_result_dialog (EAlertSink *alert_sink,
const GError *error);
gint eab_prompt_save_dialog (GtkWindow *parent);
-void eab_transfer_contacts (EBookClient *source_client,
+void eab_transfer_contacts (ESourceRegistry *registry,
+ EBookClient *source_client,
GSList *contacts, /* adopted */
gboolean delete_from_source,
EAlertSink *alert_sink);
gchar * eab_suggest_filename (const GSList *contact_list);
-ESource * eab_select_source (ESource *except_source,
+ESource * eab_select_source (ESourceRegistry *registry,
+ ESource *except_source,
const gchar *title,
const gchar *message,
const gchar *select_uid,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]