From b276c75c7c0f537cf4f5d122b1bff41420ca3232 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 1 Apr 2010 16:18:40 +0200 Subject: Bug #613352 - Changed time range not propagated to calendar --- shell/e-shell-view.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++- shell/e-shell-view.h | 4 ++++ 2 files changed, 62 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 537024a548..3a5c6e219d 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -60,6 +60,9 @@ struct _EShellViewPrivate { EFilterRule *search_rule; guint execute_search_blocked; + + guint update_actions_blocked; + gboolean update_actions_called; }; enum { @@ -629,6 +632,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); @@ -1514,13 +1520,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 d014d694ce..1e189217e1 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); -- cgit v1.2.3