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>
34 #include <gdkmm/general.h>
40 /* === U S I N G =========================================================== */
44 using namespace synfig;
45 using namespace studio;
47 /* === M A C R O S ========================================================= */
49 /* === G L O B A L S ======================================================= */
51 /* === P R O C E D U R E S ================================================= */
53 /* === M E T H O D S ======================================================= */
55 DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
59 synfigapp::Main::settings().add_domain(this,"window."+name);
62 DialogSettings::~DialogSettings()
64 synfigapp::Main::settings().remove_domain("window."+name);
68 DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
72 if(!window->is_visible())return false;
73 int x,y; window->get_position(x,y);
74 value=strprintf("%d %d",x,y);
79 if(!window->is_visible())return false;
80 int x,y; window->get_size(x,y);
81 value=strprintf("%d %d",x,y);
86 int x,y; window->get_position(x,y);
87 value=strprintf("%d",x);
92 int x,y; window->get_position(x,y);
93 value=strprintf("%d",y);
98 int x,y; window->get_size(x,y);
99 value=strprintf("%d",x);
104 int x,y; window->get_size(x,y);
105 value=strprintf("%d",y);
110 value=window->is_visible()?"1":"0";
114 return synfigapp::Settings::get_value(key,value);
118 DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
120 int screen_w(Gdk::screen_width());
121 int screen_h(Gdk::screen_height());
129 if(!strscanf(value,"%d %d",&x, &y))
132 if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
133 if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
141 if(!strscanf(value,"%d %d",&x, &y))
144 if (x > screen_w) x = 150; if (x < 0) x = 0;
145 if (y > screen_h) y = 150; if (y < 0) y = 0;
147 window->set_default_size(x,y);
152 int x,y; window->get_position(x,y);
153 x=atoi(value.c_str());
159 int x,y; window->get_position(x,y);
160 y=atoi(value.c_str());
166 int x,y; window->get_size(x,y);
167 x=atoi(value.c_str());
168 window->set_default_size(x,y);
173 int x,y; window->get_size(x,y);
174 y=atoi(value.c_str());
175 window->set_default_size(x,y);
187 return synfigapp::Settings::set_value(key,value);
190 synfigapp::Settings::KeyList
191 DialogSettings::get_key_list()const
193 synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
195 ret.push_back("size");
196 ret.push_back("pos");
197 ret.push_back("visible");