[evolution/account-mgmt: 24/54] Adapt modules/addressbook to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 24/54] Adapt modules/addressbook to the new ESource API.
- Date: Tue, 24 Apr 2012 23:46:54 +0000 (UTC)
commit 82cf6b93a698f2256c4f3a9dc28ecbf2a1d10aae
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Dec 19 09:52:40 2010 -0500
Adapt modules/addressbook to the new ESource API.
modules/addressbook/Makefile.am | 2 -
modules/addressbook/addressbook-config.c | 1357 -----------------------
modules/addressbook/addressbook-config.h | 53 -
modules/addressbook/autocompletion-config.c | 199 +---
modules/addressbook/autocompletion-config.h | 2 +-
modules/addressbook/e-book-shell-backend.c | 213 +---
modules/addressbook/e-book-shell-backend.h | 3 -
modules/addressbook/e-book-shell-content.c | 8 +
modules/addressbook/e-book-shell-migrate.c | 183 ---
modules/addressbook/e-book-shell-sidebar.c | 38 +-
modules/addressbook/e-book-shell-sidebar.h | 6 +-
modules/addressbook/e-book-shell-view-actions.c | 98 +--
modules/addressbook/e-book-shell-view-private.c | 71 +-
modules/addressbook/e-book-shell-view-private.h | 15 +-
modules/addressbook/e-book-shell-view.c | 80 +--
widgets/misc/Makefile.am | 2 +
widgets/misc/e-autocomplete-selector.h | 64 ++
17 files changed, 254 insertions(+), 2140 deletions(-)
---
diff --git a/modules/addressbook/Makefile.am b/modules/addressbook/Makefile.am
index 5757ac2..cf467c6 100644
--- a/modules/addressbook/Makefile.am
+++ b/modules/addressbook/Makefile.am
@@ -27,8 +27,6 @@ libevolution_module_addressbook_la_CPPFLAGS = \
libevolution_module_addressbook_la_SOURCES = \
evolution-module-addressbook.c \
- addressbook-config.c \
- addressbook-config.h \
autocompletion-config.c \
autocompletion-config.h \
eab-composer-util.c \
diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c
index 985eafa..d57e8f5 100644
--- a/modules/addressbook/autocompletion-config.c
+++ b/modules/addressbook/autocompletion-config.c
@@ -22,80 +22,17 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "autocompletion-config.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <libedataserver/e-source-list.h>
+#include <libedataserver/e-source-address-book.h>
+#include <libedataserver/e-source-autocomplete.h>
#include <libedataserverui/e-source-selector.h>
#include <libedataserverui/e-name-selector-entry.h>
-#include "e-util/e-config.h"
#include "e-util/e-datetime-format.h"
-#include "addressbook/gui/widgets/eab-config.h"
-
-static void
-source_selection_changed_cb (ESourceSelector *source_selector)
-{
- ESourceList *source_list;
- GSList *selection;
- GSList *l;
- GSList *groups;
-
- source_list = e_source_selector_get_source_list (source_selector);
-
- /* first we clear all the completion flags from all sources */
- for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) {
- ESourceGroup *group = E_SOURCE_GROUP (groups->data);
- GSList *sources;
-
- for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
- ESource *source = E_SOURCE (sources->data);
-
- e_source_set_property (source, "completion", NULL);
- }
- }
-
- /* then we loop over the selector's selection, setting the
- * property on those sources */
- selection = e_source_selector_get_selection (source_selector);
- for (l = selection; l; l = l->next) {
- ESource *source = E_SOURCE (l->data);
-
- e_source_set_property (source, "completion", "true");
- }
- e_source_selector_free_selection (selection);
-
- /* XXX we should pop up a dialog if this fails */
- e_source_list_sync (source_list, NULL);
-}
-
-static void
-initialize_selection (ESourceSelector *source_selector)
-{
- ESourceList *source_list;
- GSList *groups;
-
- source_list = e_source_selector_get_source_list (source_selector);
-
- for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) {
- ESourceGroup *group = E_SOURCE_GROUP (groups->data);
- GSList *sources;
-
- for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) {
- ESource *source = E_SOURCE (sources->data);
- const gchar *completion;
-
- completion = e_source_get_property (source, "completion");
- if (completion && !g_ascii_strcasecmp (completion, "true"))
- e_source_selector_select_source (source_selector, source);
- }
- }
-}
+#include "misc/e-autocomplete-selector.h"
static GtkWidget *
add_section (GtkWidget *container,
@@ -133,56 +70,25 @@ add_section (GtkWidget *container,
return widget;
}
-static GtkWidget *
-acc_get_toplevel_notebook (EConfig *ec,
- EConfigItem *item,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
-{
- if (old)
- return old;
-
- old = gtk_notebook_new ();
- gtk_widget_show (old);
-
- return old;
-}
-
-static GtkWidget *
-acc_get_general_page (EConfig *ec,
- EConfigItem *item,
- GtkWidget *parent,
- GtkWidget *old,
- gint position,
- gpointer data)
+GtkWidget *
+autocompletion_config_new (EPreferencesWindow *window)
{
EShellSettings *shell_settings;
- ESourceList *source_list;
- GtkWidget *scrolled_window;
- GtkWidget *source_selector;
+ ESourceRegistry *registry;
+ GtkWidget *container;
GtkWidget *itembox;
GtkWidget *widget;
GtkWidget *vbox;
EShell *shell;
- if (old)
- return old;
-
- g_return_val_if_fail (GTK_IS_NOTEBOOK (parent), NULL);
-
- shell = data;
+ shell = e_preferences_window_get_shell (window);
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+ registry = e_shell_get_registry (shell);
shell_settings = e_shell_get_shell_settings (shell);
- source_list = e_source_list_new_for_gconf_default (
- "/apps/evolution/addressbook/sources");
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ vbox = gtk_vbox_new (FALSE, 12);
gtk_widget_show (vbox);
itembox = add_section (vbox, _("Date/Time Format"), FALSE);
@@ -218,87 +124,20 @@ acc_get_general_page (EConfig *ec,
gtk_box_pack_start (GTK_BOX (itembox), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
- GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SCROLLED_WINDOW (widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (
- GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
- gtk_widget_show (scrolled_window);
-
- source_selector = e_source_selector_new (source_list);
- initialize_selection (E_SOURCE_SELECTOR (source_selector));
- g_signal_connect (
- source_selector, "selection_changed",
- G_CALLBACK (source_selection_changed_cb), NULL);
- gtk_container_add (GTK_CONTAINER (scrolled_window), source_selector);
- gtk_widget_show (source_selector);
-
- gtk_box_pack_start (GTK_BOX (itembox), scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show_all (vbox);
-
- gtk_notebook_append_page (GTK_NOTEBOOK (parent), vbox, gtk_label_new (_("General")));
-
- return vbox;
-}
-
-/* plugin meta-data */
-static EConfigItem acc_items[] = {
- { E_CONFIG_BOOK, (gchar *) "", (gchar *) "acc_toplevel_notebook", acc_get_toplevel_notebook },
- { E_CONFIG_PAGE, (gchar *) "00.general", (gchar *) "acc_general", acc_get_general_page }
-};
-
-static void
-acc_free (EConfig *ec,
- GSList *items,
- gpointer data)
-{
- g_slist_free (items);
-}
-
-GtkWidget *
-autocompletion_config_new (EPreferencesWindow *window)
-{
- GtkWidget *toplevel;
- GtkWidget *vbox;
- GSList *l;
- gint ii;
- EShell *shell;
- EABConfig *eab;
- EABConfigTargetPrefs *target;
- GSettings *settings;
-
- shell = e_preferences_window_get_shell (window);
-
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
- gtk_widget_show (vbox);
-
- /** @HookPoint-EABConfig: Contacts Preferences Page
- * @Id: org.gnome.evolution.addressbook.prefs
- * @Type: E_CONFIG_BOOK
- * @Class: org.gnome.evolution.addressbook.config:1.0
- * @Target: EABConfigTargetPrefs
- *
- * The main contacts preferences page.
- */
- eab = eab_config_new (E_CONFIG_BOOK, "org.gnome.evolution.addressbook.prefs");
-
- l = NULL;
- for (ii = 0; ii < G_N_ELEMENTS (acc_items); ii++)
- l = g_slist_prepend (l, &acc_items[ii]);
- e_config_add_items ((EConfig *) eab, l, acc_free, shell);
-
- settings = g_settings_new ("org.gnome.evolution.addressbook");
+ GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (itembox), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
- target = eab_config_target_new_prefs (eab, settings);
- e_config_set_target ((EConfig *) eab, (EConfigTarget *) target);
- toplevel = e_config_create_widget ((EConfig *) eab);
- gtk_box_pack_start (GTK_BOX (vbox), toplevel, TRUE, TRUE, 0);
+ container = widget;
- g_object_unref (settings);
+ widget = e_autocomplete_selector_new (registry);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ gtk_widget_show (widget);
return vbox;
}
diff --git a/modules/addressbook/autocompletion-config.h b/modules/addressbook/autocompletion-config.h
index c4630f8..2cebea1 100644
--- a/modules/addressbook/autocompletion-config.h
+++ b/modules/addressbook/autocompletion-config.h
@@ -30,7 +30,7 @@
G_BEGIN_DECLS
-GtkWidget *autocompletion_config_new (EPreferencesWindow *window);
+GtkWidget * autocompletion_config_new (EPreferencesWindow *window);
G_END_DECLS
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index 5a564e8..ac6f8b2 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -30,21 +30,23 @@
#include <libebook/e-book-client.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-group.h>
+#include <libedataserver/e-source-address-book.h>
#include <libedataserverui/e-client-utils.h>
+#include <libedataserverui/e-book-auth-util.h>
#include "e-util/e-import.h"
#include "shell/e-shell.h"
#include "shell/e-shell-window.h"
#include "widgets/misc/e-preferences-window.h"
+#include "widgets/misc/e-source-config-dialog.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
+#include "addressbook/gui/widgets/e-book-source-config.h"
#include "addressbook/gui/contact-editor/e-contact-editor.h"
#include "addressbook/gui/contact-editor/e-contact-quick-add.h"
#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
#include "addressbook/importers/evolution-addressbook-importers.h"
-#include "addressbook-config.h"
#include "autocompletion-config.h"
#include "e-book-shell-migrate.h"
@@ -61,12 +63,7 @@
((obj), E_TYPE_BOOK_SHELL_BACKEND, EBookShellBackendPrivate))
struct _EBookShellBackendPrivate {
- ESourceList *source_list;
-};
-
-enum {
- PROP_0,
- PROP_SOURCE_LIST
+ gint placeholder;
};
G_DEFINE_DYNAMIC_TYPE (
@@ -75,75 +72,6 @@ G_DEFINE_DYNAMIC_TYPE (
E_TYPE_SHELL_BACKEND)
static void
-book_shell_backend_ensure_sources (EShellBackend *shell_backend)
-{
- /* XXX This is basically the same algorithm across all backends.
- * Maybe we could somehow integrate this into EShellBackend? */
-
- EBookShellBackendPrivate *priv;
- ESourceGroup *on_this_computer;
- ESource *personal;
- GSList *sources, *iter;
- const gchar *name;
- GError *error = NULL;
-
- on_this_computer = NULL;
- personal = NULL;
-
- priv = E_BOOK_SHELL_BACKEND_GET_PRIVATE (shell_backend);
-
- e_book_client_get_sources (&priv->source_list, &error);
-
- if (error != NULL) {
- g_warning (
- "Could not get addressbook sources: %s",
- error->message);
- g_error_free (error);
- return;
- }
-
- on_this_computer = e_source_list_ensure_group (
- priv->source_list, _("On This Computer"), "local:", TRUE);
- e_source_list_ensure_group (
- priv->source_list, _("On LDAP Servers"), "ldap://", FALSE);
-
- g_return_if_fail (on_this_computer != NULL);
-
- sources = e_source_group_peek_sources (on_this_computer);
-
- /* Make sure this group includes a "Personal" source. */
- for (iter = sources; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (g_strcmp0 (relative_uri, "system") == 0) {
- personal = source;
- break;
- }
- }
-
- name = _("Personal");
-
- if (personal == NULL) {
- ESource *source;
-
- /* Create the default Personal address book. */
- source = e_source_new (name, "system");
- e_source_group_add_source (on_this_computer, source, -1);
- e_source_set_property (source, "completion", "true");
- g_object_unref (source);
- e_source_list_sync (priv->source_list, NULL);
- } else if (!e_source_get_property (personal, "name-changed")) {
- /* Force the source name to the current locale. */
- e_source_set_name (personal, name);
- e_source_list_sync (priv->source_list, NULL);
- }
-
- g_object_unref (on_this_computer);
-}
-
-static void
book_shell_backend_init_importers (void)
{
EImportClass *import_class;
@@ -252,54 +180,59 @@ action_contact_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
EShell *shell;
- EShellBackend *shell_backend;
- GSettings *settings;
- ESourceList *source_list;
- ESource *source = NULL;
+ ESource *source;
+ ESourceRegistry *registry;
const gchar *action_name;
- gchar *uid;
/* This callback is used for both contacts and contact lists. */
shell = e_shell_window_get_shell (shell_window);
- shell_backend = e_shell_get_backend_by_name (shell, "addressbook");
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- settings = g_settings_new ("org.gnome.evolution.addressbook");
- uid = g_settings_get_string (settings, "primary-addressbook");
- g_object_unref (settings);
-
- if (uid != NULL) {
- source = e_source_list_peek_source_by_uid (source_list, uid);
- g_free (uid);
- }
- if (source == NULL)
- source = e_source_list_peek_default_source (source_list);
-
- g_return_if_fail (E_IS_SOURCE (source));
+ registry = e_shell_get_registry (shell);
+ source = e_source_registry_ref_default_address_book (registry);
/* Use a callback function appropriate for the action. */
action_name = gtk_action_get_name (action);
if (strcmp (action_name, "contact-new") == 0)
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- book_shell_backend_new_contact_cb, g_object_ref (shell));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ book_shell_backend_new_contact_cb,
+ g_object_ref (shell));
if (strcmp (action_name, "contact-new-list") == 0)
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- book_shell_backend_new_contact_list_cb, g_object_ref (shell));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
+ book_shell_backend_new_contact_list_cb,
+ g_object_ref (shell));
- g_object_unref (source_list);
+ g_object_unref (source);
}
static void
action_address_book_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
- addressbook_config_create_new_source (NULL);
+ EShell *shell;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
+
+ shell = e_shell_window_get_shell (shell_window);
+
+ registry = e_shell_get_registry (shell);
+ config = e_book_source_config_new (registry, NULL);
+
+ dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
+
+ gtk_window_set_transient_for (
+ GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
+
+ icon_name = gtk_action_get_icon_name (action);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("New Address Book"));
+
+ gtk_widget_show (dialog);
}
static GtkActionEntry item_entries[] = {
@@ -366,20 +299,26 @@ static void
book_shell_backend_quick_add_email_cb (EShell *shell,
const gchar *email)
{
+ ESourceRegistry *registry;
+
/* XXX This is an ugly hack but it's the only way I could think
* of to integrate this feature with other shell modules. */
- e_contact_quick_add_email (email, NULL, NULL);
+ registry = e_shell_get_registry (shell);
+ e_contact_quick_add_email (registry, email, NULL, NULL);
}
static void
book_shell_backend_quick_add_vcard_cb (EShell *shell,
const gchar *vcard)
{
+ ESourceRegistry *registry;
+
/* XXX This is an ugly hack but it's the only way I could think
* of to integrate this feature with other shell modules. */
- e_contact_quick_add_vcard (vcard, NULL, NULL);
+ registry = e_shell_get_registry (shell);
+ e_contact_quick_add_vcard (registry, vcard, NULL, NULL);
}
static gboolean
@@ -469,40 +408,6 @@ book_shell_backend_window_added_cb (EShellBackend *shell_backend,
}
static void
-book_shell_backend_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SOURCE_LIST:
- g_value_set_object (
- value,
- e_book_shell_backend_get_source_list (
- E_BOOK_SHELL_BACKEND (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-book_shell_backend_dispose (GObject *object)
-{
- EBookShellBackendPrivate *priv;
-
- priv = E_BOOK_SHELL_BACKEND_GET_PRIVATE (object);
-
- if (priv->source_list != NULL) {
- g_object_unref (priv->source_list);
- priv->source_list = NULL;
- }
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_book_shell_backend_parent_class)->dispose (object);
-}
-
-static void
book_shell_backend_constructed (GObject *object)
{
EShell *shell;
@@ -518,7 +423,6 @@ book_shell_backend_constructed (GObject *object)
#endif
book_shell_backend_init_importers ();
- book_shell_backend_ensure_sources (shell_backend);
g_signal_connect (
shell, "event::contact-quick-add-email",
@@ -557,8 +461,6 @@ e_book_shell_backend_class_init (EBookShellBackendClass *class)
g_type_class_add_private (class, sizeof (EBookShellBackendPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->get_property = book_shell_backend_get_property;
- object_class->dispose = book_shell_backend_dispose;
object_class->constructed = book_shell_backend_constructed;
shell_backend_class = E_SHELL_BACKEND_CLASS (class);
@@ -570,16 +472,6 @@ e_book_shell_backend_class_init (EBookShellBackendClass *class)
shell_backend_class->preferences_page = "contacts";
shell_backend_class->start = NULL;
shell_backend_class->migrate = e_book_shell_backend_migrate;
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_LIST,
- g_param_spec_object (
- "source-list",
- "Source List",
- "The registry of address books",
- E_TYPE_SOURCE_LIST,
- G_PARAM_READABLE));
}
static void
@@ -602,12 +494,3 @@ e_book_shell_backend_type_register (GTypeModule *type_module)
* order to register types from a separate compilation unit. */
e_book_shell_backend_register_type (type_module);
}
-
-ESourceList *
-e_book_shell_backend_get_source_list (EBookShellBackend *book_shell_backend)
-{
- g_return_val_if_fail (
- E_IS_BOOK_SHELL_BACKEND (book_shell_backend), NULL);
-
- return book_shell_backend->priv->source_list;
-}
diff --git a/modules/addressbook/e-book-shell-backend.h b/modules/addressbook/e-book-shell-backend.h
index 00ebe3d..73a799a 100644
--- a/modules/addressbook/e-book-shell-backend.h
+++ b/modules/addressbook/e-book-shell-backend.h
@@ -23,7 +23,6 @@
#define E_BOOK_SHELL_BACKEND_H
#include <shell/e-shell-backend.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_BOOK_SHELL_BACKEND \
@@ -62,8 +61,6 @@ struct _EBookShellBackendClass {
GType e_book_shell_backend_get_type (void);
void e_book_shell_backend_type_register
(GTypeModule *type_module);
-ESourceList * e_book_shell_backend_get_source_list
- (EBookShellBackend *book_shell_backend);
G_END_DECLS
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index f3457e8..05f8bd8 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -348,6 +348,7 @@ book_shell_content_check_state (EShellContent *shell_content)
ESelectionModel *selection_model;
EAddressbookModel *model;
EAddressbookView *view;
+ GtkNotebook *notebook;
gboolean has_email = TRUE;
gboolean is_contact_list = TRUE;
guint32 state = 0;
@@ -359,6 +360,13 @@ book_shell_content_check_state (EShellContent *shell_content)
} foreach_data;
book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
+
+ /* This function may be triggered at startup before any address
+ * book views are added. Check for that and return silently. */
+ notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
+ if (gtk_notebook_get_n_pages (notebook) == 0)
+ return 0;
+
view = e_book_shell_content_get_current_view (book_shell_content);
model = e_addressbook_view_get_model (view);
diff --git a/modules/addressbook/e-book-shell-migrate.c b/modules/addressbook/e-book-shell-migrate.c
index d2d26c8..2e3de84 100644
--- a/modules/addressbook/e-book-shell-migrate.c
+++ b/modules/addressbook/e-book-shell-migrate.c
@@ -26,168 +26,8 @@
#include <config.h>
#endif
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <glib/gstdio.h>
-
-#include <gtk/gtk.h>
-
-#include <libebook/e-destination.h>
-#include <libebook/e-book-client.h>
-#include <glib/gi18n.h>
-
-#include <libedataserver/e-xml-utils.h>
-
-#include "e-util/e-util.h"
-#include "e-util/e-util-private.h"
-#include "libevolution-utils/e-xml-utils.h"
-
#include "e-book-shell-migrate.h"
-/*#define SLOW_MIGRATION*/
-
-typedef struct {
- /* this hash table maps old folder uris to new uids. It's
- * build in migrate_contact_folder and it's used in
- * migrate_completion_folders. */
- GHashTable *folder_uid_map;
-
- ESourceList *source_list;
-
- const gchar *data_dir;
-
- GtkWidget *window;
- GtkWidget *label;
- GtkWidget *folder_label;
- GtkWidget *progress;
-} MigrationContext;
-
-#define LOCAL_BASE_URI "local:"
-#define LDAP_BASE_URI "ldap://"
-#define PERSONAL_RELATIVE_URI "system"
-
-static void
-create_groups (MigrationContext *context,
- ESourceGroup **on_this_computer,
- ESourceGroup **on_ldap_servers,
- ESource **personal_source)
-{
- GSList *groups;
- ESourceGroup *group;
-
- *on_this_computer = NULL;
- *on_ldap_servers = NULL;
- *personal_source = NULL;
-
- groups = e_source_list_peek_groups (context->source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
- gchar *base_dir, *base_uri;
-
- base_dir = g_build_filename (context->data_dir, "local", NULL);
- base_uri = g_filename_to_uri (base_dir, NULL, NULL);
-
- for (g = groups; g; g = g->next) {
- group = E_SOURCE_GROUP (g->data);
-
- if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0)
- e_source_group_set_base_uri (group, LOCAL_BASE_URI);
-
- if (!*on_this_computer &&
- !strcmp (LOCAL_BASE_URI,
- e_source_group_peek_base_uri (group)))
- *on_this_computer = g_object_ref (group);
- else if (!*on_ldap_servers &&
- !strcmp (LDAP_BASE_URI,
- e_source_group_peek_base_uri (group)))
- *on_ldap_servers = g_object_ref (group);
- }
-
- g_free (base_dir);
- g_free (base_uri);
- }
-
- if (*on_this_computer) {
- /* make sure "Personal" shows up as a source under
- * this group */
- GSList *sources = e_source_group_peek_sources (*on_this_computer);
- GSList *s;
- for (s = sources; s; s = s->next) {
- ESource *source = E_SOURCE (s->data);
- const gchar *relative_uri;
-
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
- if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
- *personal_source = g_object_ref (source);
- break;
- }
- }
- }
- else {
- /* create the local source group */
- group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI);
- e_source_list_add_group (context->source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- /* Create the default Person addressbook */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- e_source_set_property (source, "completion", "true");
-
- *personal_source = source;
- }
-
- if (!*on_ldap_servers) {
- /* Create the LDAP source group */
- group = e_source_group_new (_("On LDAP Servers"), LDAP_BASE_URI);
- e_source_list_add_group (context->source_list, group, -1);
-
- *on_ldap_servers = group;
- }
-}
-
-static MigrationContext *
-migration_context_new (const gchar *data_dir)
-{
- MigrationContext *context = g_new (MigrationContext, 1);
-
- /* set up the mapping from old uris to new uids */
- context->folder_uid_map = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- e_book_client_get_sources (&context->source_list, NULL);
-
- context->data_dir = data_dir;
-
- return context;
-}
-
-static void
-migration_context_free (MigrationContext *context)
-{
- e_source_list_sync (context->source_list, NULL);
-
- g_hash_table_destroy (context->folder_uid_map);
-
- g_object_unref (context->source_list);
-
- g_free (context);
-}
-
gboolean
e_book_shell_backend_migrate (EShellBackend *shell_backend,
gint major,
@@ -195,30 +35,7 @@ e_book_shell_backend_migrate (EShellBackend *shell_backend,
gint micro,
GError **error)
{
- ESourceGroup *on_this_computer;
- ESourceGroup *on_ldap_servers;
- ESource *personal_source;
- MigrationContext *context;
- const gchar *data_dir;
-
g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), FALSE);
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- context = migration_context_new (data_dir);
-
- /* we call this unconditionally now - create_groups either
- * creates the groups/sources or it finds the necessary
- * groups/sources. */
- create_groups (context, &on_this_computer, &on_ldap_servers, &personal_source);
-
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_ldap_servers)
- g_object_unref (on_ldap_servers);
- if (personal_source)
- g_object_unref (personal_source);
-
- migration_context_free (context);
-
return TRUE;
}
diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c
index d47dbd7..57ea7d3 100644
--- a/modules/addressbook/e-book-shell-sidebar.c
+++ b/modules/addressbook/e-book-shell-sidebar.c
@@ -28,6 +28,8 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <libedataserver/e-source-address-book.h>
+
#include <e-util/e-util.h>
#include "e-book-shell-view.h"
@@ -94,7 +96,7 @@ book_shell_sidebar_constructed (GObject *object)
EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
EShellSettings *shell_settings;
- ESourceList *source_list;
+ ESourceRegistry *registry;
GtkContainer *container;
GtkWidget *widget;
@@ -110,9 +112,6 @@ book_shell_sidebar_constructed (GObject *object)
shell = e_shell_backend_get_shell (shell_backend);
shell_settings = e_shell_get_shell_settings (shell);
- source_list = e_book_shell_backend_get_source_list (
- E_BOOK_SHELL_BACKEND (shell_backend));
-
container = GTK_CONTAINER (shell_sidebar);
widget = gtk_scrolled_window_new (NULL, NULL);
@@ -126,8 +125,8 @@ book_shell_sidebar_constructed (GObject *object)
container = GTK_CONTAINER (widget);
- widget = e_addressbook_selector_new (source_list);
- e_source_selector_show_selection (E_SOURCE_SELECTOR (widget), FALSE);
+ registry = e_shell_get_registry (shell);
+ widget = e_addressbook_selector_new (registry);
gtk_container_add (GTK_CONTAINER (container), widget);
priv->selector = g_object_ref (widget);
gtk_widget_show (widget);
@@ -139,7 +138,7 @@ book_shell_sidebar_constructed (GObject *object)
G_BINDING_SYNC_CREATE,
(GBindingTransformFunc) e_binding_transform_uid_to_source,
(GBindingTransformFunc) e_binding_transform_source_to_uid,
- g_object_ref (source_list),
+ g_object_ref (registry),
(GDestroyNotify) g_object_unref);
}
@@ -149,8 +148,8 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
EBookShellSidebar *book_shell_sidebar;
ESourceSelector *selector;
ESource *source;
- gboolean can_delete = FALSE;
- gboolean is_system = FALSE;
+ gboolean removable = FALSE;
+ gboolean writable = FALSE;
gboolean has_primary_source = FALSE;
guint32 state = 0;
@@ -159,27 +158,18 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
source = e_source_selector_ref_primary_selection (selector);
if (source != NULL) {
- const gchar *uri;
- const gchar *delete;
-
has_primary_source = TRUE;
-
- uri = e_source_peek_relative_uri (source);
- is_system = (uri == NULL || strcmp (uri, "system") == 0);
-
- can_delete = !is_system;
- delete = e_source_get_property (source, "delete");
- can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
-
+ removable = e_source_get_removable (source);
+ writable = e_source_get_writable (source);
g_object_unref (source);
}
if (has_primary_source)
state |= E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
- if (can_delete)
- state |= E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE;
- if (is_system)
- state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
+ if (removable)
+ state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE;
+ if (writable)
+ state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE;
return state;
}
diff --git a/modules/addressbook/e-book-shell-sidebar.h b/modules/addressbook/e-book-shell-sidebar.h
index 104a4d4..bf1cdd0 100644
--- a/modules/addressbook/e-book-shell-sidebar.h
+++ b/modules/addressbook/e-book-shell-sidebar.h
@@ -53,9 +53,9 @@ typedef struct _EBookShellSidebarClass EBookShellSidebarClass;
typedef struct _EBookShellSidebarPrivate EBookShellSidebarPrivate;
enum {
- E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
- E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1,
- E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2
+ E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
+ E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE = 1 << 1,
+ E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE = 1 << 2
};
struct _EBookShellSidebar {
diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c
index 2c174a3..fe7f9e4 100644
--- a/modules/addressbook/e-book-shell-view-actions.c
+++ b/modules/addressbook/e-book-shell-view-actions.c
@@ -33,8 +33,6 @@
#include <widgets/misc/e-contact-map-window.h>
#endif
-#include <addressbook-config.h>
-
static void
action_address_book_copy_cb (GtkAction *action,
EBookShellView *book_shell_view)
@@ -55,22 +53,14 @@ action_address_book_delete_cb (GtkAction *action,
{
EShellView *shell_view;
EShellWindow *shell_window;
- EBookShellBackend *book_shell_backend;
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- ESourceGroup *source_group;
- ESourceList *source_list;
- EBookClient *book;
gint response;
- GError *error = NULL;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- book_shell_backend = book_shell_view->priv->book_shell_backend;
- source_list = e_book_shell_backend_get_source_list (book_shell_backend);
-
book_shell_sidebar = book_shell_view->priv->book_shell_sidebar;
selector = e_book_shell_sidebar_get_selector (book_shell_sidebar);
source = e_source_selector_ref_primary_selection (selector);
@@ -81,38 +71,10 @@ action_address_book_delete_cb (GtkAction *action,
"addressbook:ask-delete-addressbook",
e_source_get_display_name (source), NULL);
- if (response != GTK_RESPONSE_YES) {
- g_object_unref (source);
- return;
- }
-
- book = e_book_client_new (source, &error);
- if (error != NULL) {
- g_warning ("Error removing addressbook: %s", error->message);
- g_object_unref (source);
- g_error_free (error);
- return;
- }
-
- if (!e_client_remove_sync (E_CLIENT (book), NULL, NULL)) {
- e_alert_run_dialog_for_args (
- GTK_WINDOW (shell_window),
- "addressbook:remove-addressbook", NULL);
- g_object_unref (source);
- g_object_unref (book);
- return;
- }
-
- if (e_source_selector_source_is_selected (selector, source))
- e_source_selector_unselect_source (selector, source);
-
- source_group = e_source_peek_group (source);
- e_source_group_remove_source (source_group, source);
-
- e_source_list_sync (source_list, NULL);
+ if (response == GTK_RESPONSE_YES)
+ e_shell_view_remove_source (shell_view, source);
g_object_unref (source);
- g_object_unref (book);
}
static void
@@ -135,11 +97,28 @@ action_address_book_new_cb (GtkAction *action,
{
EShellView *shell_view;
EShellWindow *shell_window;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- addressbook_config_create_new_source (GTK_WIDGET (shell_window));
+ registry = book_shell_view->priv->registry;
+ config = e_book_source_config_new (registry, NULL);
+
+ dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
+
+ gtk_window_set_transient_for (
+ GTK_WINDOW (config), GTK_WINDOW (shell_window));
+
+ icon_name = gtk_action_get_icon_name (action);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("New Address Book"));
+
+ gtk_widget_show (dialog);
}
static void
@@ -183,9 +162,10 @@ action_address_book_properties_cb (GtkAction *action,
EBookShellSidebar *book_shell_sidebar;
ESource *source;
ESourceSelector *selector;
- EditorUidClosure *closure;
- GHashTable *uid_to_editor;
- const gchar *uid;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (book_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -195,31 +175,23 @@ action_address_book_properties_cb (GtkAction *action,
source = e_source_selector_ref_primary_selection (selector);
g_return_if_fail (source != NULL);
- uid = e_source_get_uid (source);
- uid_to_editor = book_shell_view->priv->uid_to_editor;
-
- closure = g_hash_table_lookup (uid_to_editor, uid);
- if (closure == NULL) {
- GtkWidget *editor;
+ registry = e_source_selector_get_registry (selector);
+ config = e_book_source_config_new (registry, source);
- editor = addressbook_config_edit_source (
- GTK_WIDGET (shell_window), source);
+ g_object_unref (source);
- closure = g_new (EditorUidClosure, 1);
- closure->editor = editor;
- closure->uid = g_strdup (uid);
- closure->view = book_shell_view;
+ dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));
- g_hash_table_insert (uid_to_editor, closure->uid, closure);
+ gtk_window_set_transient_for (
+ GTK_WINDOW (dialog), GTK_WINDOW (shell_window));
- g_object_weak_ref (
- G_OBJECT (closure->editor), (GWeakNotify)
- e_book_shell_view_editor_weak_notify, closure);
- }
+ icon_name = gtk_action_get_icon_name (action);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name);
- gtk_window_present (GTK_WINDOW (closure->editor));
+ gtk_window_set_title (
+ GTK_WINDOW (dialog), _("Address Book Properties"));
- g_object_unref (source);
+ gtk_widget_show (dialog);
}
#ifdef WITH_CONTACT_MAPS
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index 62793f3..6418612 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -256,7 +256,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
ESourceSelector *selector)
{
EShellView *shell_view;
- EShellWindow *shell_window;
EBookShellContent *book_shell_content;
EAddressbookView *view;
EAddressbookModel *model;
@@ -268,7 +267,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
gchar *view_id;
shell_view = E_SHELL_VIEW (book_shell_view);
- shell_window = e_shell_view_get_shell_window (shell_view);
book_shell_content = book_shell_view->priv->book_shell_content;
source = e_source_selector_ref_primary_selection (selector);
@@ -293,8 +291,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
e_client_utils_open_new (
source, E_CLIENT_SOURCE_TYPE_CONTACTS,
FALSE, NULL,
- e_client_utils_authenticate_handler,
- GTK_WINDOW (shell_window),
book_shell_view_loaded_cb,
g_object_ref (view));
@@ -341,7 +337,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
/* XXX No way to cancel this? */
e_client_utils_open_new (
source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
book_shell_view_loaded_cb, g_object_ref (view));
g_signal_connect_object (
@@ -435,6 +430,30 @@ book_shell_view_selector_key_press_event_cb (EShellView *shell_view,
}
static void
+book_shell_view_source_removed_cb (ESourceRegistry *registry,
+ ESource *source,
+ EBookShellView *book_shell_view)
+{
+ EBookShellViewPrivate *priv = book_shell_view->priv;
+ EBookShellContent *book_shell_content;
+ EAddressbookView *view;
+ const gchar *uid;
+
+ uid = e_source_get_uid (source);
+
+ book_shell_content = book_shell_view->priv->book_shell_content;
+
+ /* Remove the EAddressbookView for the deleted source. */
+ view = g_hash_table_lookup (priv->uid_to_view, uid);
+ if (view != NULL) {
+ e_book_shell_content_remove_view (book_shell_content, view);
+ g_hash_table_remove (priv->uid_to_view, uid);
+ }
+
+ e_shell_view_update_actions (E_SHELL_VIEW (book_shell_view));
+}
+
+static void
book_shell_view_load_view_collection (EShellViewClass *shell_view_class)
{
GalViewCollection *collection;
@@ -495,20 +514,13 @@ e_book_shell_view_private_init (EBookShellView *book_shell_view,
{
EBookShellViewPrivate *priv = book_shell_view->priv;
GHashTable *uid_to_view;
- GHashTable *uid_to_editor;
uid_to_view = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
- uid_to_editor = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
priv->uid_to_view = uid_to_view;
- priv->uid_to_editor = uid_to_editor;
priv->preview_index = -1;
if (!gal_view_collection_loaded (shell_view_class->view_collection))
@@ -523,11 +535,12 @@ void
e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
{
EBookShellViewPrivate *priv = book_shell_view->priv;
+ EShell *shell;
+ EShellView *shell_view;
+ EShellWindow *shell_window;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
EShellBackend *shell_backend;
- EShellView *shell_view;
- EShellWindow *shell_window;
ESourceSelector *selector;
shell_view = E_SHELL_VIEW (book_shell_view);
@@ -535,6 +548,7 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
shell_content = e_shell_view_get_shell_content (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
+ shell = e_shell_window_get_shell (shell_window);
e_shell_window_add_action_group (shell_window, "contacts");
e_shell_window_add_action_group (shell_window, "contacts-filter");
@@ -544,9 +558,18 @@ e_book_shell_view_private_constructed (EBookShellView *book_shell_view)
priv->book_shell_content = g_object_ref (shell_content);
priv->book_shell_sidebar = g_object_ref (shell_sidebar);
+ /* Keep our own reference to this so we can
+ * disconnect our signal handler in dispose(). */
+ priv->registry = g_object_ref (e_shell_get_registry (shell));
+
selector = e_book_shell_sidebar_get_selector (
E_BOOK_SHELL_SIDEBAR (shell_sidebar));
+ g_signal_connect (
+ priv->registry, "source-removed",
+ G_CALLBACK (book_shell_view_source_removed_cb),
+ book_shell_view);
+
g_signal_connect_object (
selector, "button-press-event",
G_CALLBACK (book_shell_view_selector_button_press_event_cb),
@@ -585,8 +608,15 @@ e_book_shell_view_private_dispose (EBookShellView *book_shell_view)
DISPOSE (priv->book_shell_content);
DISPOSE (priv->book_shell_sidebar);
+ if (priv->registry != NULL) {
+ g_signal_handlers_disconnect_matched (
+ priv->registry, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, book_shell_view);
+ g_object_unref (priv->registry);
+ priv->registry = NULL;
+ }
+
g_hash_table_remove_all (priv->uid_to_view);
- g_hash_table_remove_all (priv->uid_to_editor);
}
void
@@ -595,15 +625,4 @@ e_book_shell_view_private_finalize (EBookShellView *book_shell_view)
EBookShellViewPrivate *priv = book_shell_view->priv;
g_hash_table_destroy (priv->uid_to_view);
- g_hash_table_destroy (priv->uid_to_editor);
-}
-
-void
-e_book_shell_view_editor_weak_notify (EditorUidClosure *closure,
- GObject *where_the_object_was)
-{
- GHashTable *hash_table;
-
- hash_table = closure->view->priv->uid_to_editor;
- g_hash_table_remove (hash_table, closure->uid);
}
diff --git a/modules/addressbook/e-book-shell-view-private.h b/modules/addressbook/e-book-shell-view-private.h
index d1b30ef..a110d37 100644
--- a/modules/addressbook/e-book-shell-view-private.h
+++ b/modules/addressbook/e-book-shell-view-private.h
@@ -41,6 +41,7 @@
#include "shell/e-shell-utils.h"
#include "misc/e-popup-action.h"
#include "misc/e-selectable.h"
+#include "misc/e-source-config-dialog.h"
#include "addressbook/util/eab-book-util.h"
#include "addressbook/gui/contact-editor/e-contact-editor.h"
@@ -48,6 +49,7 @@
#include "addressbook/gui/widgets/eab-gui-util.h"
#include "addressbook/gui/widgets/e-addressbook-view.h"
#include "addressbook/gui/widgets/e-addressbook-selector.h"
+#include "addressbook/gui/widgets/e-book-source-config.h"
#include "e-book-shell-backend.h"
#include "e-book-shell-content.h"
@@ -75,14 +77,6 @@
G_BEGIN_DECLS
-typedef struct _EditorUidClosure EditorUidClosure;
-
-struct _EditorUidClosure {
- GtkWidget *editor;
- gchar *uid;
- EBookShellView *view;
-};
-
/* List these in the order to be displayed.
* Positive values are reserved for categories. */
enum {
@@ -105,8 +99,8 @@ struct _EBookShellViewPrivate {
EBookShellContent *book_shell_content;
EBookShellSidebar *book_shell_sidebar;
+ ESourceRegistry *registry;
GHashTable *uid_to_view;
- GHashTable *uid_to_editor;
gint preview_index;
@@ -129,9 +123,6 @@ void e_book_shell_view_private_finalize
void e_book_shell_view_actions_init
(EBookShellView *book_shell_view);
-void e_book_shell_view_editor_weak_notify
- (EditorUidClosure *closure,
- GObject *where_the_object_was);
void e_book_shell_view_update_search_filter
(EBookShellView *book_shell_view);
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index 84526e4..53136c2 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -29,59 +29,6 @@ static gpointer parent_class;
static GType book_shell_view_type;
static void
-book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view,
- ESourceList *source_list)
-{
- EBookShellViewPrivate *priv = book_shell_view->priv;
- EBookShellContent *book_shell_content;
- EShellView *shell_view;
- GList *keys, *iter;
-
- g_return_if_fail (E_IS_SHELL_VIEW (book_shell_view));
- g_return_if_fail (book_shell_view->priv != NULL);
-
- shell_view = E_SHELL_VIEW (book_shell_view);
- book_shell_content = book_shell_view->priv->book_shell_content;
-
- keys = g_hash_table_get_keys (priv->uid_to_view);
- for (iter = keys; iter != NULL; iter = iter->next) {
- gchar *uid = iter->data;
- EAddressbookView *view;
-
- /* If the source still exists, move on. */
- if (e_source_list_peek_source_by_uid (source_list, uid))
- continue;
-
- /* Remove the view for the deleted source. */
- view = g_hash_table_lookup (priv->uid_to_view, uid);
- e_book_shell_content_remove_view (book_shell_content, view);
- g_hash_table_remove (priv->uid_to_view, uid);
- }
- g_list_free (keys);
-
- keys = g_hash_table_get_keys (priv->uid_to_editor);
- for (iter = keys; iter != NULL; iter = iter->next) {
- gchar *uid = iter->data;
- EditorUidClosure *closure;
-
- /* If the source still exists, move on. */
- if (e_source_list_peek_source_by_uid (source_list, uid))
- continue;
-
- /* Remove the editor for the deleted source. */
- closure = g_hash_table_lookup (priv->uid_to_editor, uid);
- g_object_weak_unref (
- G_OBJECT (closure->editor), (GWeakNotify)
- e_book_shell_view_editor_weak_notify, closure);
- gtk_widget_destroy (closure->editor);
- g_hash_table_remove (priv->uid_to_editor, uid);
- }
- g_list_free (keys);
-
- e_shell_view_update_actions (shell_view);
-}
-
-static void
book_shell_view_dispose (GObject *object)
{
EBookShellView *book_shell_view;
@@ -109,22 +56,12 @@ static void
book_shell_view_constructed (GObject *object)
{
EBookShellView *book_shell_view;
- EBookShellBackend *book_shell_backend;
- ESourceList *source_list;
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (parent_class)->constructed (object);
book_shell_view = E_BOOK_SHELL_VIEW (object);
e_book_shell_view_private_constructed (book_shell_view);
-
- book_shell_backend = book_shell_view->priv->book_shell_backend;
- source_list = e_book_shell_backend_get_source_list (book_shell_backend);
-
- g_signal_connect_object (
- source_list, "changed",
- G_CALLBACK (book_shell_view_source_list_changed_cb),
- book_shell_view, G_CONNECT_SWAPPED);
}
static void
@@ -262,9 +199,10 @@ book_shell_view_update_actions (EShellView *shell_view)
/* Be descriptive. */
gboolean any_contacts_selected;
- gboolean can_delete_primary_source;
gboolean has_primary_source;
gboolean multiple_contacts_selected;
+ gboolean primary_source_is_removable;
+ gboolean primary_source_is_writable;
gboolean single_contact_selected;
gboolean selection_is_contact_list;
gboolean selection_has_email;
@@ -297,8 +235,10 @@ book_shell_view_update_actions (EShellView *shell_view)
has_primary_source =
(state & E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
- can_delete_primary_source =
- (state & E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE);
+ primary_source_is_removable =
+ (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOVABLE);
+ primary_source_is_writable =
+ (state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_WRITABLE);
any_contacts_selected =
(single_contact_selected || multiple_contacts_selected);
@@ -308,7 +248,7 @@ book_shell_view_update_actions (EShellView *shell_view)
gtk_action_set_sensitive (action, sensitive);
action = ACTION (ADDRESS_BOOK_DELETE);
- sensitive = can_delete_primary_source;
+ sensitive = primary_source_is_removable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (ADDRESS_BOOK_PRINT);
@@ -319,8 +259,12 @@ book_shell_view_update_actions (EShellView *shell_view)
sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
+ action = ACTION (ADDRESS_BOOK_PROPERTIES);
+ sensitive = primary_source_is_writable;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (ADDRESS_BOOK_RENAME);
- sensitive = can_delete_primary_source;
+ sensitive = primary_source_is_writable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (ADDRESS_BOOK_STOP);
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index a1d62c0..6abe3a6 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -21,6 +21,7 @@ widgetsinclude_HEADERS = \
e-attachment-tree-view.h \
e-attachment-view.h \
e-auth-combo-box.h \
+ e-autocomplete-selector.h \
e-buffer-tagger.h \
e-calendar.h \
e-calendar-item.h \
@@ -108,6 +109,7 @@ libemiscwidgets_la_SOURCES = \
e-attachment-tree-view.c \
e-attachment-view.c \
e-auth-combo-box.c \
+ e-autocomplete-selector.c \
e-buffer-tagger.c \
e-calendar.c \
e-calendar-item.c \
diff --git a/widgets/misc/e-autocomplete-selector.h b/widgets/misc/e-autocomplete-selector.h
new file mode 100644
index 0000000..8caa132
--- /dev/null
+++ b/widgets/misc/e-autocomplete-selector.h
@@ -0,0 +1,64 @@
+/*
+ * e-autocomplete-selector.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef E_AUTOCOMPLETE_SELECTOR_H
+#define E_AUTOCOMPLETE_SELECTOR_H
+
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_AUTOCOMPLETE_SELECTOR \
+ (e_autocomplete_selector_get_type ())
+#define E_AUTOCOMPLETE_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelector))
+#define E_AUTOCOMPLETE_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelectorClass))
+#define E_IS_AUTOCOMPLETE_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR))
+#define E_IS_AUTOCOMPLETE_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_AUTOCOMPLETE_SELECTOR))
+#define E_AUTOCOMPLETE_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_AUTOCOMPLETE_SELECTOR, EAutocompleteSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EAutocompleteSelector EAutocompleteSelector;
+typedef struct _EAutocompleteSelectorClass EAutocompleteSelectorClass;
+typedef struct _EAutocompleteSelectorPrivate EAutocompleteSelectorPrivate;
+
+struct _EAutocompleteSelector {
+ ESourceSelector parent;
+ EAutocompleteSelectorPrivate *priv;
+};
+
+struct _EAutocompleteSelectorClass {
+ ESourceSelectorClass parent_class;
+};
+
+GType e_autocomplete_selector_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_autocomplete_selector_new (ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_AUTOCOMPLETE_SELECTOR_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]