From d16ebcd8afd063f70de3856b78021f95405ee8bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Krzysztof=20Kosi=C5=84ski?= Date: Tue, 6 Apr 2010 16:47:48 +0200 Subject: [PATCH] Fix "show handles" button state on Ctrl+H --- src/widgets/toolbox.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 4b0d84d90..5c890333f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1289,6 +1289,31 @@ sp_node_toolbox_sel_modified (Inkscape::Selection *selection, guint /*flags*/, G //## Node Editing Toolbox ## //################################ +class ShowHandlesObserver + : public Inkscape::Preferences::Observer +{ +public: + ShowHandlesObserver(InkToggleAction *act) + : Inkscape::Preferences::Observer("/tools/nodes/show_handles") + , _act(act) + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->addObserver(*this); + } + ~ShowHandlesObserver() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->removeObserver(*this); + } + virtual void notify(Inkscape::Preferences::Entry const &v) { + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(_act), v.getBool()); + } + static void destroy(ShowHandlesObserver *s, InkToggleAction *) { + delete s; + } +private: + InkToggleAction *_act; +}; + static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1442,6 +1467,8 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_handles), desktop ); gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/nodes/show_handles", true) ); + ShowHandlesObserver *s = new ShowHandlesObserver(act); + g_object_weak_ref(G_OBJECT(act), (GWeakNotify) ShowHandlesObserver::destroy, (gpointer) s); } { -- 2.30.2