pitivi r1205 - in branches/SOC_2008_BLEWIS: . pitivi pitivi/ui



Author: blewis
Date: Mon Jul 21 01:27:12 2008
New Revision: 1205
URL: http://svn.gnome.org/viewvc/pitivi?rev=1205&view=rev

Log:
* pitivi/pitivi.py:
moved the uimanager instance into the Pitivi class, so that other
modules, and plugins, can merge in ui elements without coupling to the
main window.
* pitivi/ui/actions.xml:
added an entry for the timeline toolbar
* pitivi/ui/complextimeline.py:
added actions and UI definition for timeline toolbar
* pitivi/ui/mainwindow.py:
moved uimanager instance out, adjusted indentation on
some classes


Modified:
   branches/SOC_2008_BLEWIS/ChangeLog
   branches/SOC_2008_BLEWIS/pitivi/pitivi.py
   branches/SOC_2008_BLEWIS/pitivi/ui/actions.xml
   branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
   branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py

Modified: branches/SOC_2008_BLEWIS/pitivi/pitivi.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/pitivi.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/pitivi.py	Mon Jul 21 01:27:12 2008
@@ -128,6 +128,7 @@
         self.effects = Magician()
 
         if self._use_ui:
+            self.uimanager = gtk.UIManager()
             # we're starting a GUI for the time being
             self.gui = mainwindow.PitiviMainWindow()
             self.gui.show()

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/actions.xml
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/actions.xml	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/actions.xml	Mon Jul 21 01:27:12 2008
@@ -38,4 +38,6 @@
     <toolitem action="FullScreen" />
     <toolitem action="AdvancedView" />
   </toolbar>
+  <toolbar name="TimelineToolBar">
+  </toolbar>
 </ui>

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/complextimeline.py	Mon Jul 21 01:27:12 2008
@@ -39,9 +39,14 @@
 from urllib import unquote
 from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
 from pitivi.utils import closest_item
+from gettext import gettext as _
 
+
+# default heights for composition layer objects
 VIDEO_TRACK_HEIGHT = 50
 AUDIO_TRACK_HEIGHT = 20
+
+# visual styles for sources in the UI
 VIDEO_SOURCE = (
     goocanvas.Rect,
     {
@@ -67,6 +72,7 @@
     }
 )
 
+# defines visual appearance for source resize handle
 DRAG_HANDLE = (
     goocanvas.Rect,
     {
@@ -106,6 +112,7 @@
     {}
 )
 
+# the vsiual appearance for the selection marquee
 MARQUEE = (
     goocanvas.Rect,
     {
@@ -115,11 +122,38 @@
     {}
 )
 
+# cursors to be used for resizing objects
 LEFT_SIDE = gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE)
 RIGHT_SIDE = gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE)
 ARROW = gtk.gdk.Cursor(gtk.gdk.ARROW)
+
+# default number of pixels to use for edge snaping
 DEADBAND = 5
 
+# tooltip text for toolbar
+DELETE = _("Delete Selected")
+RAZOR = _("Cut clip at mouse position")
+ZOOM_IN =  _("Zoom In")
+ZOOM_OUT =  _("Zoom Out")
+SELECT_BEFORE = ("Select all sources before selected")
+SELECT_AFTER = ("Select all after selected")
+
+# ui string for the complex timeline toolbar
+ui = '''
+<ui>
+    <toolbar name="TimelineToolBar">
+        <toolitem action="ZoomOut" />
+        <toolitem action="ZoomIn" />
+        <separator />
+        <toolitem action="Razor" />
+        <separator />
+        <toolitem action="DeleteObj" />
+        <toolitem action="SelectBefore" />
+        <toolitem action="SelectAfter" />
+    </toolbar>
+</ui>
+'''
+
 class ComplexTrack(SmartGroup):
     __gtype_name__ = 'ComplexTrack'
 
@@ -414,6 +448,21 @@
             return res
         return time
 
+## Editing Operations
+
+    def deleteSelected(self, unused_action):
+        pass
+
+    def activateRazor(self, unused_action):
+        pass
+
+    def selectBeforeCurrent(self, unused_action):
+        pass
+
+    def selectAfterCurrent(self, unused_action):
+        pass
+
+
 ## ZoomableWidgetInterface overrides
 
     def _selection_changed_cb(self, selected, deselected):
@@ -465,14 +514,13 @@
 # +--ScaleRuler(gtk.Layout)
 # |
 # +--gtk.ScrolledWindow
-# |  |
-# |  +--CompositionLayers(goocanas.Canvas)
-# |  |  |
-# |  |  +--ComplexTrack(SmartGroup)
-# |  |
-# |  +--Status Bar ??
-# | 
-# +--ToolBar / (Status Bar??)
+#    |
+#    +--CompositionLayers(goocanas.Canvas)
+#    |  |
+#    |  +--ComplexTrack(SmartGroup)
+#    |
+#    +--Status Bar ??
+#
 
 class ComplexTimelineWidget(gtk.VBox, ZoomableWidgetInterface):
 
@@ -523,9 +571,26 @@
         # force update of the zoom ratio, which hasn't been set yet.
         self.compositionLayers.zoomChanged()
 
