[evolution/account-mgmt: 14/50] 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: 14/50] Adapt addressbook/gui/widgets to the new ESource API.
- Date: Wed, 7 Sep 2011 16:08:56 +0000 (UTC)
commit e22656064c2e1bb3e7a8afad8d91bd760cc7a8af
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-selector.c | 42 +++++++---------
addressbook/gui/widgets/e-addressbook-selector.h | 3 +-
addressbook/gui/widgets/e-addressbook-view.c | 18 +++---
addressbook/gui/widgets/ea-minicard-view.c | 12 +++--
addressbook/gui/widgets/eab-gui-util.c | 58 ++++++++++------------
5 files changed, 63 insertions(+), 70 deletions(-)
---
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index b6bfa01..88db401 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>
@@ -167,26 +169,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)
@@ -378,6 +367,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),
@@ -414,13 +409,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-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 7f3a7a8..3a3b07d 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -562,13 +562,13 @@ addressbook_view_constructed (GObject *object)
GalViewInstance *view_instance;
EShellView *shell_view;
ESource *source;
- gchar *uri;
+ const gchar *uid;
shell_view = e_addressbook_view_get_shell_view (view);
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_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 +579,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);
}
@@ -1111,7 +1109,7 @@ folder_bar_message (EAddressbookView *view,
{
EShellView *shell_view;
EShellSidebar *shell_sidebar;
- const gchar *name;
+ const gchar *display_name;
shell_view = e_addressbook_view_get_shell_view (view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
@@ -1119,8 +1117,8 @@ folder_bar_message (EAddressbookView *view,
if (view->priv->source == NULL)
return;
- name = e_source_peek_name (view->priv->source);
- e_shell_sidebar_set_primary_text (shell_sidebar, name);
+ 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 +1142,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
diff --git a/addressbook/gui/widgets/ea-minicard-view.c b/addressbook/gui/widgets/ea-minicard-view.c
index 58d3a5f..97d8fbd 100644
--- a/addressbook/gui/widgets/ea-minicard-view.c
+++ b/addressbook/gui/widgets/ea-minicard-view.c
@@ -149,7 +149,8 @@ ea_minicard_view_get_name (AtkObject *accessible)
gchar *string;
EMinicardView *card_view;
EBookClient *book_client = NULL;
- const gchar *source_name;
+ ESource *source;
+ const gchar *display_name;
g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL);
@@ -163,13 +164,14 @@ ea_minicard_view_get_name (AtkObject *accessible)
card_view = E_MINICARD_VIEW (reflow);
g_object_get (card_view->adapter, "client", &book_client, NULL);
g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
- source_name = e_source_peek_name (e_client_get_source (E_CLIENT (book_client)));
- if (!source_name)
- source_name="";
+ source = e_client_get_source (E_CLIENT (book_client));
+ display_name = e_source_get_display_name (source);
+ if (display_name == NULL)
+ display_name = "";
string = g_strdup_printf (ngettext ("current address book folder %s has %d card",
"current address book folder %s has %d cards",
- reflow->count), source_name, reflow->count);
+ reflow->count), display_name, reflow->count);
ATK_OBJECT_CLASS (parent_class)->set_name (accessible, string);
g_free (string);
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index c951b29..da0e89a 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -34,13 +34,14 @@
#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>
#include <e-util/e-util.h>
#include "eab-gui-util.h"
#include "util/eab-book-util.h"
-#include <libebook/e-destination.h>
#include "e-util/e-alert-dialog.h"
#include "e-util/e-html-utils.h"
#include "shell/e-shell.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
@@ -292,19 +284,17 @@ eab_select_source (ESource *except_source,
const gchar *select_uid,
GtkWindow *parent)
{
+ ESourceRegistry *registry;
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;
-
dialog = gtk_dialog_new_with_buttons (_("Select Address Book"), parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
NULL);
@@ -316,17 +306,23 @@ 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);
+ registry = e_source_registry_get_default ();
+ 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_signal_connect (selector, "primary_selection_changed",
- G_CALLBACK (source_selection_changed_cb), ok_button);
+ g_object_set_data (
+ 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);
+ e_source_selector_set_primary_selection (
+ E_SOURCE_SELECTOR (selector), source);
}
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
@@ -566,9 +562,9 @@ eab_transfer_contacts (EBookClient *source_client,
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]