summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2016-08-28 23:43:02 +1000
committerTim Mayberry <mojofunk@gmail.com>2017-04-19 09:36:55 +1000
commit6779770fee22b9409976bc63b6f1a65621c5a222 (patch)
tree78f7d92b544809cb2bf284ddfb15b39f6c2255ad /libs/gtkmm2ext
parentc627da0a9f91b793fb4ca6707416a9b71fd2a0e3 (diff)
Use XMLNode::get/set_property API in Gtkmm2ext::Tearoff class
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/tearoff.cc66
1 files changed, 26 insertions, 40 deletions
diff --git a/libs/gtkmm2ext/tearoff.cc b/libs/gtkmm2ext/tearoff.cc
index bb30e5610f..090d249b72 100644
--- a/libs/gtkmm2ext/tearoff.cc
+++ b/libs/gtkmm2ext/tearoff.cc
@@ -266,56 +266,42 @@ TearOff::torn_off() const
void
TearOff::add_state (XMLNode& node) const
{
- node.add_property ("tornoff", (_torn ? "yes" : "no"));
+ node.set_property ("tornoff", _torn);
- if (own_window_width > 0) {
- char buf[32];
-
- snprintf (buf, sizeof (buf), "%d", own_window_width);
- node.add_property ("width", buf);
- snprintf (buf, sizeof (buf), "%d", own_window_height);
- node.add_property ("height", buf);
- snprintf (buf, sizeof (buf), "%d", own_window_xpos);
- node.add_property ("xpos", buf);
- snprintf (buf, sizeof (buf), "%d", own_window_ypos);
- node.add_property ("ypos", buf);
- }
+ if (own_window_width > 0) {
+ node.set_property ("width", own_window_width);
+ node.set_property ("height", own_window_height);
+ node.set_property ("xpos", own_window_xpos);
+ node.set_property ("ypos", own_window_ypos);
+ }
}
void
TearOff::set_state (const XMLNode& node)
{
- Glib::RefPtr<Gdk::Window> win;
- XMLProperty const * prop;
+ Glib::RefPtr<Gdk::Window> win;
- if ((prop = node.property (X_("tornoff"))) == 0) {
- return;
- }
+ bool tornoff;
+ if (!node.get_property (X_("tornoff"), tornoff)) {
+ return;
+ }
- if (prop->value() == "yes") {
- tear_it_off ();
- } else {
- put_it_back ();
- }
+ if (tornoff) {
+ tear_it_off ();
+ } else {
+ put_it_back ();
+ }
- if ((prop = node.property (X_("width"))) != 0) {
- sscanf (prop->value().c_str(), "%d", &own_window_width);
- }
- if ((prop = node.property (X_("height"))) != 0) {
- sscanf (prop->value().c_str(), "%d", &own_window_height);
- }
- if ((prop = node.property (X_("xpos"))) != 0) {
- sscanf (prop->value().c_str(), "%d", &own_window_xpos);
- }
- if ((prop = node.property (X_("ypos"))) != 0) {
- sscanf (prop->value().c_str(), "%d", &own_window_ypos);
- }
+ node.get_property (X_("width"), own_window_width);
+ node.get_property (X_("height"), own_window_height);
+ node.get_property (X_("xpos"), own_window_xpos);
+ node.get_property (X_("ypos"), own_window_ypos);
- if (own_window.is_realized()) {
- own_window.set_default_size (own_window_width, own_window_height);
- own_window.move (own_window_xpos, own_window_ypos);
- }
- /* otherwise do it once the window is realized, see below */
+ if (own_window.is_realized ()) {
+ own_window.set_default_size (own_window_width, own_window_height);
+ own_window.move (own_window_xpos, own_window_ypos);
+ }
+ /* otherwise do it once the window is realized, see below */
}
void