evolution r37157 - in branches/kill-bonobo: addressbook/gui/component addressbook/gui/contact-editor calendar/gui/dialogs calendar/modules composer doc/reference/shell doc/reference/shell/tmpl mail shell shell/test



Author: mbarnes
Date: Wed Jan 28 22:28:57 2009
New Revision: 37157
URL: http://svn.gnome.org/viewvc/evolution?rev=37157&view=rev

Log:
When invoking Evolution with URIs on the command-line (e.g. mailto:),
terminate after all the windows for those URIs have been closed.


Modified:
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-module.c
   branches/kill-bonobo/addressbook/gui/contact-editor/e-contact-editor.c
   branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c
   branches/kill-bonobo/calendar/modules/e-cal-shell-module.c
   branches/kill-bonobo/calendar/modules/e-memo-shell-module.c
   branches/kill-bonobo/calendar/modules/e-task-shell-module.c
   branches/kill-bonobo/composer/e-msg-composer.c
   branches/kill-bonobo/doc/reference/shell/eshell-sections.txt
   branches/kill-bonobo/doc/reference/shell/tmpl/e-shell.sgml
   branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml
   branches/kill-bonobo/mail/e-mail-browser.c
   branches/kill-bonobo/mail/e-mail-shell-module.c
   branches/kill-bonobo/shell/e-shell-window-private.c
   branches/kill-bonobo/shell/e-shell-window.c
   branches/kill-bonobo/shell/e-shell.c
   branches/kill-bonobo/shell/e-shell.h
   branches/kill-bonobo/shell/main.c
   branches/kill-bonobo/shell/test/e-test-shell-module.c

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-module.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-module.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -63,7 +63,7 @@
 void e_shell_module_init (GTypeModule *type_module);
 
 static void
-book_shell_module_ensure_sources (EShellModule *shell_module)
+book_module_ensure_sources (EShellModule *shell_module)
 {
 	/* XXX This is basically the same algorithm across all modules.
 	 *     Maybe we could somehow integrate this into EShellModule? */
@@ -193,7 +193,7 @@
 }
 
 static void
-book_shell_module_init_importers (void)
+book_module_init_importers (void)
 {
 	EImportClass *import_class;
 	EImportImporter *importer;
@@ -217,9 +217,9 @@
 }
 
 static void
-book_shell_module_book_loaded_cb (EBook *book,
-                                  EBookStatus status,
-                                  gpointer user_data)
+book_module_book_loaded_cb (EBook *book,
+                            EBookStatus status,
+                            gpointer user_data)
 {
 	EContact *contact;
 	GtkAction *action;
@@ -280,8 +280,7 @@
 	if (book == NULL)
 		book = e_book_new_default_addressbook (NULL);
 
-	e_book_async_open (
-		book, FALSE, book_shell_module_book_loaded_cb, action);
+	e_book_async_open (book, FALSE, book_module_book_loaded_cb, action);
 }
 
 static void
@@ -319,21 +318,21 @@
 };
 
 static gboolean
-book_shell_module_is_busy (EShellModule *shell_module)
+book_module_is_busy (EShellModule *shell_module)
 {
 	return !eab_editor_request_close_all ();
 }
 
 static gboolean
-book_shell_module_shutdown (EShellModule *shell_module)
+book_module_shutdown (EShellModule *shell_module)
 {
 	/* FIXME */
 	return TRUE;
 }
 
 static gboolean
-book_shell_module_handle_uri (EShellModule *shell_module,
-                              const gchar *uri)
+book_module_handle_uri_cb (EShellModule *shell_module,
+                           const gchar *uri)
 {
 	EUri *euri;
 	const gchar *cp;
@@ -398,19 +397,22 @@
 }
 
 static void
-book_shell_module_window_created (EShellModule *shell_module,
-                                  EShellWindow *shell_window)
+book_module_window_created_cb (EShellModule *shell_module,
+                               GtkWindow *window)
 {
 	const gchar *module_name;
 
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
+
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 }
 
@@ -422,8 +424,8 @@
 	MODULE_SORT_ORDER,
 
 	/* Methods */
-	book_shell_module_is_busy,
-	book_shell_module_shutdown,
+	book_module_is_busy,
+	book_module_shutdown,
 	e_book_shell_module_migrate
 };
 
@@ -447,18 +449,18 @@
 	certificate_manager_config_init ();
 #endif
 
