Index: pitivi/pitivi.py
===================================================================
--- pitivi/pitivi.py (Revision 1019)
+++ pitivi/pitivi.py (Arbeitskopie)
@@ -36,6 +36,8 @@
from threads import ThreadMaster
import instance
+import string
+
from gettext import gettext as _
class Pitivi(gobject.GObject):
@@ -98,7 +100,59 @@
# we're starting a GUI for the time being
self.gui = mainwindow.PitiviMainWindow()
self.gui.show()
+ for i in args:
+ if i == "-usetestsave":
+ # no checkings
+ print "########### ./testsave.cfg ###############"
+ for j in self.gui.actiongroup.list_actions():
+ if j.get_name() in [ "OpenProject", "SaveProject", "NewProject" ]:
+ j.set_sensitive(True)
+ def saveProject(self, uri=None, filepath=None):
+ """ Save the current project to the uri or filepath """
+ if 0 == 1: #this is more like a jungle
+ print "============= settings ======================="
+ for i in instance.PiTiVi.__dict__:
+ if i in ["gui", "effects" ]:
+ continue
+ print i, "=", instance.PiTiVi.__dict__[i]
+ if hasattr( instance.PiTiVi.__dict__[i], "__dict__" ):
+ for j in instance.PiTiVi.__dict__[i].__dict__:
+ print "\t", j, "=", instance.PiTiVi.__dict__[i].__dict__[j]
+ if hasattr( instance.PiTiVi.__dict__[i].__dict__[j], "__dict__" ):
+ for k in instance.PiTiVi.__dict__[i].__dict__[j].__dict__:
+ print "\t\t", k, "=", instance.PiTiVi.__dict__[i].__dict__[j].__dict__[k]
+
+ filepath = "./testsave.cfg"
+ gst.info("uri:%s, filepath:%s" %(uri, filepath))
+ if not uri and not filepath:
+ self.emit("not-project", "")
+ return
+ if filepath:
+ uri = "file://" + filepath
+ #if not file_is_project(uri):
+ #self.emit("not-project", uri)
+ #return
+ if self.current.settings:
+ for i in self.__dict__.keys():
+ print i, self.__dict__[i]
+ for i in self.current.__dict__.keys():
+ print i, self.current.__dict__[i]
+ filename = uri[7:]
+ file = open(filename, "w")
+ file.write( "#sources:#######################################\n")
+ for i in self.current.sources.sources.keys():
+ file.write( "source=%s\n" % ( i ) )
+ file.write( "#videosettings:#################################\n")
+ for i in [ "videopar", "videorate" ]:
+ file.write( "%s.denom=%s\n" % (i, self.current.settings.__dict__[i].__dict__['denom']) )
+ file.write( "%s.num=%s\n" % (i, self.current.settings.__dict__[i].__dict__['num']) )
+ file.write( "%s.type=%s\n" % (i, self.current.settings.__dict__[i].__dict__['type']) )
+ for i in ["aencoder","muxer", "vencoder", "audiorate", "audiochannels", "audiodepth", "videowidth", "videoheight"]:
+ file.write( "%s=%s\n" %(i, self.current.settings.__dict__[i]) )
+ file.close()
+ #print "---- end of save ---"
+
def loadProject(self, uri=None, filepath=None):
""" Load the given file through it's uri or filepath """
gst.info("uri:%s, filepath:%s" % (uri, filepath))
@@ -112,9 +166,41 @@
self.emit("not-project", uri)
return
# if current project, try to close it
- if self._closeRunningProject():
- self.current = Project(uri)
- self.emit("new-project", self.current)
+ #if self._closeRunningProject(): #why this closes more and cannot be used to start a new project?
+ if 1 == 1: #this is crap, because i still dont know the backgrounds, it works at program-startup only, from trial+error
+ #self.current = Project(name="testsave", uri=uri) #_("New Project")) #create a new project dont works like expected
+ #
+ # so this is using the old project, but resetting some values ...
+ #self.current = Project(_("New Project"))
+ self.newBlankProject()
+ self.current.name = "### usetestsave ###"
+ self.current.description = "a test, only a test, name and description is not saved\nand we use a hardcoded filename\ntestsave.cfg"
+ filename = uri[7:]
+ file = open(filename, "r")
+ lines = file.readlines()
+ file.close()
+ self.current.setSettings(self.current.getAutoSettings())
+ for line in (lines):
+ if line[0] == "#":
+ continue
+ key, value = string.split(line[:-1], "=", 2)
+ if key == "source":
+ self.current.sources.addUri(value)
+ continue
+ if key in [ "videopar.type", "videopar.denom", "videorate.type", "videorate.denom"]:
+ continue
+ if key in [ "muxer", "vencoder", "aencoder" ]:
+ self.current.settings.__dict__[key] = value
+ continue
+ if key[0:12] == "videopar.num":
+ self.current.settings.videopar = gst.Fraction( int(float(value)), 1 )
+ continue
+ if key[0:13] == "videorate.num":
+ self.current.settings.videorate = gst.Fraction( int(float(value)), 1 )
+ continue
+ self.current.settings.__dict__[key] = int(float(value)) #string.atoi(value)
+ #self.emit("settings-changed")
+ #print "--------- loaded"
def _closeRunningProject(self):
""" close the current project """
@@ -126,13 +212,17 @@
self.current = None
return True
- def newBlankProject(self):
+ def newBlankProject(self): #try to setup a blank project - test-dr
""" start up a new blank project """
# if there's a running project we must close it
- if self._closeRunningProject():
- self.playground.pause()
- self.current = Project(_("New Project"))
- self.emit("new-project", self.current)
+ #if self._closeRunningProject():
+ self.playground.pause()
+ #self.current = Project(_("NewBlankProject"))
+ self.emit("new-project", self.current) # the signal works partly
+ for i in self.current.sources.sources.keys():
+ print "remove source", i
+ self.current.sources.__delitem__(i)
+ # the Timeline needs to be reset too - how?
def shutdown(self):
""" close PiTiVi """
@@ -153,6 +243,6 @@
def main(argv):
check.initial_checks()
- ptv = Pitivi(argv)
+ ptv = Pitivi(*argv) #test-dr to read commandline args
ptv.connect('shutdown', shutdownCb)
gtk.main()
Index: pitivi/ui/mainwindow.py
===================================================================
--- pitivi/ui/mainwindow.py (Revision 1019)
+++ pitivi/ui/mainwindow.py (Arbeitskopie)
@@ -277,13 +277,15 @@
## Toolbar/Menu actions callback
def _newProjectMenuCb(self, unused_action):
- instance.PiTiVi.new_blank_project()
+ instance.PiTiVi.newBlankProject() #test-dr
def _openProjectCb(self, unused_action):
- raise NotImplementedError
+ #raise NotImplementedError
+ instance.PiTiVi.loadProject(filepath="./testsave.cfg")
def _saveProjectCb(self, unused_action):
- raise NotImplementedError
+ #raise NotImplementedError
+ instance.PiTiVi.saveProject(filepath="./testsave.cfg")
def _saveProjectAsCb(self, unused_action):
raise NotImplementedError
@@ -336,7 +338,8 @@
## PiTiVi main object callbacks
def _newProjectCb(self, pitivi, project):
- raise NotImplementedError
+ #raise NotImplementedError
+ print "missing newProjectCb"
def _closingProjectCb(self, pitivi, project):
# Return True if we accept the project being close
@@ -347,8 +350,9 @@
return True
def _notProjectCb(self, pitivi, uri):
- raise NotImplementedError
-
+ #raise NotImplementedError
+ print "missing check for notProjectCb"
+
class EncodingDialog(GladeWindow):
""" Encoding dialog box """
glade_file = "encodingdialog.glade"