From e945f1a347023c8cc50165ed97a2295b85a3e75a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 13 Aug 2006 18:45:40 +0000 Subject: add interface for disabling interaction during long-running operations (bzr r1596) --- src/ui/view/edit-widget-interface.h | 8 ++++++++ src/ui/view/edit-widget.cpp | 27 ++++++++++++++++++++++++++- src/ui/view/edit-widget.h | 5 +++++ 3 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src/ui/view') diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index 605c72b59..7cc0133d3 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -5,7 +5,9 @@ * * Authors: * Ralf Stephan + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 2005 Ralf Stephan * * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -73,6 +75,12 @@ struct EditWidgetInterface /// Force a redraw of the canvas virtual void requestCanvasUpdateAndWait() = 0; + /// Enable interaction on this desktop + virtual void enableInteraction() = 0; + + /// Disable interaction on this desktop + virtual void disableInteraction() = 0; + /// Update the "active desktop" indicator virtual void activateDesktop() = 0; diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 6a4306147..83566c199 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -16,7 +16,9 @@ * Derek P. Moore * Lauris Kaplinski * Frank Felfe + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 1999-2005 Authors * Copyright (C) 2000-2001 Ximian, Inc. * @@ -74,7 +76,8 @@ EditWidget::EditWidget (SPDocument *doc) _act_grp(Gtk::ActionGroup::create()), _ui_mgr(Gtk::UIManager::create()), _update_s_f(false), - _update_a_f(false) + _update_a_f(false), + _interaction_disabled_counter(0) { g_warning("Creating new EditWidget"); @@ -1302,6 +1305,28 @@ EditWidget::requestCanvasUpdateAndWait() gtk_main_iteration_do(FALSE); } +void +EditWidget::enableInteraction() +{ + g_return_if_fail(_interaction_disabled_counter > 0); + + _interaction_disabled_counter--; + + if (_interaction_disabled_counter == 0) { + this->set_sensitive(true); + } +} + +void +EditWidget::disableInteraction() +{ + if (_interaction_disabled_counter == 0) { + this->set_sensitive(false); + } + + _interaction_disabled_counter++; +} + void EditWidget::activateDesktop() { diff --git a/src/ui/view/edit-widget.h b/src/ui/view/edit-widget.h index 096137c2a..55a52be4c 100644 --- a/src/ui/view/edit-widget.h +++ b/src/ui/view/edit-widget.h @@ -6,7 +6,9 @@ * Bryce W. Harrington * Derek P. Moore * Ralf Stephan + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 2004 Bryce Harrington * * Released under GNU GPL. Read the file 'COPYING' for more information. @@ -109,6 +111,8 @@ public: virtual void destroy(); virtual void requestCanvasUpdate(); virtual void requestCanvasUpdateAndWait(); + virtual void enableInteraction(); + virtual void disableInteraction(); virtual void activateDesktop(); virtual void deactivateDesktop(); virtual void viewSetPosition (NR::Point p); @@ -193,6 +197,7 @@ private: void onAdjValueChanged(); bool _update_s_f, _update_a_f; + unsigned int _interaction_disabled_counter; sigc::connection _namedview_modified_connection; }; -- cgit v1.2.3