1 /* This file is part of Beifahrer.
3 * Copyright (C) 2010 Philipp Zabel
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.
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.
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/>.
23 [CCode (cname = "hildon_gtk_entry_set_placeholder_text")]
24 extern static void gtk_entry_set_placeholder_text (Gtk.Entry entry, string placeholder_text);
26 [CCode (cname = "hildon_gtk_entry_set_input_mode")]
27 extern static void gtk_entry_set_input_mode (Gtk.Entry entry, Hildon.GtkInputMode mode);
30 public class SettingsDialog : Gtk.Dialog {
31 public const string GCONF_KEY_USE_LOCATION = "/apps/beifahrer/use_location";
32 public const string GCONF_KEY_PRELOAD = "/apps/beifahrer/preload";
33 public const string GCONF_KEY_USERNAME = "/apps/beifahrer/adac/username";
34 public const string GCONF_KEY_PASSWORD = "/apps/beifahrer/adac/password";
36 Hildon.CheckButton use_location;
37 Hildon.CheckButton preload;
38 Hildon.Entry username;
39 Hildon.Entry password;
42 public SettingsDialog (Gtk.Window window) {
43 set_title (_("Settings"));
44 set_transient_for (window);
46 var vbox = (VBox) get_content_area ();
47 use_location = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
48 use_location.set_label (_("Determine point of departure automatically"));
49 preload = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
50 preload.set_label (_("Preload lift details in the background"));
51 username = new Hildon.Entry (SizeType.FINGER_HEIGHT);
52 Hildon.gtk_entry_set_placeholder_text (username, _("Username"));
53 password = new Hildon.Entry (SizeType.FINGER_HEIGHT);
54 password.set_visibility (false);
55 Hildon.gtk_entry_set_placeholder_text (password, _("Password"));
56 vbox.pack_start (use_location, true, true, 0);
57 vbox.pack_start (preload, true, true, 0);
58 vbox.pack_start (username, true, true, 0);
59 vbox.pack_start (password, true, true, 0);
62 add_button (_("Save"), ResponseType.APPLY);
64 gconf = GConf.Client.get_default ();
66 use_location.set_active (gconf.get_bool (GCONF_KEY_USE_LOCATION));
67 preload.set_active (gconf.get_bool (GCONF_KEY_PRELOAD));
68 username.set_text (gconf.get_string (GCONF_KEY_USERNAME));
69 password.set_text (gconf.get_string (GCONF_KEY_PASSWORD));
71 use_location.set_active (true);
74 response.connect (on_response);
77 void on_response (int response_id) {
78 if (response_id == ResponseType.APPLY) try {
79 gconf.set_bool (GCONF_KEY_USE_LOCATION, use_location.get_active ());
80 gconf.set_bool (GCONF_KEY_PRELOAD, preload.get_active ());
81 gconf.set_string (GCONF_KEY_USERNAME, username.get_text ());
82 gconf.set_string (GCONF_KEY_PASSWORD, password.get_text ());