Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Adjust the 'password strength' box position. Add 'space' as one of its
Browse files Browse the repository at this point in the history
criteria. Add contextual help for all criteria.
  • Loading branch information
Pierrick Le Brun committed Feb 16, 2013
1 parent 727c8cc commit 1d2647e
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 102 deletions.
193 changes: 101 additions & 92 deletions src/salix-live-installer.glade
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,32 @@ MA 02110-1301, USA.</property>
</row>
</data>
</object>
<object class="GtkListStore" id="main_format_list_store">
<columns>
<!-- column-name type -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">ext2</col>
</row>
<row>
<col id="0" translatable="yes">ext3</col>
</row>
<row>
<col id="0" translatable="yes">ext4</col>
</row>
<row>
<col id="0" translatable="yes">reiserfs</col>
</row>
<row>
<col id="0" translatable="yes">xfs</col>
</row>
<row>
<col id="0" translatable="yes">jfs</col>
</row>
</data>
</object>
<object class="GtkListStore" id="main_partition_list_store">
<columns>
<!-- column-name disk -->
Expand Down Expand Up @@ -289,32 +315,6 @@ MA 02110-1301, USA.</property>
</row>
</data>
</object>
<object class="GtkListStore" id="main_format_list_store">
<columns>
<!-- column-name type -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">ext2</col>
</row>
<row>
<col id="0" translatable="yes">ext3</col>
</row>
<row>
<col id="0" translatable="yes">ext4</col>
</row>
<row>
<col id="0" translatable="yes">reiserfs</col>
</row>
<row>
<col id="0" translatable="yes">xfs</col>
</row>
<row>
<col id="0" translatable="yes">jfs</col>
</row>
</data>
</object>
<object class="GtkListStore" id="month_list_store">
<columns>
<!-- column-name month -->
Expand All @@ -341,67 +341,6 @@ MA 02110-1301, USA.</property>
</row>
</data>
</object>
<object class="GtkDialog" id="progress_dialog">
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="is_focus">True</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Salix installation</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center-always</property>
<property name="icon">salix-live-installer.png</property>
<property name="type_hint">normal</property>
<property name="deletable">False</property>
<property name="transient_for">main_window</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="install_progress_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Please be patient, Salix installation is in progress... </property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="install_progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="activity_mode">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="main_window">
<property name="width_request">800</property>
<property name="visible">True</property>
Expand Down Expand Up @@ -3371,8 +3310,9 @@ If you already have all the needed partitions, please click on the button 'Do no
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">1</property>
</packing>
</child>
Expand Down Expand Up @@ -3416,6 +3356,8 @@ If you already have all the needed partitions, please click on the button 'Do no
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="enter-notify-event" handler="on_user_pass_strength_enter_notify_event" swapped="no"/>
<signal name="leave-notify-event" handler="on_user_pass_strength_leave_notify_event" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -3426,8 +3368,9 @@ If you already have all the needed partitions, please click on the button 'Do no
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">2</property>
</packing>
</child>
Expand Down Expand Up @@ -3486,8 +3429,9 @@ If you already have all the needed partitions, please click on the button 'Do no
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">3</property>
</packing>
</child>
Expand Down Expand Up @@ -3647,6 +3591,8 @@ If you already have all the needed partitions, please click on the button 'Do no
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="enter-notify-event" handler="on_root_pass_strength_enter_notify_event" swapped="no"/>
<signal name="leave-notify-event" handler="on_root_pass_strength_leave_notify_event" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -3657,8 +3603,9 @@ If you already have all the needed partitions, please click on the button 'Do no
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">7</property>
</packing>
</child>
Expand Down Expand Up @@ -3717,8 +3664,9 @@ If you already have all the needed partitions, please click on the button 'Do no
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">8</property>
</packing>
</child>
Expand Down Expand Up @@ -4308,6 +4256,67 @@ If you already have all the needed partitions, please click on the button 'Do no
</object>
</child>
</object>
<object class="GtkDialog" id="progress_dialog">
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="is_focus">True</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Salix installation</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center-always</property>
<property name="icon">salix-live-installer.png</property>
<property name="type_hint">normal</property>
<property name="deletable">False</property>
<property name="transient_for">main_window</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="install_progress_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Please be patient, Salix installation is in progress... </property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkProgressBar" id="install_progressbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="activity_mode">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="win_mountpoint_list_store">
<columns>
<!-- column-name mountpoint -->
Expand Down
38 changes: 28 additions & 10 deletions src/salix-live-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def on_user_pass1_entry_enter_notify_event(self, widget, data=None):
@, !, and &)"))
def on_user_pass2_entry_enter_notify_event(self, widget, data=None):
self.ContextLabel.set_text(_("Here you must retype your password as a confirmation \
of your choice."))
of your choice."))
def on_user_visible_checkbutton_enter_notify_event(self, widget, data=None):
self.ContextLabel.set_text(_("Check this box if you want to be able to see the password you \
are typing."))
Expand Down Expand Up @@ -748,7 +748,7 @@ def partitions_settings(self):
self.MainPartitionBox.show()
def swap_detection(self):
"""
Displays the swap partitions that were detected on the system which
Display the swap partitions that were detected on the system which
will be automatically used by the installer.
Displays a warning message when no (swap) partition is found.
"""
Expand Down Expand Up @@ -855,23 +855,39 @@ def on_clone_login_undo_clicked(self, widget, data=None):
self.users_settings_liveclone()
def get_password_strength(self, pwd):
"""
Returns a number from 0 to 4 indicates the strength of the password.
Return a number from 0 to 4 to indicate the strength of the password.
"""
if not pwd:
score = 0
else:
score = 1
self.ContextLabel.set_markup(_("<b>Password strength:</b>\nLess than 5 characters"))
if len(pwd) >= 5:
score += 1
contextLabelText = _("<b>Password strength:</b>\n")
if re.search(r'\ ', pwd):
score += 0.4
else:
contextLabelText += _("No space...\n")
if re.search(r'[A-Z]', pwd):
score += 0.5
score += 0.4
else:
contextLabelText += _("No upper case letter...\n")
if re.search(r'[1-9]', pwd):
score += 0.5
score += 0.4
else:
contextLabelText += _("No number...\n")
if re.search(r'[-_.,;:!?"\']', pwd):
score += 0.5
score += 0.4
else:
contextLabelText += _("No punctuation...\n")
if re.search(r'[][(){}/\<>$%*#@^]', pwd):
score += 0.5
else:
contextLabelText += _("No symbol...\n")
score = int(math.floor(score))
self.ContextLabel.set_markup(_(contextLabelText))

