Merge dynamic-initials-field branch, enhances usability of initials field

This commit is contained in:
Sean Davis 2014-04-01 20:37:51 -04:00
commit 303ed23225
3 changed files with 32 additions and 18 deletions

View File

@ -358,6 +358,7 @@
<property name="width_chars">4</property> <property name="width_chars">4</property>
<property name="input_purpose">alpha</property> <property name="input_purpose">alpha</property>
<signal name="activate" handler="entry_focus_next" swapped="no"/> <signal name="activate" handler="entry_focus_next" swapped="no"/>
<signal name="grab-focus" handler="initials_entry_focused" swapped="no"/>
</object> </object>
</child> </child>
</object> </object>

View File

@ -231,17 +231,12 @@ class MugshotWindow(Window):
name, office, office_phone, home_phone = details.split(',', 3) name, office, office_phone, home_phone = details.split(',', 3)
break break
# Expand the user's fullname into first, last, and initials. # Expand the user's fullname into first and last.
try: try:
first_name, last_name = name.split(' ', 1) first_name, last_name = name.split(' ', 1)
initials = first_name[0] + last_name[0]
except: except:
first_name = name first_name = name
last_name = '' last_name = ''
if first_name:
initials = first_name[0]
else:
initials = ''
# If the variables are defined as 'none', use blank for cleanliness. # If the variables are defined as 'none', use blank for cleanliness.
if home_phone == 'none': if home_phone == 'none':
@ -251,7 +246,6 @@ class MugshotWindow(Window):
# Get dconf settings # Get dconf settings
logger.debug('Getting initials, email, and fax from dconf') logger.debug('Getting initials, email, and fax from dconf')
if self.settings['initials'] != '':
initials = self.settings['initials'] initials = self.settings['initials']
email = self.settings['email'] email = self.settings['email']
fax = self.settings['fax'] fax = self.settings['fax']
@ -290,6 +284,17 @@ class MugshotWindow(Window):
self.menuitem1.set_visible(False) self.menuitem1.set_visible(False)
self.image_remove.set_visible(False) self.image_remove.set_visible(False)
def suggest_initials(self, first_name, last_name):
"""Generate initials from first and last name."""
try:
initials = first_name[0] + last_name[0]
except:
if first_name:
initials = first_name[0]
else:
initials = ''
return initials
def filter_numbers(self, entry, *args): def filter_numbers(self, entry, *args):
"""Allow only numbers and + in phone entry fields.""" """Allow only numbers and + in phone entry fields."""
text = entry.get_text().strip() text = entry.get_text().strip()
@ -337,6 +342,14 @@ class MugshotWindow(Window):
vbox = widget.get_parent().get_parent().get_parent().get_parent() vbox = widget.get_parent().get_parent().get_parent().get_parent()
vbox.child_focus(Gtk.DirectionType.TAB_FORWARD) vbox.child_focus(Gtk.DirectionType.TAB_FORWARD)
def initials_entry_focused(self, widget):
"""Paste initials into empty field."""
logger.debug('Initials field focused.')
first_name = get_entry_value(self.first_name_entry)
last_name = get_entry_value(self.last_name_entry)
if get_entry_value(self.initials_entry) == '':
self.initials_entry.set_text(self.suggest_initials(first_name, last_name))
def on_cancel_button_clicked(self, widget): def on_cancel_button_clicked(self, widget):
"""When the window cancel button is clicked, close the program.""" """When the window cancel button is clicked, close the program."""
logger.debug('Cancel clicked, goodbye.') logger.debug('Cancel clicked, goodbye.')

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-01 06:18-0400\n" "POT-Creation-Date: 2014-04-01 20:36-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -61,7 +61,7 @@ msgstr ""
msgid "Browse…" msgid "Browse…"
msgstr "" msgstr ""
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:507 #: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:520
msgid "Mugshot" msgid "Mugshot"
msgstr "" msgstr ""
@ -131,37 +131,37 @@ msgid "Retry"
msgstr "" msgstr ""
#. Password was incorrect, complain. #. Password was incorrect, complain.
#: ../mugshot/MugshotWindow.py:306 #: ../mugshot/MugshotWindow.py:311
msgid "Authentication Failed" msgid "Authentication Failed"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:307 #: ../mugshot/MugshotWindow.py:312
msgid "User details were not updated." msgid "User details were not updated."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:437 #: ../mugshot/MugshotWindow.py:450
msgid "Update Pidgin buddy icon?" msgid "Update Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:438 #: ../mugshot/MugshotWindow.py:451
msgid "Would you also like to update your Pidgin buddy icon?" msgid "Would you also like to update your Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:508 #: ../mugshot/MugshotWindow.py:521
msgid "Enter your password to change user details." msgid "Enter your password to change user details."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:510 #: ../mugshot/MugshotWindow.py:523
msgid "" msgid ""
"This is a security measure to prevent unwanted updates\n" "This is a security measure to prevent unwanted updates\n"
"to your personal information." "to your personal information."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:657 #: ../mugshot/MugshotWindow.py:670
msgid "Update LibreOffice user details?" msgid "Update LibreOffice user details?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:658 #: ../mugshot/MugshotWindow.py:671
msgid "Would you also like to update your user details in LibreOffice?" msgid "Would you also like to update your user details in LibreOffice?"
msgstr "" msgstr ""