Improve initials field behavior
This commit is contained in:
parent
495105220d
commit
323435efaa
|
@ -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>
|
||||||
|
|
|
@ -234,14 +234,14 @@ class MugshotWindow(Window):
|
||||||
# Expand the user's fullname into first, last, and initials.
|
# Expand the user's fullname into first, last, and initials.
|
||||||
try:
|
try:
|
||||||
first_name, last_name = name.split(' ', 1)
|
first_name, last_name = name.split(' ', 1)
|
||||||
initials = first_name[0] + last_name[0]
|
self.initials_suggestion = first_name[0] + last_name[0]
|
||||||
except:
|
except:
|
||||||
first_name = name
|
first_name = name
|
||||||
last_name = ''
|
last_name = ''
|
||||||
if first_name:
|
if first_name:
|
||||||
initials = first_name[0]
|
self.initials_suggestion = first_name[0]
|
||||||
else:
|
else:
|
||||||
initials = ''
|
self.initials_suggestion = ''
|
||||||
|
|
||||||
# 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,8 +251,7 @@ 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']
|
||||||
|
|
||||||
|
@ -330,6 +329,12 @@ class MugshotWindow(Window):
|
||||||
logger.debug('Entry activated, focusing next widget.')
|
logger.debug('Entry activated, focusing next widget.')
|
||||||
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.')
|
||||||
|
if get_entry_value(self.initials_entry) == '':
|
||||||
|
self.initials_entry.set_text(self.initials_suggestion)
|
||||||
|
|
||||||
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."""
|
||||||
|
|
Loading…
Reference in New Issue