diff --git a/mugshot/MugshotWindow.py b/mugshot/MugshotWindow.py index c5264a9..2d920f1 100644 --- a/mugshot/MugshotWindow.py +++ b/mugshot/MugshotWindow.py @@ -223,20 +223,29 @@ class MugshotWindow(Window): face = os.path.join(home, '.face') logger.debug('Checking AccountsService for profile image') image = self.accounts_service_get_user_image() - logger.debug('Found profile image: %s' % str(image)) - if os.path.isfile(face): - if os.path.samefile(image, face): - self.updated_image = face + # AccountsService may not be supported or desired. + if image is None: + logger.debug("AccountsService is not supported.") + self.updated_image = face + self.set_user_image(face) + + # If it is supported, process and compare to ~/.face + else: + logger.debug('Found profile image: %s' % str(image)) + + if os.path.isfile(face): + if os.path.samefile(image, face): + self.updated_image = face + else: + self.updated_image = None + self.set_user_image(face) + elif os.path.isfile(image): + self.updated_image = image + self.set_user_image(image) else: self.updated_image = None - self.set_user_image(face) - elif os.path.isfile(image): - self.updated_image = image - self.set_user_image(image) - else: - self.updated_image = None - self.set_user_image(None) + self.set_user_image(None) # Search /etc/passwd for the current user's details. logger.debug('Getting user details from /etc/passwd') @@ -435,31 +444,35 @@ class MugshotWindow(Window): def accounts_service_get_user_image(self): """Get user profile image using AccountsService.""" - bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) - result = bus.call_sync('org.freedesktop.Accounts', - '/org/freedesktop/Accounts', - 'org.freedesktop.Accounts', - 'FindUserByName', - GLib.Variant('(s)', (username,)), - GLib.VariantType.new('(o)'), - Gio.DBusCallFlags.NONE, - -1, - None) - (path,) = result.unpack() + try: + bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) + result = bus.call_sync('org.freedesktop.Accounts', + '/org/freedesktop/Accounts', + 'org.freedesktop.Accounts', + 'FindUserByName', + GLib.Variant('(s)', (username,)), + GLib.VariantType.new('(o)'), + Gio.DBusCallFlags.NONE, + -1, + None) + (path,) = result.unpack() - result = bus.call_sync('org.freedesktop.Accounts', - path, - 'org.freedesktop.DBus.Properties', - 'GetAll', - GLib.Variant('(s)', - ('org.freedesktop.Accounts.User',) - ), - GLib.VariantType.new('(a{sv})'), - Gio.DBusCallFlags.NONE, - -1, - None) - (props,) = result.unpack() - return props['IconFile'] + variant = GLib.Variant('(s)', + ('org.freedesktop.Accounts.User',) + ) + result = bus.call_sync('org.freedesktop.Accounts', + path, + 'org.freedesktop.DBus.Properties', + 'GetAll', + variant, + GLib.VariantType.new('(a{sv})'), + Gio.DBusCallFlags.NONE, + -1, + None) + (props,) = result.unpack() + return props['IconFile'] + except GLib.GError: + return None def accounts_service_set_user_image(self, filename): """Set user profile image using AccountsService.""" diff --git a/po/mugshot.pot b/po/mugshot.pot index a194930..e959f44 100644 --- a/po/mugshot.pot +++ b/po/mugshot.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-04-22 06:13-0400\n" +"POT-Creation-Date: 2014-05-14 07:11-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -61,7 +61,7 @@ msgstr "" msgid "Browse…" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573 +#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:591 msgid "Mugshot" msgstr "" @@ -131,37 +131,37 @@ msgid "Retry" msgstr "" #. Password was incorrect, complain. -#: ../mugshot/MugshotWindow.py:327 +#: ../mugshot/MugshotWindow.py:341 msgid "Authentication Failed" msgstr "" -#: ../mugshot/MugshotWindow.py:328 +#: ../mugshot/MugshotWindow.py:342 msgid "User details were not updated." msgstr "" -#: ../mugshot/MugshotWindow.py:495 +#: ../mugshot/MugshotWindow.py:513 msgid "Update Pidgin buddy icon?" msgstr "" -#: ../mugshot/MugshotWindow.py:496 +#: ../mugshot/MugshotWindow.py:514 msgid "Would you also like to update your Pidgin buddy icon?" msgstr "" -#: ../mugshot/MugshotWindow.py:574 +#: ../mugshot/MugshotWindow.py:592 msgid "Enter your password to change user details." msgstr "" -#: ../mugshot/MugshotWindow.py:576 +#: ../mugshot/MugshotWindow.py:594 msgid "" "This is a security measure to prevent unwanted updates\n" "to your personal information." msgstr "" -#: ../mugshot/MugshotWindow.py:727 +#: ../mugshot/MugshotWindow.py:745 msgid "Update LibreOffice user details?" msgstr "" -#: ../mugshot/MugshotWindow.py:728 +#: ../mugshot/MugshotWindow.py:746 msgid "Would you also like to update your user details in LibreOffice?" msgstr ""