From 04aac07030e328e481df060d4b045b7e6d6117c1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 26 Nov 2009 13:29:21 -0500 Subject: Make EShell more subclassable. Add method pointers to EShellClass for all the EShell signals. Also rework my previous --quit corner case workaround: we'll want to do the full shutdown procedure after all, since the backends have already spun up. --- shell/e-shell.c | 53 ++++++++++++++++++++++++++++++++++------------------- shell/e-shell.h | 18 ++++++++++++++++++ shell/main.c | 11 ----------- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/shell/e-shell.c b/shell/e-shell.c index 38a232ba1a..544b960e6c 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -304,6 +304,15 @@ shell_ready_for_quit (EShell *shell, g_message ("Quit preparations complete."); + /* This handles a strange corner case where --quit is given on + * the command-line but no other Evolution process is running. + * We bring all the shell backends up and then immediately run + * the shutdown procedure, which gets us here. But because no + * windows have been shown yet, the usual "main loop ends when + * the last window is destroyed" trick won't work. */ + if (e_shell_get_watched_windows (shell) == NULL) + gtk_main_quit (); + /* Destroy all watched windows. Note, we iterate over a -copy- * of the watched windows list because the act of destroying a * watched window will modify the watched windows list, which @@ -692,6 +701,13 @@ shell_message_received (UniqueApp *app, message_received (app, command, data, time_); } +static void +shell_window_destroyed (EShell *shell) +{ + if (e_shell_get_watched_windows (shell) == NULL) + gtk_main_quit (); +} + static void shell_class_init (EShellClass *class) { @@ -711,6 +727,8 @@ shell_class_init (EShellClass *class) unique_app_class = UNIQUE_APP_CLASS (class); unique_app_class->message_received = shell_message_received; + class->window_destroyed = shell_window_destroyed; + /** * EShell:geometry * @@ -809,7 +827,8 @@ shell_class_init (EShellClass *class) "handle-uri", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - 0, g_signal_accumulator_true_handled, NULL, + G_STRUCT_OFFSET (EShellClass, handle_uri), + g_signal_accumulator_true_handled, NULL, e_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1, G_TYPE_STRING); @@ -834,7 +853,8 @@ shell_class_init (EShellClass *class) "prepare-for-offline", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, prepare_for_offline), + NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, E_TYPE_ACTIVITY); @@ -859,7 +879,8 @@ shell_class_init (EShellClass *class) "prepare-for-online", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, prepare_for_online), + NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, E_TYPE_ACTIVITY); @@ -884,7 +905,8 @@ shell_class_init (EShellClass *class) "prepare-for-quit", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, prepare_for_quit), + NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, E_TYPE_ACTIVITY); @@ -906,7 +928,8 @@ shell_class_init (EShellClass *class) "quit-requested", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, quit_requested), + NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); @@ -922,7 +945,8 @@ shell_class_init (EShellClass *class) "send-receive", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, send_receive), + NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WINDOW); @@ -938,7 +962,8 @@ shell_class_init (EShellClass *class) "window-created", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, window_created), + NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_WINDOW); @@ -953,7 +978,8 @@ shell_class_init (EShellClass *class) "window-destroyed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_LAST, - 0, NULL, NULL, + G_STRUCT_OFFSET (EShellClass, window_destroyed), + NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } @@ -1645,11 +1671,6 @@ e_shell_quit (EShell *shell) if (unique_app_is_running (app)) goto unique; - /* This handles the case where a --quit command-line option - * was given and no other Evolution process is running. */ - if (e_shell_get_watched_windows (shell) == NULL) - goto bypass; - if (!shell_request_quit (shell)) return FALSE; @@ -1657,12 +1678,6 @@ e_shell_quit (EShell *shell) return TRUE; -bypass: /* Bypass our usual shutdown procedure. */ - - gtk_main_quit (); - - return TRUE; - unique: /* Send a message to the other Evolution process. */ response = unique_app_send_message (app, UNIQUE_CLOSE, NULL); diff --git a/shell/e-shell.h b/shell/e-shell.h index 94821bb2b8..7d1904a828 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -30,6 +30,9 @@ #include #include + +#include + #include #include #include @@ -72,6 +75,21 @@ struct _EShell { struct _EShellClass { UniqueAppClass parent_class; + + gboolean (*handle_uri) (EShell *shell, + const gchar *uri); + void (*prepare_for_offline) (EShell *shell, + EActivity *activity); + void (*prepare_for_online) (EShell *shell, + EActivity *activity); + void (*prepare_for_quit) (EShell *shell, + EActivity *activity); + void (*quit_requested) (EShell *shell); + void (*send_receive) (EShell *shell, + GtkWindow *parent); + void (*window_created) (EShell *shell, + GtkWindow *window); + void (*window_destroyed) (EShell *shell); }; GType e_shell_get_type (void); diff --git a/shell/main.c b/shell/main.c index 3e3268b673..396cd690fa 100644 --- a/shell/main.c +++ b/shell/main.c @@ -414,13 +414,6 @@ shell_force_shutdown (void) g_assert_not_reached (); } -static void -shell_window_destroyed_cb (EShell *shell) -{ - if (e_shell_get_watched_windows (shell) == NULL) - gtk_main_quit (); -} - static void create_default_shell (void) { @@ -462,10 +455,6 @@ create_default_shell (void) "online", online, NULL); - g_signal_connect ( - shell, "window-destroyed", - G_CALLBACK (shell_window_destroyed_cb), NULL); - g_object_unref (client); /* EShell keeps its own reference to the first instance for use -- cgit v1.2.3