-        #toolbar
-        self.tb = TimelineToolBar()
-        self.pack_start(self.tb, expand=False, fill=False)
+        # toolbar actions
+        actions = (
+            ("ZoomIn", gtk.STOCK_ZOOM_IN, None, None, ZOOM_IN,
+                self._zoomInCb),
+            ("ZoomOut", gtk.STOCK_ZOOM_OUT, None, None, ZOOM_OUT, 
+                self._zoomOutCb),
+            ("DeleteObj", gtk.STOCK_DELETE, None, None, DELETE, 
+                self.compositionLayers.deleteSelected),
+            ("SelectBefore", gtk.STOCK_GOTO_FIRST, None, None, SELECT_BEFORE, 
+                self.compositionLayers.selectBeforeCurrent),
+            ("SelectAfter", gtk.STOCK_GOTO_LAST, None, None, SELECT_AFTER,
+                self.compositionLayers.selectAfterCurrent),
+        )
+        self.actiongroup = gtk.ActionGroup("complextimeline")
+        self.actiongroup.add_actions(actions)
+        self.actiongroup.add_toggle_actions((("Razor", gtk.STOCK_CUT, None, None,
+            RAZOR, self.compositionLayers.activateRazor),))
+        self.actiongroup.set_visible(False)
+        instance.PiTiVi.uimanager.insert_action_group(self.actiongroup, 0)
+        instance.PiTiVi.uimanager.add_ui_from_string(ui)
 
 ## Project callbacks
 
@@ -556,7 +621,25 @@
 
 ## ToolBar callbacks
 
-    def toolBarZoomChangedCb(self, unused_toolbar, zoomratio):
+    ## override show()/hide() methods to take care of actions
+    def show(self):
+        super(ComplexTimelineWidget, self).show()
+        self.actiongroup.set_visible(True)
+
+    def show_all(self):
+        super(ComplexTimelineWidget, self).show_all()
+        self.actiongroup.set_visible(True)
+
+    def hide(self):
+        self.actiongroup.set_visible(False)
+        super(ComplexTimelineWidget, self).hide()
+
+    def _zoomInCb(self, unused_action):
+        zoomratio = 10
+        self.setZoomRatio(zoomratio)
+
+    def _zoomOutCb(self, unused_action):
+        zoomratio = 10
         self.setZoomRatio(zoomratio)
 
 ## PlayGround timeline position callback

Modified: branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py	(original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/mainwindow.py	Mon Jul 21 01:27:12 2008
@@ -173,7 +173,7 @@
             ("File", None, _("_File")),
             ("Edit", None, _("_Edit")),
             ("View", None, _("_View")),
-            ("Help", None, _("_Help"))
+            ("Help", None, _("_Help")),
         ]
 
         self.toggleactions = [
@@ -206,11 +206,12 @@
                     action.set_sensitive(False)
             else:
                 action.set_sensitive(False)
-
-        self.uimanager = gtk.UIManager()
+        
+        self.uimanager = instance.PiTiVi.uimanager
         self.add_accel_group(self.uimanager.get_accel_group())
         self.uimanager.insert_action_group(self.actiongroup, 0)
-        self.uimanager.add_ui_from_file(os.path.join(os.path.dirname(os.path.abspath(__file__)), "actions.xml"))
+        self.uimanager.add_ui_from_file(os.path.join(os.path.dirname(
+            os.path.abspath(__file__)), "actions.xml"))
 
         self.connect_after("key-press-event", self._keyPressEventCb)
 
@@ -239,7 +240,7 @@
         self.timeline.showSimpleView()
         timelineframe = gtk.Frame()
         timelineframe.add(self.timeline)
-        vpaned.pack2(timelineframe, resize=True, shrink=True)
+        vpaned.pack2(timelineframe, resize=False, shrink=True)
 
         hpaned = gtk.HPaned()
         vpaned.pack1(hpaned, resize=True, shrink=False)
@@ -254,6 +255,7 @@
 
         hpaned.pack1(self.sourcefactories, resize=False, shrink=False)
         hpaned.pack2(self.viewer, resize=True, shrink=False)
+        vbox.pack_start(self.uimanager.get_widget("/TimelineToolBar"), False)
 
         #application icon
         self.set_icon_from_file(configure.get_global_pixmap_dir() + "/pitivi.png")
@@ -267,7 +269,7 @@
             self.viewer.window.unfullscreen()
             self.isFullScreen = False
 
-    ## PlayGround callback
+## PlayGround callback
 
     def _errorMessageResponseCb(self, dialogbox, unused_response):
         dialogbox.hide()
@@ -288,14 +290,14 @@
         self.errorDialogBox.show()
 
 
-    ## Project source list callbacks
+## Project source list callbacks
 
     def _sourcesFileAddedCb(self, unused_sources, unused_factory):
         #if (len(self.sourcefactories.sourcelist.storemodel) == 1 
         #    and not len(instance.PiTiVi.current.timeline.videocomp):
         pass
 
-    ## UI Callbacks
+## UI Callbacks
 
     def _destroyCb(self, unused_widget, data=None):
         instance.PiTiVi.shutdown()
@@ -305,7 +307,7 @@
         if gtk.gdk.keyval_name(event.keyval) in ['f', 'F', 'F11']:
             self.toggleFullScreen()
 
-    ## Toolbar/Menu actions callback
+## Toolbar/Menu actions callback
 
     def _newProjectMenuCb(self, unused_action):
         instance.PiTiVi.newBlankProject()
@@ -393,7 +395,7 @@
     def _pluginManagerCb(self, unused_action):
         PluginManagerDialog(instance.PiTiVi.plugin_manager)
 
-    ## PiTiVi main object callbacks
+## PiTiVi main object callbacks
 
     def _newProjectLoadedCb(self, pitivi, project):
         gst.log("A NEW project is loaded, update the UI!")
@@ -434,7 +436,7 @@
         dialog.destroy()
         self.set_sensitive(True)
 
-    ## PiTiVi current project callbacks
+## PiTiVi current project callbacks
 
     def _confirmOverwriteCb(self, unused_project, uri):
         message = _("Do you wish to overwrite existing file \"%s\"?") %\



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