Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
simple-pref-pusher.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2
4
5#include <gtkmm/togglebutton.h>
6
7namespace Inkscape {
8namespace UI {
9SimplePrefPusher::SimplePrefPusher(Gtk::ToggleButton *btn, Glib::ustring const &path)
10 : Observer(path)
11 , _btn(btn)
12 , freeze(false)
13{
14 freeze = true;
15 _btn->set_active( Inkscape::Preferences::get()->getBool(observed_path) );
16 freeze = false;
17
19}
20
25
26void
28{
29 bool newBool = newVal.getBool();
30 bool oldBool = _btn->get_active();
31
32 if (!freeze && (newBool != oldBool)) {
33 _btn->set_active(newBool);
34 }
35}
36
37}
38}
39
40/*
41 Local Variables:
42 mode:c++
43 c-file-style:"stroustrup"
44 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
45 indent-tabs-mode:nil
46 fill-column:99
47 End:
48*/
49// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Data type representing a typeless value of a preference.
bool getBool(bool def=false) const
Interpret the preference as a Boolean value.
Glib::ustring const observed_path
Path which the observer watches.
static Preferences * get()
Access the singleton Preferences object.
void removeObserver(Observer &)
Remove an observer an prevent further notifications to it.
void addObserver(Observer &)
Register a preference observer.
~SimplePrefPusher() override
Destructor that unregisters the preference callback.
void notify(Inkscape::Preferences::Entry const &new_val) override
Callback method invoked when the preference setting changes.
SimplePrefPusher(Gtk::ToggleButton *btn, Glib::ustring const &path)
Constructor for a boolean value that syncs to the supplied path.
Helper class to stream background task notifications as a series of messages.