~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to pitivi/pitivi.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-02-04 14:42:30 UTC
  • Revision ID: james.westby@ubuntu.com-20060204144230-9ihvyas6lhgn81k1
Tags: upstream-0.9.9.2
ImportĀ upstreamĀ versionĀ 0.9.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# PiTiVi , Non-linear video editor
 
2
#
 
3
#       pitivi/pitivi.py
 
4
#
 
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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.
 
21
 
 
22
import gobject
 
23
import gtk
 
24
import gst
 
25
import sys
 
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
 
31
 
 
32
class Pitivi(gobject.GObject):
 
33
    """
 
34
    Pitivi's main class
 
35
 
 
36
    Signals:
 
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
 
41
 
 
42
    """
 
43
    __gsignals__ = {
 
44
        "new-project" : ( gobject.SIGNAL_RUN_LAST,
 
45
                          gobject.TYPE_NONE,
 
46
                          (gobject.TYPE_PYOBJECT, )),
 
47
        "closing-project" : ( gobject.SIGNAL_RUN_LAST,
 
48
                              gobject.TYPE_BOOLEAN,
 
49
                              (gobject.TYPE_PYOBJECT, )),
 
50
        "not-project" : ( gobject.SIGNAL_RUN_LAST,
 
51
                          gobject.TYPE_NONE,
 
52
                          (gobject.TYPE_STRING, ))
 
53
        }
 
54
 
 
55
    project = None
 
56
 
 
57
    def __init__(self, *args):
 
58
        """
 
59
        initialize pitivi with the command line arguments
 
60
        """
 
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)
 
67
        
 
68
        # we're starting a GUI for the time being
 
69
        self.gui = mainwindow.PitiviMainWindow(self)
 
70
        self.gui.show()
 
71
 
 
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", "")
 
77
            return
 
78
        if filepath:
 
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)
 
83
            return
 
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)
 
88
 
 
89
    def _close_running_project(self):
 
90
        """ close the current project """
 
91
        gst.info("closing running project")
 
92
        if self.current:
 
93
            if not self.emit("closing-project", self.current):
 
94
                return False
 
95
            self.playground.pause()
 
96
            self.current = None
 
97
        return True
 
98
        
 
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)
 
106
        
 
107
def main(argv):
 
108
    ptv = Pitivi(argv)
 
109
    gtk.main()