1 /* === S Y N F I G ========================================================= */
2 /*! \file dialogsettings.cpp
3 ** \brief Template File
5 ** $Id: dialogsettings.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
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>
37 /* === U S I N G =========================================================== */
41 using namespace synfig;
42 using namespace studio;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
56 synfigapp::Main::settings().add_domain(this,"window."+name);
59 DialogSettings::~DialogSettings()
61 synfigapp::Main::settings().remove_domain("window."+name);
65 DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
69 if(!window->is_visible())return false;
70 int x,y; window->get_position(x,y);
71 value=strprintf("%d %d",x,y);
76 if(!window->is_visible())return false;
77 int x,y; window->get_size(x,y);
78 value=strprintf("%d %d",x,y);
83 int x,y; window->get_position(x,y);
84 value=strprintf("%d",x);
89 int x,y; window->get_position(x,y);
90 value=strprintf("%d",y);
95 int x,y; window->get_size(x,y);
96 value=strprintf("%d",x);
101 int x,y; window->get_size(x,y);
102 value=strprintf("%d",y);
107 value=window->is_visible()?"1":"0";
111 return synfigapp::Settings::get_value(key,value);
115 DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
123 if(!strscanf(value,"%d %d",&x, &y))
131 if(!strscanf(value,"%d %d",&x, &y))
133 window->set_default_size(x,y);
138 int x,y; window->get_position(x,y);
139 x=atoi(value.c_str());
145 int x,y; window->get_position(x,y);
146 y=atoi(value.c_str());
152 int x,y; window->get_size(x,y);
153 x=atoi(value.c_str());
154 window->set_default_size(x,y);
159 int x,y; window->get_size(x,y);
160 y=atoi(value.c_str());
161 window->set_default_size(x,y);
173 return synfigapp::Settings::set_value(key,value);
176 synfigapp::Settings::KeyList
177 DialogSettings::get_key_list()const
179 synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
181 ret.push_back("size");
182 ret.push_back("pos");
183 ret.push_back("visible");