aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell.c75
-rw-r--r--shell/e-shell.h2
-rw-r--r--shell/main.c8
3 files changed, 63 insertions, 22 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 1e5fecfe67..e03efb49cf 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -606,7 +606,7 @@ shell_constructed (GObject *object)
shell_add_backend, object);
}
-static gboolean
+static UniqueResponse
shell_message_handle_new (EShell *shell,
UniqueMessageData *data)
{
@@ -616,10 +616,10 @@ shell_message_handle_new (EShell *shell,
e_shell_create_shell_window (shell, view_name);
g_free (view_name);
- return TRUE;
+ return UNIQUE_RESPONSE_OK;
}
-static gboolean
+static UniqueResponse
shell_message_handle_open (EShell *shell,
UniqueMessageData *data)
{
@@ -645,16 +645,21 @@ shell_message_handle_open (EShell *shell,
}
g_strfreev (uris);
- return TRUE;
+ return UNIQUE_RESPONSE_OK;
}
-static gboolean
+static UniqueResponse
shell_message_handle_close (EShell *shell,
UniqueMessageData *data)
{
- e_shell_quit (shell);
+ UniqueResponse response;
- return TRUE;
+ if (e_shell_quit (shell))
+ response = UNIQUE_RESPONSE_OK;
+ else
+ response = UNIQUE_RESPONSE_CANCEL;
+
+ return response;
}
static UniqueResponse
@@ -670,19 +675,13 @@ shell_message_received (UniqueApp *app,
break; /* use the default behavior */
case UNIQUE_NEW:
- if (shell_message_handle_new (shell, data))
- return UNIQUE_RESPONSE_OK;
- break;
+ return shell_message_handle_new (shell, data);
case UNIQUE_OPEN:
- if (shell_message_handle_open (shell, data))
- return UNIQUE_RESPONSE_OK;
- break;
+ return shell_message_handle_open (shell, data);
case UNIQUE_CLOSE:
- if (shell_message_handle_close (shell, data))
- return UNIQUE_RESPONSE_OK;
- break;
+ return shell_message_handle_close (shell, data);
default:
break;
@@ -1611,15 +1610,53 @@ e_shell_event (EShell *shell,
g_signal_emit (shell, signals[EVENT], detail, event_data);
}
-void
+/**
+ * e_shell_quit:
+ * @shell: an #EShell
+ *
+ * Requests an application shutdown. This happens in two phases: the
+ * first is synchronous, the second is asynchronous.
+ *
+ * In the first phase, the @shell emits a #EShell::quit-requested signal
+ * to potentially give the user a chance to cancel shutdown. If the user
+ * cancels shutdown, the function returns %FALSE. Otherwise it proceeds
+ * into the second phase.
+ *
+ * In the second phase, the @shell emits a #EShell::prepare-for-quit
+ * signal and immediately returns %TRUE. Signal handlers may delay the
+ * actual application shutdown while they clean up resources, but there
+ * is no way to cancel shutdown at this point.
+ *
+ * Consult the documentation for these two signals for details on how
+ * to handle them.
+ *
+ * Returns: %TRUE if shutdown is underway, %FALSE if it was cancelled
+ **/
+gboolean
e_shell_quit (EShell *shell)
{
- g_return_if_fail (E_IS_SHELL (shell));
+ UniqueApp *app;
+ UniqueResponse response;
+
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
+ app = UNIQUE_APP (shell);
+
+ if (unique_app_is_running (app))
+ goto unique;
if (!shell_request_quit (shell))
- return;
+ return FALSE;
shell_prepare_for_quit (shell);
+
+ return TRUE;
+
+unique: /* Send a message to the other Evolution process. */
+
+ response = unique_app_send_message (app, UNIQUE_CLOSE, NULL);
+
+ return (response == UNIQUE_RESPONSE_OK);
}
/**
diff --git a/shell/e-shell.h b/shell/e-shell.h
index 468cc3a6f1..94821bb2b8 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -106,7 +106,7 @@ GtkWidget * e_shell_get_preferences_window (EShell *shell);
void e_shell_event (EShell *shell,
const gchar *event_name,
gpointer event_data);
-void e_shell_quit (EShell *shell);
+gboolean e_shell_quit (EShell *shell);
void e_shell_cancel_quit (EShell *shell);
G_END_DECLS
diff --git a/shell/main.c b/shell/main.c
index e96620ab24..3e3268b673 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -87,7 +87,7 @@ static gboolean force_migrate = FALSE;
static gboolean disable_eplugin = FALSE;
static gboolean disable_preview = FALSE;
static gboolean import_uris = FALSE;
-static gboolean idle_cb (gchar **uris);
+static gboolean quit = FALSE;
static gchar *geometry = NULL;
static gchar *requested_view = NULL;
@@ -237,7 +237,9 @@ idle_cb (gchar **uris)
/* These calls do the right thing when another Evolution
* process is running. */
- if (uris != NULL && *uris != NULL) {
+ if (quit)
+ e_shell_quit (shell);
+ else if (uris != NULL && *uris != NULL) {
if (e_shell_handle_uris (shell, uris, import_uris) == 0)
gtk_main_quit ();
} else
@@ -334,6 +336,8 @@ static GOptionEntry entries[] = {
&setup_only, NULL, NULL },
{ "import", 'i', 0, G_OPTION_ARG_NONE, &import_uris,
N_("Import URIs or file names given as rest of arguments."), NULL },
+ { "quit", 'q', 0, G_OPTION_ARG_NONE, &quit,
+ N_("Request a running Evolution process to quit"), NULL },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, NULL },
{ NULL }
};