[evolution/account-mgmt: 24/50] Adapt modules/calendar to the new ESource API.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/account-mgmt: 24/50] Adapt modules/calendar to the new ESource API.
- Date: Wed, 7 Sep 2011 16:09:46 +0000 (UTC)
commit 56a6de027dfa0562ebb930e04c8cbf9a8a14557a
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Dec 23 08:58:10 2010 -0500
Adapt modules/calendar to the new ESource API.
modules/Makefile.am | 4 +-
modules/calendar/Makefile.am | 4 +-
modules/calendar/e-cal-attachment-handler.c | 50 ++--
modules/calendar/e-cal-shell-backend.c | 365 ++++----------------------
modules/calendar/e-cal-shell-backend.h | 8 -
modules/calendar/e-cal-shell-migrate.c | 223 ----------------
modules/calendar/e-cal-shell-sidebar.c | 204 ++++++---------
modules/calendar/e-cal-shell-sidebar.h | 2 +
modules/calendar/e-cal-shell-view-actions.c | 122 ++++-----
modules/calendar/e-cal-shell-view-private.c | 13 +-
modules/calendar/e-cal-shell-view-private.h | 5 +-
modules/calendar/e-cal-shell-view.c | 7 +-
modules/calendar/e-calendar-preferences.c | 90 +------
modules/calendar/e-calendar-preferences.h | 2 -
modules/calendar/e-memo-shell-backend.c | 302 ++++------------------
modules/calendar/e-memo-shell-backend.h | 8 -
modules/calendar/e-memo-shell-content.c | 2 +-
modules/calendar/e-memo-shell-migrate.c | 158 +-----------
modules/calendar/e-memo-shell-sidebar.c | 141 ++++-------
modules/calendar/e-memo-shell-view-actions.c | 114 ++++-----
modules/calendar/e-memo-shell-view-private.h | 3 +-
modules/calendar/e-memo-shell-view.h | 1 -
modules/calendar/e-task-shell-backend.c | 303 ++++------------------
modules/calendar/e-task-shell-backend.h | 8 -
modules/calendar/e-task-shell-content.c | 2 +-
modules/calendar/e-task-shell-migrate.c | 166 +------------
modules/calendar/e-task-shell-sidebar.c | 142 ++++-------
modules/calendar/e-task-shell-view-actions.c | 114 ++++-----
modules/calendar/e-task-shell-view-private.h | 3 +-
modules/calendar/e-task-shell-view.h | 1 -
widgets/misc/Makefile.am | 2 +
widgets/misc/e-alarm-selector.c | 102 +++++++
widgets/misc/e-alarm-selector.h | 63 +++++
33 files changed, 718 insertions(+), 2016 deletions(-)
---
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 1018a4f..dd363d2 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -22,12 +22,10 @@ if ENABLE_WINDOWS_SENS
WINDOWS_SENS_DIR = windows-sens
endif
-# ACCOUNT_MGMT: Disable SUBDIRS
-# calendar (comes after bogofilter)
-
SUBDIRS = \
addressbook \
bogofilter \
+ calendar \
mail \
composer-autosave \
mailto-handler \
diff --git a/modules/calendar/Makefile.am b/modules/calendar/Makefile.am
index c725ded..43570f6 100644
--- a/modules/calendar/Makefile.am
+++ b/modules/calendar/Makefile.am
@@ -13,6 +13,8 @@ libevolution_module_calendar_la_CPPFLAGS = \
libevolution_module_calendar_la_SOURCES = \
evolution-module-calendar.c \
+ e-calendar-preferences.c \
+ e-calendar-preferences.h \
e-cal-attachment-handler.c \
e-cal-attachment-handler.h \
e-cal-config-calendar-item.c \
@@ -51,8 +53,6 @@ libevolution_module_calendar_la_SOURCES = \
e-cal-shell-view-private.c \
e-cal-shell-view-private.h \
e-cal-shell-view-taskpad.c \
- e-calendar-preferences.c \
- e-calendar-preferences.h \
e-memo-shell-backend.c \
e-memo-shell-backend.h \
e-memo-shell-content.c \
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
index 24a73f6..ce69d8b 100644
--- a/modules/calendar/e-cal-attachment-handler.c
+++ b/modules/calendar/e-cal-attachment-handler.c
@@ -29,6 +29,7 @@
#include <libical/ical.h>
#include <libecal/e-cal-client.h>
#include <camel/camel.h>
+#include <libecal/e-source-calendar.h>
#include <libedataserverui/e-source-selector.h>
#include <libedataserverui/e-client-utils.h>
@@ -175,7 +176,7 @@ attachment_handler_import_event (GObject *source_object,
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_object_unref (attachment);
g_error_free (error);
@@ -231,7 +232,7 @@ attachment_handler_import_todo (GObject *source_object,
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_object_unref (attachment);
g_error_free (error);
@@ -283,27 +284,30 @@ attachment_handler_run_dialog (GtkWindow *parent,
GtkWidget *dialog;
GtkWidget *container;
GtkWidget *widget;
+ GCallback callback;
+ ESourceRegistry *registry;
ESourceSelector *selector;
- ESourceList *source_list;
ESource *source;
+ ECalClient *client;
+ const gchar *extension_name;
icalcomponent *component;
- GError *error = NULL;
-
- component = attachment_handler_get_component (attachment);
- g_return_if_fail (component != NULL);
- e_cal_client_get_sources (&source_list, source_type, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to get cal sources: %s",
- G_STRFUNC, error->message);
- g_clear_error (&error);
- return;
+ switch (source_type) {
+ case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
+ extension_name = E_SOURCE_EXTENSION_CALENDAR;
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
+ extension_name = E_SOURCE_EXTENSION_TASK_LIST;
+ break;
+ case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
+ extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
+ break;
+ default:
+ g_return_if_reached ();
}
- source = e_source_list_peek_source_any (source_list);
- g_return_if_fail (source != NULL);
+ component = attachment_handler_get_component (attachment);
+ g_return_if_fail (component != NULL);
dialog = gtk_dialog_new_with_buttons (
title, parent, GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -332,10 +336,10 @@ attachment_handler_run_dialog (GtkWindow *parent,
container = widget;
- widget = e_source_selector_new (source_list);
+ registry = e_source_registry_get_default ();
+ widget = e_source_selector_new (registry, extension_name);
selector = E_SOURCE_SELECTOR (widget);
- e_source_selector_set_primary_selection (selector, source);
- e_source_selector_show_selection (selector, FALSE);
+ e_source_selector_set_show_toggles (selector, FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
@@ -352,12 +356,14 @@ attachment_handler_run_dialog (GtkWindow *parent,
switch (source_type) {
case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL,
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, NULL,
e_client_utils_authenticate_handler, NULL,
attachment_handler_import_event, g_object_ref (attachment));
break;
case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL,
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL,
e_client_utils_authenticate_handler, NULL,
attachment_handler_import_todo, g_object_ref (attachment));
break;
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 96077cf..fc3e0b8 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -29,9 +29,9 @@
#include <glib/gi18n.h>
#include <libecal/e-cal-client.h>
#include <libecal/e-cal-time-util.h>
+#include <libecal/e-source-calendar.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-group.h>
#include <libedataserverui/e-client-utils.h>
#include "e-util/e-import.h"
@@ -39,10 +39,11 @@
#include "shell/e-shell-backend.h"
#include "shell/e-shell-window.h"
#include "widgets/misc/e-preferences-window.h"
+#include "widgets/misc/e-source-config-dialog.h"
#include "calendar/gui/comp-util.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/event-editor.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "calendar/gui/e-calendar-view.h"
#include "calendar/gui/gnome-cal.h"
#include "calendar/importers/evolution-calendar-importer.h"
@@ -56,184 +57,13 @@
#include "e-calendar-preferences.h"
struct _ECalShellBackendPrivate {
- ESourceList *source_list;
-};
-
-enum {
- PROP_0,
- PROP_SOURCE_LIST
+ gint placeholder;
};
static gpointer parent_class;
static GType cal_shell_backend_type;
static void
-cal_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? */
-
- ECalShellBackend *cal_shell_backend;
- ESourceGroup *on_this_computer;
- ESourceGroup *contacts;
- ESourceList *source_list;
- ESource *birthdays;
- ESource *personal;
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *sources, *iter;
- const gchar *name;
- gchar *property;
- gboolean save_list = FALSE;
- GError *error = NULL;
-
- birthdays = NULL;
- personal = NULL;
-
- cal_shell_backend = E_CAL_SHELL_BACKEND (shell_backend);
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_cal_client_get_sources (
- &cal_shell_backend->priv->source_list,
- E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get calendar sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
-
- source_list = cal_shell_backend->priv->source_list;
-
- on_this_computer = e_source_list_ensure_group (
- source_list, _("On This Computer"), "local:", TRUE);
- contacts = e_source_list_ensure_group (
- source_list, _("Contacts"), "contacts://", TRUE);
- e_source_list_ensure_group (
- source_list, _("On The Web"), "webcal://", FALSE);
- e_source_list_ensure_group (
- source_list, _("Weather"), "weather://", FALSE);
-
- g_return_if_fail (on_this_computer != NULL);
- g_return_if_fail (contacts != 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;
- GSList *selected;
- gchar *primary;
-
- source = e_source_new (name, "system");
- e_source_set_color_spec (source, "#BECEDD");
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
- save_list = TRUE;
-
- primary = e_shell_settings_get_string (
- shell_settings, "cal-primary-calendar");
-
- selected = e_cal_shell_backend_get_selected_calendars (
- cal_shell_backend);
-
- if (primary == NULL && selected == NULL) {
- const gchar *uid;
-
- uid = e_source_peek_uid (source);
- selected = g_slist_prepend (NULL, g_strdup (uid));
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-calendar", uid);
- e_cal_shell_backend_set_selected_calendars (
- cal_shell_backend, selected);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
- g_free (primary);
- } else {
- /* Force the source name to the current locale. */
- e_source_set_name (personal, name);
- }
-
- sources = e_source_group_peek_sources (contacts);
-
- if (sources != NULL) {
- GSList *trash;
-
- /* There is only one source under Contacts. */
- birthdays = E_SOURCE (sources->data);
- sources = g_slist_next (sources);
-
- /* Delete any other sources in this group.
- * Earlier versions allowed you to create
- * additional sources under Contacts. */
- trash = g_slist_copy (sources);
- while (trash != NULL) {
- ESource *source = trash->data;
- e_source_group_remove_source (contacts, source);
- trash = g_slist_delete_link (trash, trash);
- save_list = TRUE;
- }
- }
-
- /* XXX e_source_group_get_property() returns a newly-allocated
- * string when it could just as easily return a const string.
- * Unfortunately, fixing that would break the API. */
- property = e_source_group_get_property (contacts, "create_source");
- if (property == NULL)
- e_source_group_set_property (contacts, "create_source", "no");
- g_free (property);
-
- name = _("Birthdays & Anniversaries");
-
- if (birthdays == NULL) {
- ESource *source;
-
- source = e_source_new (name, "/");
- e_source_group_add_source (contacts, source, -1);
- g_object_unref (source);
- save_list = TRUE;
-
- /* This is now a borrowed reference. */
- birthdays = source;
- } else {
- /* Force the source name to the current locale. */
- e_source_set_name (birthdays, name);
- }
-
- if (e_source_get_property (birthdays, "delete") == NULL)
- e_source_set_property (birthdays, "delete", "no");
-
- if (e_source_peek_color_spec (birthdays) == NULL)
- e_source_set_color_spec (birthdays, "#DDBECE");
-
- g_object_unref (on_this_computer);
- g_object_unref (contacts);
-
- if (save_list)
- e_source_list_sync (source_list, NULL);
-}
-
-static void
cal_shell_backend_new_event (ESource *source,
GAsyncResult *result,
EShell *shell,
@@ -254,7 +84,7 @@ cal_shell_backend_new_event (ESource *source,
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
return;
@@ -343,13 +173,12 @@ action_event_new_cb (GtkAction *action,
{
EShell *shell;
EShellView *shell_view;
- EShellBackend *shell_backend;
- EShellSettings *shell_settings;
- ESource *source = NULL;
- ESourceList *source_list;
- EClientSourceType source_type;
+ ESource *source;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
const gchar *action_name;
- gchar *uid;
+
+ shell = e_shell_window_get_shell (shell_window);
/* With a 'calendar' active shell view pass the new appointment
* request to it, thus the event will inherit selected time from
@@ -386,50 +215,54 @@ action_event_new_cb (GtkAction *action,
source_type = E_CLIENT_SOURCE_TYPE_EVENTS;
- shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
- shell_backend = e_shell_get_backend_by_name (shell, "calendar");
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-calendar");
-
- 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_source_registry_get_default ();
+ source = e_source_registry_get_default_calendar (registry);
/* Use a callback function appropriate for the action.
* FIXME Need to obtain a better default time zone. */
action_name = gtk_action_get_name (action);
if (strcmp (action_name, "event-all-day-new") == 0)
- e_client_utils_open_new (source, source_type, FALSE, NULL,
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
cal_shell_backend_event_all_day_new_cb, g_object_ref (shell));
else if (strcmp (action_name, "event-meeting-new") == 0)
- e_client_utils_open_new (source, source_type, FALSE, NULL,
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
cal_shell_backend_event_meeting_new_cb, g_object_ref (shell));
else
- e_client_utils_open_new (source, source_type, FALSE, NULL,
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
cal_shell_backend_event_new_cb, g_object_ref (shell));
-
- g_object_unref (source_list);
}
static void
action_calendar_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
- calendar_setup_new_calendar (GTK_WINDOW (shell_window));
+ ECalClientSourceType source_type;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
+
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
+ registry = e_source_registry_get_default ();
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Calendar"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static GtkActionEntry item_entries[] = {
@@ -506,7 +339,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
ECalClient *client;
ECalComponent *comp;
ESource *source;
- ESourceList *source_list;
+ ESourceRegistry *registry;
ECalClientSourceType source_type;
EUri *euri;
icalcomponent *icalcomp;
@@ -603,21 +436,10 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
* we successfully open it is another matter... */
handled = TRUE;
- e_cal_client_get_sources (&source_list, source_type, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get calendar sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- goto exit;
- }
-
- source = e_source_list_peek_source_by_uid (source_list, source_uid);
-
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, source_uid);
if (source == NULL) {
- g_warning ("%s: No source for UID '%s'", G_STRFUNC, source_uid);
- g_object_unref (source_list);
+ g_printerr ("No source for UID '%s'\n", source_uid);
goto exit;
}
@@ -629,9 +451,10 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
if (error != NULL) {
g_warning (
"%s: Failed to create/open client '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
- g_object_unref (source_list);
+ if (client != NULL)
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -651,7 +474,7 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
g_warning (
"%s: Failed to get object from client: %s",
G_STRFUNC, error->message);
- g_object_unref (source_list);
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -685,7 +508,6 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
present:
gtk_window_present (GTK_WINDOW (editor));
- g_object_unref (source_list);
g_object_unref (client);
exit:
@@ -719,40 +541,6 @@ cal_shell_backend_window_created_cb (EShellBackend *shell_backend,
}
static void
-cal_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_cal_shell_backend_get_source_list (
- E_CAL_SHELL_BACKEND (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-cal_shell_backend_dispose (GObject *object)
-{
- ECalShellBackendPrivate *priv;
-
- priv = E_CAL_SHELL_BACKEND (object)->priv;
-
- 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 (parent_class)->dispose (object);
-}
-
-static void
cal_shell_backend_constructed (GObject *object)
{
EShell *shell;
@@ -762,8 +550,6 @@ cal_shell_backend_constructed (GObject *object)
shell_backend = E_SHELL_BACKEND (object);
shell = e_shell_backend_get_shell (shell_backend);
- cal_shell_backend_ensure_sources (shell_backend);
-
g_signal_connect_swapped (
shell, "handle-uri",
G_CALLBACK (cal_shell_backend_handle_uri_cb),
@@ -803,8 +589,6 @@ cal_shell_backend_class_init (ECalShellBackendClass *class)
g_type_class_add_private (class, sizeof (ECalShellBackendPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->get_property = cal_shell_backend_get_property;
- object_class->dispose = cal_shell_backend_dispose;
object_class->constructed = cal_shell_backend_constructed;
shell_backend_class = E_SHELL_BACKEND_CLASS (class);
@@ -817,15 +601,8 @@ cal_shell_backend_class_init (ECalShellBackendClass *class)
shell_backend_class->start = NULL;
shell_backend_class->migrate = e_cal_shell_backend_migrate;
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_LIST,
- g_param_spec_object (
- "source-list",
- "Source List",
- "The registry of calendars",
- E_TYPE_SOURCE_LIST,
- G_PARAM_READABLE));
+ /* Register relevant ESource extensions. */
+ E_TYPE_SOURCE_CALENDAR;
}
static void
@@ -889,50 +666,6 @@ e_cal_shell_backend_register_type (GTypeModule *type_module)
"ECalShellBackend", &type_info, 0);
}
-ESourceList *
-e_cal_shell_backend_get_source_list (ECalShellBackend *cal_shell_backend)
-{
- g_return_val_if_fail (
- E_IS_CAL_SHELL_BACKEND (cal_shell_backend), NULL);
-
- return cal_shell_backend->priv->source_list;
-}
-
-GSList *
-e_cal_shell_backend_get_selected_calendars (ECalShellBackend *cal_shell_backend)
-{
- GConfClient *client;
- GSList *selected_calendars;
- const gchar *key;
-
- g_return_val_if_fail (
- E_IS_CAL_SHELL_BACKEND (cal_shell_backend), NULL);
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/display/selected_calendars";
- selected_calendars = gconf_client_get_list (
- client, key, GCONF_VALUE_STRING, NULL);
- g_object_unref (client);
-
- return selected_calendars;
-}
-
-void
-e_cal_shell_backend_set_selected_calendars (ECalShellBackend *cal_shell_backend,
- GSList *selected_calendars)
-{
- GConfClient *client;
- const gchar *key;
-
- g_return_if_fail (E_IS_CAL_SHELL_BACKEND (cal_shell_backend));
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/display/selected_calendars";
- gconf_client_set_list (
- client, key, GCONF_VALUE_STRING, selected_calendars, NULL);
- g_object_unref (client);
-}
-
void
e_cal_shell_backend_open_date_range (ECalShellBackend *cal_shell_backend,
const GDate *start_date,
diff --git a/modules/calendar/e-cal-shell-backend.h b/modules/calendar/e-cal-shell-backend.h
index 32fca7f..400d769 100644
--- a/modules/calendar/e-cal-shell-backend.h
+++ b/modules/calendar/e-cal-shell-backend.h
@@ -23,7 +23,6 @@
#define E_CAL_SHELL_BACKEND_H
#include <shell/e-shell-backend.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_CAL_SHELL_BACKEND \
@@ -62,13 +61,6 @@ struct _ECalShellBackendClass {
GType e_cal_shell_backend_get_type (void);
void e_cal_shell_backend_register_type
(GTypeModule *type_module);
-ESourceList * e_cal_shell_backend_get_source_list
- (ECalShellBackend *cal_shell_backend);
-GSList * e_cal_shell_backend_get_selected_calendars
- (ECalShellBackend *cal_shell_backend);
-void e_cal_shell_backend_set_selected_calendars
- (ECalShellBackend *cal_shell_backend,
- GSList *selected_calendars);
void e_cal_shell_backend_open_date_range
(ECalShellBackend *cal_shell_backend,
const GDate *start_date,
diff --git a/modules/calendar/e-cal-shell-migrate.c b/modules/calendar/e-cal-shell-migrate.c
index dd76049..3b92c99 100644
--- a/modules/calendar/e-cal-shell-migrate.c
+++ b/modules/calendar/e-cal-shell-migrate.c
@@ -25,189 +25,6 @@
#include "e-cal-shell-migrate.h"
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <libebackend/e-dbhash.h>
-#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-group.h>
-#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-xml-hash-utils.h>
-
-#include "e-util/e-util-private.h"
-#include "calendar/gui/calendar-config-keys.h"
-#include "calendar/gui/e-cal-event.h"
-#include "shell/e-shell.h"
-
-#include "e-cal-shell-backend.h"
-
-#define LOCAL_BASE_URI "local:"
-#define WEBCAL_BASE_URI "webcal://"
-#define CONTACTS_BASE_URI "contacts://"
-#define BAD_CONTACTS_BASE_URI "contact://"
-#define PERSONAL_RELATIVE_URI "system"
-
-static ESourceGroup *
-create_calendar_contact_source (ESourceList *source_list)
-{
- ESourceGroup *group;
- ESource *source;
-
- /* Create the contacts group */
- group = e_source_group_new (_("Contacts"), CONTACTS_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- source = e_source_new (_("Birthdays & Anniversaries"), "/");
- e_source_group_add_source (group, source, -1);
- g_object_unref (source);
-
- e_source_set_color_spec (source, "#FED4D3");
- e_source_group_set_readonly (group, TRUE);
-
- return group;
-}
-
-static void
-create_calendar_sources (EShellBackend *shell_backend,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESource **personal_source,
- ESourceGroup **on_the_web,
- ESourceGroup **contacts)
-{
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *groups;
- ESourceGroup *group;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *contacts = NULL;
- *personal_source = NULL;
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
- const gchar *data_dir;
- gchar *base_dir, *base_uri;
-
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- base_dir = g_build_filename (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 (BAD_CONTACTS_BASE_URI, e_source_group_peek_base_uri (group)))
- e_source_group_set_base_uri (group, CONTACTS_BASE_URI);
-
- if (!strcmp (base_uri, e_source_group_peek_base_uri (group)))
- 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_the_web && !strcmp (WEBCAL_BASE_URI,
- e_source_group_peek_base_uri (group)))
- *on_the_web = g_object_ref (group);
-
- else if (!*contacts && !strcmp (CONTACTS_BASE_URI,
- e_source_group_peek_base_uri (group)))
- *contacts = 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 (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- GSList *selected;
- gchar *primary_calendar;
-
- /* Create the default Person calendar */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- primary_calendar = e_shell_settings_get_string (
- shell_settings, "cal-primary-calendar");
-
- selected = e_cal_shell_backend_get_selected_calendars (
- E_CAL_SHELL_BACKEND (shell_backend));
-
- if (primary_calendar == NULL && selected == NULL) {
- GSList link;
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-calendar",
- e_source_peek_uid (source));
-
- link.data = (gpointer) e_source_peek_uid (source);
- link.next = NULL;
-
- e_cal_shell_backend_set_selected_calendars (
- E_CAL_SHELL_BACKEND (shell_backend), &link);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
-
- g_free (primary_calendar);
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-
- if (!*contacts) {
- group = create_calendar_contact_source (source_list);
-
- *contacts = group;
- }
-}
-
gboolean
e_cal_shell_backend_migrate (EShellBackend *shell_backend,
gint major,
@@ -215,46 +32,6 @@ e_cal_shell_backend_migrate (EShellBackend *shell_backend,
gint micro,
GError **error)
{
- ESourceGroup *on_this_computer = NULL, *on_the_web = NULL, *contacts = NULL;
- ESource *personal_source = NULL;
- ESourceList *source_list;
- ECalEvent *ece;
- ECalEventTargetBackend *target;
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
-
- /* we call this unconditionally now - create_groups either
- * creates the groups/sources or it finds the necessary
- * groups/sources. */
- create_calendar_sources (
- shell_backend, source_list, &on_this_computer,
- &personal_source, &on_the_web, &contacts);
-
- e_source_list_sync (source_list, NULL);
-
- /** @Event: component.migration
- * @Title: Migration step in component initialization
- * @Target: ECalEventTargetComponent
- *
- * component.migration is emitted during the calendar component
- * initialization process. This allows new calendar backend types
- * to be distributed as an e-d-s backend and a plugin without
- * reaching their grubby little fingers into migration.c
- */
- /* Fire off migration event */
- ece = e_cal_event_peek ();
- target = e_cal_event_target_new_module (ece, shell_backend, source_list, 0);
- e_event_emit ((EEvent *) ece, "module.migration", (EEventTarget *) target);
-
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (contacts)
- g_object_unref (contacts);
- if (personal_source)
- g_object_unref (personal_source);
-
return TRUE;
}
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index 77c5639..6581784 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -27,6 +27,8 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <libecal/e-source-calendar.h>
+#include <libedataserver/e-source-password.h>
#include <libedataserverui/e-client-utils.h>
#include "e-util/e-alert-dialog.h"
@@ -35,7 +37,6 @@
#include "calendar/gui/e-calendar-selector.h"
#include "calendar/gui/misc.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "e-cal-shell-view.h"
#include "e-cal-shell-backend.h"
@@ -45,6 +46,7 @@ struct _ECalShellSidebarPrivate {
GtkWidget *paned;
GtkWidget *selector;
GtkWidget *date_navigator;
+ GtkWidget *new_calendar_button;
/* UID -> Client */
GHashTable *client_table;
@@ -125,7 +127,7 @@ cal_shell_sidebar_backend_died_cb (ECalShellSidebar *cal_shell_sidebar,
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_object_ref (source);
@@ -147,21 +149,30 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar,
EShellView *shell_view;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceGroup *source_group;
+ ESource *parent;
ESource *source;
+ GNode *node;
+ const gchar *parent_display_name;
+ const gchar *source_display_name;
shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- source_group = e_source_peek_group (source);
+
+ node = e_source_get_node (source);
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (node->parent != NULL);
+
+ parent = E_SOURCE (node->parent->data);
+
+ parent_display_name = e_source_get_display_name (parent);
+ source_display_name = e_source_get_display_name (source);
e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:backend-error",
- e_source_group_peek_name (source_group),
- e_source_peek_name (source), message, NULL);
+ E_ALERT_SINK (shell_content), "calendar:backend-error",
+ parent_display_name, source_display_name, message, NULL);
}
static void
@@ -233,7 +244,8 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object,
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) ||
g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED))
- e_client_utils_forget_password (E_CLIENT (client));
+ /* FIXME Handle errors. */
+ e_source_password_delete_sync (source, NULL, NULL);
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
e_client_open (
@@ -275,7 +287,7 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object,
case E_CLIENT_ERROR_BUSY:
g_warning (
"%s: Cannot open '%s', it's busy (%s)",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_clear_error (&error);
return;
@@ -416,7 +428,7 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
priv->loading_default_client = NULL;
}
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (priv->client_table, uid);
/* If we already have an open connection for
@@ -467,38 +479,6 @@ cal_shell_sidebar_row_changed_cb (ECalShellSidebar *cal_shell_sidebar,
}
static void
-cal_shell_sidebar_selection_changed_cb (ECalShellSidebar *cal_shell_sidebar,
- ESourceSelector *selector)
-{
- EShellView *shell_view;
- EShellBackend *shell_backend;
- EShellSidebar *shell_sidebar;
- GSList *list, *iter;
-
- /* This signal is emitted less frequently than "row-changed",
- * especially when the model is being rebuilt. So we'll take
- * it easy on poor GConf. */
-
- shell_sidebar = E_SHELL_SIDEBAR (cal_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
-
- list = e_source_selector_get_selection (selector);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
-
- iter->data = (gpointer) e_source_peek_uid (source);
- g_object_unref (source);
- }
-
- e_cal_shell_backend_set_selected_calendars (
- E_CAL_SHELL_BACKEND (shell_backend), list);
-
- g_slist_free (list);
-}
-
-static void
cal_shell_sidebar_primary_selection_changed_cb (ECalShellSidebar *cal_shell_sidebar,
ESourceSelector *selector)
{
@@ -520,12 +500,10 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
EShell *shell;
EShellBackend *shell_backend;
EShellSettings *shell_settings;
+ ESourceRegistry *registry;
ESourceSelector *selector;
- ESourceList *source_list;
- ESource *source;
GConfBridge *bridge;
GtkTreeModel *model;
- GSList *list, *iter;
GObject *object;
const gchar *key;
@@ -540,8 +518,7 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
selector = E_SOURCE_SELECTOR (priv->selector);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
- source_list = e_cal_shell_backend_get_source_list (
- E_CAL_SHELL_BACKEND (shell_backend));
+ registry = e_source_registry_get_default ();
g_signal_connect_swapped (
model, "row-changed",
@@ -560,31 +537,9 @@ cal_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
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);
- list = e_cal_shell_backend_get_selected_calendars (
- E_CAL_SHELL_BACKEND (shell_backend));
-
- for (iter = list; iter != NULL; iter = iter->next) {
- const gchar *uid = iter->data;
-
- source = e_source_list_peek_source_by_uid (source_list, uid);
-
- if (source != NULL)
- e_source_selector_select_source (selector, source);
- }
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
-
- /* Listen for subsequent changes to the selector. */
-
- g_signal_connect_swapped (
- selector, "selection-changed",
- G_CALLBACK (cal_shell_sidebar_selection_changed_cb),
- shell_sidebar);
-
/* Bind GObject properties to GConf keys. */
bridge = gconf_bridge_get ();
@@ -648,6 +603,11 @@ cal_shell_sidebar_dispose (GObject *object)
priv->date_navigator = NULL;
}
+ if (priv->new_calendar_button != NULL) {
+ g_object_unref (priv->new_calendar_button);
+ priv->new_calendar_button = NULL;
+ }
+
if (priv->default_client != NULL) {
g_object_unref (priv->default_client);
priv->default_client = NULL;
@@ -685,19 +645,6 @@ cal_shell_sidebar_finalize (GObject *object)
}
static void
-new_calendar_clicked (GtkButton *button,
- EShellSidebar *shell_sidebar)
-{
- EShellView *shell_view;
- EShellWindow *shell_window;
-
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_window = e_shell_view_get_shell_window (shell_view);
-
- calendar_setup_new_calendar (GTK_WINDOW (shell_window));
-}
-
-static void
cal_shell_sidebar_constructed (GObject *object)
{
ECalShellSidebarPrivate *priv;
@@ -707,7 +654,7 @@ cal_shell_sidebar_constructed (GObject *object)
EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
EShellSettings *shell_settings;
- ESourceList *source_list;
+ ESourceRegistry *registry;
ECalendarItem *calitem;
GtkWidget *container;
GtkWidget *widget;
@@ -726,9 +673,6 @@ cal_shell_sidebar_constructed (GObject *object)
shell = e_shell_backend_get_shell (shell_backend);
shell_settings = e_shell_get_shell_settings (shell);
- source_list = e_cal_shell_backend_get_source_list (
- E_CAL_SHELL_BACKEND (shell_backend));
-
container = GTK_WIDGET (shell_sidebar);
widget = e_paned_new (GTK_ORIENTATION_VERTICAL);
@@ -738,34 +682,36 @@ cal_shell_sidebar_constructed (GObject *object)
container = widget;
+ widget = gtk_vbox_new (FALSE, 6);
+ gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, TRUE);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ /* "New Calendar" button is only shown in express mode.
+ * ECalShellView will bind the button to an appropriate
+ * GtkAction so we don't have to reimplement it here. */
+ if (e_shell_get_express_mode (shell)) {
+ widget = gtk_button_new ();
+ gtk_box_pack_end (
+ GTK_BOX (container), widget, FALSE, FALSE, 0);
+ priv->new_calendar_button = g_object_ref (widget);
+ gtk_widget_show (widget);
+ }
+
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
- if (!e_shell_get_express_mode (shell)) {
- gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, TRUE);
- } else {
- GtkWidget *button;
-
- container = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
-
- button = gtk_button_new_with_mnemonic (_("_New Calendar..."));
- gtk_box_pack_start (GTK_BOX (container), button, FALSE, FALSE, 0);
- g_signal_connect (
- button, "clicked",
- G_CALLBACK (new_calendar_clicked), shell_sidebar);
-
- gtk_paned_pack1 (GTK_PANED (priv->paned), container, TRUE, TRUE);
- gtk_widget_show_all (container);
- }
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
container = widget;
- widget = e_calendar_selector_new (source_list);
+ registry = e_source_registry_get_default ();
+ widget = e_calendar_selector_new (registry);
e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
gtk_container_add (GTK_CONTAINER (container), widget);
a11y = gtk_widget_get_accessible (widget);
@@ -817,20 +763,23 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
+ ESourceSelectable *extension;
ECalClient *client;
- const gchar *uri;
- const gchar *delete;
+ gboolean writable_hint;
+ const gchar *uid;
+
+ uid = e_source_get_uid (source);
+ is_system = (g_strcmp0 (uid, "system") == 0);
- uri = e_source_peek_relative_uri (source);
- is_system = (uri == NULL || strcmp (uri, "system") == 0);
+ extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_CALENDAR);
+ writable_hint =
+ e_source_selectable_get_writable_hint (extension);
- can_delete = !is_system;
- delete = e_source_get_property (source, "delete");
- can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
+ can_delete = !is_system && writable_hint;
client = g_hash_table_lookup (
- cal_shell_sidebar->priv->client_table,
- e_source_peek_uid (source));
+ cal_shell_sidebar->priv->client_table, uid);
refresh_supported =
client && e_client_check_refresh_supported (E_CLIENT (client));
}
@@ -864,8 +813,7 @@ cal_shell_sidebar_client_removed (ECalShellSidebar *cal_shell_sidebar,
NULL, NULL, cal_shell_sidebar);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
- g_return_if_fail (uid != NULL);
+ uid = e_source_get_uid (source);
g_hash_table_remove (client_table, uid);
e_source_selector_unselect_source (selector, source);
@@ -1042,6 +990,15 @@ e_cal_shell_sidebar_get_default_client (ECalShellSidebar *cal_shell_sidebar)
return cal_shell_sidebar->priv->default_client;
}
+GtkWidget *
+e_cal_shell_sidebar_get_new_calendar_button (ECalShellSidebar *cal_shell_sidebar)
+{
+ g_return_val_if_fail (
+ E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar), NULL);
+
+ return cal_shell_sidebar->priv->new_calendar_button;
+}
+
ESourceSelector *
e_cal_shell_sidebar_get_selector (ECalShellSidebar *cal_shell_sidebar)
{
@@ -1066,8 +1023,8 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
ECalClient *default_client;
ECalClient *client;
icaltimezone *timezone;
+ const gchar *display_name;
const gchar *uid;
- const gchar *uri;
gchar *message;
g_return_if_fail (E_IS_CAL_SHELL_SIDEBAR (cal_shell_sidebar));
@@ -1078,7 +1035,7 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
default_client = cal_shell_sidebar->priv->default_client;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client != NULL)
@@ -1089,7 +1046,7 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
const gchar *default_uid;
default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_peek_uid (default_source);
+ default_uid = e_source_get_uid (default_source);
if (g_strcmp0 (uid, default_uid) == 0)
client = g_object_ref (default_client);
@@ -1118,9 +1075,8 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
- uri = e_client_get_uri (E_CLIENT (client));
- /* Translators: The string field is a URI. */
- message = g_strdup_printf (_("Opening calendar at %s"), uri);
+ display_name = e_source_get_display_name (source);
+ message = g_strdup_printf (_("Opening calendar '%s'"), display_name);
cal_shell_sidebar_emit_status_message (cal_shell_sidebar, message);
g_free (message);
@@ -1155,7 +1111,7 @@ e_cal_shell_sidebar_remove_source (ECalShellSidebar *cal_shell_sidebar,
client_table = cal_shell_sidebar->priv->client_table;
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client == NULL)
diff --git a/modules/calendar/e-cal-shell-sidebar.h b/modules/calendar/e-cal-shell-sidebar.h
index 3e4d00a..0ba3326 100644
--- a/modules/calendar/e-cal-shell-sidebar.h
+++ b/modules/calendar/e-cal-shell-sidebar.h
@@ -88,6 +88,8 @@ ECalendar * e_cal_shell_sidebar_get_date_navigator
(ECalShellSidebar *cal_shell_sidebar);
ECalClient * e_cal_shell_sidebar_get_default_client
(ECalShellSidebar *cal_shell_sidebar);
+GtkWidget * e_cal_shell_sidebar_get_new_calendar_button
+ (ECalShellSidebar *cal_shell_sidebar);
ESourceSelector *
e_cal_shell_sidebar_get_selector
(ECalShellSidebar *cal_shell_sidebar);
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index 2147245..f6d5abc 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -58,33 +58,16 @@ static void
action_calendar_delete_cb (GtkAction *action,
ECalShellView *cal_shell_view)
{
- ECalShellContent *cal_shell_content;
ECalShellSidebar *cal_shell_sidebar;
- EShellBackend *shell_backend;
EShellWindow *shell_window;
EShellView *shell_view;
- ECalendarView *calendar_view;
- GnomeCalendarViewType view_type;
- GnomeCalendar *calendar;
- ECalModel *model;
- ECalClient *client;
ESourceSelector *selector;
- ESourceGroup *source_group;
- ESourceList *source_list;
ESource *source;
+ GFile *file;
gint response;
- gchar *uri;
- GError *error = NULL;
shell_view = E_SHELL_VIEW (cal_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
-
- cal_shell_content = cal_shell_view->priv->cal_shell_content;
- calendar = e_cal_shell_content_get_calendar (cal_shell_content);
- view_type = gnome_calendar_get_view (calendar);
- calendar_view = gnome_calendar_get_calendar_view (calendar, view_type);
- model = e_calendar_view_get_model (calendar_view);
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
@@ -95,49 +78,14 @@ action_calendar_delete_cb (GtkAction *action,
response = e_alert_run_dialog_for_args (
GTK_WINDOW (shell_window),
"calendar:prompt-delete-calendar",
- e_source_peek_name (source), NULL);
- if (response != GTK_RESPONSE_YES)
- return;
-
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- if (client == NULL)
- client = e_cal_client_new_from_uri (
- uri, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
- g_free (uri);
-
- g_return_if_fail (client != NULL);
-
- e_client_remove_sync (E_CLIENT (client), NULL, &error);
+ e_source_get_display_name (source), NULL);
- if (error != NULL) {
- g_warning (
- "%s: Failed to remove client: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
+ if (response != GTK_RESPONSE_YES)
return;
- }
- if (e_source_selector_source_is_selected (selector, source)) {
- e_cal_shell_sidebar_remove_source (
- cal_shell_sidebar, source);
- e_source_selector_unselect_source (selector, source);
- }
-
- source_group = e_source_peek_group (source);
- e_source_group_remove_source (source_group, source);
-
- source_list = e_cal_shell_backend_get_source_list (
- E_CAL_SHELL_BACKEND (shell_backend));
-
- e_source_list_sync (source_list, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to sync source list: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- }
+ /* FIXME Handle errors. */
+ file = e_source_get_file (source);
+ g_file_delete (file, NULL, NULL);
}
static void
@@ -203,10 +151,30 @@ action_calendar_new_cb (GtkAction *action,
{
EShellView *shell_view;
EShellWindow *shell_window;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (cal_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- calendar_setup_new_calendar (GTK_WINDOW (shell_window));
+
+ registry = e_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Calendar"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -271,11 +239,16 @@ static void
action_calendar_properties_cb (GtkAction *action,
ECalShellView *cal_shell_view)
{
- ECalShellSidebar *cal_shell_sidebar;
EShellView *shell_view;
EShellWindow *shell_window;
+ ECalShellSidebar *cal_shell_sidebar;
+ ECalClientSourceType source_type;
ESource *source;
ESourceSelector *selector;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (cal_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -283,12 +256,23 @@ action_calendar_properties_cb (GtkAction *action,
cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
source = e_source_selector_get_primary_selection (selector);
- g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (source != NULL);
- /* XXX Does this -really- need a source group parameter? */
- calendar_setup_edit_calendar (
- GTK_WINDOW (shell_window), source,
- e_source_peek_group (source));
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
+ registry = e_source_selector_get_registry (selector);
+ config = e_cal_source_config_new (registry, source, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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), _("Calendar Properties"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -375,7 +359,6 @@ action_calendar_refresh_cb (GtkAction *action,
ECalClient *client;
ECalModel *model;
ESource *source;
- gchar *uri;
GError *error = NULL;
cal_shell_content = cal_shell_view->priv->cal_shell_content;
@@ -387,10 +370,7 @@ action_calendar_refresh_cb (GtkAction *action,
source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- g_free (uri);
-
+ client = e_cal_model_get_client_for_source (model, source);
if (client == NULL)
return;
@@ -401,7 +381,7 @@ action_calendar_refresh_cb (GtkAction *action,
if (error != NULL) {
g_warning (
"%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
}
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index c2f39c5..a197267 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -513,6 +513,7 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
EMemoTable *memo_table;
ETaskTable *task_table;
ESourceSelector *selector;
+ GtkWidget *widget;
ECalModel *model;
gint ii;
@@ -540,7 +541,6 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
date_navigator = e_cal_shell_sidebar_get_date_navigator (cal_shell_sidebar);
- /* Give GnomeCalendar a handle to the date navigator, memo and task table. */
gnome_calendar_set_date_navigator (calendar, date_navigator);
gnome_calendar_set_memo_table (
calendar, memo_table ? GTK_WIDGET (memo_table) : NULL);
@@ -664,6 +664,13 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
e_cal_shell_view_update_search_filter (cal_shell_view);
e_cal_shell_view_update_timezone (cal_shell_view);
+ /* Express mode only: Bind the "New Calendar"
+ * sidebar button to the appropriate action. */
+ widget = e_cal_shell_sidebar_get_new_calendar_button (cal_shell_sidebar);
+ if (widget != NULL)
+ gtk_activatable_set_related_action (
+ GTK_ACTIVATABLE (widget), ACTION (CALENDAR_NEW));
+
/* Keep the ECalModel in sync with the sidebar. */
g_object_bind_property (
shell_sidebar, "default-client",
@@ -687,8 +694,8 @@ e_cal_shell_view_private_dispose (ECalShellView *cal_shell_view)
ECalShellViewPrivate *priv = cal_shell_view->priv;
gint i;
- /* Calling calendar's save state from here,
- * because it is too late in its dispose. */
+ /* Calling ECalShellContent's save state from here,
+ * because it is too late in its own dispose(). */
if (priv->cal_shell_content != NULL)
e_cal_shell_content_save_state (priv->cal_shell_content);
diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h
index 7c78130..469d3ec 100644
--- a/modules/calendar/e-cal-shell-view-private.h
+++ b/modules/calendar/e-cal-shell-view-private.h
@@ -31,9 +31,9 @@
#include <libedataserver/e-categories.h>
#include <libedataserver/e-data-server-util.h>
#include <libedataserver/e-sexp.h>
+#include <libedataserver/e-source-registry.h>
#include <libedataserverui/e-client-utils.h>
-#include "e-util/e-account-utils.h"
#include "e-util/e-selection.h"
#include "e-util/e-dialog-utils.h"
#include "e-util/e-file-utils.h"
@@ -41,17 +41,18 @@
#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 "calendar/gui/calendar-config.h"
#include "calendar/gui/comp-util.h"
#include "calendar/gui/e-cal-list-view.h"
#include "calendar/gui/e-cal-model-tasks.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "calendar/gui/e-calendar-view.h"
#include "calendar/gui/e-day-view.h"
#include "calendar/gui/e-week-view.h"
#include "calendar/gui/gnome-cal.h"
#include "calendar/gui/print.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/copy-source-dialog.h"
#include "calendar/gui/dialogs/event-editor.h"
#include "calendar/gui/dialogs/goto-dialog.h"
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 61a2d9c..567cfc7 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -301,6 +301,8 @@ cal_shell_view_update_actions (EShellView *shell_view)
EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
EShell *shell;
+ ESource *mail_account;
+ ESourceRegistry *registry;
GnomeCalendarViewType view_type;
GnomeCalendar *calendar;
ECalendarView *view;
@@ -345,6 +347,9 @@ cal_shell_view_update_actions (EShellView *shell_view)
gtk_widget_hide (widget);
}
+ registry = e_shell_get_registry (shell);
+ mail_account = e_source_registry_get_default_mail_account (registry);
+
cal_shell_content = priv->cal_shell_content;
calendar = e_cal_shell_content_get_calendar (cal_shell_content);
view_type = gnome_calendar_get_view (calendar);
@@ -490,7 +495,7 @@ cal_shell_view_update_actions (EShellView *shell_view)
gtk_action_set_sensitive (action, sensitive);
action = ACTION (EVENT_MEETING_NEW);
- visible = e_get_default_account () != NULL;
+ visible = (mail_account != NULL);
gtk_action_set_visible (action, visible);
}
diff --git a/modules/calendar/e-calendar-preferences.c b/modules/calendar/e-calendar-preferences.c
index 85eddd9..f0f5c97 100644
--- a/modules/calendar/e-calendar-preferences.c
+++ b/modules/calendar/e-calendar-preferences.c
@@ -34,6 +34,7 @@
#include "calendar/gui/e-cal-config.h"
#include "calendar/gui/e-timezone-entry.h"
#include "calendar/gui/calendar-config.h"
+#include "widgets/misc/e-alarm-selector.h"
#include "widgets/misc/e-dateedit.h"
#include "e-util/e-util.h"
#include "e-util/e-datetime-format.h"
@@ -339,50 +340,6 @@ notify_with_tray_toggled (GtkToggleButton *toggle,
}
static void
-alarms_selection_changed (ESourceSelector *selector,
- ECalendarPreferences *prefs)
-{
- ESourceList *source_list = prefs->alarms_list;
- GSList *selection;
- GSList *l;
- GSList *groups;
- ESource *source;
- const gchar *alarm;
-
- /* first we clear all the alarm 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) {
- source = E_SOURCE (sources->data);
-
- alarm = e_source_get_property (source, "alarm");
- if (alarm && !g_ascii_strcasecmp (alarm, "never"))
- continue;
-
- e_source_set_property (source, "alarm", "false");
- }
- }
-
- /* then we loop over the selector's selection, setting the
- * property on those sources */
- selection = e_source_selector_get_selection (selector);
- for (l = selection; l; l = l->next) {
- source = E_SOURCE (l->data);
-
- alarm = (gchar *)e_source_get_property (source, "alarm");
- if (alarm && !g_ascii_strcasecmp (alarm, "never"))
- continue;
-
- e_source_set_property (E_SOURCE (l->data), "alarm", "true");
- }
- e_source_selector_free_selection (selection);
-
- /* FIXME show an error if this fails? */
- e_source_list_sync (source_list, NULL);
-}
-
-static void
update_system_tz_widgets (EShellSettings *shell_settings,
GParamSpec *pspec,
ECalendarPreferences *prefs)
@@ -418,51 +375,24 @@ setup_changes (ECalendarPreferences *prefs)
G_CALLBACK (start_of_day_changed), prefs);
g_signal_connect (
- prefs->end_of_day, "changed",
- G_CALLBACK (end_of_day_changed), prefs);
-
- g_signal_connect (
prefs->notify_with_tray, "toggled",
G_CALLBACK (notify_with_tray_toggled), prefs);
-
- g_signal_connect (
- prefs->alarm_list_widget, "selection_changed",
- G_CALLBACK (alarms_selection_changed), prefs);
-}
-
-static void
-initialize_selection (ESourceSelector *selector,
- ESourceList *source_list)
-{
- GSList *groups;
-
- 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 = e_source_get_property (source, "alarm");
- if (!completion || !g_ascii_strcasecmp (completion, "true")) {
- if (!completion)
- e_source_set_property (E_SOURCE (source), "alarm", "true");
- e_source_selector_select_source (selector, source);
- }
- }
- }
}
static void
show_alarms_config (ECalendarPreferences *prefs)
{
+ ESourceRegistry *registry;
GConfClient *gconf;
+ GtkWidget *widget;
- if (e_cal_client_get_sources (&prefs->alarms_list, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL)) {
- prefs->alarm_list_widget = e_source_selector_new (prefs->alarms_list);
- atk_object_set_name (gtk_widget_get_accessible (prefs->alarm_list_widget), _("Selected Calendars for Reminders"));
- gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), prefs->alarm_list_widget);
- gtk_widget_show (prefs->alarm_list_widget);
- initialize_selection (E_SOURCE_SELECTOR (prefs->alarm_list_widget), prefs->alarms_list);
- }
+ registry = e_source_registry_get_default ();
+ widget = e_alarm_selector_new (registry);
+ atk_object_set_name (
+ gtk_widget_get_accessible (widget),
+ _("Selected Calendars for Alarms"));
+ gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), widget);
+ gtk_widget_show (widget);
gconf = gconf_client_get_default ();
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->notify_with_tray), gconf_client_get_bool (gconf, "/apps/evolution/calendar/notify/notify_with_tray", NULL));
diff --git a/modules/calendar/e-calendar-preferences.h b/modules/calendar/e-calendar-preferences.h
index ae96fc1..c8f5fe5 100644
--- a/modules/calendar/e-calendar-preferences.h
+++ b/modules/calendar/e-calendar-preferences.h
@@ -71,8 +71,6 @@ struct _ECalendarPreferences {
/* Alarms tab */
GtkWidget *notify_with_tray;
GtkWidget *scrolled_window;
- ESourceList *alarms_list;
- GtkWidget *alarm_list_widget;
};
struct _ECalendarPreferencesClass {
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 6f80700..72b9898 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libecal/e-cal-client.h>
+#include <libecal/e-source-calendar.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
@@ -37,10 +38,11 @@
#include "shell/e-shell.h"
#include "shell/e-shell-backend.h"
#include "shell/e-shell-window.h"
+#include "widgets/misc/e-source-config-dialog.h"
#include "calendar/gui/comp-util.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/memo-editor.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "e-memo-shell-migrate.h"
#include "e-memo-shell-view.h"
@@ -49,122 +51,13 @@
#define PERSONAL_RELATIVE_URI "system"
struct _EMemoShellBackendPrivate {
- ESourceList *source_list;
-};
-
-enum {
- PROP_0,
- PROP_SOURCE_LIST
+ gint placeholder;
};
static gpointer parent_class;
static GType memo_shell_backend_type;
static void
-memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
-{
- /* XXX This is basically the same algorithm across all modules.
- * Maybe we could somehow integrate this into EShellBackend? */
-
- EMemoShellBackend *memo_shell_backend;
- ESourceGroup *on_this_computer;
- ESourceList *source_list;
- ESource *personal;
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *sources, *iter;
- const gchar *name;
- gboolean save_list = FALSE;
- GError *error = NULL;
-
- personal = NULL;
-
- memo_shell_backend = E_MEMO_SHELL_BACKEND (shell_backend);
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_cal_client_get_sources (
- &memo_shell_backend->priv->source_list,
- E_CAL_CLIENT_SOURCE_TYPE_MEMOS, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get memo sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
-
- source_list = memo_shell_backend->priv->source_list;
-
- on_this_computer = e_source_list_ensure_group (
- source_list, _("On This Computer"), "local:", TRUE);
- e_source_list_ensure_group (
- source_list, _("On The Web"), "webcal://", FALSE);
-
- g_return_if_fail (on_this_computer);
-
- 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;
- GSList *selected;
- gchar *primary;
-
- source = e_source_new (name, "system");
- e_source_set_color_spec (source, "#BECEDD");
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
- save_list = TRUE;
-
- primary = e_shell_settings_get_string (
- shell_settings, "cal-primary-memo-list");
-
- selected = e_memo_shell_backend_get_selected_memo_lists (
- memo_shell_backend);
-
- if (primary == NULL && selected == NULL) {
- const gchar *uid;
-
- uid = e_source_peek_uid (source);
- selected = g_slist_prepend (NULL, g_strdup (uid));
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-memo-list", uid);
- e_memo_shell_backend_set_selected_memo_lists (
- memo_shell_backend, selected);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
- g_free (primary);
- } else {
- /* Force the source name to the current locale. */
- e_source_set_name (personal, name);
- }
-
- g_object_unref (on_this_computer);
-
- if (save_list)
- e_source_list_sync (source_list, NULL);
-}
-
-static void
memo_shell_backend_new_memo (ESource *source,
GAsyncResult *result,
EShell *shell,
@@ -183,7 +76,7 @@ memo_shell_backend_new_memo (ESource *source,
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
return;
@@ -240,55 +133,63 @@ action_memo_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
EShell *shell;
- EShellBackend *shell_backend;
- EShellSettings *shell_settings;
- ESource *source = NULL;
- ESourceList *source_list;
+ ESource *source;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
const gchar *action_name;
- gchar *uid;
/* This callback is used for both memos and shared memos. */
shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
- shell_backend = e_shell_get_backend_by_name (shell, "memos");
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-memo-list");
-
- 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_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
+ source = e_source_registry_get_default_memo_list (registry);
/* Use a callback function appropriate for the action.
* FIXME Need to obtain a better default time zone. */
action_name = gtk_action_get_name (action);
if (g_strcmp0 (action_name, "memo-shared-new") == 0)
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- memo_shell_backend_memo_shared_new_cb, g_object_ref (shell));
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ memo_shell_backend_memo_shared_new_cb,
+ g_object_ref (shell));
else
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_MEMOS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- memo_shell_backend_memo_new_cb, g_object_ref (shell));
-
- g_object_unref (source_list);
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ memo_shell_backend_memo_new_cb,
+ g_object_ref (shell));
}
static void
action_memo_list_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
- calendar_setup_new_memo_list (GTK_WINDOW (shell_window));
+ ECalClientSourceType source_type;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
+
+ registry = e_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Memo List"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static GtkActionEntry item_entries[] = {
@@ -328,7 +229,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
ECalClient *client;
ECalComponent *comp;
ESource *source;
- ESourceList *source_list;
+ ESourceRegistry *registry;
ECalClientSourceType source_type;
EUri *euri;
icalcomponent *icalcomp;
@@ -392,20 +293,10 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
* we successfully open it is another matter... */
handled = TRUE;
- e_cal_client_get_sources (&source_list, source_type, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get memo sources: %s",
- G_STRFUNC, error->message);
- g_clear_error (&error);
- goto exit;
- }
-
- source = e_source_list_peek_source_by_uid (source_list, source_uid);
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, source_uid);
if (source == NULL) {
g_printerr ("No source for UID '%s'\n", source_uid);
- g_object_unref (source_list);
goto exit;
}
@@ -422,7 +313,8 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
g_warning (
"%s: Failed to create/open client: %s",
G_STRFUNC, error->message);
- g_object_unref (source_list);
+ if (client != NULL)
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -442,7 +334,7 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
g_warning (
"%s: Failed to get object: %s",
G_STRFUNC, error->message);
- g_object_unref (source_list);
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -468,7 +360,6 @@ memo_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
present:
gtk_window_present (GTK_WINDOW (editor));
- g_object_unref (source_list);
g_object_unref (client);
exit:
@@ -502,40 +393,6 @@ memo_shell_backend_window_created_cb (EShellBackend *shell_backend,
}
static void
-memo_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_memo_shell_backend_get_source_list (
- E_MEMO_SHELL_BACKEND (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-memo_shell_backend_dispose (GObject *object)
-{
- EMemoShellBackendPrivate *priv;
-
- priv = E_MEMO_SHELL_BACKEND (object)->priv;
-
- 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 (parent_class)->dispose (object);
-}
-
-static void
memo_shell_backend_constructed (GObject *object)
{
EShell *shell;
@@ -544,8 +401,6 @@ memo_shell_backend_constructed (GObject *object)
shell_backend = E_SHELL_BACKEND (object);
shell = e_shell_backend_get_shell (shell_backend);
- memo_shell_backend_ensure_sources (shell_backend);
-
g_signal_connect_swapped (
shell, "handle-uri",
G_CALLBACK (memo_shell_backend_handle_uri_cb),
@@ -570,8 +425,6 @@ memo_shell_backend_class_init (EMemoShellBackendClass *class)
g_type_class_add_private (class, sizeof (EMemoShellBackendPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->get_property = memo_shell_backend_get_property;
- object_class->dispose = memo_shell_backend_dispose;
object_class->constructed = memo_shell_backend_constructed;
shell_backend_class = E_SHELL_BACKEND_CLASS (class);
@@ -584,15 +437,8 @@ memo_shell_backend_class_init (EMemoShellBackendClass *class)
shell_backend_class->start = NULL;
shell_backend_class->migrate = e_memo_shell_backend_migrate;
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_LIST,
- g_param_spec_object (
- "source-list",
- "Source List",
- "The registry of memo lists",
- E_TYPE_SOURCE_LIST,
- G_PARAM_READABLE));
+ /* Register relevant ESource extensions. */
+ E_TYPE_SOURCE_MEMO_LIST;
}
static void
@@ -629,47 +475,3 @@ e_memo_shell_backend_register_type (GTypeModule *type_module)
type_module, E_TYPE_SHELL_BACKEND,
"EMemoShellBackend", &type_info, 0);
}
-
-ESourceList *
-e_memo_shell_backend_get_source_list (EMemoShellBackend *memo_shell_backend)
-{
- g_return_val_if_fail (
- E_IS_MEMO_SHELL_BACKEND (memo_shell_backend), NULL);
-
- return memo_shell_backend->priv->source_list;
-}
-
-GSList *
-e_memo_shell_backend_get_selected_memo_lists (EMemoShellBackend *memo_shell_backend)
-{
- GConfClient *client;
- GSList *selected_memo_lists;
- const gchar *key;
-
- g_return_val_if_fail (
- E_IS_MEMO_SHELL_BACKEND (memo_shell_backend), NULL);
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/memos/selected_memos";
- selected_memo_lists = gconf_client_get_list (
- client, key, GCONF_VALUE_STRING, NULL);
- g_object_unref (client);
-
- return selected_memo_lists;
-}
-
-void
-e_memo_shell_backend_set_selected_memo_lists (EMemoShellBackend *memo_shell_backend,
- GSList *selected_memo_lists)
-{
- GConfClient *client;
- const gchar *key;
-
- g_return_if_fail (E_IS_MEMO_SHELL_BACKEND (memo_shell_backend));
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/memos/selected_memos";
- gconf_client_set_list (
- client, key, GCONF_VALUE_STRING, selected_memo_lists, NULL);
- g_object_unref (client);
-}
diff --git a/modules/calendar/e-memo-shell-backend.h b/modules/calendar/e-memo-shell-backend.h
index 8a005c4..44b0384 100644
--- a/modules/calendar/e-memo-shell-backend.h
+++ b/modules/calendar/e-memo-shell-backend.h
@@ -23,7 +23,6 @@
#define E_MEMO_SHELL_BACKEND_H
#include <shell/e-shell-backend.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_MEMO_SHELL_BACKEND \
@@ -62,13 +61,6 @@ struct _EMemoShellBackendClass {
GType e_memo_shell_backend_get_type (void);
void e_memo_shell_backend_register_type
(GTypeModule *type_module);
-ESourceList * e_memo_shell_backend_get_source_list
- (EMemoShellBackend *memo_shell_backend);
-GSList * e_memo_shell_backend_get_selected_memo_lists
- (EMemoShellBackend *memo_shell_backend);
-void e_memo_shell_backend_set_selected_memo_lists
- (EMemoShellBackend *memo_shell_backend,
- GSList *selected_memo_lists);
G_END_DECLS
diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c
index f0f4fe9..0404ccd 100644
--- a/modules/calendar/e-memo-shell-content.c
+++ b/modules/calendar/e-memo-shell-content.c
@@ -116,7 +116,7 @@ memo_shell_content_table_foreach_cb (gint model_row,
const gchar *source_uid;
source = e_client_get_source (E_CLIENT (comp_data->client));
- source_uid = e_source_peek_uid (source);
+ source_uid = e_source_get_uid (source);
foreach_data->list = g_slist_prepend (
foreach_data->list,
diff --git a/modules/calendar/e-memo-shell-migrate.c b/modules/calendar/e-memo-shell-migrate.c
index 6402cf1..08fe767 100644
--- a/modules/calendar/e-memo-shell-migrate.c
+++ b/modules/calendar/e-memo-shell-migrate.c
@@ -25,137 +25,6 @@
#include "e-memo-shell-migrate.h"
-#include <string.h>
-#include <glib/gi18n.h>
-#include <camel/camel.h>
-#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-group.h>
-#include <libedataserver/e-source-list.h>
-
-#include "e-util/e-account-utils.h"
-#include "calendar/gui/calendar-config-keys.h"
-#include "shell/e-shell.h"
-
-#include "e-memo-shell-backend.h"
-
-#define LOCAL_BASE_URI "local:"
-#define WEBCAL_BASE_URI "webcal://"
-#define PERSONAL_RELATIVE_URI "system"
-#define GROUPWISE_BASE_URI "groupwise://"
-
-static void
-create_memo_sources (EShellBackend *shell_backend,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESourceGroup **on_the_web,
- ESource **personal_source)
-{
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *groups;
- ESourceGroup *group;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *personal_source = NULL;
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- groups = e_source_list_peek_groups (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 (e_shell_backend_get_data_dir (shell_backend), "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_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group)))
- *on_the_web = 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 (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- GSList *selected;
- gchar *primary_memo_list;
-
- /* Create the default Person memo list */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- primary_memo_list = e_shell_settings_get_string (
- shell_settings, "cal-primary-memo-list");
-
- selected = e_memo_shell_backend_get_selected_memo_lists (
- E_MEMO_SHELL_BACKEND (shell_backend));
-
- if (primary_memo_list == NULL && selected == NULL) {
- GSList link;
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-memo-list",
- e_source_peek_uid (source));
-
- link.data = (gpointer) e_source_peek_uid (source);
- link.next = NULL;
-
- e_memo_shell_backend_set_selected_memo_lists (
- E_MEMO_SHELL_BACKEND (shell_backend), &link);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
-
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-}
-
gboolean
e_memo_shell_backend_migrate (EShellBackend *shell_backend,
gint major,
@@ -163,30 +32,7 @@ e_memo_shell_backend_migrate (EShellBackend *shell_backend,
gint revision,
GError **error)
{
- ESourceGroup *on_this_computer = NULL;
- ESourceGroup *on_the_web = NULL;
- ESource *personal_source = NULL;
- ESourceList *source_list = NULL;
- gboolean retval = FALSE;
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
-
- /* we call this unconditionally now - create_groups either
- * creates the groups/sources or it finds the necessary
- * groups/sources. */
- create_memo_sources (
- shell_backend, source_list, &on_this_computer,
- &on_the_web, &personal_source);
-
- e_source_list_sync (source_list, NULL);
- retval = TRUE;
-
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (personal_source)
- g_object_unref (personal_source);
+ g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), FALSE);
- return retval;
+ return TRUE;
}
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index df9ea9a..ce2309d 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -28,6 +28,8 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libecal/e-cal-client.h>
+#include <libecal/e-source-calendar.h>
+#include <libedataserver/e-source-password.h>
#include <libedataserverui/e-client-utils.h>
#include "e-util/e-alert-dialog.h"
@@ -120,7 +122,7 @@ memo_shell_sidebar_backend_died_cb (EMemoShellSidebar *memo_shell_sidebar,
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_object_ref (source);
@@ -142,21 +144,30 @@ memo_shell_sidebar_backend_error_cb (EMemoShellSidebar *memo_shell_sidebar,
EShellView *shell_view;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceGroup *source_group;
+ ESource *parent;
ESource *source;
+ GNode *node;
+ const gchar *parent_display_name;
+ const gchar *source_display_name;
shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- source_group = e_source_peek_group (source);
+
+ node = e_source_get_node (source);
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (node->parent != NULL);
+
+ parent = E_SOURCE (node->parent->data);
+
+ parent_display_name = e_source_get_display_name (parent);
+ source_display_name = e_source_get_display_name (source);
e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:backend-error",
- e_source_group_peek_name (source_group),
- e_source_peek_name (source), message, NULL);
+ E_ALERT_SINK (shell_content), "calendar:backend-error",
+ parent_display_name, source_display_name, message, NULL);
}
static void
@@ -228,7 +239,8 @@ memo_shell_sidebar_client_opened_cb (GObject *source_object,
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) ||
g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED))
- e_client_utils_forget_password (E_CLIENT (client));
+ /* FIXME Handle errors. */
+ e_source_password_delete_sync (source, NULL, NULL);
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
e_client_open (
@@ -269,7 +281,7 @@ memo_shell_sidebar_client_opened_cb (GObject *source_object,
case E_CLIENT_ERROR_BUSY:
g_warning (
"%s: Cannot open '%s', it's busy (%s)",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_clear_error (&error);
return;
@@ -410,7 +422,7 @@ memo_shell_sidebar_set_default (EMemoShellSidebar *memo_shell_sidebar,
priv->loading_default_client = NULL;
}
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (priv->client_table, uid);
/* If we already have an open connection for
@@ -461,38 +473,6 @@ memo_shell_sidebar_row_changed_cb (EMemoShellSidebar *memo_shell_sidebar,
}
static void
-memo_shell_sidebar_selection_changed_cb (EMemoShellSidebar *memo_shell_sidebar,
- ESourceSelector *selector)
-{
- EShellView *shell_view;
- EShellBackend *shell_backend;
- EShellSidebar *shell_sidebar;
- GSList *list, *iter;
-
- /* This signal is emitted less frequently than "row-changed",
- * especially when the model is being rebuilt. So we'll take
- * it easy on poor GConf. */
-
- shell_sidebar = E_SHELL_SIDEBAR (memo_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
-
- list = e_source_selector_get_selection (selector);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
-
- iter->data = (gpointer) e_source_peek_uid (source);
- g_object_unref (source);
- }
-
- e_memo_shell_backend_set_selected_memo_lists (
- E_MEMO_SHELL_BACKEND (shell_backend), list);
-
- g_slist_free (list);
-}
-
-static void
memo_shell_sidebar_primary_selection_changed_cb (EMemoShellSidebar *memo_shell_sidebar,
ESourceSelector *selector)
{
@@ -514,11 +494,9 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
EShell *shell;
EShellBackend *shell_backend;
EShellSettings *shell_settings;
+ ESourceRegistry *registry;
ESourceSelector *selector;
- ESourceList *source_list;
- ESource *source;
GtkTreeModel *model;
- GSList *list, *iter;
priv = E_MEMO_SHELL_SIDEBAR (shell_sidebar)->priv;
@@ -531,8 +509,7 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
selector = E_SOURCE_SELECTOR (priv->selector);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
- source_list = e_memo_shell_backend_get_source_list (
- E_MEMO_SHELL_BACKEND (shell_backend));
+ registry = e_source_registry_get_default ();
g_signal_connect_swapped (
model, "row-changed",
@@ -551,30 +528,8 @@ memo_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
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);
-
- list = e_memo_shell_backend_get_selected_memo_lists (
- E_MEMO_SHELL_BACKEND (shell_backend));
-
- for (iter = list; iter != NULL; iter = iter->next) {
- const gchar *uid = iter->data;
-
- source = e_source_list_peek_source_by_uid (source_list, uid);
-
- if (source != NULL)
- e_source_selector_select_source (selector, source);
- }
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
-
- /* Listen for subsequent changes to the selector. */
-
- g_signal_connect_swapped (
- selector, "selection-changed",
- G_CALLBACK (memo_shell_sidebar_selection_changed_cb),
- shell_sidebar);
}
static void
@@ -656,9 +611,8 @@ memo_shell_sidebar_constructed (GObject *object)
EMemoShellSidebarPrivate *priv;
EShellView *shell_view;
EShellWindow *shell_window;
- EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
- ESourceList *source_list;
+ ESourceRegistry *registry;
GtkContainer *container;
GtkWidget *widget;
AtkObject *a11y;
@@ -670,12 +624,8 @@ memo_shell_sidebar_constructed (GObject *object)
shell_sidebar = E_SHELL_SIDEBAR (object);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- source_list = e_memo_shell_backend_get_source_list (
- E_MEMO_SHELL_BACKEND (shell_backend));
-
container = GTK_CONTAINER (shell_sidebar);
widget = gtk_scrolled_window_new (NULL, NULL);
@@ -689,7 +639,8 @@ memo_shell_sidebar_constructed (GObject *object)
container = GTK_CONTAINER (widget);
- widget = e_memo_list_selector_new (source_list);
+ registry = e_source_registry_get_default ();
+ widget = e_memo_list_selector_new (registry);
e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
gtk_container_add (container, widget);
a11y = gtk_widget_get_accessible (widget);
@@ -721,20 +672,24 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
+ ESourceSelectable *extension;
ECalClient *client;
- const gchar *uri;
- const gchar *delete;
+ gboolean writable_hint;
+ const gchar *uid;
+
+ uid = e_source_get_uid (source);
+ is_system = (g_strcmp0 (uid, "system") == 0);
- uri = e_source_peek_relative_uri (source);
- is_system = (uri == NULL || strcmp (uri, "system") == 0);
+ extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_MEMO_LIST);
+ writable_hint =
+ e_source_selectable_get_writable_hint (extension);
- can_delete = !is_system;
- delete = e_source_get_property (source, "delete");
- can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
+ can_delete = !is_system && writable_hint;
client = g_hash_table_lookup (
memo_shell_sidebar->priv->client_table,
- e_source_peek_uid (source));
+ e_source_get_uid (source));
refresh_supported =
client && e_client_check_refresh_supported (E_CLIENT (client));
}
@@ -768,8 +723,7 @@ memo_shell_sidebar_client_removed (EMemoShellSidebar *memo_shell_sidebar,
NULL, NULL, memo_shell_sidebar);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
- g_return_if_fail (uid != NULL);
+ uid = e_source_get_uid (source);
g_hash_table_remove (client_table, uid);
e_source_selector_unselect_source (selector, source);
@@ -952,8 +906,8 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
ECalClient *default_client;
ECalClient *client;
icaltimezone *timezone;
+ const gchar *display_name;
const gchar *uid;
- const gchar *uri;
gchar *message;
g_return_if_fail (E_IS_MEMO_SHELL_SIDEBAR (memo_shell_sidebar));
@@ -964,7 +918,7 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
default_client = memo_shell_sidebar->priv->default_client;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client != NULL)
@@ -975,7 +929,7 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
const gchar *default_uid;
default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_peek_uid (default_source);
+ default_uid = e_source_get_uid (default_source);
if (g_strcmp0 (uid, default_uid) == 0)
client = g_object_ref (default_client);
@@ -1004,9 +958,8 @@ e_memo_shell_sidebar_add_source (EMemoShellSidebar *memo_shell_sidebar,
g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
- uri = e_client_get_uri (E_CLIENT (client));
- /* Translators: The string field is a URI. */
- message = g_strdup_printf (_("Opening memos at %s"), uri);
+ display_name = e_source_get_display_name (source);
+ message = g_strdup_printf (_("Opening memo list '%s'"), display_name);
memo_shell_sidebar_emit_status_message (memo_shell_sidebar, message);
g_free (message);
@@ -1041,7 +994,7 @@ e_memo_shell_sidebar_remove_source (EMemoShellSidebar *memo_shell_sidebar,
client_table = memo_shell_sidebar->priv->client_table;
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client == NULL)
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index eacb5c1..8a42b63 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -128,32 +128,17 @@ static void
action_memo_list_delete_cb (GtkAction *action,
EMemoShellView *memo_shell_view)
{
- EMemoShellBackend *memo_shell_backend;
- EMemoShellContent *memo_shell_content;
EMemoShellSidebar *memo_shell_sidebar;
EShellWindow *shell_window;
EShellView *shell_view;
- EMemoTable *memo_table;
- ECalClient *client;
- ECalModel *model;
ESourceSelector *selector;
- ESourceGroup *source_group;
- ESourceList *source_list;
ESource *source;
+ GFile *file;
gint response;
- gchar *uri;
- GError *error = NULL;
shell_view = E_SHELL_VIEW (memo_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- memo_shell_backend = memo_shell_view->priv->memo_shell_backend;
- source_list = e_memo_shell_backend_get_source_list (memo_shell_backend);
-
- memo_shell_content = memo_shell_view->priv->memo_shell_content;
- memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
- model = e_memo_table_get_model (memo_table);
-
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
source = e_source_selector_get_primary_selection (selector);
@@ -163,46 +148,14 @@ action_memo_list_delete_cb (GtkAction *action,
response = e_alert_run_dialog_for_args (
GTK_WINDOW (shell_window),
"calendar:prompt-delete-memo-list",
- e_source_peek_name (source), NULL);
- if (response != GTK_RESPONSE_YES)
- return;
-
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- if (client == NULL)
- client = e_cal_client_new_from_uri (
- uri, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL);
- g_free (uri);
-
- g_return_if_fail (client != NULL);
-
- e_client_remove_sync (E_CLIENT (client), NULL, &error);
+ e_source_get_display_name (source), NULL);
- if (error != NULL) {
- g_warning (
- "%s: Failed to remove client: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
+ if (response != GTK_RESPONSE_YES)
return;
- }
- if (e_source_selector_source_is_selected (selector, source)) {
- e_memo_shell_sidebar_remove_source (
- memo_shell_sidebar, 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, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to sync source list: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- }
+ /* FIXME Handle errors. */
+ file = e_source_get_file (source);
+ g_file_delete (file, NULL, NULL);
}
static void
@@ -211,10 +164,30 @@ action_memo_list_new_cb (GtkAction *action,
{
EShellView *shell_view;
EShellWindow *shell_window;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (memo_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- calendar_setup_new_memo_list (GTK_WINDOW (shell_window));
+
+ registry = e_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Memo List"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -251,11 +224,16 @@ static void
action_memo_list_properties_cb (GtkAction *action,
EMemoShellView *memo_shell_view)
{
- EMemoShellSidebar *memo_shell_sidebar;
EShellView *shell_view;
EShellWindow *shell_window;
+ EMemoShellSidebar *memo_shell_sidebar;
+ ECalClientSourceType source_type;
ESource *source;
ESourceSelector *selector;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (memo_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -263,9 +241,23 @@ action_memo_list_properties_cb (GtkAction *action,
memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
source = e_source_selector_get_primary_selection (selector);
- g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (source != NULL);
+
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
+ registry = e_source_selector_get_registry (selector);
+ config = e_cal_source_config_new (registry, source, source_type);
- calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source);
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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), _("Memo List Properties"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -278,7 +270,6 @@ action_memo_list_refresh_cb (GtkAction *action,
ECalClient *client;
ECalModel *model;
ESource *source;
- gchar *uri;
GError *error = NULL;
memo_shell_content = memo_shell_view->priv->memo_shell_content;
@@ -290,10 +281,7 @@ action_memo_list_refresh_cb (GtkAction *action,
source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- g_free (uri);
-
+ client = e_cal_model_get_client_for_source (model, source);
if (client == NULL)
return;
@@ -304,7 +292,7 @@ action_memo_list_refresh_cb (GtkAction *action,
if (error != NULL) {
g_warning (
"%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
}
diff --git a/modules/calendar/e-memo-shell-view-private.h b/modules/calendar/e-memo-shell-view-private.h
index 0a6a390..08ac2b8 100644
--- a/modules/calendar/e-memo-shell-view-private.h
+++ b/modules/calendar/e-memo-shell-view-private.h
@@ -36,12 +36,13 @@
#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 "calendar/gui/comp-util.h"
#include "calendar/gui/e-cal-component-preview.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "calendar/gui/e-calendar-selector.h"
#include "calendar/gui/print.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/copy-source-dialog.h"
#include "calendar/gui/dialogs/memo-editor.h"
diff --git a/modules/calendar/e-memo-shell-view.h b/modules/calendar/e-memo-shell-view.h
index 686ae73..7538368 100644
--- a/modules/calendar/e-memo-shell-view.h
+++ b/modules/calendar/e-memo-shell-view.h
@@ -23,7 +23,6 @@
#define E_MEMO_SHELL_VIEW_H
#include <shell/e-shell-view.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_MEMO_SHELL_VIEW \
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index bb296fd..85a0e09 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libecal/e-cal-client.h>
+#include <libecal/e-source-calendar.h>
#include <libedataserver/e-url.h>
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-list.h>
@@ -37,10 +38,11 @@
#include "shell/e-shell.h"
#include "shell/e-shell-backend.h"
#include "shell/e-shell-window.h"
+#include "widgets/misc/e-source-config-dialog.h"
#include "calendar/gui/comp-util.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/task-editor.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "e-task-shell-content.h"
#include "e-task-shell-migrate.h"
@@ -48,123 +50,13 @@
#include "e-task-shell-view.h"
struct _ETaskShellBackendPrivate {
- ESourceList *source_list;
-};
-
-enum {
- PROP_0,
- PROP_SOURCE_LIST
+ gint placeholder;
};
static gpointer parent_class;
static GType task_shell_backend_type;
static void
-task_shell_backend_ensure_sources (EShellBackend *shell_backend)
-{
- /* XXX This is basically the same algorithm across all modules.
- * Maybe we could somehow integrate this into EShellBackend? */
-
- ETaskShellBackend *task_shell_backend;
- ESourceGroup *on_this_computer;
- ESourceList *source_list;
- ESource *personal;
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *sources, *iter;
- const gchar *name;
- gboolean save_list = FALSE;
- GError *error = NULL;
-
- on_this_computer = NULL;
- personal = NULL;
-
- task_shell_backend = E_TASK_SHELL_BACKEND (shell_backend);
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- e_cal_client_get_sources (
- &task_shell_backend->priv->source_list,
- E_CAL_CLIENT_SOURCE_TYPE_TASKS, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get task sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
-
- source_list = task_shell_backend->priv->source_list;
-
- on_this_computer = e_source_list_ensure_group (
- source_list, _("On This Computer"), "local:", TRUE);
- e_source_list_ensure_group (
- source_list, _("On The Web"), "webcal://", FALSE);
-
- g_return_if_fail (on_this_computer);
-
- 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;
- GSList *selected;
- gchar *primary;
-
- source = e_source_new (name, "system");
- e_source_set_color_spec (source, "#BECEDD");
- e_source_group_add_source (on_this_computer, source, -1);
- g_object_unref (source);
- save_list = TRUE;
-
- primary = e_shell_settings_get_string (
- shell_settings, "cal-primary-task-list");
-
- selected = e_task_shell_backend_get_selected_task_lists (
- task_shell_backend);
-
- if (primary == NULL && selected == NULL) {
- const gchar *uid;
-
- uid = e_source_peek_uid (source);
- selected = g_slist_prepend (NULL, g_strdup (uid));
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-task-list", uid);
- e_task_shell_backend_set_selected_task_lists (
- task_shell_backend, selected);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
- g_free (primary);
- } else {
- /* Force the source name to the current locale. */
- e_source_set_name (personal, name);
- }
-
- g_object_unref (on_this_computer);
-
- if (save_list)
- e_source_list_sync (source_list, NULL);
-}
-
-static void
task_shell_backend_new_task (ESource *source,
GAsyncResult *result,
EShell *shell,
@@ -183,7 +75,7 @@ task_shell_backend_new_task (ESource *source,
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open '%s': %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
return;
@@ -239,55 +131,63 @@ action_task_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
EShell *shell;
- EShellBackend *shell_backend;
- EShellSettings *shell_settings;
- ESource *source = NULL;
- ESourceList *source_list;
+ ESource *source;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
const gchar *action_name;
- gchar *uid;
/* This callback is used for both tasks and assigned tasks. */
shell = e_shell_window_get_shell (shell_window);
- shell_settings = e_shell_get_shell_settings (shell);
- shell_backend = e_shell_get_backend_by_name (shell, "tasks");
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
- g_return_if_fail (E_IS_SOURCE_LIST (source_list));
-
- uid = e_shell_settings_get_string (
- shell_settings, "cal-primary-task-list");
-
- 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_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
+ source = e_source_registry_get_default_task_list (registry);
/* Use a callback function appropriate for the action.
* FIXME Need to obtain a better default time zone. */
action_name = gtk_action_get_name (action);
if (strcmp (action_name, "task-assigned-new") == 0)
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- task_shell_backend_task_assigned_new_cb, g_object_ref (shell));
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ task_shell_backend_task_assigned_new_cb,
+ g_object_ref (shell));
else
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_TASKS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- task_shell_backend_task_new_cb, g_object_ref (shell));
-
- g_object_unref (source_list);
+ e_client_utils_open_new (
+ source, source_type, FALSE, NULL,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ task_shell_backend_task_new_cb,
+ g_object_ref (shell));
}
static void
action_task_list_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
- calendar_setup_new_task_list (GTK_WINDOW (shell_window));
+ ECalClientSourceType source_type;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
+
+ registry = e_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Task List"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static GtkActionEntry item_entries[] = {
@@ -327,7 +227,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
ECalClient *client;
ECalComponent *comp;
ESource *source;
- ESourceList *source_list;
+ ESourceRegistry *registry;
ECalClientSourceType source_type;
EUri *euri;
icalcomponent *icalcomp;
@@ -392,20 +292,10 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
* we successfully open it is another matter... */
handled = TRUE;
- e_cal_client_get_sources (&source_list, source_type, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Could not get task sources: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- goto exit;
- }
-
- source = e_source_list_peek_source_by_uid (source_list, source_uid);
+ registry = e_source_registry_get_default ();
+ source = e_source_registry_lookup_by_uid (registry, source_uid);
if (source == NULL) {
g_printerr ("No source for UID '%s'\n", source_uid);
- g_object_unref (source_list);
goto exit;
}
@@ -422,7 +312,8 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
g_warning (
"%s: Failed to create/open client: %s",
G_STRFUNC, error->message);
- g_object_unref (source_list);
+ if (client != NULL)
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -442,7 +333,7 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
g_warning (
"%s: Failed to get object: %s",
G_STRFUNC, error->message);
- g_object_unref (source_list);
+ g_object_unref (client);
g_error_free (error);
goto exit;
}
@@ -473,7 +364,6 @@ task_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
present:
gtk_window_present (GTK_WINDOW (editor));
- g_object_unref (source_list);
g_object_unref (client);
exit:
@@ -507,40 +397,6 @@ task_shell_backend_window_created_cb (EShellBackend *shell_backend,
}
static void
-task_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_task_shell_backend_get_source_list (
- E_TASK_SHELL_BACKEND (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-task_shell_backend_dispose (GObject *object)
-{
- ETaskShellBackendPrivate *priv;
-
- priv = E_TASK_SHELL_BACKEND (object)->priv;
-
- 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 (parent_class)->dispose (object);
-}
-
-static void
task_shell_backend_constructed (GObject *object)
{
EShell *shell;
@@ -549,8 +405,6 @@ task_shell_backend_constructed (GObject *object)
shell_backend = E_SHELL_BACKEND (object);
shell = e_shell_backend_get_shell (shell_backend);
- task_shell_backend_ensure_sources (shell_backend);
-
g_signal_connect_swapped (
shell, "handle-uri",
G_CALLBACK (task_shell_backend_handle_uri_cb),
@@ -575,8 +429,6 @@ task_shell_backend_class_init (ETaskShellBackendClass *class)
g_type_class_add_private (class, sizeof (ETaskShellBackendPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->get_property = task_shell_backend_get_property;
- object_class->dispose = task_shell_backend_dispose;
object_class->constructed = task_shell_backend_constructed;
shell_backend_class = E_SHELL_BACKEND_CLASS (class);
@@ -588,16 +440,6 @@ task_shell_backend_class_init (ETaskShellBackendClass *class)
shell_backend_class->preferences_page = "calendar-and-tasks";
shell_backend_class->start = NULL;
shell_backend_class->migrate = e_task_shell_backend_migrate;
-
- g_object_class_install_property (
- object_class,
- PROP_SOURCE_LIST,
- g_param_spec_object (
- "source-list",
- "Source List",
- "The registry of task lists",
- E_TYPE_SOURCE_LIST,
- G_PARAM_READABLE));
}
static void
@@ -633,48 +475,7 @@ e_task_shell_backend_register_type (GTypeModule *type_module)
task_shell_backend_type = g_type_module_register_type (
type_module, E_TYPE_SHELL_BACKEND,
"ETaskShellBackend", &type_info, 0);
-}
-
-ESourceList *
-e_task_shell_backend_get_source_list (ETaskShellBackend *task_shell_backend)
-{
- g_return_val_if_fail (
- E_IS_TASK_SHELL_BACKEND (task_shell_backend), NULL);
-
- return task_shell_backend->priv->source_list;
-}
-GSList *
-e_task_shell_backend_get_selected_task_lists (ETaskShellBackend *task_shell_backend)
-{
- GConfClient *client;
- GSList *selected_task_lists;
- const gchar *key;
-
- g_return_val_if_fail (
- E_IS_TASK_SHELL_BACKEND (task_shell_backend), NULL);
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/tasks/selected_tasks";
- selected_task_lists = gconf_client_get_list (
- client, key, GCONF_VALUE_STRING, NULL);
- g_object_unref (client);
-
- return selected_task_lists;
-}
-
-void
-e_task_shell_backend_set_selected_task_lists (ETaskShellBackend *task_shell_backend,
- GSList *selected_task_lists)
-{
- GConfClient *client;
- const gchar *key;
-
- g_return_if_fail (E_IS_TASK_SHELL_BACKEND (task_shell_backend));
-
- client = gconf_client_get_default ();
- key = "/apps/evolution/calendar/tasks/selected_tasks";
- gconf_client_set_list (
- client, key, GCONF_VALUE_STRING, selected_task_lists, NULL);
- g_object_unref (client);
+ /* Register relevant ESource extensions. */
+ E_TYPE_SOURCE_TASK_LIST;
}
diff --git a/modules/calendar/e-task-shell-backend.h b/modules/calendar/e-task-shell-backend.h
index ba56e91..a9f1085 100644
--- a/modules/calendar/e-task-shell-backend.h
+++ b/modules/calendar/e-task-shell-backend.h
@@ -23,7 +23,6 @@
#define E_TASK_SHELL_BACKEND_H
#include <shell/e-shell-backend.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_TASK_SHELL_BACKEND \
@@ -62,13 +61,6 @@ struct _ETaskShellBackendClass {
GType e_task_shell_backend_get_type (void);
void e_task_shell_backend_register_type
(GTypeModule *type_module);
-ESourceList * e_task_shell_backend_get_source_list
- (ETaskShellBackend *task_shell_backend);
-GSList * e_task_shell_backend_get_selected_task_lists
- (ETaskShellBackend *task_shell_backend);
-void e_task_shell_backend_set_selected_task_lists
- (ETaskShellBackend *task_shell_backend,
- GSList *selected_task_lists);
G_END_DECLS
diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c
index 743bb93..6ee9b40 100644
--- a/modules/calendar/e-task-shell-content.c
+++ b/modules/calendar/e-task-shell-content.c
@@ -116,7 +116,7 @@ task_shell_content_table_foreach_cb (gint model_row,
const gchar *source_uid;
source = e_client_get_source (E_CLIENT (comp_data->client));
- source_uid = e_source_peek_uid (source);
+ source_uid = e_source_get_uid (source);
foreach_data->list = g_slist_prepend (
foreach_data->list,
diff --git a/modules/calendar/e-task-shell-migrate.c b/modules/calendar/e-task-shell-migrate.c
index 60499d6..40b731a 100644
--- a/modules/calendar/e-task-shell-migrate.c
+++ b/modules/calendar/e-task-shell-migrate.c
@@ -25,149 +25,6 @@
#include "e-task-shell-migrate.h"
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <glib/gi18n.h>
-#include <glib/gstdio.h>
-#include <libebackend/e-dbhash.h>
-#include <libedataserver/e-source.h>
-#include <libedataserver/e-source-group.h>
-#include <libedataserver/e-source-list.h>
-#include <libedataserver/e-xml-hash-utils.h>
-#include <libedataserver/e-xml-utils.h>
-
-#include "e-util/e-util-private.h"
-#include "calendar/gui/calendar-config-keys.h"
-#include "shell/e-shell.h"
-
-#include "e-task-shell-backend.h"
-
-#define LOCAL_BASE_URI "local:"
-#define WEBCAL_BASE_URI "webcal://"
-#define PERSONAL_RELATIVE_URI "system"
-
-static void
-create_task_sources (EShellBackend *shell_backend,
- ESourceList *source_list,
- ESourceGroup **on_this_computer,
- ESourceGroup **on_the_web,
- ESource **personal_source)
-{
- EShell *shell;
- EShellSettings *shell_settings;
- GSList *groups;
- ESourceGroup *group;
-
- *on_this_computer = NULL;
- *on_the_web = NULL;
- *personal_source = NULL;
-
- shell = e_shell_backend_get_shell (shell_backend);
- shell_settings = e_shell_get_shell_settings (shell);
-
- groups = e_source_list_peek_groups (source_list);
- if (groups) {
- /* groups are already there, we need to search for things... */
- GSList *g;
- const gchar *data_dir;
- gchar *base_dir, *base_uri;
-
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- base_dir = g_build_filename (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_the_web && !strcmp (WEBCAL_BASE_URI,
- e_source_group_peek_base_uri (group)))
- *on_the_web = 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 (source_list, group, -1);
-
- *on_this_computer = group;
- }
-
- if (!*personal_source) {
- GSList *selected;
- gchar *primary_task_list;
-
- /* Create the default Person task list */
- ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
- e_source_group_add_source (*on_this_computer, source, -1);
-
- primary_task_list = e_shell_settings_get_string (
- shell_settings, "cal-primary-task-list");
-
- selected = e_task_shell_backend_get_selected_task_lists (
- E_TASK_SHELL_BACKEND (shell_backend));
-
- if (primary_task_list == NULL && selected == NULL) {
- GSList link;
-
- e_shell_settings_set_string (
- shell_settings, "cal-primary-task-list",
- e_source_peek_uid (source));
-
- link.data = (gpointer) e_source_peek_uid (source);
- link.next = NULL;
-
- e_task_shell_backend_set_selected_task_lists (
- E_TASK_SHELL_BACKEND (shell_backend), &link);
- }
-
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- g_slist_free (selected);
-
- e_source_set_color_spec (source, "#BECEDD");
- *personal_source = source;
- }
-
- if (!*on_the_web) {
- /* Create the Webcal source group */
- group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
- e_source_list_add_group (source_list, group, -1);
-
- *on_the_web = group;
- }
-}
-
gboolean
e_task_shell_backend_migrate (EShellBackend *shell_backend,
gint major,
@@ -175,28 +32,7 @@ e_task_shell_backend_migrate (EShellBackend *shell_backend,
gint micro,
GError **error)
{
- ESourceGroup *on_this_computer = NULL;
- ESourceGroup *on_the_web = NULL;
- ESource *personal_source = NULL;
- ESourceList *source_list;
-
- g_object_get (shell_backend, "source-list", &source_list, NULL);
-
- /* we call this unconditionally now - create_groups either
- * creates the groups/sources or it finds the necessary
- * groups/sources. */
- create_task_sources (
- shell_backend, source_list, &on_this_computer,
- &on_the_web, &personal_source);
-
- e_source_list_sync (source_list, NULL);
-
- if (on_this_computer)
- g_object_unref (on_this_computer);
- if (on_the_web)
- g_object_unref (on_the_web);
- if (personal_source)
- g_object_unref (personal_source);
+ g_return_val_if_fail (E_IS_SHELL_BACKEND (shell_backend), FALSE);
return TRUE;
}
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index 7987071..1eb6e79 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -28,6 +28,8 @@
#include <string.h>
#include <glib/gi18n.h>
#include <libecal/e-cal-client.h>
+#include <libecal/e-source-calendar.h>
+#include <libedataserver/e-source-password.h>
#include <libedataserverui/e-client-utils.h>
#include "e-util/e-alert-dialog.h"
@@ -120,7 +122,7 @@ task_shell_sidebar_backend_died_cb (ETaskShellSidebar *task_shell_sidebar,
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
g_object_ref (source);
@@ -142,21 +144,30 @@ task_shell_sidebar_backend_error_cb (ETaskShellSidebar *task_shell_sidebar,
EShellView *shell_view;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
- ESourceGroup *source_group;
+ ESource *parent;
ESource *source;
+ GNode *node;
+ const gchar *parent_display_name;
+ const gchar *source_display_name;
shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
shell_content = e_shell_view_get_shell_content (shell_view);
source = e_client_get_source (E_CLIENT (client));
- source_group = e_source_peek_group (source);
+
+ node = e_source_get_node (source);
+ g_return_if_fail (node != NULL);
+ g_return_if_fail (node->parent != NULL);
+
+ parent = E_SOURCE (node->parent->data);
+
+ parent_display_name = e_source_get_display_name (parent);
+ source_display_name = e_source_get_display_name (source);
e_alert_submit (
- E_ALERT_SINK (shell_content),
- "calendar:backend-error",
- e_source_group_peek_name (source_group),
- e_source_peek_name (source), message, NULL);
+ E_ALERT_SINK (shell_content), "calendar:backend-error",
+ parent_display_name, source_display_name, message, NULL);
}
static void
@@ -228,7 +239,8 @@ task_shell_sidebar_client_opened_cb (GObject *source_object,
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED) ||
g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED))
- e_client_utils_forget_password (E_CLIENT (client));
+ /* FIXME Handle errors. */
+ e_source_password_delete_sync (source, NULL, NULL);
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
e_client_open (
@@ -269,7 +281,7 @@ task_shell_sidebar_client_opened_cb (GObject *source_object,
case E_CLIENT_ERROR_BUSY:
g_warning (
"%s: Cannot open '%s', it's busy (%s)",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_clear_error (&error);
return;
@@ -410,7 +422,7 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
priv->loading_default_client = NULL;
}
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (priv->client_table, uid);
/* If we already have an open connection for
@@ -461,38 +473,6 @@ task_shell_sidebar_row_changed_cb (ETaskShellSidebar *task_shell_sidebar,
}
static void
-task_shell_sidebar_selection_changed_cb (ETaskShellSidebar *task_shell_sidebar,
- ESourceSelector *selector)
-{
- EShellView *shell_view;
- EShellBackend *shell_backend;
- EShellSidebar *shell_sidebar;
- GSList *list, *iter;
-
- /* This signal is emitted less frequently than "row-changed",
- * especially when the model is being rebuilt. So we'll take
- * it easy on poor GConf. */
-
- shell_sidebar = E_SHELL_SIDEBAR (task_shell_sidebar);
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
-
- list = e_source_selector_get_selection (selector);
-
- for (iter = list; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
-
- iter->data = (gpointer) e_source_peek_uid (source);
- g_object_unref (source);
- }
-
- e_task_shell_backend_set_selected_task_lists (
- E_TASK_SHELL_BACKEND (shell_backend), list);
-
- g_slist_free (list);
-}
-
-static void
task_shell_sidebar_primary_selection_changed_cb (ETaskShellSidebar *task_shell_sidebar,
ESourceSelector *selector)
{
@@ -514,11 +494,9 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
EShell *shell;
EShellBackend *shell_backend;
EShellSettings *shell_settings;
+ ESourceRegistry *registry;
ESourceSelector *selector;
- ESourceList *source_list;
- ESource *source;
GtkTreeModel *model;
- GSList *list, *iter;
priv = E_TASK_SHELL_SIDEBAR (shell_sidebar)->priv;
@@ -531,8 +509,7 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
selector = E_SOURCE_SELECTOR (priv->selector);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector));
- source_list = e_task_shell_backend_get_source_list (
- E_TASK_SHELL_BACKEND (shell_backend));
+ registry = e_source_registry_get_default ();
g_signal_connect_swapped (
model, "row-changed",
@@ -551,30 +528,8 @@ task_shell_sidebar_restore_state_cb (EShellWindow *shell_window,
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);
-
- list = e_task_shell_backend_get_selected_task_lists (
- E_TASK_SHELL_BACKEND (shell_backend));
-
- for (iter = list; iter != NULL; iter = iter->next) {
- const gchar *uid = iter->data;
-
- source = e_source_list_peek_source_by_uid (source_list, uid);
-
- if (source != NULL)
- e_source_selector_select_source (selector, source);
- }
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
-
- /* Listen for subsequent changes to the selector. */
-
- g_signal_connect_swapped (
- selector, "selection-changed",
- G_CALLBACK (task_shell_sidebar_selection_changed_cb),
- shell_sidebar);
}
static void
@@ -656,9 +611,8 @@ task_shell_sidebar_constructed (GObject *object)
ETaskShellSidebarPrivate *priv;
EShellView *shell_view;
EShellWindow *shell_window;
- EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
- ESourceList *source_list;
+ ESourceRegistry *registry;
GtkContainer *container;
GtkWidget *widget;
AtkObject *a11y;
@@ -670,12 +624,8 @@ task_shell_sidebar_constructed (GObject *object)
shell_sidebar = E_SHELL_SIDEBAR (object);
shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- source_list = e_task_shell_backend_get_source_list (
- E_TASK_SHELL_BACKEND (shell_backend));
-
container = GTK_CONTAINER (shell_sidebar);
widget = gtk_scrolled_window_new (NULL, NULL);
@@ -689,7 +639,8 @@ task_shell_sidebar_constructed (GObject *object)
container = GTK_CONTAINER (widget);
- widget = e_task_list_selector_new (source_list);
+ registry = e_source_registry_get_default ();
+ widget = e_task_list_selector_new (registry);
e_source_selector_set_select_new (E_SOURCE_SELECTOR (widget), TRUE);
gtk_container_add (container, widget);
a11y = gtk_widget_get_accessible (widget);
@@ -721,21 +672,24 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
source = e_source_selector_get_primary_selection (selector);
if (source != NULL) {
+ ESourceSelectable *extension;
ECalClient *client;
- const gchar *uri;
- const gchar *delete_prop;
+ gboolean writable_hint;
+ const gchar *uid;
+
+ uid = e_source_get_uid (source);
+ is_system = (g_strcmp0 (uid, "system") == 0);
- uri = e_source_peek_relative_uri (source);
- is_system = (uri == NULL || strcmp (uri, "system") == 0);
+ extension = e_source_get_extension (
+ source, E_SOURCE_EXTENSION_TASK_LIST);
+ writable_hint =
+ e_source_selectable_get_writable_hint (extension);
- can_delete = !is_system;
- delete_prop = e_source_get_property (source, "delete");
- can_delete = can_delete &&
- (delete_prop == NULL || strcmp (delete_prop, "no") != 0);
+ can_delete = !is_system && writable_hint;
client = g_hash_table_lookup (
task_shell_sidebar->priv->client_table,
- e_source_peek_uid (source));
+ e_source_get_uid (source));
refresh_supported = client &&
e_client_check_refresh_supported (E_CLIENT (client));
}
@@ -769,8 +723,7 @@ task_shell_sidebar_client_removed (ETaskShellSidebar *task_shell_sidebar,
NULL, NULL, task_shell_sidebar);
source = e_client_get_source (E_CLIENT (client));
- uid = e_source_peek_uid (source);
- g_return_if_fail (uid != NULL);
+ uid = e_source_get_uid (source);
g_hash_table_remove (client_table, uid);
e_source_selector_unselect_source (selector, source);
@@ -953,8 +906,8 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
ECalClient *default_client;
ECalClient *client;
icaltimezone *timezone;
+ const gchar *display_name;
const gchar *uid;
- const gchar *uri;
gchar *message;
g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar));
@@ -965,7 +918,7 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
default_client = task_shell_sidebar->priv->default_client;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client != NULL)
@@ -976,7 +929,7 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
const gchar *default_uid;
default_source = e_client_get_source (E_CLIENT (default_client));
- default_uid = e_source_peek_uid (default_source);
+ default_uid = e_source_get_uid (default_source);
if (g_strcmp0 (uid, default_uid) == 0)
client = g_object_ref (default_client);
@@ -1005,9 +958,8 @@ e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
g_hash_table_insert (client_table, g_strdup (uid), client);
e_source_selector_select_source (selector, source);
- uri = e_client_get_uri (E_CLIENT (client));
- /* Translators: The string field is a URI. */
- message = g_strdup_printf (_("Opening tasks at %s"), uri);
+ display_name = e_source_get_display_name (source);
+ message = g_strdup_printf (_("Opening task list '%s'"), display_name);
task_shell_sidebar_emit_status_message (task_shell_sidebar, message);
g_free (message);
@@ -1042,7 +994,7 @@ e_task_shell_sidebar_remove_source (ETaskShellSidebar *task_shell_sidebar,
client_table = task_shell_sidebar->priv->client_table;
- uid = e_source_peek_uid (source);
+ uid = e_source_get_uid (source);
client = g_hash_table_lookup (client_table, uid);
if (client == NULL)
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 1fb4867..6191e5f 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -151,32 +151,17 @@ static void
action_task_list_delete_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
- ETaskShellBackend *task_shell_backend;
- ETaskShellContent *task_shell_content;
ETaskShellSidebar *task_shell_sidebar;
EShellWindow *shell_window;
EShellView *shell_view;
- ETaskTable *task_table;
- ECalClient *client;
- ECalModel *model;
ESourceSelector *selector;
- ESourceGroup *source_group;
- ESourceList *source_list;
ESource *source;
+ GFile *file;
gint response;
- gchar *uri;
- GError *error = NULL;
shell_view = E_SHELL_VIEW (task_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- task_shell_backend = task_shell_view->priv->task_shell_backend;
- source_list = e_task_shell_backend_get_source_list (task_shell_backend);
-
- task_shell_content = task_shell_view->priv->task_shell_content;
- task_table = e_task_shell_content_get_task_table (task_shell_content);
- model = e_task_table_get_model (task_table);
-
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
source = e_source_selector_get_primary_selection (selector);
@@ -186,46 +171,14 @@ action_task_list_delete_cb (GtkAction *action,
response = e_alert_run_dialog_for_args (
GTK_WINDOW (shell_window),
"calendar:prompt-delete-task-list",
- e_source_peek_name (source), NULL);
- if (response != GTK_RESPONSE_YES)
- return;
+ e_source_get_display_name (source), NULL);
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- if (client == NULL)
- client = e_cal_client_new_from_uri (
- uri, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, NULL);
- g_free (uri);
-
- g_return_if_fail (client != NULL);
-
- e_client_remove_sync (E_CLIENT (client), NULL, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to remove client: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
+ if (response != GTK_RESPONSE_YES)
return;
- }
-
- if (e_source_selector_source_is_selected (selector, source)) {
- e_task_shell_sidebar_remove_source (
- task_shell_sidebar, 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, &error);
-
- if (error != NULL) {
- g_warning (
- "%s: Failed to sync srouce list: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- }
+ /* FIXME Handle errors. */
+ file = e_source_get_file (source);
+ g_file_delete (file, NULL, NULL);
}
static void
@@ -234,10 +187,30 @@ action_task_list_new_cb (GtkAction *action,
{
EShellView *shell_view;
EShellWindow *shell_window;
+ ESourceRegistry *registry;
+ ECalClientSourceType source_type;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (task_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- calendar_setup_new_task_list (GTK_WINDOW (shell_window));
+
+ registry = e_source_registry_get_default ();
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
+ config = e_cal_source_config_new (registry, NULL, source_type);
+
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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 Task List"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -274,11 +247,16 @@ static void
action_task_list_properties_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
- ETaskShellSidebar *task_shell_sidebar;
EShellView *shell_view;
EShellWindow *shell_window;
+ ETaskShellSidebar *task_shell_sidebar;
+ ECalClientSourceType source_type;
ESource *source;
ESourceSelector *selector;
+ ESourceRegistry *registry;
+ GtkWidget *config;
+ GtkWidget *dialog;
+ const gchar *icon_name;
shell_view = E_SHELL_VIEW (task_shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
@@ -286,9 +264,23 @@ action_task_list_properties_cb (GtkAction *action,
task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
source = e_source_selector_get_primary_selection (selector);
- g_return_if_fail (E_IS_SOURCE (source));
+ g_return_if_fail (source != NULL);
+
+ source_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
+ registry = e_source_selector_get_registry (selector);
+ config = e_cal_source_config_new (registry, source, source_type);
- calendar_setup_edit_task_list (GTK_WINDOW (shell_window), source);
+ dialog = e_source_config_dialog_new (
+ E_SOURCE_CONFIG (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), _("Task List Properties"));
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
}
static void
@@ -301,7 +293,6 @@ action_task_list_refresh_cb (GtkAction *action,
ECalClient *client;
ECalModel *model;
ESource *source;
- gchar *uri;
GError *error = NULL;
task_shell_content = task_shell_view->priv->task_shell_content;
@@ -313,10 +304,7 @@ action_task_list_refresh_cb (GtkAction *action,
source = e_source_selector_get_primary_selection (selector);
g_return_if_fail (E_IS_SOURCE (source));
- uri = e_source_get_uri (source);
- client = e_cal_model_get_client_for_uri (model, uri);
- g_free (uri);
-
+ client = e_cal_model_get_client_for_source (model, source);
if (client == NULL)
return;
@@ -327,7 +315,7 @@ action_task_list_refresh_cb (GtkAction *action,
if (error != NULL) {
g_warning (
"%s: Failed to refresh '%s', %s",
- G_STRFUNC, e_source_peek_name (source),
+ G_STRFUNC, e_source_get_display_name (source),
error->message);
g_error_free (error);
}
diff --git a/modules/calendar/e-task-shell-view-private.h b/modules/calendar/e-task-shell-view-private.h
index ec2173f..3af5a1c 100644
--- a/modules/calendar/e-task-shell-view-private.h
+++ b/modules/calendar/e-task-shell-view-private.h
@@ -38,14 +38,15 @@
#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 "calendar/gui/calendar-config.h"
#include "calendar/gui/comp-util.h"
#include "calendar/gui/e-cal-component-preview.h"
#include "calendar/gui/e-cal-model-tasks.h"
+#include "calendar/gui/e-cal-source-config.h"
#include "calendar/gui/e-calendar-selector.h"
#include "calendar/gui/print.h"
-#include "calendar/gui/dialogs/calendar-setup.h"
#include "calendar/gui/dialogs/copy-source-dialog.h"
#include "calendar/gui/dialogs/task-editor.h"
diff --git a/modules/calendar/e-task-shell-view.h b/modules/calendar/e-task-shell-view.h
index 853d90c..d756c10 100644
--- a/modules/calendar/e-task-shell-view.h
+++ b/modules/calendar/e-task-shell-view.h
@@ -23,7 +23,6 @@
#define E_TASK_SHELL_VIEW_H
#include <shell/e-shell-view.h>
-#include <libedataserver/e-source-list.h>
/* Standard GObject macros */
#define E_TYPE_TASK_SHELL_VIEW \
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index ae3ffa4..3fba87f 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -8,6 +8,7 @@ widgetsinclude_HEADERS = \
e-action-combo-box.h \
e-activity-bar.h \
e-activity-proxy.h \
+ e-alarm-selector.h \
e-alert-bar.h \
e-attachment.h \
e-attachment-button.h \
@@ -98,6 +99,7 @@ libemiscwidgets_la_SOURCES = \
e-action-combo-box.c \
e-activity-bar.c \
e-activity-proxy.c \
+ e-alarm-selector.c \
e-alert-bar.c \
e-attachment.c \
e-attachment-button.c \
diff --git a/widgets/misc/e-alarm-selector.c b/widgets/misc/e-alarm-selector.c
new file mode 100644
index 0000000..0eeeba3
--- /dev/null
+++ b/widgets/misc/e-alarm-selector.c
@@ -0,0 +1,102 @@
+/*
+ * e-alarm-selector.c
+ *
+ * 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/>
+ *
+ */
+
+#include "e-alarm-selector.h"
+
+#include <libecal/e-source-calendar.h>
+#include <libedataserver/e-source-alarms.h>
+
+G_DEFINE_TYPE (
+ EAlarmSelector,
+ e_alarm_selector,
+ E_TYPE_SOURCE_SELECTOR)
+
+static gboolean
+alarm_selector_get_source_selected (ESourceSelector *selector,
+ ESource *source)
+{
+ ESourceAlarms *extension;
+ const gchar *extension_name;
+
+ extension_name = e_source_selector_get_extension_name (selector);
+
+ /* Make sure this source is a calendar. */
+ if (!e_source_has_extension (source, extension_name))
+ return FALSE;
+
+ extension_name = E_SOURCE_EXTENSION_ALARMS;
+ extension = e_source_get_extension (source, extension_name);
+ g_return_val_if_fail (E_IS_SOURCE_ALARMS (extension), FALSE);
+
+ return e_source_alarms_get_include_me (extension);
+}
+
+static gboolean
+alarm_selector_set_source_selected (ESourceSelector *selector,
+ ESource *source,
+ gboolean selected)
+{
+ ESourceAlarms *extension;
+ const gchar *extension_name;
+
+ extension_name = e_source_selector_get_extension_name (selector);
+
+ /* Make sure this source is a calendar. */
+ if (!e_source_has_extension (source, extension_name))
+ return FALSE;
+
+ extension_name = E_SOURCE_EXTENSION_ALARMS;
+ extension = e_source_get_extension (source, extension_name);
+ g_return_val_if_fail (E_IS_SOURCE_ALARMS (extension), FALSE);
+
+ /* Avoid unnecessary signal emissions and disk writes. */
+ if (selected == e_source_alarms_get_include_me (extension))
+ return FALSE;
+
+ e_source_alarms_set_include_me (extension, selected);
+
+ return TRUE;
+}
+
+static void
+e_alarm_selector_class_init (EAlarmSelectorClass *class)
+{
+ ESourceSelectorClass *source_selector_class;
+
+ source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
+ source_selector_class->get_source_selected =
+ alarm_selector_get_source_selected;
+ source_selector_class->set_source_selected =
+ alarm_selector_set_source_selected;
+}
+
+static void
+e_alarm_selector_init (EAlarmSelector *selector)
+{
+}
+
+GtkWidget *
+e_alarm_selector_new (ESourceRegistry *registry)
+{
+ g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
+
+ return g_object_new (
+ E_TYPE_ALARM_SELECTOR,
+ "extension-name", E_SOURCE_EXTENSION_CALENDAR,
+ "registry", registry, NULL);
+}
diff --git a/widgets/misc/e-alarm-selector.h b/widgets/misc/e-alarm-selector.h
new file mode 100644
index 0000000..2ad9c49
--- /dev/null
+++ b/widgets/misc/e-alarm-selector.h
@@ -0,0 +1,63 @@
+/*
+ * e-alarm-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_ALARM_SELECTOR_H
+#define E_ALARM_SELECTOR_H
+
+#include <libedataserverui/e-source-selector.h>
+
+/* Standard GObject macros */
+#define E_TYPE_ALARM_SELECTOR \
+ (e_alarm_selector_get_type ())
+#define E_ALARM_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_ALARM_SELECTOR, EAlarmSelector))
+#define E_ALARM_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_ALARM_SELECTOR, EAlarmSelectorClass))
+#define E_IS_ALARM_SELECTOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_ALARM_SELECTOR))
+#define E_IS_ALARM_SELECTOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_ALARM_SELECTOR))
+#define E_ALARM_SELECTOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_ALARM_SELECTOR, EAlarmSelectorClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EAlarmSelector EAlarmSelector;
+typedef struct _EAlarmSelectorClass EAlarmSelectorClass;
+typedef struct _EAlarmSelectorPrivate EAlarmSelectorPrivate;
+
+struct _EAlarmSelector {
+ ESourceSelector parent;
+ EAlarmSelectorPrivate *priv;
+};
+
+struct _EAlarmSelectorClass {
+ ESourceSelectorClass parent_class;
+};
+
+GType e_alarm_selector_get_type (void) G_GNUC_CONST;
+GtkWidget * e_alarm_selector_new (ESourceRegistry *registry);
+
+G_END_DECLS
+
+#endif /* E_ALARM_SELECTOR_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]