Make cheese and clutter optional, simplify user image widget
This commit is contained in:
parent
6d9539db97
commit
4b17431640
|
@ -157,7 +157,6 @@
|
||||||
<object class="GtkMenu" id="image_menu">
|
<object class="GtkMenu" id="image_menu">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<signal name="hide" handler="on_image_menu_hide" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImageMenuItem" id="image_from_stock">
|
<object class="GtkImageMenuItem" id="image_from_stock">
|
||||||
<property name="label" translatable="yes">Select from stock…</property>
|
<property name="label" translatable="yes">Select from stock…</property>
|
||||||
|
@ -205,14 +204,6 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkListStore" id="liststore1">
|
|
||||||
<columns>
|
|
||||||
<!-- column-name filename -->
|
|
||||||
<column type="gchararray"/>
|
|
||||||
<!-- column-name stock_image -->
|
|
||||||
<column type="GdkPixbuf"/>
|
|
||||||
</columns>
|
|
||||||
</object>
|
|
||||||
<object class="MugshotWindow" id="mugshot_window">
|
<object class="MugshotWindow" id="mugshot_window">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Mugshot</property>
|
<property name="title" translatable="yes">Mugshot</property>
|
||||||
|
@ -230,14 +221,15 @@
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="spacing">12</property>
|
<property name="spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleButton" id="image_button">
|
<object class="GtkMenuButton" id="image_button">
|
||||||
<property name="width_request">128</property>
|
<property name="width_request">128</property>
|
||||||
<property name="height_request">128</property>
|
<property name="height_request">128</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="relief">half</property>
|
<property name="relief">half</property>
|
||||||
<signal name="clicked" handler="on_image_button_clicked" swapped="no"/>
|
<property name="xalign">0</property>
|
||||||
|
<property name="popup">image_menu</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="user_image">
|
<object class="GtkImage" id="user_image">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -713,6 +705,14 @@
|
||||||
<action-widget response="-10">button2</action-widget>
|
<action-widget response="-10">button2</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="GtkListStore" id="liststore1">
|
||||||
|
<columns>
|
||||||
|
<!-- column-name filename -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name stock_image -->
|
||||||
|
<column type="GdkPixbuf"/>
|
||||||
|
</columns>
|
||||||
|
</object>
|
||||||
<object class="GtkWindow" id="stock_browser">
|
<object class="GtkWindow" id="stock_browser">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title" translatable="yes">Select a photo…</property>
|
<property name="title" translatable="yes">Select a photo…</property>
|
||||||
|
|
|
@ -32,8 +32,6 @@ import os
|
||||||
from mugshot_lib import helpers
|
from mugshot_lib import helpers
|
||||||
from mugshot_lib.CameraDialog import CameraDialog
|
from mugshot_lib.CameraDialog import CameraDialog
|
||||||
|
|
||||||
Clutter.init(None)
|
|
||||||
|
|
||||||
|
|
||||||
class CameraBox(GtkClutter.Embed):
|
class CameraBox(GtkClutter.Embed):
|
||||||
__gsignals__ = {
|
__gsignals__ = {
|
||||||
|
@ -167,6 +165,7 @@ class CameraMugshotDialog(CameraDialog):
|
||||||
|
|
||||||
# Initialize Gst or nothing will work.
|
# Initialize Gst or nothing will work.
|
||||||
Gst.init(None)
|
Gst.init(None)
|
||||||
|
Clutter.init(None)
|
||||||
|
|
||||||
self.camera = CameraBox(self)
|
self.camera = CameraBox(self)
|
||||||
self.camera.show()
|
self.camera.show()
|
||||||
|
|
|
@ -33,7 +33,11 @@ import logging
|
||||||
logger = logging.getLogger('mugshot')
|
logger = logging.getLogger('mugshot')
|
||||||
|
|
||||||
from mugshot_lib import Window, SudoDialog, helpers
|
from mugshot_lib import Window, SudoDialog, helpers
|
||||||
from mugshot.CameraMugshotDialog import CameraMugshotDialog
|
|
||||||
|
try:
|
||||||
|
from mugshot.CameraMugshotDialog import CameraMugshotDialog
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
username = GLib.get_user_name()
|
username = GLib.get_user_name()
|
||||||
home = GLib.get_home_dir()
|
home = GLib.get_home_dir()
|
||||||
|
@ -93,6 +97,15 @@ def has_gstreamer_camerasrc_support():
|
||||||
return has_support
|
return has_support
|
||||||
|
|
||||||
|
|
||||||
|
def has_camera_libraries():
|
||||||
|
"""Return True if it is possible to display the camera dialog."""
|
||||||
|
try:
|
||||||
|
from gi.repository import Cheese, Clutter, GtkClutter
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_camera_installed():
|
def get_camera_installed():
|
||||||
"""Return True if /dev/video0 exists."""
|
"""Return True if /dev/video0 exists."""
|
||||||
if not os.path.exists('/dev/video0'):
|
if not os.path.exists('/dev/video0'):
|
||||||
|
@ -111,6 +124,8 @@ def get_has_camera_support():
|
||||||
return False
|
return False
|
||||||
if not has_gstreamer_camerasrc_support():
|
if not has_gstreamer_camerasrc_support():
|
||||||
return False
|
return False
|
||||||
|
if not has_camera_libraries():
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,18 +161,6 @@ def get_confirmation_dialog(parent, primary_message, secondary_message,
|
||||||
return response == Gtk.ResponseType.YES
|
return response == Gtk.ResponseType.YES
|
||||||
|
|
||||||
|
|
||||||
def menu_position(self, menu, data=None, something_else=None):
|
|
||||||
'''Position a menu at the bottom of its attached widget'''
|
|
||||||
widget = menu.get_attach_widget()
|
|
||||||
allocation = widget.get_allocation()
|
|
||||||
window_pos = widget.get_window().get_position()
|
|
||||||
# Align the left side of the menu with the left side of the button.
|
|
||||||
x = window_pos[0] + allocation.x
|
|
||||||
# Align the top of the menu with the bottom of the button.
|
|
||||||
y = window_pos[1] + allocation.y + allocation.height
|
|
||||||
return (x, y, True)
|
|
||||||
|
|
||||||
|
|
||||||
# See mugshot_lib.Window.py for more details about how this class works
|
# See mugshot_lib.Window.py for more details about how this class works
|
||||||
class MugshotWindow(Window):
|
class MugshotWindow(Window):
|
||||||
|
|
||||||
|
@ -169,13 +172,10 @@ class MugshotWindow(Window):
|
||||||
super(MugshotWindow, self).finish_initializing(builder)
|
super(MugshotWindow, self).finish_initializing(builder)
|
||||||
self.set_wmclass("Mugshot", "Mugshot")
|
self.set_wmclass("Mugshot", "Mugshot")
|
||||||
|
|
||||||
self.CameraDialog = CameraMugshotDialog
|
|
||||||
|
|
||||||
# User Image widgets
|
# User Image widgets
|
||||||
self.image_button = builder.get_object('image_button')
|
self.image_button = builder.get_object('image_button')
|
||||||
self.user_image = builder.get_object('user_image')
|
self.user_image = builder.get_object('user_image')
|
||||||
self.image_menu = builder.get_object('image_menu')
|
self.image_menu = builder.get_object('image_menu')
|
||||||
self.image_menu.attach_to_widget(self.image_button, detach_cb)
|
|
||||||
self.image_from_camera = builder.get_object('image_from_camera')
|
self.image_from_camera = builder.get_object('image_from_camera')
|
||||||
self.image_from_stock = builder.get_object('image_from_stock')
|
self.image_from_stock = builder.get_object('image_from_stock')
|
||||||
self.image_from_stock.set_visible(os.path.exists(faces_dir) and
|
self.image_from_stock.set_visible(os.path.exists(faces_dir) and
|
||||||
|
@ -183,6 +183,12 @@ class MugshotWindow(Window):
|
||||||
self.menuitem1 = builder.get_object('menuitem1')
|
self.menuitem1 = builder.get_object('menuitem1')
|
||||||
self.image_remove = builder.get_object('image_remove')
|
self.image_remove = builder.get_object('image_remove')
|
||||||
|
|
||||||
|
if get_has_camera_support():
|
||||||
|
self.CameraDialog = CameraMugshotDialog
|
||||||
|
self.image_from_camera.set_visible(True)
|
||||||
|
else:
|
||||||
|
self.image_from_camera.set_visible(False)
|
||||||
|
|
||||||
# Entry widgets (chfn)
|
# Entry widgets (chfn)
|
||||||
self.first_name_entry = builder.get_object('first_name')
|
self.first_name_entry = builder.get_object('first_name')
|
||||||
self.last_name_entry = builder.get_object('last_name')
|
self.last_name_entry = builder.get_object('last_name')
|
||||||
|
@ -374,20 +380,6 @@ class MugshotWindow(Window):
|
||||||
logger.debug('Cancel clicked, goodbye.')
|
logger.debug('Cancel clicked, goodbye.')
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
# = 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():
|
|
||||||
logger.debug('Show photo menu')
|
|
||||||
self.image_from_camera.set_visible(get_has_camera_support())
|
|
||||||
self.image_menu.popup(None, None, menu_position,
|
|
||||||
self.image_menu, 3,
|
|
||||||
Gtk.get_current_event_time())
|
|
||||||
|
|
||||||
def on_image_menu_hide(self, widget):
|
|
||||||
"""Untoggle the image button when the menu is hidden."""
|
|
||||||
self.image_button.set_active(False)
|
|
||||||
|
|
||||||
def on_image_remove_activate(self, widget):
|
def on_image_remove_activate(self, widget):
|
||||||
"""Remove the user's profile image."""
|
"""Remove the user's profile image."""
|
||||||
self.updated_image = ""
|
self.updated_image = ""
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2015-08-31 22:28-0400\n"
|
"POT-Creation-Date: 2015-09-06 16:23-0400\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -61,7 +61,7 @@ msgstr ""
|
||||||
msgid "Browse…"
|
msgid "Browse…"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:589
|
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:581
|
||||||
msgid "Mugshot"
|
msgid "Mugshot"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -103,49 +103,49 @@ msgstr ""
|
||||||
|
|
||||||
#. Set the record button to retry, and disable it until the capture
|
#. Set the record button to retry, and disable it until the capture
|
||||||
#. finishes.
|
#. finishes.
|
||||||
#: ../mugshot/CameraMugshotDialog.py:237
|
#: ../mugshot/CameraMugshotDialog.py:236
|
||||||
msgid "Retry"
|
msgid "Retry"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:322
|
#: ../mugshot/MugshotWindow.py:328
|
||||||
msgid "Authentication cancelled."
|
msgid "Authentication cancelled."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:325
|
#: ../mugshot/MugshotWindow.py:331
|
||||||
msgid "Authentication failed."
|
msgid "Authentication failed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:328
|
#: ../mugshot/MugshotWindow.py:334
|
||||||
msgid "An error occurred when saving changes."
|
msgid "An error occurred when saving changes."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:330
|
#: ../mugshot/MugshotWindow.py:336
|
||||||
msgid "User details were not updated."
|
msgid "User details were not updated."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:499
|
#: ../mugshot/MugshotWindow.py:491
|
||||||
msgid "Update Pidgin buddy icon?"
|
msgid "Update Pidgin buddy icon?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:500
|
#: ../mugshot/MugshotWindow.py:492
|
||||||
msgid "Would you also like to update your Pidgin buddy icon?"
|
msgid "Would you also like to update your Pidgin buddy icon?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:590
|
#: ../mugshot/MugshotWindow.py:582
|
||||||
msgid "Enter your password to change user details."
|
msgid "Enter your password to change user details."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:592
|
#: ../mugshot/MugshotWindow.py:584
|
||||||
msgid ""
|
msgid ""
|
||||||
"This is a security measure to prevent unwanted updates\n"
|
"This is a security measure to prevent unwanted updates\n"
|
||||||
"to your personal information."
|
"to your personal information."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:797
|
#: ../mugshot/MugshotWindow.py:789
|
||||||
msgid "Update LibreOffice user details?"
|
msgid "Update LibreOffice user details?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../mugshot/MugshotWindow.py:798
|
#: ../mugshot/MugshotWindow.py:790
|
||||||
msgid "Would you also like to update your user details in LibreOffice?"
|
msgid "Would you also like to update your user details in LibreOffice?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue