本文整理汇总了Python中pitivi.utils.pipeline.Seeker类的典型用法代码示例。如果您正苦于以下问题:Python Seeker类的具体用法?Python Seeker怎么用?Python Seeker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Seeker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, instance, uimap):
Loggable.__init__(self)
Signallable.__init__(self)
self.app = instance
self.bt = {}
self.settings = {}
self.source = None
self.created = False
self.seeker = Seeker()
#Drag attributes
self._drag_events = []
self._signals_connected = False
self._createUI()
self.textbuffer = Gtk.TextBuffer()
self.pangobuffer = InteractivePangoBuffer()
self.textarea.set_buffer(self.pangobuffer)
self.textbuffer.connect("changed", self._updateSourceText)
self.pangobuffer.connect("changed", self._updateSourceText)
#Connect buttons
self.pangobuffer.setup_widget_from_pango(self.bt["bold"], "<b>bold</b>")
self.pangobuffer.setup_widget_from_pango(self.bt["italic"], "<i>italic</i>")
示例2: __init__
def __init__(self, settings=None, realizedCb=None, sink=None):
# Prevent black frames and flickering while resizing or changing focus:
# The aspect ratio gets overridden by setDisplayAspectRatio.
Gtk.AspectFrame.__init__(self, xalign=0.5, yalign=0.5,
ratio=4.0 / 3.0, obey_child=False)
Loggable.__init__(self)
self.drawing_area = Pitivi.viewer_new(sink)
self.drawing_area.set_double_buffered(False)
self.drawing_area.connect("draw", self._drawCb, None)
# We keep the ViewerWidget hidden initially, or the desktop wallpaper
# would show through the non-double-buffered widget!
if realizedCb:
self.drawing_area.connect("realize", realizedCb, self)
self.add(self.drawing_area)
self.drawing_area.show()
self.seeker = Seeker()
self.settings = settings
self.box = None
self.stored = False
self.area = None
self.zoom = 1.0
self.sink = sink
self.pixbuf = None
self.pipeline = None
self.transformation_properties = None
self._setting_ratio = False
示例3: __init__
def __init__(self, app, undock_action=None):
Gtk.VBox.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New ViewerContainer")
self.pipeline = None
self.docked = True
self.seeker = Seeker()
# Only used for restoring the pipeline position after a live clip trim preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.undock_action = undock_action
if undock_action:
self.undock_action.connect("activate", self._toggleDocked)
if not self.settings.viewerDocked:
self.undock()
示例4: __init__
def __init__(self, instance, hadj):
Gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
self.app = instance
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.SCROLL_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = Gst.Fraction(1 / 1)
self.ns_per_frame = float(1 / self.frame_rate) * Gst.SECOND
self.connect('draw', self.drawCb)
self.connect('configure-event', self.configureEventCb)
self.callback_id = None
self.callback_id_scroll = None
示例5: setPipeline
def setPipeline(self, pipeline, position=None):
"""
Set the Viewer to the given Pipeline.
Properly switches the currently set action to that new Pipeline.
@param pipeline: The Pipeline to switch to.
@type pipeline: L{Pipeline}.
@param position: Optional position to seek to initially.
"""
self.debug("self.pipeline:%r", self.pipeline)
self.seeker = Seeker()
self._disconnectFromPipeline()
if self.pipeline:
self.pipeline.set_state(Gst.State.NULL)
self.pipeline = pipeline
if self.pipeline:
self.pipeline.pause()
self.seeker.seek(position)
self.pipeline.connect("state-change", self._pipelineStateChangedCb)
self.pipeline.connect("position", self._positionCb)
self.pipeline.connect("window-handle-message", self._windowHandleMessageCb)
self.pipeline.connect("duration-changed", self._durationChangedCb)
self._setUiActive()
示例6: __init__
def __init__(self, instance, hadj):
gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
self.app = instance
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.need_update = True
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = gst.Fraction(1 / 1)
示例7: __init__
def __init__(self, app):
Gtk.Box.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New ViewerContainer")
self.pipeline = None
self.docked = True
self.seeker = Seeker()
self.target = None
# Only used for restoring the pipeline position after a live clip trim
# preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.__owning_pipeline = False
if not self.settings.viewerDocked:
self.undock()
示例8: __init__
def __init__(self, settings=None):
Gtk.DrawingArea.__init__(self)
Loggable.__init__(self)
self.seeker = Seeker()
self.settings = settings
self.box = None
self.stored = False
self.area = None
self.zoom = 1.0
self.sink = None
self.pixbuf = None
self.pipeline = None
self.transformation_properties = None
示例9: __init__
def __init__(self, timeline, hadj):
Gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
# Allows stealing focus from other GTK widgets, prevent accidents:
self.props.can_focus = True
self.connect("focus-in-event", self._focusInCb)
self.connect("focus-out-event", self._focusOutCb)
self.timeline = timeline
self._background_color = timeline.get_style_context().lookup_color(
'theme_bg_color')[1]
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.SCROLL_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.frame_rate = Gst.Fraction(1 / 1)
self.ns_per_frame = float(1 / self.frame_rate) * Gst.SECOND
self.connect('draw', self.drawCb)
self.connect('configure-event', self.configureEventCb)
self.callback_id = None
self.callback_id_scroll = None
self.set_size_request(0, HEIGHT)
style = self.get_style_context()
color_normal = style.get_color(Gtk.StateFlags.NORMAL)
color_insensitive = style.get_color(Gtk.StateFlags.INSENSITIVE)
self._color_normal = color_normal
self._color_dimmed = Gdk.RGBA(
*[(x * 3 + y * 2) / 5
for x, y in ((color_normal.red, color_insensitive.red),
(color_normal.green, color_insensitive.green),
(color_normal.blue, color_insensitive.blue))])
self.scales = SCALES
示例10: __init__
def __init__(self, settings=None):
gtk.DrawingArea.__init__(self)
Loggable.__init__(self)
self.seeker = Seeker()
self.settings = settings
self.box = None
self.stored = False
self.area = None
self.zoom = 1.0
self.sink = None
self.pixbuf = None
self.pipeline = None
self.transformation_properties = None
for state in range(gtk.STATE_INSENSITIVE + 1):
self.modify_bg(state, self.style.black)
示例11: __init__
def __init__(self, app):
Loggable.__init__(self)
self.app = app
self.action_log = app.action_log
self.settings = {}
self.source = None
self.seeker = Seeker()
# Drag attributes
self._drag_events = []
self._signals_connected = False
self._setting_props = False
self._setting_initial_props = False
self._children_props_handler = None
self._createUI()
示例12: ViewerContainer
class ViewerContainer(Gtk.Box, Loggable):
"""
A wiget holding a viewer and the controls.
"""
__gtype_name__ = 'ViewerContainer'
__gsignals__ = {
"activate-playback-controls": (GObject.SignalFlags.RUN_LAST,
None, (GObject.TYPE_BOOLEAN,)),
}
INHIBIT_REASON = _("Currently playing")
def __init__(self, app):
Gtk.Box.__init__(self)
self.set_border_width(SPACING)
self.app = app
self.settings = app.settings
self.system = app.system
Loggable.__init__(self)
self.log("New ViewerContainer")
self.pipeline = None
self.docked = True
self.seeker = Seeker()
self.target = None
# Only used for restoring the pipeline position after a live clip trim
# preview:
self._oldTimelinePos = None
self._haveUI = False
self._createUi()
self.__owning_pipeline = False
if not self.settings.viewerDocked:
self.undock()
def setPipeline(self, pipeline, position=None):
"""
Set the Viewer to the given Pipeline.
Properly switches the currently set action to that new Pipeline.
@param pipeline: The Pipeline to switch to.
@type pipeline: L{Pipeline}.
@param position: Optional position to seek to initially.
"""
self._disconnectFromPipeline()
if self.target:
parent = self.target.get_parent()
if parent:
parent.remove(self.target)
self.debug("New pipeline: %r", pipeline)
self.pipeline = pipeline
if position:
self.seeker.seek(position)
self.pipeline.connect("state-change", self._pipelineStateChangedCb)
self.pipeline.connect("position", self._positionCb)
self.pipeline.connect("duration-changed", self._durationChangedCb)
self.__owning_pipeline = False
self.__createNewViewer()
self._setUiActive()
self.pipeline.pause()
def __createNewViewer(self):
self.sink = self.pipeline.createSink()
self.pipeline.setSink(self.sink)
self.target = ViewerWidget(self.sink, self.app)
if self.docked:
self.pack_start(self.target, True, True, 0)
screen = Gdk.Screen.get_default()
height = screen.get_height()
if height >= 800:
# show the controls and force the aspect frame to have at least the same
# width (+110, which is a magic number to minimize dead padding).
req = self.buttons.size_request()
width = req.width
height = req.height
width += 110
height = int(width / self.target.props.ratio)
self.target.set_size_request(width, height)
else:
self.external_vbox.pack_start(self.target, False, False, 0)
self.target.props.expand = True
self.external_vbox.child_set(self.target, fill=True)
self.setDisplayAspectRatio(self.app.project_manager.current_project.getDAR())
self.target.show_all()
def _disconnectFromPipeline(self):
#.........这里部分代码省略.........
示例13: TitleEditor
class TitleEditor(Loggable):
def __init__(self, instance, uimap):
Loggable.__init__(self)
Signallable.__init__(self)
self.app = instance
self.bt = {}
self.settings = {}
self.source = None
self.created = False
self.seeker = Seeker()
#Drag attributes
self._drag_events = []
self._signals_connected = False
self._createUI()
self.textbuffer = Gtk.TextBuffer()
self.pangobuffer = InteractivePangoBuffer()
self.textarea.set_buffer(self.pangobuffer)
self.textbuffer.connect("changed", self._updateSourceText)
self.pangobuffer.connect("changed", self._updateSourceText)
#Connect buttons
self.pangobuffer.setup_widget_from_pango(self.bt["bold"], "<b>bold</b>")
self.pangobuffer.setup_widget_from_pango(self.bt["italic"], "<i>italic</i>")
def _createUI(self):
builder = Gtk.Builder()
builder.add_from_file(os.path.join(get_ui_dir(), "titleeditor.ui"))
builder.connect_signals(self)
self.widget = builder.get_object("box1") # To be used by tabsmanager
self.infobar = builder.get_object("infobar")
self.editing_box = builder.get_object("editing_box")
self.textarea = builder.get_object("textview")
self.markup_button = builder.get_object("markupToggle")
toolbar = builder.get_object("toolbar")
toolbar.get_style_context().add_class("inline-toolbar")
buttons = ["bold", "italic", "font", "font_fore_color", "back_color"]
for button in buttons:
self.bt[button] = builder.get_object(button)
settings = ["valignment", "halignment", "xpos", "ypos"]
for setting in settings:
self.settings[setting] = builder.get_object(setting)
for n, en in {_("Custom"): "position",
_("Top"): "top",
_("Center"): "center",
_("Bottom"): "bottom",
_("Baseline"): "baseline"}.items():
self.settings["valignment"].append(en, n)
for n, en in {_("Custom"): "position",
_("Left"): "left",
_("Center"): "center",
_("Right"): "right"}.items():
self.settings["halignment"].append(en, n)
self._deactivate()
def _textviewFocusedCb(self, unused_widget, unused_event):
self.app.gui.setActionsSensitive(False)
def _textviewUnfocusedCb(self, unused_widget, unused_event):
self.app.gui.setActionsSensitive(True)
def _backgroundColorButtonCb(self, widget):
self.textarea.modify_base(self.textarea.get_state(), widget.get_color())
color = widget.get_rgba()
color_int = 0
color_int += int(color.red * 255) * 256 ** 2
color_int += int(color.green * 255) * 256 ** 1
color_int += int(color.blue * 255) * 256 ** 0
color_int += int(color.alpha * 255) * 256 ** 3
self.debug("Setting title background color to %s", hex(color_int))
self.source.set_background(color_int)
def _frontTextColorButtonCb(self, widget):
suc, a, t, s = Pango.parse_markup("<span color='" + widget.get_color().to_string() + "'>color</span>", -1, u'\x00')
ai = a.get_iterator()
font, lang, attrs = ai.get_font()
tags = self.pangobuffer.get_tags_from_attrs(None, None, attrs)
self.pangobuffer.apply_tag_to_selection(tags[0])
def _fontButtonCb(self, widget):
font_desc = widget.get_font_name().split(" ")
font_face = " ".join(font_desc[:-1])
font_size = str(int(font_desc[-1]) * 1024)
text = "<span face='" + font_face + "'><span size='" + font_size + "'>text</span></span>"
suc, a, t, s = Pango.parse_markup(text, -1, u'\x00')
ai = a.get_iterator()
font, lang, attrs = ai.get_font()
tags = self.pangobuffer.get_tags_from_attrs(font, None, attrs)
for tag in tags:
self.pangobuffer.apply_tag_to_selection(tag)
def _markupToggleCb(self, markup_button):
# FIXME: either make this feature rock-solid or replace it by a
# Clear markup" button. Currently it is possible for the user to create
#.........这里部分代码省略.........
示例14: ScaleRuler
class ScaleRuler(gtk.DrawingArea, Zoomable, Loggable):
__gsignals__ = {
"expose-event": "override",
"button-press-event": "override",
"button-release-event": "override",
"motion-notify-event": "override",
"scroll-event": "override",
"seek": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
[gobject.TYPE_UINT64])
}
border = 0
min_tick_spacing = 3
scale = [0, 0, 0, 0.5, 1, 2, 5, 10, 15, 30, 60, 120, 300, 600, 3600]
subdivide = ((1, 1.0), (2, 0.5), (10, .25))
def __init__(self, instance, hadj):
gtk.DrawingArea.__init__(self)
Zoomable.__init__(self)
Loggable.__init__(self)
self.log("Creating new ScaleRuler")
self.app = instance
self._seeker = Seeker()
self.hadj = hadj
hadj.connect("value-changed", self._hadjValueChangedCb)
self.add_events(gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK)
self.pixbuf = None
# all values are in pixels
self.pixbuf_offset = 0
self.pixbuf_offset_painted = 0
# This is the number of width we allocate for the pixbuf
self.pixbuf_multiples = 4
self.position = 0 # In nanoseconds
self.pressed = False
self.need_update = True
self.min_frame_spacing = 5.0
self.frame_height = 5.0
self.frame_rate = gst.Fraction(1 / 1)
def _hadjValueChangedCb(self, hadj):
self.pixbuf_offset = self.hadj.get_value()
self.queue_draw()
## Zoomable interface override
def zoomChanged(self):
self.need_update = True
self.queue_draw()
## timeline position changed method
def timelinePositionChanged(self, value, unused_frame=None):
self.position = value
self.queue_draw()
## gtk.Widget overrides
def do_expose_event(self, event):
self.log("exposing ScaleRuler %s", list(event.area))
x, y, width, height = event.area
self.repaintIfNeeded(width, height)
# offset in pixbuf to paint
offset_to_paint = self.pixbuf_offset - self.pixbuf_offset_painted
self.window.draw_pixbuf(
self.style.fg_gc[gtk.STATE_NORMAL],
self.pixbuf,
int(offset_to_paint), 0,
x, y, width, height,
gtk.gdk.RGB_DITHER_NONE)
# draw the position
context = self.window.cairo_create()
self.drawPosition(context)
return False
def do_button_press_event(self, event):
self.debug("button pressed at x:%d", event.x)
self.pressed = True
position = self.pixelToNs(event.x + self.pixbuf_offset)
self._seeker.seek(position)
return True
def do_button_release_event(self, event):
self.debug("button released at x:%d", event.x)
self.pressed = False
# The distinction between the ruler and timeline canvas is theoretical.
# If the user interacts with the ruler, have the timeline steal focus
# from other widgets. This reactivates keyboard shortcuts for playback.
timeline = self.app.gui.timeline_ui
timeline._canvas.grab_focus(timeline._root_item)
return False
def do_motion_notify_event(self, event):
position = self.pixelToNs(event.x + self.pixbuf_offset)
#.........这里部分代码省略.........
示例15: ViewerWidget
class ViewerWidget(Gtk.DrawingArea, Loggable):
"""
Widget for displaying properly GStreamer video sink
@ivar settings: The settings of the application.
@type settings: L{GlobalSettings}
"""
__gsignals__ = {}
def __init__(self, settings=None):
Gtk.DrawingArea.__init__(self)
Loggable.__init__(self)
self.seeker = Seeker()
self.settings = settings
self.box = None
self.stored = False
self.area = None
self.zoom = 1.0
self.sink = None
self.pixbuf = None
self.pipeline = None
self.transformation_properties = None
# FIXME PyGi Styling with Gtk3
#for state in range(Gtk.StateType.INSENSITIVE + 1):
#self.modify_bg(state, self.style.black)
def init_transformation_events(self):
self.set_events(Gdk.EventMask.BUTTON_PRESS_MASK
| Gdk.EventMask.BUTTON_RELEASE_MASK
| Gdk.EventMask.POINTER_MOTION_MASK
| Gdk.EventMask.POINTER_MOTION_HINT_MASK)
def show_box(self):
if not self.box:
self.box = TransformationBox(self.settings)
self.box.init_size(self.area)
self._update_gradient()
self.connect("button-press-event", self.button_press_event)
self.connect("button-release-event", self.button_release_event)
self.connect("motion-notify-event", self.motion_notify_event)
self.connect("size-allocate", self._sizeCb)
self.box.set_transformation_properties(self.transformation_properties)
self.renderbox()
def _sizeCb(self, widget, area):
# The transformation box is cleared when using regular rendering
# so we need to flush the pipeline
self.seeker.flush()
def hide_box(self):
if self.box:
self.box = None
self.disconnect_by_func(self.button_press_event)
self.disconnect_by_func(self.button_release_event)
self.disconnect_by_func(self.motion_notify_event)
self.seeker.flush()
self.zoom = 1.0
if self.sink:
self.sink.set_render_rectangle(*self.area)
def set_transformation_properties(self, transformation_properties):
self.transformation_properties = transformation_properties
def _store_pixbuf(self):
"""
When not playing, store a pixbuf of the current viewer image.
This will allow it to be restored for the transformation box.
"""
if self.box and self.zoom != 1.0:
# The transformation box is active and dezoomed
# crop away 1 pixel border to avoid artefacts on the pixbuf
self.pixbuf = Gdk.pixbuf_get_from_window(self.get_window(),
self.box.area.x + 1, self.box.area.y + 1,
self.box.area.width - 2, self.box.area.height - 2)
else:
self.pixbuf = Gdk.pixbuf_get_from_window(self.get_window(),
0, 0,
self.get_window().get_width(),
self.get_window().get_height())
self.stored = True
def do_realize(self):
"""
Redefine gtk DrawingArea's do_realize method to handle multiple OSes.
This is called when creating the widget to get the window ID.
"""
Gtk.DrawingArea.do_realize(self)
if platform.system() == 'Windows':
self.window_xid = self.props.window.handle
else:
self.window_xid = self.get_property('window').get_xid()
def button_release_event(self, widget, event):
if event.button == 1:
self.box.update_effect_properties()
self.box.release_point()
#.........这里部分代码省略.........