-	book_shell_module_init_importers ();
-	book_shell_module_ensure_sources (shell_module);
+	book_module_init_importers ();
+	book_module_ensure_sources (shell_module);
 
 	e_plugin_hook_register_type (eab_config_get_type ());
 
 	g_signal_connect_swapped (
 		shell, "handle-uri",
-		G_CALLBACK (book_shell_module_handle_uri), shell_module);
+		G_CALLBACK (book_module_handle_uri_cb), shell_module);
 
 	g_signal_connect_swapped (
 		shell, "window-created",
-		G_CALLBACK (book_shell_module_window_created), shell_module);
+		G_CALLBACK (book_module_window_created_cb), shell_module);
 
 	autocompletion_config_init ();
 }

Modified: branches/kill-bonobo/addressbook/gui/contact-editor/e-contact-editor.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/contact-editor/e-contact-editor.c	(original)
+++ branches/kill-bonobo/addressbook/gui/contact-editor/e-contact-editor.c	Wed Jan 28 22:28:57 2009
@@ -52,6 +52,7 @@
 #include "misc/e-url-entry.h"
 #include "e-util/e-icon-factory.h"
 #include "e-util/e-util-private.h"
+#include "shell/e-shell.h"
 
 #include "eab-contact-merging.h"
 
@@ -3359,6 +3360,7 @@
 e_contact_editor_init (EContactEditor *e_contact_editor)
 {
 	GladeXML *gui;
+	EShell *shell;
 	GtkWidget *widget, *label;
 	GtkEntryCompletion *completion;
 	char *gladefile;
@@ -3436,6 +3438,10 @@
 
 	/* show window */
 	gtk_widget_show (e_contact_editor->app);
+
+	/* FIXME Shell should be passed in. */
+	shell = e_shell_get_default ();
+	e_shell_watch_window (shell, GTK_WINDOW (e_contact_editor->app));
 }
 
 static void

Modified: branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c
==============================================================================
--- branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c	(original)
+++ branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c	Wed Jan 28 22:28:57 2009
@@ -39,6 +39,7 @@
 #include <e-util/e-dialog-utils.h>
 #include <e-util/e-util-private.h>
 #include <e-util/gconf-bridge.h>
+#include <shell/e-shell.h>
 
 #include <camel/camel-url.h>
 #include <camel/camel-exception.h>
@@ -1780,6 +1781,7 @@
 	CompEditorPrivate *priv;
 	GtkActionGroup *action_group;
 	GtkAction *action;
+	EShell *shell;
 	GError *error = NULL;
 
 	editor->priv = priv = COMP_EDITOR_GET_PRIVATE (editor);
@@ -1871,6 +1873,10 @@
 	g_signal_connect(editor, "drag-motion", G_CALLBACK(drag_motion), editor);
 
 	gtk_window_set_type_hint (GTK_WINDOW (editor), GDK_WINDOW_TYPE_HINT_NORMAL);
+
+	/* FIXME Shell should be passed in. */
+	shell = e_shell_get_default ();
+	e_shell_watch_window (shell, GTK_WINDOW (editor));
 }
 
 static gboolean

Modified: branches/kill-bonobo/calendar/modules/e-cal-shell-module.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-cal-shell-module.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-cal-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -423,27 +423,30 @@
 }
 
 static gboolean
-cal_module_handle_uri (EShellModule *shell_module,
-                       const gchar *uri)
+cal_module_handle_uri_cb (EShellModule *shell_module,
+                          const gchar *uri)
 {
 	/* FIXME */
 	return FALSE;
 }
 
 static void
-cal_module_window_created (EShellModule *shell_module,
-                           EShellWindow *shell_window)
+cal_module_window_created_cb (EShellModule *shell_module,
+                              GtkWindow *window)
 {
 	const gchar *module_name;
 
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
+
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 }
 
@@ -476,11 +479,11 @@
 
 	g_signal_connect_swapped (
 		shell, "handle-uri",
-		G_CALLBACK (cal_module_handle_uri), shell_module);
+		G_CALLBACK (cal_module_handle_uri_cb), shell_module);
 
 	g_signal_connect_swapped (
 		shell, "window-created",
-		G_CALLBACK (cal_module_window_created), shell_module);
+		G_CALLBACK (cal_module_window_created_cb), shell_module);
 
 	cal_module_init_preferences ();
 }

Modified: branches/kill-bonobo/calendar/modules/e-memo-shell-module.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-memo-shell-module.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-memo-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -306,8 +306,8 @@
 };
 
 static gboolean
