From 8d6d0a20f37f463172b10f039aa60f7450ab91e2 Mon Sep 17 00:00:00 2001
From: kurono <andres.gomez@cern.ch>
Date: Sun, 30 Mar 2014 14:57:55 +0200
Subject: [PATCH] Fix for 5594: tails-greeter: better administration password
 UI

---
 GdmGreeter/optionswindow.py |   21 +++++++++++--------
 glade/optionswindow.glade   |   47 ++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/GdmGreeter/optionswindow.py b/GdmGreeter/optionswindow.py
index 5a2459b..15eec80 100644
--- a/GdmGreeter/optionswindow.py
+++ b/GdmGreeter/optionswindow.py
@@ -20,7 +20,8 @@
 
 """
 
-import logging, gtk, os
+import logging, gtk, gettext, os
+_ = gettext.gettext
 import GdmGreeter
 from GdmGreeter.language import TranslatableWindow
 from helpwindow import HelpWindow
@@ -37,8 +38,8 @@ class OptionsWindow(TranslatableWindow):
         builder.connect_signals(self)
         self.entry_password = builder.get_object("password_entry")
         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.warning_area_empty = builder.get_object("warning_area_empty")
+        self.warning_area_match = builder.get_object("warning_area_match")
         self.camouflage_checkbox = builder.get_object("camouflage_checkbox")
         self.macspoof_checkbox = builder.get_object("macspoof_checkbox")
         self.macspoof_checkbox.set_active(True)
@@ -53,7 +54,8 @@ class OptionsWindow(TranslatableWindow):
         self.entry_password2.set_visibility(False)
 
         def cb_pw_changed(*args):
-            self.warning_area.hide()
+            self.warning_area_empty.hide()
+            self.warning_area_match.hide()
             # compact the window
             self.window.resize(1, 1)
 
@@ -114,10 +116,13 @@ class OptionsWindow(TranslatableWindow):
         """Validate the selected options"""
         auth_password = self.entry_password.get_text()
         test_password = self.entry_password2.get_text()
-        passwords_match = test_password == auth_password
-        if not passwords_match:
-            self.warning_area.show()
-        return passwords_match
+        if len(auth_password) == 0 or len(test_password) == 0:
+            self.warning_area_empty.show()
+            return False
+        elif not auth_password == test_password:
+            self.warning_area_match.show()
+            return False
+        return True
 
     def set_options_and_login(self):
         """Activate the selected options if they are valid"""
diff --git a/glade/optionswindow.glade b/glade/optionswindow.glade
index 1632b62..a3ad0ea 100644
--- a/glade/optionswindow.glade
+++ b/glade/optionswindow.glade
@@ -227,12 +227,12 @@ Otherwise it will be disabled for better security.</property>
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkHBox" id="warning_area">
+                              <object class="GtkHBox" id="warning_area_empty">
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="spacing">6</property>
                                 <child>
-                                  <object class="GtkImage" id="warning_image">
+                                  <object class="GtkImage" id="warning_image_empty">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="stock">gtk-dialog-warning</property>
@@ -245,7 +245,48 @@ Otherwise it will be disabled for better security.</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkLabel" id="warning_label">
+                                  <object class="GtkLabel" id="warning_label_empty">
+                                    <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;Password must not be empty&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_match">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkImage" id="warning_image_match">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="stock">gtk-dialog-warning</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="warning_label_match">
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="xalign">0</property>
-- 
1.7.9.5

