[pitivi] Add MenuItem for layer deletion and remove temporary button



commit b8913aa7547f2d51378aa3474d8f4697c7eeb831
Author: Paul Lange <palango gmx de>
Date:   Wed Jul 4 19:56:50 2012 +0200

    Add MenuItem for layer deletion and remove temporary button

 data/ui/mainwindow.xml      |    2 ++
 pitivi/mainwindow.py        |   12 ++++++++++++
 pitivi/timeline/layer.py    |   20 --------------------
 pitivi/timeline/timeline.py |   16 ++++++++++++++++
 4 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/data/ui/mainwindow.xml b/data/ui/mainwindow.xml
index c467407..5d9887b 100644
--- a/data/ui/mainwindow.xml
+++ b/data/ui/mainwindow.xml
@@ -37,6 +37,8 @@
     </menu>
     <menu action="Timeline">
       <placeholder name="Timeline" />
+      <separator />
+      <menuitem action="RemoveLayer" />
     </menu>
     <menu action="Help">
       <menuitem action="UserManual" />
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 0128f0a..88f2123 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -285,6 +285,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
             ("Preferences", gtk.STOCK_PREFERENCES, None,
             None, None, self._prefsCb),
 
+            ("RemoveLayer", gtk.STOCK_REMOVE, _("Remove layer"),
+             None, _("Remove the selected layer from the project"), self._removeLayerCb),
+
             ("Quit", gtk.STOCK_QUIT, None, None, None, self._quitCb),
 
             ("About", gtk.STOCK_ABOUT, None,
@@ -375,6 +378,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         self.timeline_ui = Timeline(instance, self.uimanager)
         self.timeline_ui.setProjectManager(self.app.projectManager)
+        self.timeline_ui.controls.connect("selection-changed", self._selectedLayerChangedCb)
         self.app.current = None
         vpaned.pack2(self.timeline_ui, resize=True, shrink=False)
         self.timeline_ui.show()
@@ -552,6 +556,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
         to remove all instances of that clip."""
         self.timeline_ui.purgeObject(uri)
 
+    def _selectedLayerChangedCb(self, widget, layer):
+        self.main_actions.get_action("RemoveLayer").set_sensitive(layer != None)
+
 ## Toolbar/Menu actions callback
 
     def _newProjectMenuCb(self, unused_action):
@@ -589,6 +596,11 @@ class PitiviMainWindow(gtk.Window, Loggable):
     def _projectSettingsCb(self, unused_action):
         self.showProjectSettingsDialog()
 
+    def _removeLayerCb(self, unused_action):
+        layer = self.timeline_ui.controls.getSelectedLayer()
+        timeline = layer.get_timeline()
+        timeline.remove_layer(layer)
+
     def showProjectSettingsDialog(self):
         from pitivi.project import ProjectSettingsDialog
         ProjectSettingsDialog(self, self.app.current).window.run()
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index bbede24..665a89a 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -98,22 +98,11 @@ class BaseLayerControl(gtk.EventBox, Loggable):
         visible_option.set_active(True)
         visible_option.props.sensitive = False
 
-        # Temporary delete button
-        del_button = gtk.Button()
-        del_button.set_tooltip_text(_("Delete this layer"))
-        del_button.connect("clicked", self._deleteLayerCb)
-        del_button.set_relief(gtk.RELIEF_NONE)
-
-        del_image = gtk.Image()
-        del_image.set_from_icon_name("edit-delete", gtk.ICON_SIZE_MENU)
-        del_button.add(del_image)
-
         # Upper bar
         upper = gtk.HBox()
         upper.pack_start(self.name_entry, True, True)
         upper.pack_start(self.solo_button, False, False)
         upper.pack_start(visible_option, False, False)
-        upper.pack_start(del_button, False, False)
 
         # Lower bar
         self.lower_hbox = gtk.HBox()
@@ -149,15 +138,6 @@ class BaseLayerControl(gtk.EventBox, Loggable):
     def _focusChangeCb(self, widget, direction, sensitive_actions):
         self._app.gui.setActionsSensitive(sensitive_actions)
 
-    def _deleteLayerCb(self, widget):
-        """
-        Remove layer associated with this widget
-
-        Disposal of widget is handles by TimelineControls
-        """
-        timeline = self._layer.get_timeline()
-        timeline.remove_layer(self._layer)
-
     def _soloToggledCb(self, button):
         """
         Send TimelineControls the new solo-ed layer
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 9fb7e33..1ed940b 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -476,11 +476,19 @@ class TimelineControls(gtk.VBox, Loggable):
     Holds and manages the LayerControlWidgets
     """
 
+    __gsignals__ = {
+       "selection-changed": (
+            gobject.SIGNAL_RUN_LAST,
+            gobject.TYPE_NONE,
+            (gobject.TYPE_PYOBJECT,),)
+       }
+
     def __init__(self, instance):
         gtk.VBox.__init__(self)
         Loggable.__init__(self)
         self.app = instance
         self._layer_controls = {}
+        self._selected_layer = None
         self._timeline = None
         self.set_spacing(LAYER_SPACING)
         self.type_map = {ges.TRACK_TYPE_AUDIO: AudioLayerControl,
@@ -611,6 +619,11 @@ class TimelineControls(gtk.VBox, Loggable):
         """
         Select layer_control and unselect all other controls
         """
+        # if selected layer changed
+        if self._selected_layer != layer:
+            self._selected_layer = layer
+            self.emit("selection-changed", layer)
+
         for key, controls in self._layer_controls.iteritems():
             # selected widget not in this layer
             if key != layer:
@@ -625,6 +638,9 @@ class TimelineControls(gtk.VBox, Loggable):
                     controls[ges.TRACK_TYPE_VIDEO].selected = True
                     controls[ges.TRACK_TYPE_AUDIO].selected = False
 
+    def getSelectedLayer(self):
+        return self._selected_layer
+
 
 class InfoStub(gtk.HBox, Loggable):
     """



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]