1
# PiTiVi , Non-linear video editor
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU Lesser General Public
9
# License as published by the Free Software Foundation; either
10
# version 2.1 of the License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public
18
# License along with this program; if not, write to the
19
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
# Boston, MA 02111-1307, USA.
26
from ui import mainwindow
27
from discoverer import Discoverer
28
from playground import PlayGround
29
from project import Project, file_is_project
30
from effects import Magician
32
class Pitivi(gobject.GObject):
37
new-project : A new project has been loaded, the Project object is given
38
closing-project : Pitivi wishes to close the project, callbacks return False
39
if they don't want the project to be closed, True otherwise
40
not-project : The given uri is not a project file
44
"new-project" : ( gobject.SIGNAL_RUN_LAST,
46
(gobject.TYPE_PYOBJECT, )),
47
"closing-project" : ( gobject.SIGNAL_RUN_LAST,
49
(gobject.TYPE_PYOBJECT, )),
50
"not-project" : ( gobject.SIGNAL_RUN_LAST,
52
(gobject.TYPE_STRING, ))
57
def __init__(self, *args):
59
initialize pitivi with the command line arguments
61
gst.info("starting up pitivi...")
62
gobject.GObject.__init__(self)
63
# TODO parse cmd line arguments
64
self.playground = PlayGround()
65
self.current = Project("New Project")
66
self.effects = Magician(self)
68
# we're starting a GUI for the time being
69
self.gui = mainwindow.PitiviMainWindow(self)
72
def load_project(self, uri=None, filepath=None):
73
""" Load the given file through it's uri or filepath """
74
gst.info("uri:%s, filepath:%s" % (uri, filepath))
75
if not uri and not filepath:
76
self.emit("not-project", "")
79
uri = "file://" + filepath
80
# is the given filepath a valid pitivi project
81
if not file_is_project(uri):
82
self.emit("not-project", uri)
84
# if current project, try to close it
85
if self._close_running_project():
86
self.current = Project(uri)
87
self.emit("new-project", self.current)
89
def _close_running_project(self):
90
""" close the current project """
91
gst.info("closing running project")
93
if not self.emit("closing-project", self.current):
95
self.playground.pause()
99
def new_blank_project(self):
100
""" start up a new blank project """
101
# if there's a running project we must close it
102
if self._close_running_project():
103
self.playground.pause()
104
self.current = Project("New Project")
105
self.emit("new-project", self.current)