Use AccountsService to set the profile image

This commit is contained in:
Sean Davis 2014-03-02 11:41:30 -05:00
parent 07403bc380
commit 76e9af4a22
2 changed files with 32 additions and 7 deletions

View File

@ -29,7 +29,7 @@ import dbus
import tempfile
from gi.repository import Gtk, GdkPixbuf, GLib # pylint: disable=E0611
from gi.repository import Gtk, GdkPixbuf, GLib, Gio # pylint: disable=E0611
import logging
logger = logging.getLogger('mugshot')
@ -356,10 +356,35 @@ class MugshotWindow(Window):
# Copy the new file to ~/.face
shutil.copyfile(self.updated_image, face)
self.accounts_service_set_user_image(face)
self.set_pidgin_buddyicon(face)
self.updated_image = None
return True
def accounts_service_set_user_image(self, filename):
"""Set 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()
bus.call_sync('org.freedesktop.Accounts',
path,
'org.freedesktop.Accounts.User',
'SetIconFile',
GLib.Variant('(s)', (filename,)),
GLib.VariantType.new('()'),
Gio.DBusCallFlags.NONE,
-1,
None)
def set_pidgin_buddyicon(self, filename=None):
"""Sets the pidgin buddyicon to filename (usually ~/.face).

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-25 20:37-0500\n"
"POT-Creation-Date: 2014-03-02 11:38-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -115,7 +115,7 @@ msgstr ""
msgid "Password:"
msgstr ""
#: ../mugshot/__init__.py:32
#: ../mugshot/__init__.py:34
msgid "Show debug messages (-vv debugs mugshot_lib also)"
msgstr ""
@ -148,18 +148,18 @@ msgstr ""
msgid "Retry"
msgstr ""
#: ../mugshot/MugshotWindow.py:375
#: ../mugshot/MugshotWindow.py:398
msgid "Update Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:376
#: ../mugshot/MugshotWindow.py:399
msgid "Would you also like to update your Pidgin buddy icon?"
msgstr ""
#: ../mugshot/MugshotWindow.py:583
#: ../mugshot/MugshotWindow.py:605
msgid "Update LibreOffice user details?"
msgstr ""
#: ../mugshot/MugshotWindow.py:584
#: ../mugshot/MugshotWindow.py:606
msgid "Would you also like to update your user details in LibreOffice?"
msgstr ""