summaryrefslogtreecommitdiffstats
path: root/src/ui/simple-pref-pusher.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/ui/simple-pref-pusher.h
parentInitial commit. (diff)
downloadinkscape-upstream.tar.xz
inkscape-upstream.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/ui/simple-pref-pusher.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/ui/simple-pref-pusher.h b/src/ui/simple-pref-pusher.h
new file mode 100644
index 0000000..c17c625
--- /dev/null
+++ b/src/ui/simple-pref-pusher.h
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef SEEN_SIMPLE_PREF_PUSHER_H
+#define SEEN_SIMPLE_PREF_PUSHER_H
+
+#include "preferences.h"
+
+namespace Gtk {
+class ToggleToolButton;
+}
+
+namespace Inkscape {
+namespace UI {
+
+/**
+ * A simple mediator class that sets the state of a Gtk::ToggleToolButton when
+ * a preference is changed. Unlike the PrefPusher class, this does not provide
+ * the reverse process, so you still need to write your own handler for the
+ * "toggled" signal on the ToggleToolButton.
+ */
+class SimplePrefPusher : public Inkscape::Preferences::Observer
+{
+public:
+ /**
+ * Constructor for a boolean value that syncs to the supplied path.
+ * Initializes the widget to the current preference stored state and registers callbacks
+ * for widget changes and preference changes.
+ *
+ * @param act the widget to synchronize preference with.
+ * @param path the path to the preference the widget is synchronized with.
+ * @param callback function to invoke when changes are pushed.
+ * @param cbData data to be passed on to the callback function.
+ */
+ SimplePrefPusher(Gtk::ToggleToolButton *btn,
+ Glib::ustring const & path);
+
+ /**
+ * Destructor that unregisters the preference callback.
+ */
+ ~SimplePrefPusher() override;
+
+ /**
+ * Callback method invoked when the preference setting changes.
+ */
+ void notify(Inkscape::Preferences::Entry const &new_val) override;
+
+
+private:
+ Gtk::ToggleToolButton *_btn;
+ bool freeze;
+};
+
+}
+}
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :