aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-29 06:28:57 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-29 06:28:57 +0800
commit70fce0bbb0712dc70a15c481c0b65d68a98a4ff7 (patch)
tree51b39245f74e32ac2878e4f65492e895a1ad0eb8
parent533d59e2cd30ba79a99a71907ffdda65505e633a (diff)
downloadgsoc2013-evolution-70fce0bbb0712dc70a15c481c0b65d68a98a4ff7.tar.gz
gsoc2013-evolution-70fce0bbb0712dc70a15c481c0b65d68a98a4ff7.tar.zst
gsoc2013-evolution-70fce0bbb0712dc70a15c481c0b65d68a98a4ff7.zip
When invoking Evolution with URIs on the command-line (e.g. mailto:),
terminate after all the windows for those URIs have been closed. svn path=/branches/kill-bonobo/; revision=37157
-rw-r--r--addressbook/gui/component/e-book-shell-module.c44
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c6
-rw-r--r--calendar/gui/dialogs/comp-editor.c6
-rw-r--r--calendar/modules/e-cal-shell-module.c19
-rw-r--r--calendar/modules/e-memo-shell-module.c19
-rw-r--r--calendar/modules/e-task-shell-module.c19
-rw-r--r--composer/e-msg-composer.c2
-rw-r--r--doc/reference/shell/eshell-sections.txt5
-rw-r--r--doc/reference/shell/tmpl/e-shell.sgml30
-rw-r--r--doc/reference/shell/tmpl/eshell-unused.sgml17
-rw-r--r--mail/e-mail-browser.c7
-rw-r--r--mail/e-mail-shell-module.c46
-rw-r--r--shell/e-shell-window-private.c2
-rw-r--r--shell/e-shell-window.c19
-rw-r--r--shell/e-shell.c167
-rw-r--r--shell/e-shell.h6
-rw-r--r--shell/main.c15
-rw-r--r--shell/test/e-test-shell-module.c11
18 files changed, 263 insertions, 177 deletions
diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c
index b538c59559..139f55ffd4 100644
--- a/addressbook/gui/component/e-book-shell-module.c
+++ b/addressbook/gui/component/e-book-shell-module.c
@@ -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 @@ book_shell_module_ensure_sources (EShellModule *shell_module)
}
static void
-book_shell_module_init_importers (void)
+book_module_init_importers (void)
{
EImportClass *import_class;
EImportImporter *importer;
@@ -217,9 +217,9 @@ book_shell_module_init_importers (void)
}
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 @@ action_contact_new_cb (GtkAction *action,
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 GtkActionEntry source_entries[] = {
};
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 @@ book_shell_module_handle_uri (EShellModule *shell_module,
}
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 @@ static EShellModuleInfo module_info = {
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 @@ e_shell_module_init (GTypeModule *type_module)
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 ();
}
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index e5686d3f76..8499e774db 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -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 @@ static void
e_contact_editor_init (EContactEditor *e_contact_editor)
{
GladeXML *gui;
+ EShell *shell;
GtkWidget *widget, *label;
GtkEntryCompletion *completion;
char *gladefile;
@@ -3436,6 +3438,10 @@ e_contact_editor_init (EContactEditor *e_contact_editor)
/* 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
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index e9967eccaf..3e6fc65aad 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -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 @@ comp_editor_init (CompEditor *editor)
CompEditorPrivate *priv;
GtkActionGroup *action_group;
GtkAction *action;
+ EShell *shell;
GError *error = NULL;
editor->priv = priv = COMP_EDITOR_GET_PRIVATE (editor);
@@ -1871,6 +1873,10 @@ comp_editor_init (CompEditor *editor)
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
diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c
index d4fed663be..176b8d04bc 100644
--- a/calendar/modules/e-cal-shell-module.c
+++ b/calendar/modules/e-cal-shell-module.c
@@ -423,27 +423,30 @@ cal_module_init_preferences (void)
}
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 @@ e_shell_module_init (GTypeModule *type_module)
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 ();
}
diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c
index a82a8c5235..5e8f9a53bf 100644
--- a/calendar/modules/e-memo-shell-module.c
+++ b/calendar/modules/e-memo-shell-module.c
@@ -306,8 +306,8 @@ static GtkActionEntry source_entries[] = {
};
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 @@ exit:
}
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 @@ e_shell_module_init (GTypeModule *type_module)
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);
}
diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c
index 80cfc0a61a..76db5b056b 100644
--- a/calendar/modules/e-task-shell-module.c
+++ b/calendar/modules/e-task-shell-module.c
@@ -306,8 +306,8 @@ static GtkActionEntry source_entries[] = {
};
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 @@ exit:
}
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 @@ e_shell_module_init (GTypeModule *type_module)
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);
}
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 1e219badee..dee28d0691 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -2115,7 +2115,7 @@ msg_composer_constructor (GType type,
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;
}
diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt
index 79575ed74d..7fd48d7538 100644
--- a/doc/reference/shell/eshell-sections.txt
+++ b/doc/reference/shell/eshell-sections.txt
@@ -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
diff --git a/doc/reference/shell/tmpl/e-shell.sgml b/doc/reference/shell/tmpl/e-shell.sgml
index 1b96f4a40d..f43136be2f 100644
--- a/doc/reference/shell/tmpl/e-shell.sgml
+++ b/doc/reference/shell/tmpl/e-shell.sgml
@@ -111,16 +111,17 @@ EShell
@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 @@ EShell
@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:
diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml
index d8c74f0d7b..84203c957d 100644
--- a/doc/reference/shell/tmpl/eshell-unused.sgml
+++ b/doc/reference/shell/tmpl/eshell-unused.sgml
@@ -1769,6 +1769,23 @@ intelligent
@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>
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index ad736236cf..0bc40f13ab 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -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 @@ mail_browser_constructed (GObject *object)
{
EMailBrowserPrivate *priv;
EMailReader *reader;
+ EShellModule *shell_module;
+ EShell *shell;
GtkAccelGroup *accel_group;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
@@ -337,6 +340,10 @@ mail_browser_constructed (GObject *object)
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 (
diff --git a/mail/e-mail-shell-module.c b/mail/e-mail-shell-module.c
index 680c994aec..760eca6ab7 100644
--- a/mail/e-mail-shell-module.c
+++ b/mail/e-mail-shell-module.c
@@ -556,18 +556,6 @@ exit:
}
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 @@ mail_shell_module_prepare_for_offline_cb (EShell *shell,
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 @@ mail_shell_module_window_weak_notify_cb (EShell *shell,
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 @@ e_shell_module_init (GTypeModule *type_module)
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);
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index 53f7c28c64..02aac6cf10 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -340,6 +340,8 @@ e_shell_window_private_constructed (EShellWindow *shell_window)
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. */
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 82727fecdd..ecc30cb9b5 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -132,17 +132,22 @@ static void
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
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 160d637d54..e2d7761965 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -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 @@ shell_parse_debug_string (EShell *shell)
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 @@ shell_window_delete_event_cb (EShell *shell,
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 @@ shell_window_focus_in_event_cb (EShell *shell,
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 @@ shell_shutdown_timeout (EShell *shell)
* 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 @@ shell_class_init (EShellClass *class)
/**
* 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 @@ shell_class_init (EShellClass *class)
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 @@ e_shell_get_type (void)
*
* 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_modules (EShell *shell)
}
/**
- * 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 @@ GtkWidget *
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 @@ e_shell_create_shell_window (EShell *shell,
}
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 @@ unique: /* Send a message to the other Evolution process. */
**/
guint
e_shell_handle_uris (EShell *shell,
- const gchar **uris)
+ gchar **uris)
{
UniqueApp *app;
UniqueMessageData *data;
@@ -1163,11 +1126,10 @@ e_shell_handle_uris (EShell *shell,
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 @@ unique: /* Send a message to the other Evolution process. */
}
/**
+ * 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
diff --git a/shell/e-shell.h b/shell/e-shell.h
index 9e30550283..3f23779ee7 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -78,7 +78,6 @@ struct _EShellClass {
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 @@ EShellSettings *e_shell_get_shell_settings (EShell *shell);
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);
diff --git a/shell/main.c b/shell/main.c
index 670b24d1a2..ce1b467754 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -306,7 +306,6 @@ static gboolean
idle_cb (gchar **uris)
{
EShell *shell;
- guint ii;
#ifdef KILL_PROCESS_CMD
kill_old_dataserver ();
@@ -314,23 +313,21 @@ idle_cb (gchar **uris)
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 @@ set_paths (void)
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 ();
}
diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c
index fc489fa3b0..a7d2389fb7 100644
--- a/shell/test/e-test-shell-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -115,20 +115,23 @@ test_module_send_receive_cb (EShellModule *shell_module,
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));
}