-memo_module_handle_uri (EShellModule *shell_module,
-                        const gchar *uri)
+memo_module_handle_uri_cb (EShellModule *shell_module,
+                           const gchar *uri)
 {
 	CompEditor *editor;
 	CompEditorFlags flags = 0;
@@ -443,19 +443,22 @@
 }
 
 static void
-memo_module_window_created (EShellModule *shell_module,
-                            EShellWindow *shell_window)
+memo_module_window_created_cb (EShellModule *shell_module,
+                               GtkWindow *window)
 {
 	const gchar *module_name;
 
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
+
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 }
 
@@ -488,9 +491,9 @@
 
 	g_signal_connect_swapped (
 		shell, "handle-uri",
-		G_CALLBACK (memo_module_handle_uri), shell_module);
+		G_CALLBACK (memo_module_handle_uri_cb), shell_module);
 
 	g_signal_connect_swapped (
 		shell, "window-created",
-		G_CALLBACK (memo_module_window_created), shell_module);
+		G_CALLBACK (memo_module_window_created_cb), shell_module);
 }

Modified: branches/kill-bonobo/calendar/modules/e-task-shell-module.c
==============================================================================
--- branches/kill-bonobo/calendar/modules/e-task-shell-module.c	(original)
+++ branches/kill-bonobo/calendar/modules/e-task-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -306,8 +306,8 @@
 };
 
 static gboolean
-task_module_handle_uri (EShellModule *shell_module,
-                        const gchar *uri)
+task_module_handle_uri_cb (EShellModule *shell_module,
+                           const gchar *uri)
 {
 	CompEditor *editor;
 	CompEditorFlags flags = 0;
@@ -449,19 +449,22 @@
 }
 
 static void
-task_module_window_created (EShellModule *shell_module,
-                            EShellWindow *shell_window)
+task_module_window_created_cb (EShellModule *shell_module,
+                               GtkWindow *window)
 {
 	const gchar *module_name;
 
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
+
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 }
 
@@ -494,9 +497,9 @@
 
 	g_signal_connect_swapped (
 		shell, "handle-uri",
-		G_CALLBACK (task_module_handle_uri), shell_module);
+		G_CALLBACK (task_module_handle_uri_cb), shell_module);
 
 	g_signal_connect_swapped (
 		shell, "window-created",
-		G_CALLBACK (task_module_window_created), shell_module);
+		G_CALLBACK (task_module_window_created_cb), shell_module);
 }

Modified: branches/kill-bonobo/composer/e-msg-composer.c
==============================================================================
--- branches/kill-bonobo/composer/e-msg-composer.c	(original)
+++ branches/kill-bonobo/composer/e-msg-composer.c	Wed Jan 28 22:28:57 2009
@@ -2115,7 +2115,7 @@
 		G_OBJECT (shell_settings), "composer-magic-smileys",
 		G_OBJECT (composer), "magic-smileys");
 
-	e_shell_event (shell, "new-editor", object);
+	e_shell_watch_window (shell, GTK_WINDOW (object));
 
 	return object;
 }

Modified: branches/kill-bonobo/doc/reference/shell/eshell-sections.txt
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/eshell-sections.txt	(original)
+++ branches/kill-bonobo/doc/reference/shell/eshell-sections.txt	Wed Jan 28 22:28:57 2009
@@ -4,13 +4,14 @@
 EShell
 e_shell_get_default
 e_shell_get_shell_modules
-e_shell_get_shell_windows
 e_shell_get_canonical_name
 e_shell_get_module_by_name
 e_shell_get_module_by_scheme
 e_shell_get_shell_settings
 e_shell_create_shell_window
-e_shell_handle_uri
+e_shell_handle_uris
+e_shell_watch_window
+e_shell_get_watched_windows
 e_shell_send_receive
 e_shell_get_network_available
 e_shell_set_network_available

