aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-01-08 02:23:46 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-01-08 02:23:46 +0800
commit8d8e4ac1c23905892a42b779188c852fdead7f5f (patch)
tree01609ceef7151d75f81fdc8762ac6c25215e8a51 /shell
parent13a0edc3d27cce65a0f720e98516f7ab902ad0fc (diff)
downloadgsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.gz
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.bz2
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.lz
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.xz
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.tar.zst
gsoc2013-evolution-8d8e4ac1c23905892a42b779188c852fdead7f5f.zip
Tweak the EShell API.
Disable File -> Close Window when there's only one window. Replace EMMessageBrowser with EMailBrowser. svn path=/branches/kill-bonobo/; revision=37009
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-content.c46
-rw-r--r--shell/e-shell-migrate.c2
-rw-r--r--shell/e-shell-window-actions.c4
-rw-r--r--shell/e-shell-window-private.c19
-rw-r--r--shell/e-shell-window-private.h3
-rw-r--r--shell/e-shell-window.c42
-rw-r--r--shell/e-shell.c80
-rw-r--r--shell/e-shell.h8
-rw-r--r--shell/main.c7
-rw-r--r--shell/test/e-test-shell-module.c5
10 files changed, 135 insertions, 81 deletions
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index bde5a84084..4c02ba3709 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -459,35 +459,35 @@ shell_content_dispose (GObject *object)
priv->filter_label = NULL;
}
- if (priv->filter_combo_box != NULL) {
- g_object_unref (priv->filter_combo_box);
- priv->filter_combo_box = NULL;
- }
+ if (priv->filter_combo_box != NULL) {
+ g_object_unref (priv->filter_combo_box);
+ priv->filter_combo_box = NULL;
+ }
if (priv->search_context != NULL) {
g_object_unref (priv->search_context);
priv->search_context = NULL;
}
- if (priv->search_label != NULL) {
- g_object_unref (priv->search_label);
- priv->search_label = NULL;
- }
-
- if (priv->search_entry != NULL) {
- g_object_unref (priv->search_entry);
- priv->search_entry = NULL;
- }
-
- if (priv->scope_label != NULL) {
- g_object_unref (priv->scope_label);
- priv->scope_label = NULL;
- }
-
- if (priv->scope_combo_box != NULL) {
- g_object_unref (priv->scope_combo_box);
- priv->scope_combo_box = NULL;
- }
+ if (priv->search_label != NULL) {
+ g_object_unref (priv->search_label);
+ priv->search_label = NULL;
+ }
+
+ if (priv->search_entry != NULL) {
+ g_object_unref (priv->search_entry);
+ priv->search_entry = NULL;
+ }
+
+ if (priv->scope_label != NULL) {
+ g_object_unref (priv->scope_label);
+ priv->scope_label = NULL;
+ }
+
+ if (priv->scope_combo_box != NULL) {
+ g_object_unref (priv->scope_combo_box);
+ priv->scope_combo_box = NULL;
+ }
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
diff --git a/shell/e-shell-migrate.c b/shell/e-shell-migrate.c
index 9979899563..b4467028f4 100644
--- a/shell/e-shell-migrate.c
+++ b/shell/e-shell-migrate.c
@@ -56,7 +56,7 @@ shell_migrate_attempt (EShell *shell,
GList *modules;
gboolean success = TRUE;
- modules = e_shell_list_modules (shell);
+ modules = e_shell_get_shell_modules (shell);
while (success && modules != NULL) {
EShellModule *shell_module = modules->data;
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index dc4307fe5c..cf513669c8 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -863,7 +863,7 @@ action_new_window_cb (GtkAction *action,
EShell *shell;
shell = e_shell_window_get_shell (shell_window);
- e_shell_create_window (shell);
+ e_shell_create_shell_window (shell);
}
/**
@@ -1970,7 +1970,7 @@ e_shell_window_create_switcher_actions (EShellWindow *shell_window)
ui_manager = e_shell_window_get_ui_manager (shell_window);
merge_id = gtk_ui_manager_new_merge_id (ui_manager);
shell = e_shell_window_get_shell (shell_window);
- list = e_shell_list_modules (shell);
+ list = e_shell_get_shell_modules (shell);
/* Construct a group of radio actions from the various EShellView
* subclasses and register them with the EShellSwitcher. These
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index a1027e437c..6fcdc2b6fc 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -173,6 +173,7 @@ e_shell_window_private_init (EShellWindow *shell_window)
{
EShellWindowPrivate *priv = shell_window->priv;
GHashTable *loaded_views;
+ GArray *signal_handler_ids;
GtkAccelGroup *accel_group;
GtkToolItem *item;
GtkWidget *container;
@@ -185,6 +186,8 @@ e_shell_window_private_init (EShellWindow *shell_window)
(GDestroyNotify) g_free,
(GDestroyNotify) g_object_unref);
+ signal_handler_ids = g_array_new (FALSE, FALSE, sizeof (gulong));
+
priv->ui_manager = gtk_ui_manager_new ();
priv->shell_actions = gtk_action_group_new ("shell");
priv->gal_view_actions = gtk_action_group_new ("gal-view");
@@ -194,6 +197,7 @@ e_shell_window_private_init (EShellWindow *shell_window)
priv->switcher_actions = gtk_action_group_new ("switcher");
priv->loaded_views = loaded_views;
priv->active_view = "unknown";
+ priv->signal_handler_ids = signal_handler_ids;
merge_id = gtk_ui_manager_new_merge_id (priv->ui_manager);
priv->custom_rule_merge_id = merge_id;
@@ -369,6 +373,21 @@ e_shell_window_private_dispose (EShellWindow *shell_window)
{
EShellWindowPrivate *priv = shell_window->priv;
+ /* Need to disconnect handlers before we unref the shell. */
+ if (priv->signal_handler_ids != NULL) {
+ GArray *array = priv->signal_handler_ids;
+ gulong handler_id;
+ guint ii;
+
+ for (ii = 0; ii < array->len; ii++) {
+ handler_id = g_array_index (array, gulong, ii);
+ g_signal_handler_disconnect (priv->shell, handler_id);
+ }
+
+ g_array_free (array, TRUE);
+ priv->signal_handler_ids = NULL;
+ }
+
DISPOSE (priv->shell);
DISPOSE (priv->ui_manager);
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
index a31640d347..ea69968344 100644
--- a/shell/e-shell-window-private.h
+++ b/shell/e-shell-window-private.h
@@ -99,6 +99,9 @@ struct _EShellWindowPrivate {
/* Miscellaneous */
+ /* Shell signal handlers. */
+ GArray *signal_handler_ids;
+
guint destroyed : 1; /* XXX Do we still need this? */
guint safe_mode : 1;
};
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index a110bad82f..ef36b0e9c9 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -129,17 +129,57 @@ shell_window_online_mode_notify_cb (EShell *shell,
}
static void
+shell_window_update_close_action_cb (EShellWindow *shell_window)
+{
+ EShell *shell;
+ GList *shell_windows;
+ gboolean sensitive;
+
+ shell = e_shell_window_get_shell (shell_window);
+ shell_windows = e_shell_get_shell_windows (shell);
+ g_return_if_fail (shell_windows != NULL);
+
+ /* Disable Close Window if there's only one window.
+ * Helps prevent users from accidentally quitting. */
+ sensitive = (g_list_length (shell_windows) > 1);
+ gtk_action_set_sensitive (ACTION (CLOSE), sensitive);
+}
+
+static void
shell_window_set_shell (EShellWindow *shell_window,
EShell *shell)
{
+ GArray *array;
+ gulong handler_id;
+
g_return_if_fail (shell_window->priv->shell == NULL);
shell_window->priv->shell = g_object_ref (shell);
- g_signal_connect (
+ /* Need to disconnect these when the window is closing. */
+
+ array = shell_window->priv->signal_handler_ids;
+
+ handler_id = g_signal_connect (
shell, "notify::online-mode",
G_CALLBACK (shell_window_online_mode_notify_cb),
shell_window);
+ g_array_append_val (array, handler_id);
+
+ handler_id = g_signal_connect_swapped (
+ shell, "window-created",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
+
+ g_array_append_val (array, handler_id);
+
+ handler_id = g_signal_connect_swapped (
+ shell, "window-destroyed",
+ G_CALLBACK (shell_window_update_close_action_cb),
+ shell_window);
+
+ g_array_append_val (array, handler_id);
+
g_object_notify (G_OBJECT (shell), "online-mode");
}
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 38cc875a17..09726d612d 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -58,7 +58,7 @@ enum {
PROP_0,
PROP_NETWORK_AVAILABLE,
PROP_ONLINE_MODE,
- PROP_SETTINGS
+ PROP_SHELL_SETTINGS
};
enum {
@@ -131,14 +131,12 @@ shell_window_weak_notify_cb (EShell *shell,
GObject *where_the_object_was)
{
GList *active_windows;
- gboolean last_window;
active_windows = shell->priv->active_windows;
active_windows = g_list_remove (active_windows, where_the_object_was);
shell->priv->active_windows = active_windows;
- last_window = (shell->priv->active_windows == NULL);
- g_signal_emit (shell, signals[WINDOW_DESTROYED], 0, last_window);
+ g_signal_emit (shell, signals[WINDOW_DESTROYED], 0);
}
static void
@@ -306,7 +304,7 @@ shell_shutdown_timeout (EShell *shell)
static guint message_timer = 1;
/* Module list is read-only; do not free. */
- list = e_shell_list_modules (shell);
+ list = e_shell_get_shell_modules (shell);
/* Any module can defer shutdown if it's still busy. */
for (iter = list; proceed && iter != NULL; iter = iter->next) {
@@ -387,9 +385,9 @@ shell_get_property (GObject *object,
E_SHELL (object)));
return;
- case PROP_SETTINGS:
+ case PROP_SHELL_SETTINGS:
g_value_set_object (
- value, e_shell_get_settings (
+ value, e_shell_get_shell_settings (
E_SHELL (object)));
return;
}
@@ -522,11 +520,11 @@ shell_class_init (EShellClass *class)
**/
g_object_class_install_property (
object_class,
- PROP_SETTINGS,
+ PROP_SHELL_SETTINGS,
g_param_spec_object (
- "settings",
- _("Settings"),
- _("Application settings"),
+ "shell-settings",
+ _("Shell Settings"),
+ _("Application-wide settings"),
E_TYPE_SHELL_SETTINGS,
G_PARAM_READABLE));
@@ -655,7 +653,6 @@ shell_class_init (EShellClass *class)
/**
* EShell::window-destroyed
* @shell: the #EShell which emitted the signal
- * @last_window: whether that was the last #EShellWindow
*
* Emitted when an #EShellWindow is destroyed.
**/
@@ -664,9 +661,8 @@ shell_class_init (EShellClass *class)
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -739,7 +735,7 @@ e_shell_get_default (void)
}
/**
- * e_shell_list_modules:
+ * e_shell_get_shell_modules:
* @shell: an #EShell
*
* Returns a list of loaded #EShellModule instances. The list is
@@ -748,7 +744,7 @@ e_shell_get_default (void)
* Returns: a list of loaded #EShellModule instances
**/
GList *
-e_shell_list_modules (EShell *shell)
+e_shell_get_shell_modules (EShell *shell)
{
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -756,6 +752,26 @@ e_shell_list_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
@@ -834,9 +850,8 @@ e_shell_get_module_by_scheme (EShell *shell,
return g_hash_table_lookup (hash_table, scheme);
}
-
/**
- * e_shell_get_settings:
+ * e_shell_get_shell_settings:
* @shell: an #EShell
*
* Returns the #EShellSettings instance for @shell.
@@ -844,7 +859,7 @@ e_shell_get_module_by_scheme (EShell *shell,
* Returns: the #EShellSettings instance for @shell
**/
EShellSettings *
-e_shell_get_settings (EShell *shell)
+e_shell_get_shell_settings (EShell *shell)
{
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
@@ -852,7 +867,7 @@ e_shell_get_settings (EShell *shell)
}
/**
- * e_shell_create_window:
+ * e_shell_create_shell_window:
* @shell: an #EShell
*
* Creates a new #EShellWindow and emits the #EShell::window-created
@@ -862,7 +877,7 @@ e_shell_get_settings (EShell *shell)
* Returns: a new #EShellWindow
**/
GtkWidget *
-e_shell_create_window (EShell *shell)
+e_shell_create_shell_window (EShell *shell)
{
GList *active_windows;
GtkWidget *shell_window;
@@ -895,27 +910,6 @@ e_shell_create_window (EShell *shell)
}
/**
- * e_shell_get_focused_window:
- * @shell: an #EShell
- *
- * Returns the most recently focused #EShellWindow. Useful for choosing
- * a parent for a transient window. This only works for windows created
- * with e_shell_create_window().
- *
- * Returns: the most recently focused #EShellWindow
- **/
-GtkWidget *
-e_shell_get_focused_window (EShell *shell)
-{
- g_return_val_if_fail (E_IS_SHELL (shell), NULL);
-
- if (shell->priv->active_windows == NULL)
- return NULL;
-
- return GTK_WIDGET (shell->priv->active_windows->data);
-}
-
-/**
* e_shell_handle_uri:
* @shell: an #EShell
* @uri: the URI to be handled
diff --git a/shell/e-shell.h b/shell/e-shell.h
index e482f93960..1503ca776b 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -76,16 +76,16 @@ struct _EShellClass {
GType e_shell_get_type (void);
EShell * e_shell_get_default (void);
-GList * e_shell_list_modules (EShell *shell);
+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,
const gchar *name);
EShellModule * e_shell_get_module_by_scheme (EShell *shell,
const gchar *scheme);
-EShellSettings *e_shell_get_settings (EShell *shell);
-GtkWidget * e_shell_create_window (EShell *shell);
-GtkWidget * e_shell_get_focused_window (EShell *shell);
+EShellSettings *e_shell_get_shell_settings (EShell *shell);
+GtkWidget * e_shell_create_shell_window (EShell *shell);
gboolean e_shell_handle_uri (EShell *shell,
const gchar *uri);
void e_shell_send_receive (EShell *shell,
diff --git a/shell/main.c b/shell/main.c
index b078320c32..3c51bc1c46 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -317,7 +317,7 @@ idle_cb (gchar **uris)
g_object_unref (client);
}
- shell_window = e_shell_create_window (shell);
+ shell_window = e_shell_create_shell_window (shell);
#if 0 /* MBARNES */
if (shell == NULL) {
@@ -462,10 +462,9 @@ set_paths (void)
#endif
static void
-shell_window_destroyed_cb (EShell *shell,
- gboolean last_window)
+shell_window_destroyed_cb (EShell *shell)
{
- if (last_window)
+ if (e_shell_get_shell_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 6b2c5c4179..fc489fa3b0 100644
--- a/shell/test/e-test-shell-module.c
+++ b/shell/test/e-test-shell-module.c
@@ -133,10 +133,9 @@ test_module_window_created_cb (EShellModule *shell_module,
}
static void
-test_module_window_destroyed_cb (EShellModule *shell_module,
- gboolean last_window)
+test_module_window_destroyed_cb (EShellModule *shell_module)
{
- g_debug ("%s (last=%d)", G_STRFUNC, last_window);
+ g_debug ("%s", G_STRFUNC);
}
static EShellModuleInfo module_info = {