Pythonize glade, PEP8
This commit is contained in:
parent
413f8c2af9
commit
90f2978a08
|
@ -5,7 +5,7 @@
|
|||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
|
|
|
@ -657,12 +657,12 @@
|
|||
<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">
|
||||
<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">
|
||||
<object class="GtkButtonBox" id="filechooserdialog_action_area1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
|
|
|
@ -33,6 +33,8 @@ from mugshot_lib import helpers
|
|||
from mugshot_lib.CameraDialog import CameraDialog
|
||||
|
||||
Clutter.init(None)
|
||||
|
||||
|
||||
class CameraBox(GtkClutter.Embed):
|
||||
__gsignals__ = {
|
||||
'photo-saved': (GObject.SIGNAL_RUN_LAST,
|
||||
|
@ -42,27 +44,29 @@ class CameraBox(GtkClutter.Embed):
|
|||
GObject.TYPE_NONE,
|
||||
(GObject.TYPE_INT,))
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, parent):
|
||||
GtkClutter.Embed.__init__(self)
|
||||
self.state = Gst.State.NULL
|
||||
self.parent = parent
|
||||
|
||||
|
||||
self.stage = self.get_stage()
|
||||
self.layout_manager = Clutter.BoxLayout()
|
||||
|
||||
|
||||
self.scroll = Clutter.ScrollActor.new()
|
||||
self.scroll.set_scroll_mode(Clutter.ScrollMode.HORIZONTALLY)
|
||||
|
||||
|
||||
self.textures_box = Clutter.Actor(layout_manager=self.layout_manager)
|
||||
self.textures_box.set_x_align(Clutter.ActorAlign.CENTER)
|
||||
|
||||
|
||||
self.scroll.add_actor(self.textures_box)
|
||||
self.stage.add_actor(self.scroll)
|
||||
|
||||
self.video_texture = Clutter.Texture.new()
|
||||
|
||||
self.layout_manager.pack(self.video_texture, expand=True, x_fill=False, y_fill=False, x_align=Clutter.BoxAlignment.CENTER, y_align=Clutter.BoxAlignment.CENTER)
|
||||
self.layout_manager.pack(
|
||||
self.video_texture, expand=True, x_fill=False, y_fill=False,
|
||||
x_align=Clutter.BoxAlignment.CENTER, y_align=Clutter.BoxAlignment.CENTER)
|
||||
|
||||
self.camera = Cheese.Camera.new(self.video_texture, None, 100, 100)
|
||||
Cheese.Camera.setup(self.camera, None)
|
||||
|
@ -73,32 +77,32 @@ class CameraBox(GtkClutter.Embed):
|
|||
node = data.get_device_node()
|
||||
self.camera.set_device_by_device_node(node)
|
||||
self.camera.switch_camera_device()
|
||||
|
||||
device_monitor=Cheese.CameraDeviceMonitor.new()
|
||||
|
||||
device_monitor = Cheese.CameraDeviceMonitor.new()
|
||||
device_monitor.connect("added", added)
|
||||
device_monitor.coldplug()
|
||||
|
||||
|
||||
self.connect("size-allocate", self.on_size_allocate)
|
||||
self.camera.connect("photo-taken", self.on_photo_taken)
|
||||
self.camera.connect("state-flags-changed", self.on_state_flags_changed)
|
||||
|
||||
|
||||
self._save_filename = ""
|
||||
|
||||
|
||||
def on_state_flags_changed(self, camera, state):
|
||||
self.state = state
|
||||
self.emit("gst-state-changed", self.state)
|
||||
|
||||
|
||||
def play(self):
|
||||
if self.state != Gst.State.PLAYING:
|
||||
Cheese.Camera.play(self.camera)
|
||||
|
||||
|
||||
def pause(self):
|
||||
if self.state == Gst.State.PLAYING:
|
||||
Cheese.Camera.play(self.camera)
|
||||
|
||||
|
||||
def stop(self):
|
||||
Cheese.Camera.stop(self.camera)
|
||||
|
||||
|
||||
def on_size_allocate(self, widget, allocation):
|
||||
vheight = self.video_texture.get_height()
|
||||
vwidth = self.video_texture.get_width()
|
||||
|
@ -106,24 +110,24 @@ class CameraBox(GtkClutter.Embed):
|
|||
vformat = self.camera.get_current_video_format()
|
||||
vheight = vformat.height
|
||||
vwidth = vformat.width
|
||||
|
||||
|
||||
height = allocation.height
|
||||
mult = vheight / height
|
||||
width = round(vwidth / mult,1)
|
||||
|
||||
width = round(vwidth / mult, 1)
|
||||
|
||||
self.video_texture.set_height(height)
|
||||
self.video_texture.set_width(width)
|
||||
|
||||
|
||||
point = Clutter.Point()
|
||||
point.x = (self.video_texture.get_width() - allocation.width) / 2
|
||||
point.y = 0
|
||||
|
||||
|
||||
self.scroll.scroll_to_point(point)
|
||||
|
||||
|
||||
def take_photo(self, target_filename):
|
||||
self._save_filename = target_filename
|
||||
return self.camera.take_photo_pixbuf()
|
||||
|
||||
|
||||
def on_photo_taken(self, camera, pixbuf):
|
||||
# Get the image dimensions.
|
||||
height = pixbuf.get_height()
|
||||
|
@ -144,17 +148,18 @@ class CameraBox(GtkClutter.Embed):
|
|||
|
||||
# Overwrite the temporary file with our new cropped image.
|
||||
new_pixbuf.savev(self._save_filename, "png", [], [])
|
||||
|
||||
|
||||
self.emit("photo-saved", self._save_filename)
|
||||
|
||||
|
||||
|
||||
|
||||
class CameraMugshotDialog(CameraDialog):
|
||||
|
||||
"""Camera Capturing Dialog"""
|
||||
__gtype_name__ = "CameraMugshotDialog"
|
||||
__gsignals__ = {'apply': (GObject.SIGNAL_RUN_LAST,
|
||||
GObject.TYPE_NONE,
|
||||
(GObject.TYPE_STRING,))
|
||||
}
|
||||
}
|
||||
|
||||
def finish_initializing(self, builder): # pylint: disable=E1002
|
||||
"""Set up the camera dialog"""
|
||||
|
@ -162,10 +167,10 @@ class CameraMugshotDialog(CameraDialog):
|
|||
|
||||
# Initialize Gst or nothing will work.
|
||||
Gst.init(None)
|
||||
|
||||
|
||||
self.camera = CameraBox(self)
|
||||
self.camera.show()
|
||||
|
||||
|
||||
self.camera.connect("gst-state-changed", self.on_camera_state_changed)
|
||||
self.camera.connect("photo-saved", self.on_camera_photo_saved)
|
||||
|
||||
|
@ -181,24 +186,24 @@ class CameraMugshotDialog(CameraDialog):
|
|||
self.filename = None
|
||||
|
||||
self.show_all()
|
||||
|
||||
|
||||
def on_camera_state_changed(self, widget, state):
|
||||
if state == Gst.State.PLAYING or self.apply_button.get_sensitive():
|
||||
self.record_button.set_sensitive(True)
|
||||
else:
|
||||
self.record_button.set_sensitive(False)
|
||||
|
||||
|
||||
def on_camera_photo_saved(self, widget, filename):
|
||||
self.filename = filename
|
||||
self.apply_button.set_sensitive(True)
|
||||
self.camera.pause()
|
||||
|
||||
|
||||
def play(self):
|
||||
self.camera.play()
|
||||
|
||||
|
||||
def pause(self):
|
||||
self.camera.pause()
|
||||
|
||||
|
||||
def stop(self):
|
||||
self.camera.stop()
|
||||
|
||||
|
@ -242,7 +247,7 @@ class CameraMugshotDialog(CameraDialog):
|
|||
def on_camera_cancel_clicked(self, widget):
|
||||
"""When the Cancel button is clicked, just hide the dialog."""
|
||||
self.hide()
|
||||
|
||||
|
||||
def on_camera_mugshot_dialog_destroy(self, widget, data=None):
|
||||
"""When the application exits, remove the current temporary file and
|
||||
stop the gstreamer element."""
|
||||
|
|
|
@ -160,6 +160,7 @@ def menu_position(self, menu, data=None, something_else=None):
|
|||
|
||||
# See mugshot_lib.Window.py for more details about how this class works
|
||||
class MugshotWindow(Window):
|
||||
|
||||
"""Mugshot GtkWindow"""
|
||||
__gtype_name__ = "MugshotWindow"
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ from xml.etree.cElementTree import ElementTree
|
|||
# pylint: disable=R0904
|
||||
# the many public methods is a feature of Gtk.Builder
|
||||
class Builder(Gtk.Builder):
|
||||
|
||||
''' extra features
|
||||
connects glade defined handler to default_handler if necessary
|
||||
auto connects widget to handler with matching name or alias
|
||||
|
@ -164,7 +165,9 @@ class Builder(Gtk.Builder):
|
|||
# this class deliberately does not provide any public interfaces
|
||||
# apart from the glade widgets
|
||||
class UiFactory():
|
||||
|
||||
''' provides an object with attributes as glade widgets'''
|
||||
|
||||
def __init__(self, widget_dict):
|
||||
"""Initialize the UiFactory."""
|
||||
self._widget_dict = widget_dict
|
||||
|
|
|
@ -24,6 +24,7 @@ from . helpers import get_builder
|
|||
|
||||
|
||||
class CameraDialog(Gtk.Dialog):
|
||||
|
||||
"""Camera Dialog"""
|
||||
__gtype_name__ = "CameraDialog"
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ def env_spawn(command, timeout):
|
|||
|
||||
|
||||
class SudoDialog(Gtk.Dialog):
|
||||
|
||||
'''
|
||||
Creates a new SudoDialog. This is a replacement for using gksudo which
|
||||
provides additional flexibility when performing sudo commands.
|
||||
|
@ -108,6 +109,7 @@ class SudoDialog(Gtk.Dialog):
|
|||
- REJECT: Password invalid.
|
||||
- ACCEPT: Password valid.
|
||||
'''
|
||||
|
||||
def __init__(self, title=None, parent=None, icon=None, message=None,
|
||||
name=None, retries=-1):
|
||||
"""Initialize the SudoDialog."""
|
||||
|
|
|
@ -26,6 +26,7 @@ from . helpers import get_builder, show_uri
|
|||
|
||||
|
||||
class Window(Gtk.Window):
|
||||
|
||||
"""This class is meant to be subclassed by MugshotWindow. It provides
|
||||
common functions and some boilerplate."""
|
||||
__gtype_name__ = "Window"
|
||||
|
|
|
@ -54,7 +54,9 @@ def get_media_file(media_file_name):
|
|||
|
||||
|
||||
class NullHandler(logging.Handler):
|
||||
|
||||
"""Handle NULL"""
|
||||
|
||||
def emit(self, record):
|
||||
"""Do not emit anything."""
|
||||
pass
|
||||
|
|
|
@ -20,7 +20,7 @@ __all__ = [
|
|||
'project_path_not_found',
|
||||
'get_data_file',
|
||||
'get_data_path',
|
||||
]
|
||||
]
|
||||
|
||||
# Where your project will look for your data (for instance, images and ui
|
||||
# files). By default, this is ../data, relative your trunk layout
|
||||
|
@ -32,6 +32,7 @@ import os
|
|||
|
||||
|
||||
class project_path_not_found(Exception):
|
||||
|
||||
"""Raised when we can't find the project directory."""
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-08-29 22:19-0400\n"
|
||||
"POT-Creation-Date: 2015-08-31 22:28-0400\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"
|
||||
|
@ -61,7 +61,7 @@ msgstr ""
|
|||
msgid "Browse…"
|
||||
msgstr ""
|
||||
|
||||
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:588
|
||||
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:589
|
||||
msgid "Mugshot"
|
||||
msgstr ""
|
||||
|
||||
|
@ -103,80 +103,80 @@ msgstr ""
|
|||
|
||||
#. Set the record button to retry, and disable it until the capture
|
||||
#. finishes.
|
||||
#: ../mugshot/CameraMugshotDialog.py:232
|
||||
#: ../mugshot/CameraMugshotDialog.py:237
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:321
|
||||
#: ../mugshot/MugshotWindow.py:322
|
||||
msgid "Authentication cancelled."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:324
|
||||
#: ../mugshot/MugshotWindow.py:325
|
||||
msgid "Authentication failed."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:327
|
||||
#: ../mugshot/MugshotWindow.py:328
|
||||
msgid "An error occurred when saving changes."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:329
|
||||
#: ../mugshot/MugshotWindow.py:330
|
||||
msgid "User details were not updated."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:498
|
||||
#: ../mugshot/MugshotWindow.py:499
|
||||
msgid "Update Pidgin buddy icon?"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:499
|
||||
#: ../mugshot/MugshotWindow.py:500
|
||||
msgid "Would you also like to update your Pidgin buddy icon?"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:589
|
||||
#: ../mugshot/MugshotWindow.py:590
|
||||
msgid "Enter your password to change user details."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:591
|
||||
#: ../mugshot/MugshotWindow.py:592
|
||||
msgid ""
|
||||
"This is a security measure to prevent unwanted updates\n"
|
||||
"to your personal information."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:796
|
||||
#: ../mugshot/MugshotWindow.py:797
|
||||
msgid "Update LibreOffice user details?"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot/MugshotWindow.py:797
|
||||
#: ../mugshot/MugshotWindow.py:798
|
||||
msgid "Would you also like to update your user details in LibreOffice?"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:122
|
||||
#: ../mugshot_lib/SudoDialog.py:124
|
||||
msgid "Password Required"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:159
|
||||
#: ../mugshot_lib/SudoDialog.py:161
|
||||
msgid "Incorrect password... try again."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:169
|
||||
#: ../mugshot_lib/SudoDialog.py:171
|
||||
msgid "Password:"
|
||||
msgstr ""
|
||||
|
||||
#. Buttons
|
||||
#: ../mugshot_lib/SudoDialog.py:180
|
||||
#: ../mugshot_lib/SudoDialog.py:182
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:183
|
||||
#: ../mugshot_lib/SudoDialog.py:185
|
||||
msgid "OK"
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:204
|
||||
#: ../mugshot_lib/SudoDialog.py:206
|
||||
msgid ""
|
||||
"Enter your password to\n"
|
||||
"perform administrative tasks."
|
||||
msgstr ""
|
||||
|
||||
#: ../mugshot_lib/SudoDialog.py:206
|
||||
#: ../mugshot_lib/SudoDialog.py:208
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The application '%s' lets you\n"
|
||||
|
|
4
setup.py
4
setup.py
|
@ -132,7 +132,9 @@ write_appdata_file("data/appdata/mugshot.appdata.xml.in")
|
|||
|
||||
|
||||
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
|
||||
|
||||
"""Command Class to install and update the directory."""
|
||||
|
||||
def run(self):
|
||||
"""Run the setup commands."""
|
||||
DistUtilsExtra.auto.install_auto.run(self)
|
||||
|
@ -197,4 +199,4 @@ DistUtilsExtra.auto.setup(
|
|||
data_files=[('share/man/man1', ['mugshot.1']),
|
||||
('share/appdata', ['data/appdata/mugshot.appdata.xml'])],
|
||||
cmdclass={'install': InstallAndUpdateDataDirectory}
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue