[pitivi: 1/7] add missing menu items and supporting code
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi: 1/7] add missing menu items and supporting code
- Date: Thu, 9 Apr 2009 14:26:33 -0400 (EDT)
commit e129532d225df460806e0d147ef3106251137812
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date: Wed Apr 1 22:34:08 2009 -0700
add missing menu items and supporting code
---
pitivi/ui/actions.xml | 48 ------------------------------
pitivi/ui/mainwindow.py | 27 ++++++++++++++---
pitivi/ui/mainwindow.xml | 60 ++++++++++++++++++++++++++++++++++++++
pitivi/ui/sourcelist.py | 72 ++++++++++++++++++++++++++++++++++++---------
pitivi/ui/timeline.py | 27 ++++++++++++++--
5 files changed, 162 insertions(+), 72 deletions(-)
diff --git a/pitivi/ui/actions.xml b/pitivi/ui/actions.xml
deleted file mode 100644
index 3e61922..0000000
--- a/pitivi/ui/actions.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<ui>
- <menubar name="MainMenuBar">
- <menu action="File">
- <menuitem action="NewProject" />
- <menuitem action="OpenProject" />
- <menuitem action="SaveProject" />
- <menuitem action="SaveProjectAs" />
- <menuitem action="ProjectSettings" />
- <menuitem action="NetstreamCapture" />
- <menuitem action="Screencast" />
- <separator />
- <menuitem action="RenderProject" />
- <separator />
- <menuitem action="ImportfromCam" />
- <placeholder name="SourceList"/>
- <separator />
- <menuitem action="Quit" />
- </menu>
- <menu action="Edit">
- <menuitem action="PluginManager" />
- </menu>
- <menu action="View">
- <menuitem action="FullScreen" />
- </menu>
- <menu action="Help">
- <menuitem action="About" />
- </menu>
- </menubar>
- <toolbar name="MainToolBar">
- <toolitem action="NewProject" />
- <toolitem action="OpenProject" />
- <toolitem action="SaveProject" />
- <separator />
- <placeholder name="SourceList" />
- <separator />
- <toolitem action="RenderProject" />
- <separator />
- <toolitem action="FullScreen" />
- </toolbar>
- <toolbar name="TimelineToolBar">
- <placeholder name="Timeline" />
- <separator />
- </toolbar>
- <accelerator action="FullScreenAlternate" />
- <accelerator action="PlayPause" />
- <accelerator action="RenderProject" />
- <accelerator action="Loop" />
-</ui>
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 8541cd6..f1123eb 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -226,7 +226,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
None, _("Save the current project"), self._saveProjectCb),
("SaveProjectAs", gtk.STOCK_SAVE_AS, None,
None, _("Save the current project"), self._saveProjectAsCb),
- ("ProjectSettings", gtk.STOCK_PROPERTIES, _("Project settings"),
+ ("ProjectSettings", gtk.STOCK_PROPERTIES, _("Project Settings"),
None, _("Edit the project settings"), self._projectSettingsCb),
("RenderProject", 'pitivi-render' , _("_Render project"),
None, _("Render project"), self._recordCb),
@@ -234,7 +234,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
_("_Plugins..."),
None, _("Manage plugins"), self._pluginManagerCb),
("ImportfromCam", gtk.STOCK_ADD ,
- _("_Import from Webcam..."),
+ _("Import from _Webcam..."),
None, _("Import Camera stream"), self._ImportWebcam),
("Screencast", gtk.STOCK_ADD ,
_("_Make screencast..."),
@@ -248,6 +248,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
("File", None, _("_File")),
("Edit", None, _("_Edit")),
("View", None, _("_View")),
+ ("Library", None, _("_Library")),
+ ("Timeline", None, _("_Timeline")),
("Rewind", gtk.STOCK_MEDIA_REWIND, None, None, REWIND,
self.rewind),
("PlayPause", gtk.STOCK_MEDIA_PLAY, None, "space", PLAY,
@@ -264,7 +266,11 @@ class PitiviMainWindow(gtk.Window, Loggable):
_("View the main window on the whole screen"),
self._fullScreenCb),
("FullScreenAlternate", gtk.STOCK_FULLSCREEN, None, "F11", None,
- self._fullScreenAlternateCb)
+ self._fullScreenAlternateCb),
+ ("ShowHideMainToolbar", None, _("Main Toolbar"), None, None,
+ self._showHideMainToolBar, True),
+ ("ShowHideTimelineToolbar", None, _("Timeline Toolbar"), None,
+ None, self._showHideTimelineToolbar, True),
]
self.actiongroup = gtk.ActionGroup("mainwindow")
@@ -281,6 +287,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
action.set_sensitive(False)
elif action_name == "ImportfromCam":
self.webcam_button = action
+ action.set_sensitive(False)
elif action_name == "Screencast":
# FIXME : re-enable this action once istanbul integration is complete
# and upstream istanbul has applied packages for proper interaction.
@@ -289,7 +296,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
"ProjectSettings", "Quit", "File", "Edit", "Help", "About",
"View", "FullScreen", "FullScreenAlternate", "ImportSources",
"ImportSourcesFolder", "PluginManager", "PlayPause",
- "Project", "FrameForward", "FrameBackward"]:
+ "Project", "FrameForward", "FrameBackward",
+ "ShowHideMainToolbar", "ShowHideTimelineToolbar", "Library",
+ "Timeline"]:
action.set_sensitive(True)
elif action_name in ["SaveProject", "SaveProjectAs",
"NewProject", "OpenProject"]:
@@ -302,7 +311,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
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"))
+ os.path.abspath(__file__)), "mainwindow.xml"))
def _createUi(self):
""" Create the graphical interface """
@@ -556,6 +565,14 @@ class PitiviMainWindow(gtk.Window, Loggable):
def _fullScreenAlternateCb(self, unused_action):
self.actiongroup.get_action("FullScreen").activate()
+ def _showHideMainToolBar(self, action):
+ self.uimanager.get_widget("/MainToolBar").props.visible = \
+ action.props.active
+
+ def _showHideTimelineToolbar(self, action):
+ self.uimanager.get_widget("/TimelineToolBar").props.visible = \
+ action.props.active
+
def _aboutResponseCb(self, dialog, unused_response):
dialog.destroy()
diff --git a/pitivi/ui/mainwindow.xml b/pitivi/ui/mainwindow.xml
new file mode 100644
index 0000000..b467820
--- /dev/null
+++ b/pitivi/ui/mainwindow.xml
@@ -0,0 +1,60 @@
+<ui>
+ <menubar name="MainMenuBar">
+ <menu action="File">
+ <menuitem action="NewProject" />
+ <menuitem action="OpenProject" />
+ <menuitem action="SaveProject" />
+ <menuitem action="SaveProjectAs" />
+ <separator />
+ <menuitem action="Quit" />
+ </menu>
+ <menu action="Edit">
+ <menuitem action="PluginManager" />
+ </menu>
+ <menu action="View">
+ <menuitem action="ShowHideMainToolbar" />
+ <menuitem action="ShowHideTimelineToolbar" />
+ <separator />
+ <placeholder name="Timeline" />
+ <separator />
+ <menuitem action="FullScreen" />
+ </menu>
+ <menu action="Library">
+ <menuitem action="RenderProject" />
+ <separator />
+ <menuitem action="ImportfromCam" />
+ <menuitem action="NetstreamCapture" />
+ <menuitem action="Screencast" />
+ <placeholder name="SourceList" />
+ <separator />
+ <placeholder name="Timeline" />
+ <separator />
+ <menuitem action="ProjectSettings" />
+ </menu>
+ <menu action="Timeline">
+ <placeholder name="Timeline" />
+ </menu>
+ <menu action="Help">
+ <menuitem action="About" />
+ </menu>
+ </menubar>
+ <toolbar name="MainToolBar">
+ <toolitem action="NewProject" />
+ <toolitem action="OpenProject" />
+ <toolitem action="SaveProject" />
+ <separator />
+ <placeholder name="SourceList" />
+ <separator />
+ <toolitem action="RenderProject" />
+ <separator />
+ <toolitem action="FullScreen" />
+ </toolbar>
+ <toolbar name="TimelineToolBar">
+ <placeholder name="Timeline" />
+ <separator />
+ </toolbar>
+ <accelerator action="FullScreenAlternate" />
+ <accelerator action="PlayPause" />
+ <accelerator action="RenderProject" />
+ <accelerator action="Loop" />
+</ui>
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index ba0d240..4636de8 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -60,10 +60,13 @@ GlobalSettings.addConfigOption('closeImportDialog',
ui = '''
<ui>
<menubar name="MainMenuBar">
- <menu action="File">
+ <menu action="Library">
<placeholder name="SourceList" >
<menuitem action="ImportSources" />
<menuitem action="ImportSourcesFolder" />
+ <menuitem action="RemoveSources" />
+ <separator />
+ <menuitem action="InsertEnd" />
</placeholder>
</menu>
</menubar>
@@ -177,6 +180,7 @@ class SourceList(gtk.VBox, Loggable):
self.treeview.set_headers_visible(False)
tsel = self.treeview.get_selection()
tsel.set_mode(gtk.SELECTION_MULTIPLE)
+ tsel.connect("changed", self._treeSelectionChanged)
pixbufcol = gtk.TreeViewColumn(_("Icon"))
pixbufcol.set_expand(False)
@@ -270,18 +274,35 @@ class SourceList(gtk.VBox, Loggable):
# Error dialog box
self.errorDialogBox = None
- # our actions
+ # always available
actions = (
("ImportSources", gtk.STOCK_ADD, _("_Import clips..."),
None, _("Import clips to use"), self._importSourcesCb),
("ImportSourcesFolder", gtk.STOCK_ADD,
- _("_Import folder of clips..."), None,
+ _("Import _folder of clips..."), None,
_("Import folder of clips to use"), self._importSourcesFolderCb),
)
- self.actiongroup = gtk.ActionGroup("sourcelist")
- self.actiongroup.add_actions(actions)
+
+ # only available when selection is non-empty
+ selection_actions = (
+ ("RemoveSources", gtk.STOCK_DELETE,
+ _("_Remove from project"), None, None,
+ self._removeSourcesCb),
+ ("InsertEnd", gtk.STOCK_COPY,
+ _("Insert at _end of timeline"), "Insert", None,
+ self._insertEndCb),
+ )
+
uiman = self.app.gui.uimanager
- uiman.insert_action_group(self.actiongroup, 0)
+ actiongroup = gtk.ActionGroup("sourcelistpermanent")
+ actiongroup.add_actions(actions)
+ uiman.insert_action_group(actiongroup, 0)
+
+ self.selection_actions = gtk.ActionGroup("sourcelistselection")
+ self.selection_actions.add_actions(selection_actions)
+ self.selection_actions.set_sensitive(False)
+ uiman.insert_action_group(self.selection_actions, 0)
+
uiman.add_ui_from_string(ui)
def _importSourcesCb(self, unused_action):
@@ -290,6 +311,19 @@ class SourceList(gtk.VBox, Loggable):
def _importSourcesFolderCb(self, unused_action):
self.showImportSourcesDialog(True)
+ def _removeSourcesCb(self, unused_action):
+ self._removeSources()
+
+ def _insertEndCb(self, unused_action):
+ timeline = self.app.current.timeline
+ sources = self.app.current.sources
+ start = timeline.duration
+ for uri in self.getSelectedItems():
+ factory = sources[uri]
+ source = timeline.addSourceFactory(factory)
+ source.setStart(start)
+ start += source.duration
+
def _getIcon(self, iconname, alternate):
icontheme = gtk.icon_theme_get_default()
pixdir = get_pixmap_dir()
@@ -504,15 +538,7 @@ class SourceList(gtk.VBox, Loggable):
self.debug("closing")
self._importDialog = None
-
- ## UI Button callbacks
-
- def _addButtonClickedCb(self, unused_widget=None):
- """ called when a user clicks on the add button """
- self.showImportSourcesDialog()
-
- def _removeButtonClickedCb(self, unused_widget=None):
- """ Called when a user clicks on the remove button """
+ def _removeSources(self):
tsel = self.treeview.get_selection()
if tsel.count_selected_rows() < 1:
return
@@ -524,6 +550,16 @@ class SourceList(gtk.VBox, Loggable):
uri = model[path][COL_URI]
del self.app.current.sources[uri]
+ ## UI Button callbacks
+
+ def _addButtonClickedCb(self, unused_widget=None):
+ """ called when a user clicks on the add button """
+ self.showImportSourcesDialog()
+
+ def _removeButtonClickedCb(self, unused_widget=None):
+ """ Called when a user clicks on the remove button """
+ self._removeSources()
+
def _playButtonClickedCb(self, unused_widget):
""" Called when a user clicks on the play button """
# get the selected filesourcefactory
@@ -605,6 +641,12 @@ class SourceList(gtk.VBox, Loggable):
treeview.get_selection().select_path(path)
return False
+ def _treeSelectionChanged(self, tsel):
+ if self.getSelectedItems():
+ self.selection_actions.set_sensitive(True)
+ else:
+ self.selection_actions.set_sensitive(False)
+
def _rowActivatedCb(self, unused_treeview, path, unused_column):
factory = self.storemodel[path][COL_FACTORY]
self.emit('play', factory)
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 2809a2f..50f7c62 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -49,9 +49,25 @@ GROUP = _("Group clips")
SELECT_BEFORE = ("Select all sources before selected")
SELECT_AFTER = ("Select all after selected")
-# ui string for the complex timeline toolbar
ui = '''
<ui>
+ <menubar name="MainMenuBar">
+ <menu action="View">
+ <placeholder name="Timeline">
+ <menuitem action="ZoomIn" />
+ <menuitem action="ZoomOut" />
+ </placeholder>
+ </menu>
+ <menu action="Timeline">
+ <placeholder name="Timeline">
+ <menuitem action="Razor" />
+ <menuitem action="DeleteObj" />
+ <separator />
+ <menuitem action="UnlinkObj" />
+ <menuitem action="LinkObj" />
+ </placeholder>
+ </menu>
+ </menubar>
<toolbar name="TimelineToolBar">
<placeholder name="Timeline">
<toolitem action="ZoomOut" />
@@ -166,11 +182,14 @@ class Timeline(gtk.Table, Loggable, Zoomable):
("GroupObj", "pitivi-group", None, None, GROUP,
self.groupSelected),
)
- razor = gtk.ToggleAction("Razor", None, RAZOR, "pitivi-split")
- razor.connect("toggled", self.toggleRazor)
+
+ toggle_actions = (
+ ("Razor", "pitivi-split", _("Razor"), "<Ctrl>R", RAZOR,
+ self.toggleRazor),
+ )
self.actiongroup = gtk.ActionGroup("complextimeline")
self.actiongroup.add_actions(actions)
- self.actiongroup.add_action(razor)
+ self.actiongroup.add_toggle_actions(toggle_actions)
#self.actiongroup.set_visible(False)
self.ui_manager.insert_action_group(self.actiongroup, 0)
self.ui_manager.add_ui_from_string(ui)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]