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
9 ** Copyright (c) 2007, 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "dialogsettings.h"
34 #include <synfigapp/main.h>
35 #include <gdkmm/general.h>
41 /* === U S I N G =========================================================== */
45 using namespace synfig;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
60 synfigapp::Main::settings().add_domain(this,"window."+name);
63 DialogSettings::~DialogSettings()
65 synfigapp::Main::settings().remove_domain("window."+name);
69 DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
73 // if(!window->is_visible())return false;
74 int x,y; window->get_position(x,y);
75 value=strprintf("%d %d",x,y);
80 // if(!window->is_visible())return false;
81 int x,y; window->get_size(x,y);
82 value=strprintf("%d %d",x,y);
87 int x,y; window->get_position(x,y);
88 value=strprintf("%d",x);
93 int x,y; window->get_position(x,y);
94 value=strprintf("%d",y);
99 int x,y; window->get_size(x,y);
100 value=strprintf("%d",x);
105 int x,y; window->get_size(x,y);
106 value=strprintf("%d",y);
111 value=window->is_visible()?"1":"0";
115 return synfigapp::Settings::get_value(key,value);
119 DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
121 int screen_w(Gdk::screen_width());
122 int screen_h(Gdk::screen_height());
130 if(!strscanf(value,"%d %d",&x, &y))
133 if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
134 if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
142 if(!strscanf(value,"%d %d",&x, &y))
145 if (x > screen_w) x = 150; if (x < 0) x = 0;
146 if (y > screen_h) y = 150; if (y < 0) y = 0;
148 window->set_default_size(x,y);
153 int x,y; window->get_position(x,y);
154 x=atoi(value.c_str());
160 int x,y; window->get_position(x,y);
161 y=atoi(value.c_str());
167 int x,y; window->get_size(x,y);
168 x=atoi(value.c_str());
169 window->set_default_size(x,y);
174 int x,y; window->get_size(x,y);
175 y=atoi(value.c_str());
176 window->set_default_size(x,y);
188 return synfigapp::Settings::set_value(key,value);
191 synfigapp::Settings::KeyList
192 DialogSettings::get_key_list()const
194 synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
196 ret.push_back("size");
197 ret.push_back("pos");
198 ret.push_back("visible");