From c84dfa2aaf1d4dc6bd786e550f3f55a00bdcc794 Mon Sep 17 00:00:00 2001 From: Sean Davis Date: Sun, 2 Mar 2014 14:38:10 -0500 Subject: [PATCH] Add button to remove profile image --- data/ui/MugshotWindow.ui | 169 +++++++++++++++++++++------------------ mugshot/MugshotWindow.py | 14 +++- po/mugshot.pot | 38 ++++----- 3 files changed, 123 insertions(+), 98 deletions(-) diff --git a/data/ui/MugshotWindow.ui b/data/ui/MugshotWindow.ui index e0cee56..9ff1818 100644 --- a/data/ui/MugshotWindow.ui +++ b/data/ui/MugshotWindow.ui @@ -1,6 +1,7 @@ + - + @@ -135,77 +136,6 @@ - - False - 5 - Select a photo… - GtkFileChooserDialog - True - mugshot - dialog - mugshot_window - False - False - box8 - False - - - - False - vertical - 2 - - - False - end - - - gtk-cancel - True - False - True - True - - - False - True - 0 - - - - - gtk-apply - True - True - True - True - True - True - - - False - True - 1 - - - - - False - True - end - 0 - - - - - - - - - button1 - button2 - - True False @@ -258,6 +188,22 @@ + + + True + False + + + + + gtk-remove + True + False + True + True + + + @@ -461,8 +407,8 @@ True phone - + @@ -548,10 +494,9 @@ True True - True phone - + @@ -696,6 +641,77 @@ + + False + 5 + Select a photo… + GtkFileChooserDialog + True + mugshot + dialog + mugshot_window + False + False + box8 + False + + + + False + vertical + 2 + + + False + end + + + gtk-cancel + True + False + True + True + + + False + True + 0 + + + + + gtk-apply + True + True + True + True + True + True + + + False + True + 1 + + + + + False + True + end + 0 + + + + + + + + + button1 + button2 + + False 5 @@ -901,9 +917,10 @@ to your personal information. True True + 0 liststore1 - + diff --git a/mugshot/MugshotWindow.py b/mugshot/MugshotWindow.py index dfd7bd8..b2dda01 100644 --- a/mugshot/MugshotWindow.py +++ b/mugshot/MugshotWindow.py @@ -296,7 +296,7 @@ class MugshotWindow(Window): if self.get_libreoffice_details_updated(): self.set_libreoffice_data() - if self.updated_image: + if self.updated_image is not None: self.save_image() self.save_gsettings() @@ -335,6 +335,11 @@ class MugshotWindow(Window): """Untoggle the image button when the menu is hidden.""" self.image_button.set_active(False) + def on_image_remove_activate(self, widget): + """Remove the user's profile image.""" + self.updated_image = "" + self.set_user_image(None) + def on_camera_dialog_apply(self, widget, data=None): """Commit changes when apply is clicked.""" self.updated_image = data @@ -343,7 +348,7 @@ class MugshotWindow(Window): def save_image(self): """Copy the updated image filename to ~/.face""" # Check if the image has been updated. - if not self.updated_image: + if self.updated_image is None: logger.debug('Photo not updated, not saving changes.') return False @@ -355,7 +360,10 @@ class MugshotWindow(Window): os.remove(face) # Copy the new file to ~/.face - shutil.copyfile(self.updated_image, face) + if os.path.isfile(self.updated_image): + shutil.copyfile(self.updated_image, face) + else: + face = "" self.accounts_service_set_user_image(face) self.set_pidgin_buddyicon(face) self.updated_image = None diff --git a/po/mugshot.pot b/po/mugshot.pot index 48efb06..36b2c87 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-03-02 11:38-0500\n" +"POT-Creation-Date: 2014-03-02 14:35-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -50,53 +50,53 @@ msgid "Crop" msgstr "" #: ../data/ui/MugshotWindow.ui.h:6 -msgid "Select a photo…" -msgstr "" - -#: ../data/ui/MugshotWindow.ui.h:7 msgid "Select from stock…" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:8 +#: ../data/ui/MugshotWindow.ui.h:7 msgid "Capture from camera…" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:9 +#: ../data/ui/MugshotWindow.ui.h:8 msgid "Browse…" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:10 +#: ../data/ui/MugshotWindow.ui.h:9 msgid "Mugshot" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:11 +#: ../data/ui/MugshotWindow.ui.h:10 msgid "First Name" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:12 +#: ../data/ui/MugshotWindow.ui.h:11 msgid "Last Name" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:13 +#: ../data/ui/MugshotWindow.ui.h:12 msgid "Initials" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:14 +#: ../data/ui/MugshotWindow.ui.h:13 msgid "Home Phone" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:15 +#: ../data/ui/MugshotWindow.ui.h:14 msgid "Email Address" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:16 +#: ../data/ui/MugshotWindow.ui.h:15 msgid "Office Phone" msgstr "" -#: ../data/ui/MugshotWindow.ui.h:17 +#: ../data/ui/MugshotWindow.ui.h:16 msgid "Fax" msgstr "" +#: ../data/ui/MugshotWindow.ui.h:17 +msgid "Select a photo…" +msgstr "" + #: ../data/ui/MugshotWindow.ui.h:18 msgid "Password Required" msgstr "" @@ -148,18 +148,18 @@ msgstr "" msgid "Retry" msgstr "" -#: ../mugshot/MugshotWindow.py:398 +#: ../mugshot/MugshotWindow.py:406 msgid "Update Pidgin buddy icon?" msgstr "" -#: ../mugshot/MugshotWindow.py:399 +#: ../mugshot/MugshotWindow.py:407 msgid "Would you also like to update your Pidgin buddy icon?" msgstr "" -#: ../mugshot/MugshotWindow.py:605 +#: ../mugshot/MugshotWindow.py:613 msgid "Update LibreOffice user details?" msgstr "" -#: ../mugshot/MugshotWindow.py:606 +#: ../mugshot/MugshotWindow.py:614 msgid "Would you also like to update your user details in LibreOffice?" msgstr ""