PEP8 for __init__.py and MugshotWindow.py

This commit is contained in:
Sean Davis 2014-04-01 21:42:05 -04:00
parent 85a69692ab
commit 2da1541586
2 changed files with 89 additions and 77 deletions

View File

@ -278,7 +278,7 @@ class MugshotWindow(Window):
self.email_entry.set_text(email)
self.fax_entry.set_text(fax)
# = Mugshot Window ======================================================= #
# = Mugshot Window ====================================================== #
def set_user_image(self, filename=None):
"""Scale and set the user profile image."""
logger.debug("Setting user profile image to %s" % str(filename))
@ -322,7 +322,8 @@ class MugshotWindow(Window):
primary = _("Authentication Failed")
secondary = _("User details were not updated.")
dialog = Gtk.MessageDialog(transient_for=self, flags=0,
message_type=Gtk.MessageType.WARNING,
message_type=
Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.OK,
text=primary)
dialog.format_secondary_text(secondary)
@ -367,7 +368,7 @@ class MugshotWindow(Window):
logger.debug('Cancel clicked, goodbye.')
self.destroy()
# = Image Button and Menu ================================================ #
# = Image Button and Menu =============================================== #
def on_image_button_clicked(self, widget):
"""When the menu button is clicked, display the photo menu."""
if widget.get_active():
@ -441,7 +442,8 @@ class MugshotWindow(Window):
'org.freedesktop.DBus.Properties',
'GetAll',
GLib.Variant('(s)',
('org.freedesktop.Accounts.User',)),
('org.freedesktop.Accounts.User',)
),
GLib.VariantType.new('(a{sv})'),
Gio.DBusCallFlags.NONE,
-1,
@ -482,9 +484,9 @@ class MugshotWindow(Window):
logger.debug('Pidgin not installed or never opened, not updating.')
return
logger.debug('Prompting user to update pidgin buddy icon')
update_pidgin = get_confirmation_dialog(self,
_("Update Pidgin buddy icon?"),
_("Would you also like to update your Pidgin buddy icon?"),
primary = _("Update Pidgin buddy icon?")
secondary = _("Would you also like to update your Pidgin buddy icon?")
update_pidgin = get_confirmation_dialog(self, primary, secondary,
'pidgin')
if update_pidgin:
if has_running_process('pidgin'):
@ -532,12 +534,19 @@ class MugshotWindow(Window):
def get_chfn_details_updated(self):
"""Return True if chfn-related details have been modified."""
logger.debug('Checking if chfn details have been modified.')
if self.first_name != self.first_name_entry.get_text().strip() or \
self.last_name != self.last_name_entry.get_text().strip() or \
self.home_phone != self.home_phone_entry.get_text().strip() or \
self.office_phone != self.office_phone_entry.get_text().strip():
modified = True
if self.first_name != self.first_name_entry.get_text().strip():
modified = False
if self.last_name != self.last_name_entry.get_text().strip():
modified = False
if self.home_phone != self.home_phone_entry.get_text().strip():
modified = False
if self.office_phone != self.office_phone_entry.get_text().strip():
modified = False
if modified:
logger.debug('chfn details have been modified.')
return True
else:
logger.debug('chfn details have NOT been modified.')
return False
@ -628,7 +637,7 @@ class MugshotWindow(Window):
return_codes.append(child.exitstatus)
return return_codes
# = LibreOffice ========================================================== #
# = LibreOffice ========================================================= #
def get_libreoffice_details_updated(self):
"""Return True if LibreOffice settings need to be updated."""
# Return False if there is no preferences file.
@ -656,8 +665,8 @@ class MugshotWindow(Window):
return False
def get_libreoffice_data(self):
"""Get each of the preferences from the LibreOffice registymodifications
preferences file.
"""Get each of the preferences from the LibreOffice
registymodifications preferences file.
Return a dict with the details."""
prefs_file = libreoffice_prefs
@ -702,10 +711,11 @@ class MugshotWindow(Window):
prefs_file = libreoffice_prefs
if os.path.isfile(prefs_file):
logger.debug('Prompting user to update LibreOffice details.')
update_libreoffice = get_confirmation_dialog(self,
update_libreoffice = \
get_confirmation_dialog(self,
_("Update LibreOffice user details?"),
_("Would you also like to update your user "
"details in LibreOffice?"),
_("Would you also like to update your "
"user details in LibreOffice?"),
'libreoffice-startcenter')
if update_libreoffice:
logger.debug('Confirm: Updating details.')
@ -821,7 +831,7 @@ class MugshotWindow(Window):
else:
logger.debug('Reject: Not updating.')
# = Stock Browser ======================================================== #
# = Stock Browser ======================================================= #
def on_image_from_stock_activate(self, widget):
"""When the 'Select image from stock' menu item is clicked, load and
display the stock photo browser."""
@ -842,14 +852,15 @@ class MugshotWindow(Window):
full_path = os.path.join(faces_dir, filename)
if os.path.isfile(full_path):
pixbuf = GdkPixbuf.Pixbuf.new_from_file(full_path)
scaled = pixbuf.scale_simple(90, 90, GdkPixbuf.InterpType.HYPER)
scaled = pixbuf.scale_simple(90, 90,
GdkPixbuf.InterpType.HYPER)
model.append([full_path, scaled])
def on_stock_iconview_selection_changed(self, widget):
"""Enable stock submission only when an item is selected."""
selected_items = self.iconview.get_selected_items()
self.builder.get_object('stock_ok').set_sensitive(
len(selected_items) > 0)
is_sensitive = len(selected_items) > 0
self.builder.get_object('stock_ok').set_sensitive(is_sensitive)
def on_stock_browser_delete_event(self, widget, event):
"""Hide the stock browser instead of deleting it."""
@ -879,7 +890,7 @@ class MugshotWindow(Window):
"""Allow selecting a stock photo with Enter."""
self.on_stock_ok_clicked(widget)
# = Image Browser ======================================================== #
# = Image Browser ======================================================= #
def on_image_from_browse_activate(self, widget):
"""Browse for a user profile image."""
# Run the dialog, grab the filename if confirmed, then hide the dialog.
@ -938,7 +949,8 @@ class MugshotWindow(Window):
self.filechooser_preview_pixbuf = \
filechooser_pixbuf.new_subpixbuf(start_x, start_y, width, height)
scaled = self.filechooser_preview_pixbuf.scale_simple(128, 128,
scaled = self.filechooser_preview_pixbuf.scale_simple(
128, 128,
GdkPixbuf.InterpType.HYPER)
self.file_chooser_preview.set_from_pixbuf(scaled)