[pitivi] timeline: Do not keep track of the mode/edge of edition
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Do not keep track of the mode/edge of edition
- Date: Thu, 11 Jun 2015 09:18:49 +0000 (UTC)
commit 624962c4952e72f695159cbe8389b0c88093217b
Author: Thibault Saunier <tsaunier gnome org>
Date: Thu May 14 17:20:03 2015 +0200
timeline: Do not keep track of the mode/edge of edition
Summary:
Instead just check what widget has been clicked, if it is a TrimHandle,
use its edge as editing edge, and force trimming as a mode.
Fixes T60 and T71
Maniphest Tasks: T60
Reviewers: aleb
Differential Revision: http://phabricator.freedesktop.org/D179
pitivi/timeline/elements.py | 14 --------------
pitivi/timeline/timeline.py | 18 +++++++++++++++---
pitivi/utils/validate.py | 20 +++++++++-----------
3 files changed, 24 insertions(+), 28 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index be4a319..7966eac 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -509,7 +509,6 @@ class TrimHandle(Gtk.EventBox, Loggable):
else:
self.props.halign = Gtk.Align.START
- self.connect("event", self._eventCb)
self.connect("notify::window", self._windowSetCb)
def _windowSetCb(self, window, pspec):
@@ -518,16 +517,6 @@ class TrimHandle(Gtk.EventBox, Loggable):
def do_show_all(self):
self.info("DO not do anythin on .show_all")
- def _eventCb(self, element, event):
- if event.type == Gdk.EventType.ENTER_NOTIFY:
- self.clip.edit_mode = GES.EditMode.EDIT_TRIM
- self.clip.dragging_edge = self.edge
- elif event.type == Gdk.EventType.LEAVE_NOTIFY:
- self.clip.dragging_edge = GES.Edge.EDGE_NONE
- self.clip.edit_mode = None
-
- return False
-
def do_get_preferred_width(self):
return TrimHandle.DEFAULT_WIDTH, TrimHandle.DEFAULT_WIDTH
@@ -570,9 +559,6 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self._savePositionState()
self._connectWidgetSignals()
- self.edit_mode = None
- self.dragging_edge = GES.Edge.EDGE_NONE
-
self._connectGES()
self.get_accessible().set_name(self.bClip.get_name())
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 4087fdb..b503357 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -41,7 +41,7 @@ from pitivi.utils.timeline import Zoomable, TimelineError
from pitivi.utils.ui import alter_style_class, EXPANDED_SIZE, SPACING, CONTROL_WIDTH
from pitivi.utils.widgets import ZoomBox
-from pitivi.timeline.elements import Clip
+from pitivi.timeline.elements import Clip, TrimHandle
from pitivi.utils import timeline as timelineUtils
from pitivi.timeline.layer import SpacedSeparator, Layer, LayerControls
@@ -526,6 +526,9 @@ class Timeline(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
if res and button == 1:
self.draggingElement = self._getParentOfType(event_widget, Clip)
self.debug("Dragging element is %s" % self.draggingElement)
+ if isinstance(event_widget, TrimHandle):
+ self.__clickedHandle = event_widget
+
if self.draggingElement is not None:
self.__drag_start_x = event.x
@@ -797,6 +800,7 @@ class Timeline(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
# Edition handling
def __setupTimelineEdition(self):
self.draggingElement = None
+ self.__clickedHandle = None
self.editing_context = None
self.__got_dragged = False
self.__drag_start_x = 0
@@ -859,10 +863,17 @@ class Timeline(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
if self.__got_dragged is False:
self.__got_dragged = True
self.allowSeek = False
+ if self.__clickedHandle:
+ edit_mode = GES.EditMode.EDIT_TRIM
+ dragging_edge = self.__clickedHandle.edge
+ else:
+ edit_mode = GES.EditMode.EDIT_NORMAL
+ dragging_edge = GES.Edge.EDGE_NONE
+
self.editing_context = timelineUtils.EditingContext(self.draggingElement.bClip,
self.bTimeline,
- self.draggingElement.edit_mode,
- self.draggingElement.dragging_edge,
+ edit_mode,
+ dragging_edge,
None,
self.app.action_log)
@@ -940,6 +951,7 @@ class Timeline(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
self.editing_context.finish()
self.draggingElement = None
+ self.__clickedHandle = None
self.__got_dragged = False
self.editing_context = None
self.hideSnapBar()
diff --git a/pitivi/utils/validate.py b/pitivi/utils/validate.py
index 4c65185..44a7731 100644
--- a/pitivi/utils/validate.py
+++ b/pitivi/utils/validate.py
@@ -189,12 +189,6 @@ def _releaseButtonIfNeeded(scenario, action, timeline, container, edge, layer_pr
event.y = y
container.ui.sendFakeEvent(event, container.ui)
- if isinstance(container, GES.SourceClip):
- if edge == GES.Edge.EDGE_START:
- container.ui.leftHandle._eventCb(container.ui.leftHandle,
Gdk.Event.new(Gdk.EventType.LEAVE_NOTIFY))
- if edge == GES.Edge.EDGE_END:
- container.ui.rightHandle._eventCb(container.ui.rightHandle,
Gdk.Event.new(Gdk.EventType.LEAVE_NOTIFY))
-
if layer_prio > 0 and container.get_layer().get_priority() != layer_prio:
scenario.report_simple(GLib.quark_from_string("scenario::execution-error"),
"Resulting clip priority: %s"
@@ -301,15 +295,19 @@ def editContainer(scenario, action):
if not hasattr(scenario, "dragging") or scenario.dragging is False \
or scenario.last_edge != edge:
+ widget = container.ui
+ event_widget = container.ui
if isinstance(container, GES.SourceClip):
if edge == GES.Edge.EDGE_START:
- container.ui.leftHandle._eventCb(container.ui.leftHandle,
Gdk.Event.new(Gdk.EventType.ENTER_NOTIFY))
+ event_widget = container.ui.leftHandle
+ event = timeline
elif edge == GES.Edge.EDGE_END:
- container.ui.rightHandle._eventCb(container.ui.rightHandle,
Gdk.Event.new(Gdk.EventType.ENTER_NOTIFY))
+ event_widget = container.ui.rightHandle
+ event = timeline
scenario.dragging = True
event = Event(Gdk.EventType.BUTTON_PRESS, button=1, y=y)
- container.ui.sendFakeEvent(event, container.ui)
+ widget.sendFakeEvent(event, event_widget)
event = Event(Gdk.EventType.MOTION_NOTIFY, button=1,
x=timelineUtils.Zoomable.nsToPixelAccurate(position) -
@@ -320,8 +318,8 @@ def editContainer(scenario, action):
GstValidate.print_action(action, "Editing %s to %s in %s mode, edge: %s "
"with new layer prio: %d\n" % (action.structure["container-name"],
Gst.TIME_ARGS(position),
- timeline.ui.draggingElement.edit_mode,
- timeline.ui.draggingElement.dragging_edge,
+ scenario.last_mode,
+ edge,
layer_prio))
_releaseButtonIfNeeded(scenario, action, timeline, container, edge, layer_prio,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]