From 48462592cb67d956cf8b4a69eba00153d585c462 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 22 Jan 2010 11:46:34 -0500 Subject: Add a EShellWindow::shell-view-created signal. The signal uses the name of the newly created shell view as the detail, so for example "shell-view-created::mail" is emitted when the "mail" view is created. Also, add e_shell_window_peek_shell_view() to obtain a shell view if it exists but without instantiating it. Using these new tools, teach the templates plugin to wait for the user to switch to the "mail" view before connecting to its "update-actions" signal. Previously is was instantiating the "mail" view itself. --- plugins/templates/templates.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'plugins/templates/templates.c') diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c index 1ed02dd22d..b88e26d29d 100644 --- a/plugins/templates/templates.c +++ b/plugins/templates/templates.c @@ -767,6 +767,15 @@ init_composer_actions (GtkUIManager *ui_manager, return TRUE; } +static void +mail_shell_view_created_cb (EShellWindow *shell_window, + EShellView *shell_view) +{ + g_signal_connect ( + shell_view, "update-actions", + G_CALLBACK (update_actions_cb), NULL); +} + gboolean init_shell_actions (GtkUIManager *ui_manager, EShellWindow *shell_window) @@ -775,8 +784,6 @@ init_shell_actions (GtkUIManager *ui_manager, GtkActionGroup *action_group; guint merge_id; - shell_view = e_shell_window_get_shell_view (shell_window, "mail"); - /* This is where we keep dynamically-built menu items. */ e_shell_window_add_action_group (shell_window, "templates"); action_group = e_lookup_action_group (ui_manager, "templates"); @@ -787,9 +794,14 @@ init_shell_actions (GtkUIManager *ui_manager, G_OBJECT (action_group), "merge-id", GUINT_TO_POINTER (merge_id)); - g_signal_connect ( - shell_view, "update-actions", - G_CALLBACK (update_actions_cb), NULL); + /* Be careful not to instantiate the mail view ourselves. */ + shell_view = e_shell_window_peek_shell_view (shell_window, "mail"); + if (shell_view != NULL) + mail_shell_view_created_cb (shell_window, shell_view); + else + g_signal_connect ( + shell_window, "shell-view-created::mail", + G_CALLBACK (mail_shell_view_created_cb), NULL); return TRUE; } -- cgit v1.2.3