From b58f3eed4fef68c0394cd01627818247664640e9 Mon Sep 17 00:00:00 2001 From: johncoswell Date: Sun, 13 Aug 2006 18:45:40 +0000 Subject: [PATCH] add interface for disabling interaction during long-running operations --- src/desktop.cpp | 13 +++++++++++++ src/desktop.h | 6 ++++++ src/ui/view/edit-widget-interface.h | 8 ++++++++ src/ui/view/edit-widget.cpp | 27 ++++++++++++++++++++++++++- src/ui/view/edit-widget.h | 5 +++++ src/widgets/desktop-widget.cpp | 26 ++++++++++++++++++++++++++ src/widgets/desktop-widget.h | 9 +++++++++ 7 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/desktop.cpp b/src/desktop.cpp index 04328e84d..51580249e 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -8,7 +8,9 @@ * MenTaLguY * bulia byak * Ralf Stephan + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 2004 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@ -1028,6 +1030,17 @@ SPDesktop::updateNow() sp_canvas_update_now(canvas); } +void +SPDesktop::enableInteraction() +{ + _widget->enableInteraction(); +} + +void SPDesktop::disableInteraction() +{ + _widget->disableInteraction(); +} + //---------------------------------------------------------------------- // Callback implementations. The virtual ones are connected by the view. diff --git a/src/desktop.h b/src/desktop.h index 5e0b1f3a8..c9484f2fe 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -9,7 +9,9 @@ * Frank Felfe * bulia byak * Ralf Stephan + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 1999-2005 authors * Copyright (C) 2000-2001 Ximian, Inc. * @@ -92,6 +94,7 @@ struct SPDesktop : public Inkscape::UI::View::View unsigned int dkey; unsigned int number; bool is_fullscreen; + unsigned int interaction_disabled_counter; /// \todo fixme: This has to be implemented in different way */ guint guides_active : 1; @@ -226,6 +229,9 @@ struct SPDesktop : public Inkscape::UI::View::View void updateNow(); void updateCanvasNow(); + void enableInteraction(); + void disableInteraction(); + void fullscreen(); void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget) 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; }; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 795fdb0f8..9ede6f27e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -8,7 +8,9 @@ * MenTaLguY * bulia byak * Ralf Stephan + * John Bintz * + * Copyright (C) 2006 John Bintz * Copyright (C) 2004 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@ -171,6 +173,8 @@ sp_desktop_widget_init (SPDesktopWidget *dtw) dtw->desktop = NULL; + dtw->_interaction_disabled_counter = 0; + dtw->tt = gtk_tooltips_new (); /* Main table */ @@ -669,6 +673,28 @@ SPDesktopWidget::requestCanvasUpdateAndWait() { } +void +SPDesktopWidget::enableInteraction() +{ + g_return_if_fail(_interaction_disabled_counter > 0); + + _interaction_disabled_counter--; + + if (_interaction_disabled_counter == 0) { + gtk_widget_set_sensitive(GTK_WIDGET(this), TRUE); + } +} + +void +SPDesktopWidget::disableInteraction() +{ + if (_interaction_disabled_counter == 0) { + gtk_widget_set_sensitive(GTK_WIDGET(this), FALSE); + } + + _interaction_disabled_counter++; +} + void SPDesktopWidget::setCoordinateStatus(NR::Point p) { diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index 409f38a8d..0514dd393 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -5,6 +5,7 @@ * SPDesktopWidget: handling Gtk events on a desktop. * * Authors: + * John Bintz (c) 2006 * Ralf Stephan (c) 2005, distrib. under GPL2 * ? -2004 */ @@ -92,6 +93,8 @@ struct SPDesktopWidget { Inkscape::UI::Widget::SelectedStyle *selected_style; gint coord_status_id, select_status_id; + + unsigned int _interaction_disabled_counter; SPCanvas *canvas; NR::Point ruler_origin; @@ -135,6 +138,10 @@ struct SPDesktopWidget { { _dtw->requestCanvasUpdate(); } virtual void requestCanvasUpdateAndWait() { _dtw->requestCanvasUpdateAndWait(); } + virtual void enableInteraction() + { _dtw->enableInteraction(); } + virtual void disableInteraction() + { _dtw->disableInteraction(); } virtual void activateDesktop() { sp_dtw_desktop_activate (_dtw); } virtual void deactivateDesktop() @@ -186,6 +193,8 @@ struct SPDesktopWidget { void setCoordinateStatus(NR::Point p); void requestCanvasUpdate(); void requestCanvasUpdateAndWait(); + void enableInteraction(); + void disableInteraction(); void updateTitle(gchar const *uri); }; -- 2.30.2