1 /* === S Y N F I G ========================================================= */
2 /*! \file dialogsettings.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "dialogsettings.h"
33 #include <synfigapp/main.h>
39 /* === U S I N G =========================================================== */
43 using namespace synfig;
44 using namespace studio;
46 /* === M A C R O S ========================================================= */
48 /* === G L O B A L S ======================================================= */
50 /* === P R O C E D U R E S ================================================= */
52 /* === M E T H O D S ======================================================= */
54 DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
58 synfigapp::Main::settings().add_domain(this,"window."+name);
61 DialogSettings::~DialogSettings()
63 synfigapp::Main::settings().remove_domain("window."+name);
67 DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
71 if(!window->is_visible())return false;
72 int x,y; window->get_position(x,y);
73 value=strprintf("%d %d",x,y);
78 if(!window->is_visible())return false;
79 int x,y; window->get_size(x,y);
80 value=strprintf("%d %d",x,y);
85 int x,y; window->get_position(x,y);
86 value=strprintf("%d",x);
91 int x,y; window->get_position(x,y);
92 value=strprintf("%d",y);
97 int x,y; window->get_size(x,y);
98 value=strprintf("%d",x);
103 int x,y; window->get_size(x,y);
104 value=strprintf("%d",y);
109 value=window->is_visible()?"1":"0";
113 return synfigapp::Settings::get_value(key,value);
117 DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
125 if(!strscanf(value,"%d %d",&x, &y))
133 if(!strscanf(value,"%d %d",&x, &y))
135 window->set_default_size(x,y);
140 int x,y; window->get_position(x,y);
141 x=atoi(value.c_str());
147 int x,y; window->get_position(x,y);
148 y=atoi(value.c_str());
154 int x,y; window->get_size(x,y);
155 x=atoi(value.c_str());
156 window->set_default_size(x,y);
161 int x,y; window->get_size(x,y);
162 y=atoi(value.c_str());
163 window->set_default_size(x,y);
175 return synfigapp::Settings::set_value(key,value);
178 synfigapp::Settings::KeyList
179 DialogSettings::get_key_list()const
181 synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
183 ret.push_back("size");
184 ret.push_back("pos");
185 ret.push_back("visible");