[Tails-dev] Fix to #5917 tails-greeter password field : Warn…

Delete this message

Reply to this message
Author: Andres Gomez Ramirez
Date:  
To: The Tails public development discussion list
Subject: [Tails-dev] Fix to #5917 tails-greeter password field : Warn when caps-lock in ON
Hi, I created a patch for feature #5917 (tails-greeter password field : Warn when caps-lock in ON).

I had a problem when caps lock key was on. I press the key again and it doesn't generate a key event, so the warning message does not hide until i press another key; don't know if this is GTK normal behavior or specific to my keyboard or virtualbox. Could please somebody check that?

kind regards,

kurono.




From 3f5fd5c90e1ef2cfe0873bd2e6f282487cc36242 Mon Sep 17 00:00:00 2001
From: kurono <andres.gomez@???>
Date: Sat, 5 Oct 2013 23:32:21 +0200
Subject: [PATCH 3/3] tails-greeter password field : Warn when caps-lock in ON

---
 GdmGreeter/optionswindow.py     |    8 ++++++++
 GdmGreeter/persistencewindow.py |    7 +++++++
 glade/optionswindow.glade       |   41 +++++++++++++++++++++++++++++++++++++
 glade/persistencewindow.glade   |   43 ++++++++++++++++++++++++++++++++++++++-
 4 files changed, 98 insertions(+), 1 deletion(-)


diff --git a/GdmGreeter/optionswindow.py b/GdmGreeter/optionswindow.py
index 9042cb9..cd8fa40 100644
--- a/GdmGreeter/optionswindow.py
+++ b/GdmGreeter/optionswindow.py
@@ -38,12 +38,14 @@ class OptionsWindow(TranslatableWindow):
         self.entry_password2 = builder.get_object("password_entry2")
         self.warning_label = builder.get_object("warning_label")
         self.warning_area = builder.get_object("warning_area")
+    self.caps_lock_warning_area = builder.get_object("caps_lock_warning_area")
         self.camouflage_checkbox = builder.get_object("camouflage_checkbox")


         TranslatableWindow.__init__(self, builder.get_object("options_dialog"))
         self.window.set_visible(False)


         self.warning_area.hide()
+    self.caps_lock_warning_area.hide()
         self.entry_password.set_visibility(False)
         self.entry_password2.set_visibility(False)


@@ -86,6 +88,12 @@ class OptionsWindow(TranslatableWindow):
                     self.entry_password2.grab_focus()
                 else:
                     self.set_options_and_login()
+            elif event.keyval == gtk.keysyms.Caps_Lock:            
+        if event.state & gtk.gdk.LOCK_MASK:
+            self.caps_lock_warning_area.show()
+        elif not (event.state & gtk.gdk.LOCK_MASK):
+        self.caps_lock_warning_area.hide()    
+


     def delete_event_cb(self, widget, event=None):
         """Ignore delete event (Esc)"""
diff --git a/GdmGreeter/persistencewindow.py b/GdmGreeter/persistencewindow.py
index 657544f..7df7a2a 100644
--- a/GdmGreeter/persistencewindow.py
+++ b/GdmGreeter/persistencewindow.py
@@ -53,6 +53,7 @@ class PersistenceWindow(TranslatableWindow):
         self.readonly_checkbutton = builder.get_object("readonly_checkbutton")
         self.warning_label = builder.get_object("warning_label")
         self.warning_area = builder.get_object("warning_area")
+        self.caps_lock_warning_area = builder.get_object("caps_lock_warning_area")
         self.warning_image = builder.get_object("warning_area")
         # self.spinner = builder.get_object("spinner")
         self.checked_img_moreoptions_yes = builder.get_object("moreoptions_yes_checked_img")
@@ -61,6 +62,7 @@ class PersistenceWindow(TranslatableWindow):
         self.checked_img_persistence_no  = builder.get_object("persistence_no_checked_img")


         self.warning_area.hide()
+        self.caps_lock_warning_area.hide()


         # FIXME: list_containers may raise exceptions. Deal with that.
         self.containers = [
@@ -189,6 +191,11 @@ class PersistenceWindow(TranslatableWindow):
         if event:
             if event.keyval in [ gtk.keysyms.Return, gtk.keysyms.KP_Enter ]:
                 self.go()
+            elif event.keyval == gtk.keysyms.Caps_Lock:            
+        if event.state & gtk.gdk.LOCK_MASK:
+            self.caps_lock_warning_area.show()
+        elif not (event.state & gtk.gdk.LOCK_MASK):
+        self.caps_lock_warning_area.hide()


     def delete_event_cb(self, widget, event=None):
         """Ignore delete event (Esc)"""
diff --git a/glade/optionswindow.glade b/glade/optionswindow.glade
index e0bedaa..30054a6 100644
--- a/glade/optionswindow.glade
+++ b/glade/optionswindow.glade
@@ -184,6 +184,47 @@ Otherwise it will be disabled for better security.</property>
                     <property name="position">2</property>
                   </packing>
                 </child>
+        <child>
+                  <object class="GtkHBox" id="caps_lock_warning_area">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkImage" id="caps_lock_warning_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="stock">gtk-info</property>
+                        <property name="icon-size">1</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="caps_lock_warning_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">10</property>
+                        <property name="ypad">10</property>
+                        <property name="label" translatable="yes">&lt;i&gt;Caps lock is on&lt;/i&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
                 <child>
                   <object class="GtkHBox" id="warning_area">
                     <property name="visible">True</property>
diff --git a/glade/persistencewindow.glade b/glade/persistencewindow.glade
index 0b6f25f..f4b3c91 100644
--- a/glade/persistencewindow.glade
+++ b/glade/persistencewindow.glade
@@ -292,6 +292,47 @@
                     <property name="position">2</property>
                   </packing>
                 </child>
+        <child>
+                  <object class="GtkHBox" id="caps_lock_warning_area">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkImage" id="caps_lock_warning_image">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="stock">gtk-info</property>
+                        <property name="icon-size">1</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="caps_lock_warning_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="xpad">10</property>
+                        <property name="ypad">10</property>
+                        <property name="label" translatable="yes">&lt;i&gt;Caps lock is on&lt;/i&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
                 <child>
                   <object class="GtkHBox" id="warning_area">
                     <property name="can_focus">False</property>