diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/e-shell-view.c | 59 | ||||
-rw-r--r-- | shell/e-shell-view.h | 4 |
2 files changed, 62 insertions, 1 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 51ad7dd2d0..6cae11cb03 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -71,6 +71,9 @@ struct _EShellViewPrivate { EFilterRule *search_rule; guint execute_search_blocked; + + guint update_actions_blocked; + gboolean update_actions_called; }; enum { @@ -730,6 +733,9 @@ shell_view_update_actions (EShellView *shell_view) EShellWindow *shell_window; EFocusTracker *focus_tracker; + g_return_if_fail (!shell_view->priv->update_actions_blocked); + g_return_if_fail (e_shell_view_is_active (shell_view)); + shell_window = e_shell_view_get_shell_window (shell_view); focus_tracker = e_shell_window_get_focus_tracker (shell_window); @@ -1664,13 +1670,64 @@ e_shell_view_unblock_execute_search (EShellView *shell_view) * #EShellView::update-actions signal is typically emitted just before * showing a popup menu or just after the user selects an item in the * shell view. + * + * Emission can be blocked by e_shell_view_block_update_actions(). **/ void e_shell_view_update_actions (EShellView *shell_view) { g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0); + if (!e_shell_view_is_active (shell_view)) + return; + + if (shell_view->priv->update_actions_blocked > 0) { + shell_view->priv->update_actions_called = TRUE; + } else { + shell_view->priv->update_actions_called = FALSE; + g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0); + } +} + +/** + * e_shell_view_block_update_actions: + * @shell_view: an #EShellView + * + * Block emission of #EShellView::update-actions signal through + * e_shell_view_update_actions(). The emission si blocked until + * e_shell_view_unblock_update_actions() is called same times as + * this function. + **/ +void +e_shell_view_block_update_actions (EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (shell_view->priv->update_actions_blocked + 1 != 0); + + shell_view->priv->update_actions_blocked++; + if (shell_view->priv->update_actions_blocked == 1) + shell_view->priv->update_actions_called = FALSE; +} + +/** + * e_shell_view_unblock_update_actions: + * @shell_view: an #EShellView + * + * Unblock emission of #EShellView::update-actions signal through + * e_shell_view_update_actions(), previously blocked by function + * e_shell_view_block_update_actions(). + **/ +void +e_shell_view_unblock_update_actions (EShellView *shell_view) +{ + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + g_return_if_fail (shell_view->priv->update_actions_blocked > 0); + + shell_view->priv->update_actions_blocked--; + if (!shell_view->priv->update_actions_blocked && shell_view->priv->update_actions_called) { + shell_view->priv->update_actions_called = FALSE; + e_shell_view_update_actions (shell_view); + } } /** diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h index 2cf2136693..4387082f21 100644 --- a/shell/e-shell-view.h +++ b/shell/e-shell-view.h @@ -215,6 +215,10 @@ void e_shell_view_block_execute_search void e_shell_view_unblock_execute_search (EShellView *shell_view); void e_shell_view_update_actions (EShellView *shell_view); +void e_shell_view_block_update_actions + (EShellView *shell_view); +void e_shell_view_unblock_update_actions + (EShellView *shell_view); GtkWidget * e_shell_view_show_popup_menu (EShellView *shell_view, const gchar *widget_path, GdkEventButton *event); |