c8724557f65b3904d7b91cec69e2f7cd23567b30
[beifahrer] / src / settings-dialog.vala
1 /* This file is part of Beifahrer.
2  *
3  * Copyright (C) 2010 Philipp Zabel
4  *
5  * Beifahrer is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Beifahrer is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Beifahrer. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 using Gtk;
20 using Hildon;
21
22 public class SettingsDialog : Gtk.Dialog {
23         public const string GCONF_KEY_USE_LOCATION = "/apps/beifahrer/use_location";
24
25         Hildon.CheckButton use_location;
26         GConf.Client gconf;
27
28         public SettingsDialog (Gtk.Window window) {
29                 set_title (_("Settings"));
30                 set_transient_for (window);
31
32                 var vbox = (VBox) get_content_area ();
33                 use_location = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
34                 use_location.set_label (_("Determine point of departure automatically"));
35                 vbox.pack_start (use_location, true, true, 0);
36                 vbox.show_all ();
37
38                 add_button (_("Save"), ResponseType.APPLY);
39
40                 gconf = GConf.Client.get_default ();
41                 try {
42                         use_location.set_active (gconf.get_bool (GCONF_KEY_USE_LOCATION));
43                 } catch (Error e) {
44                         use_location.set_active (true);
45                 }
46
47                 response.connect (on_response);
48         }
49
50         void on_response (int response_id) {
51                 if (response_id == ResponseType.APPLY) try {
52                         gconf.set_bool (GCONF_KEY_USE_LOCATION, use_location.get_active ());
53                         this.destroy ();
54                 } catch (Error e) {
55                 }
56         }
57 }