aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar/e-memo-shell-backend.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-08-21 01:25:21 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-08-24 03:21:59 +0800
commit7c1ec3723ad7367449c93e8559c27158b24a51dd (patch)
tree643be187abc027398868d87a8befe88db5bc330e /modules/calendar/e-memo-shell-backend.c
parentbd5e9031b9dc61669723f7ec6e0de3d7138a43d6 (diff)
downloadgsoc2013-evolution-7c1ec3723ad7367449c93e8559c27158b24a51dd.tar.gz
gsoc2013-evolution-7c1ec3723ad7367449c93e8559c27158b24a51dd.tar.zst
gsoc2013-evolution-7c1ec3723ad7367449c93e8559c27158b24a51dd.zip
Add e_load_cal_source_async().
Similar to e_load_book_source_async() in libedataserverui (and may wind up there eventually). This replaces e_auth_new_cal_from_source(). void e_load_cal_source_async (ESource *source, ECalSourceType source_type, icaltimezone *default_zone, GtkWindow *parent, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); ECal * e_load_cal_source_finish (ESource *source, GAsyncResult *result, GError **error);
Diffstat (limited to 'modules/calendar/e-memo-shell-backend.c')
-rw-r--r--modules/calendar/e-memo-shell-backend.c102
1 files changed, 52 insertions, 50 deletions
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 8f5bf40825..d54c32f98e 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -153,19 +153,18 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
}
static void
-memo_shell_backend_memo_new_cb (ECal *cal,
- const GError *error,
- EShell *shell)
+memo_shell_backend_new_memo (ESource *source,
+ GAsyncResult *result,
+ EShell *shell,
+ CompEditorFlags flags)
{
+ ECal *cal;
ECalComponent *comp;
CompEditor *editor;
- CompEditorFlags flags = 0;
/* XXX Handle errors better. */
- if (error)
- return;
-
- flags |= COMP_EDITOR_NEW_ITEM;
+ cal = e_load_cal_source_finish (source, result, NULL);
+ g_return_if_fail (E_IS_CAL (cal));
comp = cal_comp_memo_new_with_defaults (cal);
cal_comp_update_time_by_active_window (comp, shell);
@@ -179,42 +178,45 @@ memo_shell_backend_memo_new_cb (ECal *cal,
}
static void
-memo_shell_backend_memo_shared_new_cb (ECal *cal,
- const GError *error,
- EShell *shell)
+memo_shell_backend_memo_new_cb (ESource *source,
+ GAsyncResult *result,
+ EShell *shell)
{
- ECalComponent *comp;
- CompEditor *editor;
CompEditorFlags flags = 0;
- /* XXX Handle errors better. */
- if (error)
- return;
+ flags |= COMP_EDITOR_NEW_ITEM;
+
+ memo_shell_backend_new_memo (source, result, shell, flags);
+
+ g_object_unref (shell);
+}
+
+static void
+memo_shell_backend_memo_shared_new_cb (ESource *source,
+ GAsyncResult *result,
+ EShell *shell)
+{
+ CompEditorFlags flags = 0;
flags |= COMP_EDITOR_NEW_ITEM;
flags |= COMP_EDITOR_IS_SHARED;
flags |= COMP_EDITOR_USER_ORG;
- comp = cal_comp_memo_new_with_defaults (cal);
- cal_comp_update_time_by_active_window (comp, shell);
- editor = memo_editor_new (cal, shell, flags);
- comp_editor_edit_comp (editor, comp);
-
- gtk_window_present (GTK_WINDOW (editor));
+ memo_shell_backend_new_memo (source, result, shell, flags);
- g_object_unref (comp);
- g_object_unref (cal);
+ g_object_unref (shell);
}
static void
action_memo_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
- ECal *cal = NULL;
- ECalSourceType source_type;
- ESourceList *source_list;
- EShellSettings *shell_settings;
EShell *shell;
+ EShellBackend *shell_backend;
+ EShellSettings *shell_settings;
+ ESource *source = NULL;
+ ESourceList *source_list;
+ ECalSourceType source_type;
const gchar *action_name;
gchar *uid;
@@ -224,43 +226,43 @@ action_memo_new_cb (GtkAction *action,
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");
- if (!e_cal_get_sources (&source_list, source_type, NULL)) {
- g_warning ("Could not get memo sources from GConf!");
- return;
- }
+ 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) {
- ESource *source;
-
source = e_source_list_peek_source_by_uid (source_list, uid);
- if (source != NULL)
- cal = e_auth_new_cal_from_source (source, source_type);
g_free (uid);
}
- if (cal == NULL)
- cal = e_auth_new_cal_from_default (source_type);
+ if (source == NULL)
+ source = e_source_list_peek_default_source (source_list);
- g_return_if_fail (cal != NULL);
+ g_return_if_fail (E_IS_SOURCE (source));
- /* Connect the appropriate signal handler. */
+ /* 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, "memo-shared-new") == 0)
- g_signal_connect (
- cal, "cal-opened-ex",
- G_CALLBACK (memo_shell_backend_memo_shared_new_cb),
- shell);
+ if (g_strcmp0 (action_name, "memo-shared-new") == 0)
+ e_load_cal_source_async (
+ source, source_type, NULL,
+ GTK_WINDOW (shell_window),
+ NULL, (GAsyncReadyCallback)
+ memo_shell_backend_memo_shared_new_cb,
+ g_object_ref (shell));
else
- g_signal_connect (
- cal, "cal-opened-ex",
- G_CALLBACK (memo_shell_backend_memo_new_cb),
- shell);
+ e_load_cal_source_async (
+ source, source_type, NULL,
+ GTK_WINDOW (shell_window),
+ NULL, (GAsyncReadyCallback)
+ memo_shell_backend_memo_new_cb,
+ g_object_ref (shell));
- e_cal_open_async (cal, FALSE);
+ g_object_unref (source_list);
}
static void