[pitivi] Connect to ProjectManager signals from the main window.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] Connect to ProjectManager signals from the main window.
- Date: Sun, 7 Jun 2009 03:56:28 -0400 (EDT)
commit f2df2f15d34e5c5a6ecaa632248cda6d077b13f7
Author: Alessandro Decina <alessandro d gmail com>
Date: Fri Jun 5 19:47:57 2009 +0200
Connect to ProjectManager signals from the main window.
---
pitivi/formatters/base.py | 4 ++--
pitivi/formatters/etree.py | 9 ++++++---
pitivi/projectmanager.py | 3 ---
pitivi/ui/mainwindow.py | 43 ++++++++++++++++++++++---------------------
4 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/pitivi/formatters/base.py b/pitivi/formatters/base.py
index f49c134..74016b0 100644
--- a/pitivi/formatters/base.py
+++ b/pitivi/formatters/base.py
@@ -327,7 +327,7 @@ class Formatter(Signallable, Loggable):
self.debug("uri:%s", uri)
if not uri_is_valid(uri):
self.warning("invalid URI")
- return None
+ raise FormatterError("invalid URI")
# skip non local uri
if not uri.split('://', 1)[0] in ["file"]:
@@ -360,7 +360,7 @@ class Formatter(Signallable, Loggable):
return probable
# Houston, we have lost contact with mission://fail
- return None
+ raise FormatterError("Couldn't find %s" % uri)
#}
diff --git a/pitivi/formatters/etree.py b/pitivi/formatters/etree.py
index ad443b9..b7db18f 100644
--- a/pitivi/formatters/etree.py
+++ b/pitivi/formatters/etree.py
@@ -171,8 +171,6 @@ class ElementTreeFormatter(Formatter):
if isinstance(filename, unicode):
filename = filename.encode("utf-8")
filename = self.validateSourceURI(filename)
- if filename is None:
- return None
if filename is not None:
factory = klass(filename)
@@ -555,7 +553,12 @@ class ElementTreeFormatter(Formatter):
# rediscover the factories
closure = {"rediscovered": 0}
- sources = self._loadSources()
+ try:
+ sources = self._loadSources()
+ except FormatterError, e:
+ self.emit("new-project-failed", location, e)
+ return
+
uris = [source.uri for source in sources]
discoverer = project.sources.discoverer
discoverer.connect("discovery-done", self._discovererDiscoveryDoneCb,
diff --git a/pitivi/projectmanager.py b/pitivi/projectmanager.py
index 139ca40..8f67486 100644
--- a/pitivi/projectmanager.py
+++ b/pitivi/projectmanager.py
@@ -136,9 +136,6 @@ class ProjectManager(Signallable, Loggable):
def _formatterNewProjectFailed(self, formatter, uri, exception):
self._disconnectFromFormatter(formatter)
-
- self.handleException(exception)
- self.warning("error loading the project")
self.current = None
self.emit("new-project-failed", uri, exception)
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 469b1b9..4a11cf7 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -26,6 +26,7 @@ Main GTK+ window
import os
import gtk
import gobject
+gobject.threads_init()
import gst
import gst.pbutils
from urllib import unquote
@@ -166,6 +167,19 @@ class PitiviMainWindow(gtk.Window, Loggable):
self._createUi(instance)
self.app = instance
+ self.app.projectManager.connect("new-project-loading",
+ self._projectManagerNewProjectLoadingCb)
+ self.app.projectManager.connect("new-project-loaded",
+ self._projectManagerNewProjectLoadedCb)
+ self.app.projectManager.connect("new-project-failed",
+ self._projectManagerNewProjectFailedCb)
+ self.app.projectManager.connect("closing-project",
+ self._projectManagerClosingProjectCb)
+ self.app.projectManager.connect("project-closed",
+ self._projectManagerProjectClosedCb)
+ self.app.projectManager.connect("missing-uri",
+ self._projectManagerMissingUriCb)
+
# if no webcams available, hide the webcam action
self.app.deviceprobe.connect("device-added", self._deviceChangeCb)
self.app.deviceprobe.connect("device-removed", self._deviceChangeCb)
@@ -627,29 +641,19 @@ class PitiviMainWindow(gtk.Window, Loggable):
def loop(self, unused_action):
pass
-## PiTiVi main object callbacks
-
- def _setApplication(self):
- if self.app:
- self.project = self.app.current
-
- app = receiver(_setApplication)
-
- @handler(app, "new-project-loaded")
- def _newProjectLoadedCb(self, unused_pitivi, project):
+
+ def _projectManagerNewProjectLoadedCb(self, projectManager, project):
self.log("A NEW project is loaded, update the UI!")
self.project = project
# ungrey UI
self.set_sensitive(True)
- @handler(app, "new-project-loading")
- def _newProjectLoadingCb(self, unused_instance, project):
+ def _projectManagerNewProjectLoadingCb(self, projectManager, uri):
self.log("A NEW project is being loaded, deactivate UI")
# grey UI
self.set_sensitive(False)
- @handler(app, "closing-project")
- def _closingProjectCb(self, unused_pitivi, project):
+ def _projectManagerClosingProjectCb(self, projectManager, project):
if not project.hasUnsavedModifications():
return True
@@ -665,15 +669,13 @@ class PitiviMainWindow(gtk.Window, Loggable):
return True
return False
- @handler(app, "project-closed")
- def _projectClosedCb(self, unused_pitivi, project):
+ def _projectManagerProjectClosedCb(self, projectManager, project):
# we must disconnect from the project pipeline before it is released
self.viewer.setAction(None)
self.viewer.setPipeline(None)
return False
- @handler(app, "new-project-failed")
- def _notProjectCb(self, unused_pitivi, uri, exception):
+ def _projectManagerNewProjectFailedCb(self, projectManager, uri, exception):
# ungrey UI
dialog = gtk.MessageDialog(self,
gtk.DIALOG_MODAL,
@@ -687,9 +689,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
dialog.destroy()
self.set_sensitive(True)
- @handler(app, "missing-uri")
- def _missingUriCb(self, instance, formatter, uri):
- dialog = gtk.Dialog(_("Locate missing file..."),
+ def _projectManagerMissingUriCb(self, instance, formatter, uri):
+ dialog = gtk.Dialog(_("Locate missing file..."),
self,
gtk.DIALOG_MODAL,
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]