diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-01-23 00:46:34 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-01-23 00:46:34 +0800 |
commit | 48462592cb67d956cf8b4a69eba00153d585c462 (patch) | |
tree | e23046a3bcadc5b27457c85b13ec3a2c9460741c /shell | |
parent | 97ec849ee54387df954ee461ae371c3054443bfa (diff) | |
download | gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar.gz gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar.bz2 gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar.lz gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar.xz gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.tar.zst gsoc2013-evolution-48462592cb67d956cf8b4a69eba00153d585c462.zip |
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.
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-window.c | 70 | ||||
-rw-r--r-- | shell/e-shell-window.h | 7 |
2 files changed, 72 insertions, 5 deletions
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index d3d6107e24..d159406e08 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -40,7 +40,13 @@ enum { PROP_UI_MANAGER }; +enum { + SHELL_VIEW_CREATED, + LAST_SIGNAL +}; + static gpointer parent_class; +static gulong signals[LAST_SIGNAL]; static void shell_window_menubar_update_new_menu (EShellWindow *shell_window) @@ -753,6 +759,26 @@ shell_window_class_init (EShellWindowClass *class) _("The shell window's GtkUIManager"), GTK_TYPE_UI_MANAGER, G_PARAM_READABLE)); + + /** + * EShellWindow::shell-view-created + * @shell_window: the #EShellWindow which emitted the signal + * @shell_view: the new #EShellView + * + * Emitted when a new #EShellView is instantiated by way of + * e_shell_window_get_shell_view(). The signal detail denotes + * the new view name, which can be used to obtain notification + * of when a particular #EShellView is created. + **/ + signals[SHELL_VIEW_CREATED] = g_signal_new ( + "shell-view-created", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + G_STRUCT_OFFSET (EShellWindowClass, shell_view_created), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_SHELL_VIEW); } static void @@ -849,6 +875,9 @@ e_shell_window_get_shell (EShellWindow *shell_window) * active view name, as returned by e_shell_window_get_active_view(), * should be requested. * + * The function emits a #EShellWindow::shell-view-created signal with + * @view_name as the signal detail when it instantiates an #EShellView. + * * Returns: the requested #EShellView, or %NULL if no such view is * registered **/ @@ -858,21 +887,52 @@ e_shell_window_get_shell_view (EShellWindow *shell_window, { EShellView *shell_view; EShellWindowClass *class; - GHashTable *loaded_views; g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); g_return_val_if_fail (view_name != NULL, NULL); - loaded_views = shell_window->priv->loaded_views; - shell_view = g_hash_table_lookup (loaded_views, view_name); - + shell_view = e_shell_window_peek_shell_view (shell_window, view_name); if (shell_view != NULL) return shell_view; class = E_SHELL_WINDOW_GET_CLASS (shell_window); g_return_val_if_fail (class->create_shell_view != NULL, NULL); - return class->create_shell_view (shell_window, view_name); + shell_view = class->create_shell_view (shell_window, view_name); + + g_signal_emit ( + shell_window, signals[SHELL_VIEW_CREATED], + g_quark_from_string (view_name), shell_view); + + return shell_view; +} + +/** + * e_shell_window_peek_shell_view: + * @shell_window: an #EShellWindow + * @view_name: name of a shell view + * + * Returns the #EShellView named @view_name (see the + * <structfield>name</structfield> field in #EShellBackendInfo), or + * %NULL if the requested view has not yet been instantiated. Unlike + * e_shell_window_get_shell_view(), this function will not instantiate + * the view itself. + * + * Returns: the requested #EShellView, or %NULL if no such view is + * instantiated + **/ +EShellView * +e_shell_window_peek_shell_view (EShellWindow *shell_window, + const gchar *view_name) +{ + GHashTable *loaded_views; + + g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL); + g_return_val_if_fail (view_name != NULL, NULL); + + loaded_views = shell_window->priv->loaded_views; + + return g_hash_table_lookup (loaded_views, view_name); } /** diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index 4ac76ba5d4..0bd71075c9 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -73,6 +73,10 @@ struct _EShellWindow { struct _EShellWindowClass { GtkWindowClass parent_class; + /* Signals */ + void (*shell_view_created) (EShellWindow *shell_window, + struct _EShellView *shell_view); + /* These are all protected methods. Not for public use. */ GtkWidget * (*construct_menubar) (EShellWindow *shell_window); GtkWidget * (*construct_toolbar) (EShellWindow *shell_window); @@ -92,6 +96,9 @@ EShell * e_shell_window_get_shell (EShellWindow *shell_window); struct _EShellView * e_shell_window_get_shell_view (EShellWindow *shell_window, const gchar *view_name); +struct _EShellView * + e_shell_window_peek_shell_view (EShellWindow *shell_window, + const gchar *view_name); GtkAction * e_shell_window_get_shell_view_action (EShellWindow *shell_window, const gchar *view_name); |