Modified: branches/kill-bonobo/doc/reference/shell/tmpl/e-shell.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/e-shell.sgml	(original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/e-shell.sgml	Wed Jan 28 22:28:57 2009
@@ -111,16 +111,17 @@
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_get_shell_windows ##### -->
+<!-- ##### FUNCTION e_shell_get_canonical_name ##### -->
 <para>
 
 </para>
 
 @shell: 
+ name: 
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_get_canonical_name ##### -->
+<!-- ##### FUNCTION e_shell_get_module_by_name ##### -->
 <para>
 
 </para>
@@ -130,51 +131,60 @@
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_get_module_by_name ##### -->
+<!-- ##### FUNCTION e_shell_get_module_by_scheme ##### -->
 <para>
 
 </para>
 
 @shell: 
- name: 
+ scheme: 
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_get_module_by_scheme ##### -->
+<!-- ##### FUNCTION e_shell_get_shell_settings ##### -->
 <para>
 
 </para>
 
 @shell: 
- scheme: 
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_get_shell_settings ##### -->
+<!-- ##### FUNCTION e_shell_create_shell_window ##### -->
 <para>
 
 </para>
 
 @shell: 
+ view_name: 
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_create_shell_window ##### -->
+<!-- ##### FUNCTION e_shell_handle_uris ##### -->
 <para>
 
 </para>
 
 @shell: 
+ uris: 
 @Returns: 
 
 
-<!-- ##### FUNCTION e_shell_handle_uri ##### -->
+<!-- ##### FUNCTION e_shell_watch_window ##### -->
+<para>
+
+</para>
+
+ shell: 
+ window: 
+
+
+<!-- ##### FUNCTION e_shell_get_watched_windows ##### -->
 <para>
 
 </para>
 
 @shell: 
- uri: 
 @Returns: 
 
 

Modified: branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml
==============================================================================
--- branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml	(original)
+++ branches/kill-bonobo/doc/reference/shell/tmpl/eshell-unused.sgml	Wed Jan 28 22:28:57 2009
@@ -1769,6 +1769,23 @@
 @shell: 
 @Returns: 
 
+<!-- ##### FUNCTION e_shell_get_shell_windows ##### -->
+<para>
+
+</para>
+
+ shell: 
+ Returns: 
+
+<!-- ##### FUNCTION e_shell_handle_uri ##### -->
+<para>
+
+</para>
+
+ shell: 
+ uri: 
+ Returns: 
+
 <!-- ##### FUNCTION e_shell_list_modules ##### -->
 <para>
 

Modified: branches/kill-bonobo/mail/e-mail-browser.c
==============================================================================
--- branches/kill-bonobo/mail/e-mail-browser.c	(original)
+++ branches/kill-bonobo/mail/e-mail-browser.c	Wed Jan 28 22:28:57 2009
@@ -27,6 +27,7 @@
 
 #include "e-util/e-util.h"
 #include "e-util/gconf-bridge.h"
+#include "shell/e-shell.h"
 
 #include "mail/e-mail-reader.h"
 #include "mail/e-mail-reader-utils.h"
@@ -321,6 +322,8 @@
 {
 	EMailBrowserPrivate *priv;
 	EMailReader *reader;
+	EShellModule *shell_module;
+	EShell *shell;
 	GtkAccelGroup *accel_group;
 	GtkActionGroup *action_group;
 	GtkUIManager *ui_manager;
@@ -337,6 +340,10 @@
 
 	e_mail_reader_init (reader);
 
+	shell_module = e_mail_reader_get_shell_module (reader);
+	shell = e_shell_module_get_shell (shell_module);
+	e_shell_watch_window (shell, GTK_WINDOW (object));
+
 	action_group = priv->action_group;
 	gtk_action_group_set_translation_domain (action_group, domain);
 	gtk_action_group_add_actions (

Modified: branches/kill-bonobo/mail/e-mail-shell-module.c
==============================================================================
--- branches/kill-bonobo/mail/e-mail-shell-module.c	(original)
+++ branches/kill-bonobo/mail/e-mail-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -556,18 +556,6 @@
 }
 
 static void
-mail_shell_module_event_new_editor_cb (EShell *shell,
-                                       GtkWindow *editor,
-                                       EShellModule *shell_module)
-{
-	if (!E_IS_MSG_COMPOSER (editor))
-		return;
-
-	/* Integrate the new composer into the mail module. */
-	em_configure_new_composer (E_MSG_COMPOSER (editor));
-}
-
-static void
 mail_shell_module_notify_online_mode_cb (EShell *shell,
                                          GParamSpec *pspec,
                                          EShellModule *shell_module)
@@ -702,13 +690,13 @@
                                           EActivity *activity,
                                           EShellModule *shell_module)
 {
-	GList *shell_windows;
+	GList *watched_windows;
 	GtkWidget *parent = NULL;
 	gboolean synchronize = FALSE;
 
-	shell_windows = e_shell_get_shell_windows (shell);
-	if (shell_windows != NULL)
-		parent = GTK_WIDGET (shell_windows->data);
+	watched_windows = e_shell_get_watched_windows (shell);
+	if (watched_windows != NULL)
+		parent = GTK_WIDGET (watched_windows->data);
 
 	if (e_shell_get_network_available (shell))
 		synchronize = em_utils_prompt_user (
@@ -771,33 +759,42 @@
 
 static void
 mail_shell_module_window_created_cb (EShell *shell,
-                                     EShellWindow *shell_window,
+                                     GtkWindow *window,
                                      EShellModule *shell_module)
 {
 	static gboolean first_time = TRUE;
 	const gchar *module_name;
 
+	if (E_IS_MSG_COMPOSER (window)) {
+		/* Integrate the new composer into the mail module. */
+		em_configure_new_composer (E_MSG_COMPOSER (window));
+		return;
+	}
+
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
+
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 
 	g_signal_connect_swapped (
 		shell, "event::mail-icon",
-		G_CALLBACK (mail_shell_module_mail_icon_cb), shell_window);
+		G_CALLBACK (mail_shell_module_mail_icon_cb), window);
 
 	g_object_weak_ref (
-		G_OBJECT (shell_window), (GWeakNotify)
+		G_OBJECT (window), (GWeakNotify)
 		mail_shell_module_window_weak_notify_cb, shell);
 
 	if (first_time) {
 		g_signal_connect (
-			shell_window, "map-event",
+			window, "map-event",
 			G_CALLBACK (e_msg_composer_check_autosave), NULL);
 		first_time = FALSE;
 	}
@@ -850,11 +847,6 @@
 	folder_tree_model = em_folder_tree_model_new (shell_module);
 
 	g_signal_connect (
-		shell, "event::new-editor",
-		G_CALLBACK (mail_shell_module_event_new_editor_cb),
-		shell_module);
-
-	g_signal_connect (
 		shell, "notify::online-mode",
 		G_CALLBACK (mail_shell_module_notify_online_mode_cb),
 		shell_module);

Modified: branches/kill-bonobo/shell/e-shell-window-private.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window-private.c	(original)
+++ branches/kill-bonobo/shell/e-shell-window-private.c	Wed Jan 28 22:28:57 2009
@@ -340,6 +340,8 @@
 	shell = e_shell_window_get_shell (shell_window);
 	shell_settings = e_shell_get_shell_settings (shell);
 
+	e_shell_watch_window (shell, GTK_WINDOW (shell_window));
+
 	/* Create the switcher actions before we set the initial
 	 * shell view, because the shell view relies on them for
 	 * default settings during construction. */

Modified: branches/kill-bonobo/shell/e-shell-window.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window.c	(original)
+++ branches/kill-bonobo/shell/e-shell-window.c	Wed Jan 28 22:28:57 2009
@@ -132,17 +132,22 @@
 shell_window_update_close_action_cb (EShellWindow *shell_window)
 {
 	EShell *shell;
-	GList *shell_windows;
-	gboolean sensitive;
+	GList *watched_windows;
+	gint n_shell_windows = 0;
 
 	shell = e_shell_window_get_shell (shell_window);
-	shell_windows = e_shell_get_shell_windows (shell);
-	g_return_if_fail (shell_windows != NULL);
+	watched_windows = e_shell_get_watched_windows (shell);
 
-	/* Disable Close Window if there's only one window.
+	/* Count the shell windows. */
+	while (watched_windows != NULL) {
+		if (E_IS_SHELL_WINDOW (watched_windows->data))
+			n_shell_windows++;
+		watched_windows = g_list_next (watched_windows);
+	}
+
+	/* Disable Close Window if there's only one shell window.
 	 * Helps prevent users from accidentally quitting. */
-	sensitive = (g_list_length (shell_windows) > 1);
-	gtk_action_set_sensitive (ACTION (CLOSE), sensitive);
+	gtk_action_set_sensitive (ACTION (CLOSE), n_shell_windows > 1);
 }
 
 static void

Modified: branches/kill-bonobo/shell/e-shell.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell.c	(original)
+++ branches/kill-bonobo/shell/e-shell.c	Wed Jan 28 22:28:57 2009
@@ -38,7 +38,7 @@
 	((obj), E_TYPE_SHELL, EShellPrivate))
 
 struct _EShellPrivate {
-	GList *active_windows;
+	GList *watched_windows;
 	EShellSettings *settings;
 
 	/* Shell Modules */
@@ -101,12 +101,21 @@
 		e_shell_settings_enable_debug (shell->priv->settings);
 }
 
+static void
+shell_notify_online_mode_cb (EShell *shell)
+{
+	gboolean online;
+
+	online = e_shell_get_online_mode (shell);
+	e_passwords_set_online (online);
+}
+
 static gboolean
 shell_window_delete_event_cb (EShell *shell,
-                              EShellWindow *shell_window)
+                              GtkWindow *window)
 {
 	/* If other windows are open we can safely close this one. */
-	if (g_list_length (shell->priv->active_windows) > 1)
+	if (g_list_length (shell->priv->watched_windows) > 1)
 		return FALSE;
 
 	/* Otherwise we initiate application shutdown. */
@@ -116,16 +125,16 @@
 static gboolean
 shell_window_focus_in_event_cb (EShell *shell,
                                 GdkEventFocus *event,
-                                EShellWindow *shell_window)
+                                GtkWindow *window)
 {
 	GList *list, *link;
 
-	/* Keep the active windows list sorted by most recently focused,
+	/* Keep the watched windows list sorted by most recently focused,
 	 * so the first item in the list should always be the currently
-	 * focused shell window. */
+	 * focused window. */
 
-	list = shell->priv->active_windows;
-	link = g_list_find (list, shell_window);
+	list = shell->priv->watched_windows;
+	link = g_list_find (list, window);
 	g_return_val_if_fail (link != NULL, FALSE);
 
 	if (link != list) {
@@ -133,29 +142,20 @@
 		list = g_list_concat (link, list);
 	}
 
-	shell->priv->active_windows = list;
+	shell->priv->watched_windows = list;
 
 	return FALSE;
 }
 
 static void
-shell_notify_online_mode_cb (EShell *shell)
-{
-	gboolean online;
-
-	online = e_shell_get_online_mode (shell);
-	e_passwords_set_online (online);
-}
-
-static void
 shell_window_weak_notify_cb (EShell *shell,
                              GObject *where_the_object_was)
 {
-	GList *active_windows;
+	GList *list;
 
-	active_windows = shell->priv->active_windows;
-	active_windows = g_list_remove (active_windows, where_the_object_was);
-	shell->priv->active_windows = active_windows;
+	list = shell->priv->watched_windows;
+	list = g_list_remove (list, where_the_object_was);
+	shell->priv->watched_windows = list;
 
 	g_signal_emit (shell, signals[WINDOW_DESTROYED], 0);
 }
@@ -380,7 +380,7 @@
 	 * the act of destroying a shell window will modify the active
 	 * windows list, which would otherwise derail the iteration. */
 	if (proceed) {
-		list = g_list_copy (shell->priv->active_windows);
+		list = g_list_copy (shell->priv->watched_windows);
 		g_list_foreach (list, (GFunc) gtk_widget_destroy, NULL);
 		g_list_free (list);
 
@@ -748,9 +748,9 @@
 	/**
 	 * EShell::window-created
 	 * @shell: the #EShell which emitted the signal
-	 * @shell_window: the newly created #EShellWindow
+	 * @window: the newly created #GtkWindow
 	 *
-	 * Emitted when a new #EShellWindow is created.
+	 * Emitted when @shell begins watching a newly created window.
 	 **/
 	signals[WINDOW_CREATED] = g_signal_new (
 		"window-created",
@@ -759,7 +759,7 @@
 		0, NULL, NULL,
 		g_cclosure_marshal_VOID__OBJECT,
 		G_TYPE_NONE, 1,
-		E_TYPE_SHELL_WINDOW);
+		GTK_TYPE_WINDOW);
 
 	/**
 	 * EShell::window-destroyed
@@ -896,6 +896,9 @@
  *
  * Returns the #EShell created by <function>main()</function>.
  *
+ * Try to obtain the #EShell from elsewhere if you can.  This function
+ * is intended as a temporary workaround for when that proves difficult.
+ *
  * Returns: the #EShell singleton
  **/
 EShell *
@@ -925,26 +928,6 @@
 }
 
 /**
- * e_shell_get_shell_windows:
- * @shell: an #EShell
- *
- * Returns a list of active #EShellWindow instances that were created by
- * e_shell_create_shell_window().  The list is sorted by the most recently
- * focused window, such that the first instance is the currently focused
- * window.  (Useful for choosing a parent for a transient window.)  The
- * list is owned by @shell and should not be modified or freed.
- *
- * Returns: a list of active #EShellWindow instances
- **/
-GList *
-e_shell_get_shell_windows (EShell *shell)
-{
-	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
-
-	return shell->priv->active_windows;
-}
-
-/**
  * e_shell_get_canonical_name:
  * @shell: an #EShell
  * @name: the name or alias of an #EShellModule
@@ -1052,7 +1035,6 @@
 e_shell_create_shell_window (EShell *shell,
                              const gchar *view_name)
 {
-	GList *active_windows;
 	GtkWidget *shell_window;
 	UniqueMessageData *data;
 	UniqueApp *app;
@@ -1085,25 +1067,6 @@
 	}
 
 	shell_window = e_shell_window_new (shell, shell->priv->safe_mode);
-	unique_app_watch_window (app, GTK_WINDOW (shell_window));
-
-	active_windows = shell->priv->active_windows;
-	active_windows = g_list_prepend (active_windows, shell_window);
-	shell->priv->active_windows = active_windows;
-
-	g_signal_connect_swapped (
-		shell_window, "delete-event",
-		G_CALLBACK (shell_window_delete_event_cb), shell);
-
-	g_signal_connect_swapped (
-		shell_window, "focus-in-event",
-		G_CALLBACK (shell_window_focus_in_event_cb), shell);
-
-	g_object_weak_ref (
-		G_OBJECT (shell_window), (GWeakNotify)
-		shell_window_weak_notify_cb, shell);
-
-	g_signal_emit (shell, signals[WINDOW_CREATED], 0, shell_window);
 
 	gtk_widget_show (shell_window);
 
@@ -1135,7 +1098,7 @@
  **/
 guint
 e_shell_handle_uris (EShell *shell,
-                     const gchar **uris)
+                     gchar **uris)
 {
 	UniqueApp *app;
 	UniqueMessageData *data;
@@ -1163,11 +1126,10 @@
 
 unique:  /* Send a message to the other Evolution process. */
 
-	/* XXX Do something with UniqueResponse?
-	 * XXX set_uris() should take a "const" URI list. */
+	/* XXX Do something with UniqueResponse? */
 
 	data = unique_message_data_new ();
-	unique_message_data_set_uris (data, (gchar **) uris);
+	unique_message_data_set_uris (data, uris);
 	unique_app_send_message (app, UNIQUE_OPEN, data);
 	unique_message_data_free (data);
 
@@ -1175,6 +1137,71 @@
 }
 
 /**
+ * e_shell_watch_window:
+ * @shell: an #EShell
+ * @window: a #GtkWindow
+ *
+ * Makes @shell "watch" a newly created toplevel window, and emits the
+ * #EShell::window-created signal.  All #EShellWindow<!-- -->s should be
+ * watched, along with any editor or viewer windows that may be shown in
+ * response to e_shell_handle_uris().  When the last watched window is
+ * closed, Evolution terminates.
+ **/
+void
+e_shell_watch_window (EShell *shell,
+                      GtkWindow *window)
+{
+	GList *list;
+
+	g_return_if_fail (E_IS_SHELL (shell));
+	g_return_if_fail (GTK_IS_WINDOW (window));
+
+	list = shell->priv->watched_windows;
+
+	/* Ignore duplicates. */
+	if (g_list_find (list, window) != NULL)
+		return;
+
+	list = g_list_prepend (list, window);
+	shell->priv->watched_windows = list;
+
+	unique_app_watch_window (UNIQUE_APP (shell), window);
+
+	g_signal_connect_swapped (
+		window, "delete-event",
+		G_CALLBACK (shell_window_delete_event_cb), shell);
+
+	g_signal_connect_swapped (
+		window, "focus-in-event",
+		G_CALLBACK (shell_window_focus_in_event_cb), shell);
+
+	g_object_weak_ref (
+		G_OBJECT (window), (GWeakNotify)
+		shell_window_weak_notify_cb, shell);
+
+	g_signal_emit (shell, signals[WINDOW_CREATED], 0, window);
+}
+
+/**
+ * e_shell_get_watched_windows:
+ * @shell: an #EShell
+ *
+ * Returns a list of windows being watched by @shell.  The list is sorted
+ * by the most recently focused window, such that the first instance is the
+ * currently focused window.  (Useful for choosing a parent for a transient
+ * window.)  The list is owned by @shell and should not be modified or freed.
+ *
+ * Returns: a list of watched windows
+ **/
+GList *
+e_shell_get_watched_windows (EShell *shell)
+{
+	g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+	return shell->priv->watched_windows;
+}
+
+/**
  * e_shell_send_receive:
  * @shell: an #EShell
  * @parent: the parent #GtkWindow

Modified: branches/kill-bonobo/shell/e-shell.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell.h	(original)
+++ branches/kill-bonobo/shell/e-shell.h	Wed Jan 28 22:28:57 2009
@@ -78,7 +78,6 @@
 GType		e_shell_get_type		(void);
 EShell *	e_shell_get_default		(void);
 GList *		e_shell_get_shell_modules	(EShell *shell);
-GList *		e_shell_get_shell_windows	(EShell *shell);
 const gchar *	e_shell_get_canonical_name	(EShell *shell,
 						 const gchar *name);
 EShellModule *	e_shell_get_module_by_name	(EShell *shell,
@@ -89,7 +88,10 @@
 GtkWidget *	e_shell_create_shell_window	(EShell *shell,
 						 const gchar *view_name);
 guint		e_shell_handle_uris		(EShell *shell,
-                                                 const gchar **uris);
+						 gchar **uris);
+void		e_shell_watch_window		(EShell *shell,
+						 GtkWindow *window);
+GList *		e_shell_get_watched_windows	(EShell *shell);
 void		e_shell_send_receive		(EShell *shell,
 						 GtkWindow *parent);
 gboolean	e_shell_get_network_available	(EShell *shell);

Modified: branches/kill-bonobo/shell/main.c
==============================================================================
--- branches/kill-bonobo/shell/main.c	(original)
+++ branches/kill-bonobo/shell/main.c	Wed Jan 28 22:28:57 2009
@@ -306,7 +306,6 @@
 idle_cb (gchar **uris)
 {
 	EShell *shell;
-	guint ii;
 
 #ifdef KILL_PROCESS_CMD
 	kill_old_dataserver ();
@@ -314,23 +313,21 @@
 
 	shell = e_shell_get_default ();
 
-	/* These calls do the right thing when there's another
-	 * Evolution process running. */
+	/* These calls do the right thing when another Evolution
+	 * process is running. */
 	if (uris != NULL && *uris != NULL)
 		e_shell_handle_uris (shell, uris);
 	else
 		e_shell_create_shell_window (shell, requested_view);
 
