Add button to remove profile image

This commit is contained in:
Sean Davis 2014-03-02 14:38:10 -05:00
parent 76e9af4a22
commit c84dfa2aaf
3 changed files with 123 additions and 98 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.6"/>
<!-- interface-requires mugshot_window 1.0 -->
<!-- interface-local-resource-path ../media -->
<object class="GtkBox" id="box8">
@ -135,77 +136,6 @@
</packing>
</child>
</object>
<object class="GtkFileChooserDialog" id="filechooserdialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Select a photo…</property>
<property name="role">GtkFileChooserDialog</property>
<property name="modal">True</property>
<property name="icon_name">mugshot</property>
<property name="type_hint">dialog</property>
<property name="transient_for">mugshot_window</property>
<property name="create_folders">False</property>
<property name="local_only">False</property>
<property name="preview_widget">box8</property>
<property name="use_preview_label">False</property>
<signal name="update-preview" handler="on_filechooserdialog_update_preview" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="filechooserdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="filechooserdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button1</action-widget>
<action-widget response="-10">button2</action-widget>
</action-widgets>
</object>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -258,6 +188,22 @@
<signal name="activate" handler="on_image_from_browse_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="image_remove">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_image_remove_activate" swapped="no"/>
</object>
</child>
</object>
<object class="GtkListStore" id="liststore1">
<columns>
@ -461,8 +407,8 @@
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="input_purpose">phone</property>
<signal name="changed" handler="filter_numbers" swapped="no"/>
<signal name="activate" handler="entry_focus_next" swapped="no"/>
<signal name="changed" handler="filter_numbers" swapped="no"/>
</object>
</child>
</object>
@ -548,10 +494,9 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
<property name="input_purpose">phone</property>
<signal name="changed" handler="filter_numbers" swapped="no"/>
<signal name="activate" handler="entry_focus_next" swapped="no"/>
<signal name="changed" handler="filter_numbers" swapped="no"/>
</object>
</child>
</object>
@ -696,6 +641,77 @@
</object>
</child>
</object>
<object class="GtkFileChooserDialog" id="filechooserdialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Select a photo…</property>
<property name="role">GtkFileChooserDialog</property>
<property name="modal">True</property>
<property name="icon_name">mugshot</property>
<property name="type_hint">dialog</property>
<property name="transient_for">mugshot_window</property>
<property name="create_folders">False</property>
<property name="local_only">False</property>
<property name="preview_widget">box8</property>
<property name="use_preview_label">False</property>
<signal name="update-preview" handler="on_filechooserdialog_update_preview" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="filechooserdialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="filechooserdialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button1</action-widget>
<action-widget response="-10">button2</action-widget>
</action-widgets>
</object>
<object class="GtkDialog" id="password_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@ -901,9 +917,10 @@ to your personal information.</property>
<object class="GtkIconView" id="stock_iconview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin">0</property>
<property name="model">liststore1</property>
<signal name="selection-changed" handler="on_stock_iconview_selection_changed" swapped="no"/>
<signal name="item-activated" handler="on_stock_iconview_item_activated" swapped="no"/>
<signal name="selection-changed" handler="on_stock_iconview_selection_changed" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="cellrendererpixbuf"/>
<attributes>

View File

@ -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

View File

@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -50,53 +50,53 @@ msgid "<b>Crop</b>"
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 "<b>First Name</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:12
#: ../data/ui/MugshotWindow.ui.h:11
msgid "<b>Last Name</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:13
#: ../data/ui/MugshotWindow.ui.h:12
msgid "<b>Initials</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:14
#: ../data/ui/MugshotWindow.ui.h:13
msgid "<b>Home Phone</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:15
#: ../data/ui/MugshotWindow.ui.h:14
msgid "<b>Email Address</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:16
#: ../data/ui/MugshotWindow.ui.h:15
msgid "<b>Office Phone</b>"
msgstr ""
#: ../data/ui/MugshotWindow.ui.h:17
#: ../data/ui/MugshotWindow.ui.h:16
msgid "<b>Fax</b>"
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 ""