[pitivi] Remove obsolete View and Controller classes
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Remove obsolete View and Controller classes
- Date: Wed, 24 Apr 2013 18:02:11 +0000 (UTC)
commit 4226bc27002731607ddd4634562fd7a49325560e
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date: Wed Apr 17 03:58:17 2013 +0200
Remove obsolete View and Controller classes
pitivi/utils/timeline.py | 228 ----------------------------------------------
1 files changed, 0 insertions(+), 228 deletions(-)
---
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index 1c4d9e0..86c32d7 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -289,234 +289,6 @@ class EditingContext(Signallable):
ARROW = Gdk.Cursor.new(Gdk.CursorType.ARROW)
-class Controller(Loggable):
-
- """
- A controller which implements drag-and-drop bahavior on connected view
- objects in the timeline. Subclasses may override the drag_start, drag_end,
- pos, and set_pos methods
- """
-
- # note we SHOULD be using the gtk function for this, but it doesn't appear
- # to be exposed in pygtk
- __DRAG_THRESHOLD__ = Point(0, 0)
-
- _view = receiver()
-
- _dragging = None
- _canvas = None
- _cursor = None
- _ptr_within = False
- _last_click = None
- _initial = None
- _mousedown = None
- _last_event = None
- _pending_drag_start = None
- _pending_drag_end = False
- _shift_down = False
- _control_down = False
- _handle_enter_leave = True
- _handle_mouse_up_down = True
- _handle_motion_notify = True
-
- def __init__(self, instance, view=None):
- object.__init__(self)
- self._view = view
- self.app = instance
- Loggable.__init__(self)
-
-## convenience functions
-
- def from_event(self, event):
- """returns the coordinates of an event"""
- return Point(*self._canvas.convert_from_pixels(event.x, event.y))
-
- def from_item_event(self, item, event):
- return Point(*self._canvas.convert_from_item_space(item,
- *self.from_event(event)))
-
- def to_item_space(self, item, point):
- return Point(*self._canvas.convert_to_item_space(item, *point))
-
- def pos(self, item):
- bounds = item.get_bounds()
- return Point(bounds.x1, bounds.y1)
-
-## signal handlers
-
- @handler(_view, "enter_notify_event")
- def enter_notify_event(self, item, target, event):
- self._event_common(item, target, event)
- self._canvas.grab_focus(item)
- if self._cursor and item is target:
- event.window.set_cursor(self._cursor)
- if not self._dragging:
- self.enter(item, target)
- self._ptr_within = True
- return self._handle_enter_leave or self._dragging
-
- @handler(_view, "leave_notify_event")
- def leave_notify_event(self, item, target, event):
- self._event_common(item, target, event)
- self._canvas.keyboard_ungrab(item, event.time)
- self._ptr_within = False
- if not self._dragging:
- self.leave(item, target)
- event.window.set_cursor(ARROW)
- return self._handle_enter_leave or self._dragging
-
- @handler(_view, "button_press_event")
- def button_press_event(self, item, target, event):
- self._event_common(item, target, event)
- if not self._canvas:
- self._canvas = item.get_canvas()
- self._mousedown = self.pos(item) - self.transform(self.from_item_event(item, event))
- self._dragging = target
- self._initial = self.pos(target)
- self._pending_drag_start = (item, target, event)
- return self._handle_mouse_up_down
-
- @handler(_view, "motion_notify_event")
- def motion_notify_event(self, item, target, event):
- self._event_common(item, target, event)
- if self._dragging:
- if self._pending_drag_start is not None:
- pending_drag_start, self._pending_drag_start = self._pending_drag_start, None
- self._pending_drag_end = True
- self._drag_start(*pending_drag_start)
-
- self.set_pos(self._dragging,
- self.transform(self._mousedown + self.from_item_event(item, event)))
- return self._handle_motion_notify
- else:
- self.hover(item, target, event)
- return False
-
- @handler(_view, "button_release_event")
- def button_release_event(self, item, target, event):
- self._event_common(item, target, event)
- self._drag_end(item, self._dragging, event)
- self._dragging = None
- return self._handle_mouse_up_down
-
- @handler(_view, "key_press_event")
- def key_press_event(self, item, target, event):
- self._event_common(item, target, event)
- kv = event.keyval
- if kv in (Gdk.KEY_Shift_L, Gdk.KEY_Shift_R):
- self._shift_down = True
- elif kv in (Gdk.KEY_Control_L, Gdk.KEY_Control_R):
- self._control_down = True
- return self.key_press(kv)
-
- @handler(_view, "key_release_event")
- def key_release_event(self, item, target, event):
- self._event_common(item, target, event)
- kv = event.keyval
- if kv in (Gdk.KEY_Shift_L, Gdk.KEY_Shift_R):
- self._shift_down = False
- elif kv in (Gdk.KEY_Control_L, Gdk.KEY_Control_R):
- self._control_down = False
- return self.key_release(kv)
-
-## internal callbacks
-
- def _event_common(self, item, target, event):
- if not self._canvas:
- self._canvas = item.get_canvas()
- # might there be a better way to do this?
- self._hadj = self._canvas.app.gui.timeline_ui.hadj
- self._vadj = self._canvas.app.gui.timeline_ui.vadj
- self._last_event = event
- _, s = event.get_state()
- self._shift_down = s & Gdk.ModifierType.SHIFT_MASK
- self._control_down = s & Gdk.ModifierType.CONTROL_MASK
-
- def _drag_start(self, item, target, event):
- self.drag_start(item, target, event)
-
- def _drag_end(self, item, target, event):
- self._pending_drag_start = None
- pending_drag_end, self._pending_drag_end = self._pending_drag_end, False
- if pending_drag_end:
- self.drag_end(item, target, event)
-
- if self._ptr_within and self._drag_threshold():
- point = self.from_item_event(item, event)
- if self._last_click and (event.time - self._last_click < 400):
- self.double_click(point)
- else:
- self.click(point)
- self._last_click = event.time
- event.window.set_cursor(self._cursor)
- else:
- event.window.set_cursor(ARROW)
-
- def _drag_threshold(self):
- last = self.pos(self._dragging)
- if abs(self._initial - last) > self.__DRAG_THRESHOLD__:
- return False
- return True
-
-## protected interface for subclasses
-
- def click(self, pos):
- pass
-
- def double_click(self, pos):
- pass
-
- def drag_start(self, item, target, event):
- pass
-
- def drag_end(self, item, target, event):
- pass
-
- def set_pos(self, obj, pos):
- obj.props.x, obj.props.y = pos
-
- def transform(self, pos):
- return pos
-
- def enter(self, item, target):
- pass
-
- def leave(self, item, target):
- pass
-
- def key_press(self, keyval):
- pass
-
- def key_release(self, keyval):
- pass
-
- def hover(self, item, target, event):
- pass
-
-
-class View(object):
-
- Controller = Controller
-
- def __init__(self, instance, default_mode=GES.EditMode.EDIT_NORMAL):
- object.__init__(self)
- self._controller = self.Controller(instance, default_mode, view=self)
-
-## public interface
-
- def focus(self):
- pass
-
- def select(self):
- pass
-
- def activate(self):
- pass
-
- def normal(self):
- pass
-
-
class Zoomable(object):
"""
Interface for managing tranformation between timeline timestamps and UI
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]