Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Inkscape::UI::SimplePrefPusher Class Reference

A simple mediator class that sets the state of a Gtk::ToggleButton when a preference is changed. More...

#include <simple-pref-pusher.h>

Inheritance diagram for Inkscape::UI::SimplePrefPusher:
Inkscape::Preferences::Observer

Public Member Functions

 SimplePrefPusher (Gtk::ToggleButton *btn, Glib::ustring const &path)
 Constructor for a boolean value that syncs to the supplied path.
 
 ~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.
 
- Public Member Functions inherited from Inkscape::Preferences::Observer
 Observer (Glib::ustring path)
 Constructor.
 
virtual ~Observer ()
 

Private Attributes

Gtk::ToggleButton * _btn
 
bool freeze
 

Additional Inherited Members

- Public Attributes inherited from Inkscape::Preferences::Observer
Glib::ustring const observed_path
 Path which the observer watches.
 

Detailed Description

A simple mediator class that sets the state of a Gtk::ToggleButton 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 ToggleButton.

Definition at line 20 of file simple-pref-pusher.h.

Constructor & Destructor Documentation

◆ SimplePrefPusher()

Inkscape::UI::SimplePrefPusher::SimplePrefPusher ( Gtk::ToggleButton *  btn,
Glib::ustring const &  path 
)

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.

Parameters
actthe widget to synchronize preference with.
paththe path to the preference the widget is synchronized with.
callbackfunction to invoke when changes are pushed.
cbDatadata to be passed on to the callback function.

Definition at line 9 of file simple-pref-pusher.cpp.

References _btn, Inkscape::Preferences::addObserver(), freeze, Inkscape::Preferences::get(), and Inkscape::Preferences::Observer::observed_path.

◆ ~SimplePrefPusher()

Inkscape::UI::SimplePrefPusher::~SimplePrefPusher ( )
override

Destructor that unregisters the preference callback.

Definition at line 21 of file simple-pref-pusher.cpp.

References Inkscape::Preferences::get(), and Inkscape::Preferences::removeObserver().

Member Function Documentation

◆ notify()

void Inkscape::UI::SimplePrefPusher::notify ( Inkscape::Preferences::Entry const &  new_val)
overridevirtual

Callback method invoked when the preference setting changes.

Implements Inkscape::Preferences::Observer.

Definition at line 27 of file simple-pref-pusher.cpp.

References _btn, freeze, and Inkscape::Preferences::Entry::getBool().

Member Data Documentation

◆ _btn

Gtk::ToggleButton* Inkscape::UI::SimplePrefPusher::_btn
private

Definition at line 47 of file simple-pref-pusher.h.

Referenced by notify(), and SimplePrefPusher().

◆ freeze

bool Inkscape::UI::SimplePrefPusher::freeze
private

Definition at line 48 of file simple-pref-pusher.h.

Referenced by notify(), and SimplePrefPusher().


The documentation for this class was generated from the following files: