aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-04-25 23:16:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-04-25 23:42:04 +0800
commit532e24fe115fa35f496b12415d539685f12c63d0 (patch)
tree5daffbda2868ddbe009067a301040d9179fc9002 /modules/calendar
parentafe1d97399538c8a5dedb18cf51ced4c8bb36203 (diff)
downloadgsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar.gz
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar.bz2
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar.lz
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar.xz
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.tar.zst
gsoc2013-evolution-532e24fe115fa35f496b12415d539685f12c63d0.zip
ETaskShellSidebar: Submit an EActivity when obtaining an EClient.
Remove this status message nonsense that I came up with during the kill-bonoto rewrite. Instead submit a real EActivity to the shell backend. Mismanagement of the status message seems to be blocking application shut down in some cases.
Diffstat (limited to 'modules/calendar')
-rw-r--r--modules/calendar/e-task-shell-sidebar.c109
1 files changed, 58 insertions, 51 deletions
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index e6a89f01c4..b037a67934 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -53,12 +53,12 @@ struct _ETaskShellSidebarPrivate {
/* Not referenced, only for pointer comparison. */
ESource *connecting_default_source_instance;
- GCancellable *connecting_default_client;
- GCancellable *loading_clients;
+ EActivity *connecting_default_client;
};
struct _ConnectClosure {
ETaskShellSidebar *task_shell_sidebar;
+ EActivity *activity;
/* For error messages. */
gchar *unique_display_name;
@@ -89,25 +89,54 @@ connect_closure_new (ETaskShellSidebar *task_shell_sidebar,
ESource *source)
{
ConnectClosure *closure;
+ EAlertSink *alert_sink;
+ GCancellable *cancellable;
ESourceRegistry *registry;
ESourceSelector *selector;
+ EShellView *shell_view;
+ EShellBackend *shell_backend;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
+ gchar *text;
+
+ 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);
+ shell_content = e_shell_view_get_shell_content (shell_view);
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
registry = e_source_selector_get_registry (selector);
closure = g_slice_new0 (ConnectClosure);
closure->task_shell_sidebar = g_object_ref (task_shell_sidebar);
+ closure->activity = e_activity_new ();
closure->unique_display_name =
e_source_registry_dup_unique_display_name (
registry, source, E_SOURCE_EXTENSION_TASK_LIST);
+ text = g_strdup_printf (
+ _("Opening task list '%s'"),
+ closure->unique_display_name);
+ e_activity_set_text (closure->activity, text);
+ g_free (text);
+
+ alert_sink = E_ALERT_SINK (shell_content);
+ e_activity_set_alert_sink (closure->activity, alert_sink);
+
+ cancellable = g_cancellable_new ();
+ e_activity_set_cancellable (closure->activity, cancellable);
+ g_object_unref (cancellable);
+
+ e_shell_backend_add_activity (shell_backend, closure->activity);
+
return closure;
}
static void
connect_closure_free (ConnectClosure *closure)
{
- g_object_unref (closure->task_shell_sidebar);
+ g_clear_object (&closure->task_shell_sidebar);
+ g_clear_object (&closure->activity);
g_free (closure->unique_display_name);
@@ -182,19 +211,15 @@ task_shell_sidebar_emit_status_message (ETaskShellSidebar *task_shell_sidebar,
}
static void
-task_shell_sidebar_handle_connect_error (ETaskShellSidebar *task_shell_sidebar,
+task_shell_sidebar_handle_connect_error (EActivity *activity,
const gchar *unique_display_name,
const GError *error)
{
- EShellView *shell_view;
- EShellContent *shell_content;
- EShellSidebar *shell_sidebar;
+ EAlertSink *alert_sink;
gboolean cancelled = FALSE;
gboolean offline_error;
- 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);
+ alert_sink = e_activity_get_alert_sink (activity);
cancelled |= g_error_matches (
error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
@@ -204,17 +229,17 @@ task_shell_sidebar_handle_connect_error (ETaskShellSidebar *task_shell_sidebar,
offline_error = g_error_matches (
error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE);
- if (cancelled) {
+ if (e_activity_handle_cancellation (activity, error)) {
/* do nothing */
} else if (offline_error) {
e_alert_submit (
- E_ALERT_SINK (shell_content),
+ alert_sink,
"calendar:prompt-no-contents-offline-tasks",
unique_display_name,
NULL);
} else {
e_alert_submit (
- E_ALERT_SINK (shell_content),
+ alert_sink,
"calendar:failed-open-tasks",
unique_display_name,
error->message,
@@ -241,13 +266,15 @@ task_shell_sidebar_client_connect_cb (GObject *source_object,
if (error != NULL) {
task_shell_sidebar_handle_connect_error (
- closure->task_shell_sidebar,
+ closure->activity,
closure->unique_display_name,
error);
g_error_free (error);
goto exit;
}
+ e_activity_set_state (closure->activity, E_ACTIVITY_COMPLETED);
+
e_task_shell_sidebar_add_client (closure->task_shell_sidebar, client);
g_object_unref (client);
@@ -277,20 +304,19 @@ task_shell_sidebar_default_connect_cb (GObject *source_object,
((client != NULL) && (error == NULL)) ||
((client == NULL) && (error != NULL)));
- if (priv->connecting_default_client) {
- g_object_unref (priv->connecting_default_client);
- priv->connecting_default_client = NULL;
- }
+ g_clear_object (&priv->connecting_default_client);
if (error != NULL) {
task_shell_sidebar_handle_connect_error (
- closure->task_shell_sidebar,
+ closure->activity,
closure->unique_display_name,
error);
g_error_free (error);
goto exit;
}
+ e_activity_set_state (closure->activity, E_ACTIVITY_COMPLETED);
+
source = e_client_get_source (client);
if (source == priv->connecting_default_source_instance)
@@ -316,6 +342,7 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
{
ETaskShellSidebarPrivate *priv;
ESourceSelector *selector;
+ ConnectClosure *closure;
priv = task_shell_sidebar->priv;
@@ -325,22 +352,23 @@ task_shell_sidebar_set_default (ETaskShellSidebar *task_shell_sidebar,
if (source == priv->connecting_default_source_instance)
return;
- /* Cancel any unfinished previous request. */
+ /* Cancel the previous request if unfinished. */
if (priv->connecting_default_client != NULL) {
- g_cancellable_cancel (priv->connecting_default_client);
+ e_activity_cancel (priv->connecting_default_client);
g_object_unref (priv->connecting_default_client);
priv->connecting_default_client = NULL;
}
+ closure = connect_closure_new (task_shell_sidebar, source);
+
/* it's only for pointer comparison, no need to ref it */
priv->connecting_default_source_instance = source;
- priv->connecting_default_client = g_cancellable_new ();
+ priv->connecting_default_client = g_object_ref (closure->activity);
e_client_selector_get_client (
E_CLIENT_SELECTOR (selector), source,
- priv->connecting_default_client,
- task_shell_sidebar_default_connect_cb,
- connect_closure_new (task_shell_sidebar, source));
+ e_activity_get_cancellable (closure->activity),
+ task_shell_sidebar_default_connect_cb, closure);
}
static void
@@ -472,17 +500,11 @@ task_shell_sidebar_dispose (GObject *object)
}
if (priv->connecting_default_client != NULL) {
- g_cancellable_cancel (priv->connecting_default_client);
+ e_activity_cancel (priv->connecting_default_client);
g_object_unref (priv->connecting_default_client);
priv->connecting_default_client = NULL;
}
- if (priv->loading_clients != NULL) {
- g_cancellable_cancel (priv->loading_clients);
- g_object_unref (priv->loading_clients);
- priv->loading_clients = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_task_shell_sidebar_parent_class)->dispose (object);
}
@@ -619,8 +641,6 @@ task_shell_sidebar_client_removed (ETaskShellSidebar *task_shell_sidebar,
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
e_source_selector_unselect_source (selector, source);
-
- task_shell_sidebar_emit_status_message (task_shell_sidebar, NULL);
}
static void
@@ -704,8 +724,6 @@ e_task_shell_sidebar_init (ETaskShellSidebar *task_shell_sidebar)
task_shell_sidebar->priv =
E_TASK_SHELL_SIDEBAR_GET_PRIVATE (task_shell_sidebar);
- task_shell_sidebar->priv->loading_clients = g_cancellable_new ();
-
/* Postpone widget construction until we have a shell view. */
}
@@ -768,33 +786,22 @@ void
e_task_shell_sidebar_add_source (ETaskShellSidebar *task_shell_sidebar,
ESource *source)
{
- ESourceRegistry *registry;
ESourceSelector *selector;
- gchar *display_name;
- gchar *message;
+ ConnectClosure *closure;
g_return_if_fail (E_IS_TASK_SHELL_SIDEBAR (task_shell_sidebar));
g_return_if_fail (E_IS_SOURCE (source));
selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
- registry = e_source_selector_get_registry (selector);
e_source_selector_select_source (selector, source);
- display_name = e_source_registry_dup_unique_display_name (
- registry, source, E_SOURCE_EXTENSION_TASK_LIST);
-
- message = g_strdup_printf (_("Opening task list '%s'"), display_name);
- task_shell_sidebar_emit_status_message (task_shell_sidebar, message);
- g_free (message);
-
- g_free (display_name);
+ closure = connect_closure_new (task_shell_sidebar, source);
e_client_selector_get_client (
E_CLIENT_SELECTOR (selector), source,
- task_shell_sidebar->priv->loading_clients,
- task_shell_sidebar_client_connect_cb,
- connect_closure_new (task_shell_sidebar, source));
+ e_activity_get_cancellable (closure->activity),
+ task_shell_sidebar_client_connect_cb, closure);
}
void