Debian packaging: 0.0.4-1
[beifahrer] / src / settings-dialog.vala
index 8617e83..aea80c1 100644 (file)
 using Gtk;
 using Hildon;
 
+namespace Hildon {
+       [CCode (cname = "hildon_gtk_entry_set_placeholder_text")]
+       extern static void gtk_entry_set_placeholder_text (Gtk.Entry entry, string placeholder_text);
+
+       [CCode (cname = "hildon_gtk_entry_set_input_mode")]
+       extern static void gtk_entry_set_input_mode (Gtk.Entry entry, Hildon.GtkInputMode mode);
+}
+
 public class SettingsDialog : Gtk.Dialog {
        public const string GCONF_KEY_USE_LOCATION = "/apps/beifahrer/use_location";
        public const string GCONF_KEY_PRELOAD = "/apps/beifahrer/preload";
+       public const string GCONF_KEY_USERNAME = "/apps/beifahrer/adac/username";
+       public const string GCONF_KEY_PASSWORD = "/apps/beifahrer/adac/password";
 
        Hildon.CheckButton use_location;
        Hildon.CheckButton preload;
+       Hildon.Entry username;
+       Hildon.Entry password;
        GConf.Client gconf;
 
        public SettingsDialog (Gtk.Window window) {
@@ -36,8 +48,15 @@ public class SettingsDialog : Gtk.Dialog {
                use_location.set_label (_("Determine point of departure automatically"));
                preload = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
                preload.set_label (_("Preload lift details in the background"));
+               username = new Hildon.Entry (SizeType.FINGER_HEIGHT);
+               Hildon.gtk_entry_set_placeholder_text (username, _("Username"));
+               password = new Hildon.Entry (SizeType.FINGER_HEIGHT);
+               password.set_visibility (false);
+               Hildon.gtk_entry_set_placeholder_text (password, _("Password"));
                vbox.pack_start (use_location, true, true, 0);
                vbox.pack_start (preload, true, true, 0);
+               vbox.pack_start (username, true, true, 0);
+               vbox.pack_start (password, true, true, 0);
                vbox.show_all ();
 
                add_button (_("Save"), ResponseType.APPLY);
@@ -46,6 +65,8 @@ public class SettingsDialog : Gtk.Dialog {
                try {
                        use_location.set_active (gconf.get_bool (GCONF_KEY_USE_LOCATION));
                        preload.set_active (gconf.get_bool (GCONF_KEY_PRELOAD));
+                       username.set_text (gconf.get_string (GCONF_KEY_USERNAME));
+                       password.set_text (gconf.get_string (GCONF_KEY_PASSWORD));
                } catch (Error e) {
                        use_location.set_active (true);
                }
@@ -57,6 +78,8 @@ public class SettingsDialog : Gtk.Dialog {
                if (response_id == ResponseType.APPLY) try {
                        gconf.set_bool (GCONF_KEY_USE_LOCATION, use_location.get_active ());
                        gconf.set_bool (GCONF_KEY_PRELOAD, preload.get_active ());
+                       gconf.set_string (GCONF_KEY_USERNAME, username.get_text ());
+                       gconf.set_string (GCONF_KEY_PASSWORD, password.get_text ());
                        this.destroy ();
                } catch (Error e) {
                }