[pitivi] Add layer movement menu items
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Add layer movement menu items
- Date: Sat, 21 Jul 2012 20:01:18 +0000 (UTC)
commit e766747f9cf3a8da303d4fa7cfdc50686416a005
Author: Paul Lange <palango gmx de>
Date: Wed Jul 11 19:17:58 2012 +0200
Add layer movement menu items
pitivi/timeline/layer.py | 34 ++++++++++++++++++++++++++++++----
pitivi/timeline/timeline.py | 13 +++++++++++--
2 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 371bd0a..b6ebdb0 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -119,10 +119,25 @@ class BaseLayerControl(gtk.VBox, Loggable):
self.show_all()
# Popup Menu
+ # TODO: add icons
self.popup = gtk.Menu()
- menu_dellayer = gtk.ImageMenuItem(_("_Delete layer"))
- menu_dellayer.connect("activate", self._deleteLayerCb)
- self.popup.append(menu_dellayer)
+ layer_delete = gtk.ImageMenuItem(_("_Delete layer"))
+ layer_delete.connect("activate", self._deleteLayerCb)
+ layer_up = gtk.ImageMenuItem(_("Move layer up"))
+ layer_up.connect("activate", self._moveLayerCb, -1)
+ layer_down = gtk.ImageMenuItem(_("Move layer down"))
+ layer_down.connect("activate", self._moveLayerCb, 1)
+ layer_first = gtk.ImageMenuItem(_("Move layer to top"))
+ layer_first.connect("activate", self._moveLayerCb, -2)
+ layer_last = gtk.ImageMenuItem(_("Move layer to bottom"))
+ layer_last.connect("activate", self._moveLayerCb, 2)
+
+ self.popup.append(layer_first)
+ self.popup.append(layer_up)
+ self.popup.append(layer_down)
+ self.popup.append(layer_last)
+ self.popup.append(gtk.SeparatorMenuItem())
+ self.popup.append(layer_delete)
self.popup.show_all()
# Drag and drop
@@ -134,7 +149,7 @@ class BaseLayerControl(gtk.VBox, Loggable):
def _dragDataGetCb(self, widget, context, selection, targetType, eventTime):
if targetType == TYPE_PITIVI_LAYER_CONTROL:
selection.set(selection.target, 8,
- str(self._app.gui.timeline_ui.controls.getControlIdString(self)))
+ str(self._app.gui.timeline_ui.controls.getControlIndex(self)))
def getSelected(self):
return self._selected
@@ -199,6 +214,17 @@ class BaseLayerControl(gtk.VBox, Loggable):
timeline = self._layer.get_timeline()
timeline.remove_layer(self._layer)
+ def _moveLayerCb(self, widget, step):
+ index = self._app.gui.timeline_ui.controls.getControlIndex(self)
+ if abs(step) == 1:
+ index += step
+ elif step == -2:
+ index = 0
+ else:
+ index = self._layer.get_timeline().get_layers()
+
+ self._app.gui.timeline_ui.controls.moveControlWidget(self, index)
+
def getHeight(self):
return self.get_allocation().height
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 4593df2..fbbf88f 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -721,12 +721,21 @@ class TimelineControls(gtk.VBox, Loggable):
for child in self.get_children():
next = counter + child.getHeight()
if y >= counter and y < next:
- self.reorder_child(widget, index)
+ self.moveControlWidget(widget, index)
+ return
counter = next
index += 1
+ def moveControlWidget(self, control, index):
+ """
+ Moves control to the given index and cares for moving the linked layer
+ as well as updating separators
+ """
+ self.reorder_child(control, index)
+
# reorder linked audio/video layer
+ widget_type = type(control)
index = 0
for child in self.get_children():
# only set layer priority once
@@ -738,7 +747,7 @@ class TimelineControls(gtk.VBox, Loggable):
self._orderControls()
self._hideLastSeparator()
- def getControlIdString(self, control):
+ def getControlIndex(self, control):
"""
Returns an unique ID of a control
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]