return score
def set_progressbar_strength(self, pwd, draw_widget):
strength = self.get_password_strength(pwd)
Expand All @@ -886,12 +902,14 @@ def set_progressbar_strength(self, pwd, draw_widget):
progress_color = draw_widget.get_colormap().alloc_color("#CCCC00")
elif strength == 4:
progress_color = draw_widget.get_colormap().alloc_color("#00FF00")
self.ContextLabel.set_markup(_("<b>Password strength:</b>\n\nSatisfactory!"))
gc.set_foreground(bg_color)
draw_widget.window.draw_rectangle(gc, True, 0, 0, 80, 25)
draw_widget.window.draw_rectangle(gc, True, 0, 1, 80, 20)
gc.set_foreground(progress_color)
draw_widget.window.draw_rectangle(gc, True, 0, 0, 20 * strength, 25)
draw_widget.window.draw_rectangle(gc, True, 0, 1, 20 * strength, 20)
gc.set_foreground(border_color)
draw_widget.window.draw_rectangle(gc, False, 0, 0, 80, 25)
draw_widget.window.draw_rectangle(gc, False, 0, 1, 80, 20)

def on_user_pass1_entry_changed(self, widget, data=None):
self.set_progressbar_strength(widget.get_text().strip(), self.UserPassStrength)
def on_user_visible_checkbutton_toggled(self, widget, data=None):
Expand Down Expand Up @@ -1074,7 +1092,7 @@ def info_dialog(message, parent = None):
# Error window skeleton:
def error_dialog(message, parent = None):
"""
Displays an error message.
Display an error message.
"""
dialog = gtk.MessageDialog(parent = parent, type = gtk.MESSAGE_ERROR, buttons = gtk.BUTTONS_CLOSE, flags = gtk.DIALOG_MODAL)
dialog.set_markup(message)
Expand Down

0 comments on commit 1d2647e

Please sign in to comment.