-	if (unique_app_is_running (UNIQUE_APP (shell))) {
+	/* If another Evolution process is running, we're done. */
+	if (unique_app_is_running (UNIQUE_APP (shell)))
 		gtk_main_quit ();
-		return FALSE;
-	}
 
 	/* This must be done after EShell has loaded all the modules.
 	 * For example the mail module makes the global variable `session`
 	 * which is being used by several EPlugins */
-
-	if (uris == NULL && !disable_eplugin)
+	else if (uris == NULL && !disable_eplugin)
 		e_plugin_load_plugins_with_missing_symbols ();
 
 	return FALSE;
@@ -471,7 +468,7 @@
 static void
 shell_window_destroyed_cb (EShell *shell)
 {
-	if (e_shell_get_shell_windows (shell) == NULL)
+	if (e_shell_get_watched_windows (shell) == NULL)
 		gtk_main_quit ();
 }
 

Modified: branches/kill-bonobo/shell/test/e-test-shell-module.c
==============================================================================
--- branches/kill-bonobo/shell/test/e-test-shell-module.c	(original)
+++ branches/kill-bonobo/shell/test/e-test-shell-module.c	Wed Jan 28 22:28:57 2009
@@ -115,20 +115,23 @@
 
 static void
 test_module_window_created_cb (EShellModule *shell_module,
-                               EShellWindow *shell_window)
+                               GtkWindow *window)
 {
 	const gchar *module_name;
 
-	g_debug ("%s (window=%p)", G_STRFUNC, shell_window);
+	g_debug ("%s (%s)", G_STRFUNC, G_OBJECT_TYPE_NAME (window));
+
+	if (!E_IS_SHELL_WINDOW (window))
+		return;
 
 	module_name = G_TYPE_MODULE (shell_module)->name;
 
 	e_shell_window_register_new_item_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		item_entries, G_N_ELEMENTS (item_entries));
 
 	e_shell_window_register_new_source_actions (
-		shell_window, module_name,
+		E_SHELL_WINDOW (window), module_name,
 		source_entries, G_N_ELEMENTS (source_entries));
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]