From: Krzysztof KosiƄski Date: Tue, 6 Apr 2010 14:47:48 +0000 (+0200) Subject: Fix "show handles" button state on Ctrl+H X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d16ebcd8afd063f70de3856b78021f95405ee8bc;p=inkscape.git Fix "show handles" button state on Ctrl+H --- 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); } {