pitivi r1281 - in trunk/pitivi: . ui



Author: edwardrv
Date: Fri Sep 26 17:15:44 2008
New Revision: 1281
URL: http://svn.gnome.org/viewvc/pitivi?rev=1281&view=rev

Log:
more basic cleanups

Modified:
   trunk/pitivi/bin.py
   trunk/pitivi/ui/netstream_managerdialog.py
   trunk/pitivi/ui/pluginmanagerdialog.py
   trunk/pitivi/ui/screencast_managerdialog.py
   trunk/pitivi/ui/webcam_managerdialog.py

Modified: trunk/pitivi/bin.py
==============================================================================
--- trunk/pitivi/bin.py	(original)
+++ trunk/pitivi/bin.py	Fri Sep 26 17:15:44 2008
@@ -26,13 +26,8 @@
 import gobject
 import gst
 from elements.smartscale import SmartVideoScale
-from objectfactory import FileSourceFactory
-from signalgroup import SignalGroup
 from ui import plumber
-import instance
-from sourcelist import SourceList
 from threads import CallbackThread
-import time
 
 class SmartBin(gst.Pipeline):
     """
@@ -93,7 +88,7 @@
         Returns False if there was a problem.
         """
         self.debug("asinkthread : %r" % asinkthread)
-        res, state, pending = self.get_state(0)
+        state  = self.get_state(0)[1]
         if state == gst.STATE_PLAYING:
             self.warning("is in PAUSED or higher : %s" % state)
             return False
@@ -112,7 +107,7 @@
         Returns False if there was a problem.
         """
         self.debug("vsinkthread : %r" % vsinkthread)
-        res , state , pending = self.get_state(0)
+        state = self.get_state(0)[1]
         if state == gst.STATE_PLAYING:
             self.warning("is in PAUSED or higher : %s" % state)
             return False
@@ -131,7 +126,7 @@
         Returns False if there was a problem.
         """
         self.debug("asinkthread : %r" % self.asinkthread)
-        result, state, pending = self.get_state(0)
+        state = self.get_state(0)[1]
         if state in [gst.STATE_PAUSED, gst.STATE_PLAYING]:
             self.warning("is in PAUSED, not removing audiosink")
             return False
@@ -150,7 +145,7 @@
         Returns False if there was a problem.
         """
         self.debug("vsinkthread : %r" % self.vsinkthread)
-        result, state, pending = self.get_state(0)
+        state = self.get_state(0)[1]
         if state in [gst.STATE_PAUSED, gst.STATE_PLAYING]:
             self.warning("is in PAUSED or higher : %s" % state)
             return False
@@ -532,13 +527,13 @@
         cspace = gst.element_factory_make('ffmpegcolorspace')
         vscale = gst.element_factory_make('videoscale')
         vscale.props.method = 1
-        self.vsinkthread.add(self.videosink,timeoverlay, vqueue, vscale, cspace)
+        self.vsinkthread.add(self.videosink, timeoverlay, vqueue, vscale, cspace)
         vqueue.link(timeoverlay)
         timeoverlay.link(self.videosink)
-        timeoverlay.set_property("halign","right")
-        timeoverlay.set_property("valign","bottom")
-        timeoverlay.set_property("deltax",65)
-        timeoverlay.set_property("deltay",20)
+        timeoverlay.set_property("halign", "right")
+        timeoverlay.set_property("valign", "bottom")
+        timeoverlay.set_property("deltax", 65)
+        timeoverlay.set_property("deltay", 20)
 
 
         cspace.link(vscale)
@@ -557,7 +552,7 @@
         self.asinkthread.audiosink = self.audiosink
         self.asinkthread.add_pad(gst.GhostPad("sink", aconv.get_pad('sink')))
 
-    def connectSink(self,player,is_video,is_audio):
+    def connectSink(self, player, is_video, is_audio):
         if is_video is True :
             player.setVideoSinkThread(self.vsinkthread)
         if is_audio is True :
@@ -590,12 +585,12 @@
         self.q2.props.max_size_time = 30 * gst.SECOND
         self.q2.props.max_size_buffers = 0
         self.q2.props.max_size_bytes = 0
-        self.add(self.videosrc,self.audiosrc,self.q1,self.q2)
+        self.add(self.videosrc, self.audiosrc, self.q1, self.q2)
 
     def _connectSource(self):
         self.debug("connecting sources")
-        gst.element_link_many(self.videosrc,self.q1,self.vtee)
-        gst.element_link_many(self.audiosrc,self.q2,self.atee)
+        gst.element_link_many(self.videosrc, self.q1, self.vtee)
+        gst.element_link_many(self.audiosrc, self.q2, self.atee)
         self.debug("finished connecting sources")
 
     def _asyncReset(self, uri, setting):
@@ -637,7 +632,7 @@
     A Pipeline which return audio/video info about the uri stream
     """
 
-    def __init__(self,uri):
+    def __init__(self, uri):
         self.is_audio = False
         self.is_video = True
 
@@ -656,7 +651,7 @@
 
     def info(self):
         CallbackThread(self.kill).start()
-        return (self.is_video,self.is_audio)
+        return (self.is_video, self.is_audio)
 
     def _new_decoded_pad_cb(self, dbin, pad, is_last):
 
@@ -672,9 +667,9 @@
     SmartBin derivative for capturing streams.
     """
 
-    def __init__(self,uri):
+    def __init__(self, uri):
         gst.log("Creating new smartcapturebin")
-        (self.is_video,self.is_audio) = (True,True)
+        (self.is_video, self.is_audio) = (True, True)
         self.uri = uri
         SmartBin.__init__(self, "smartcapturebin", has_video=self.is_video,
                           has_audio=self.is_audio,
@@ -684,19 +679,19 @@
     def _addSource(self):
         self.urisrc = gst.element_make_from_uri(gst.URI_SRC,
                                                 self.uri)
-        self.decodebin = gst.element_factory_make("decodebin","decode-smartbin")
-        self.videoq = gst.element_factory_make("queue","video-queue")
-        self.audioq = gst.element_factory_make("queue","audio-queue")
+        self.decodebin = gst.element_factory_make("decodebin", "decode-smartbin")
+        self.videoq = gst.element_factory_make("queue", "video-queue")
+        self.audioq = gst.element_factory_make("queue", "audio-queue")
 
-        self.add(self.urisrc,self.decodebin,self.videoq,self.audioq)
+        self.add(self.urisrc, self.decodebin, self.videoq, self.audioq)
 
     def _connectSource(self):
         self.debug("connecting sources")
-        gst.element_link_many(self.urisrc,self.decodebin)
+        gst.element_link_many(self.urisrc, self.decodebin)
         if self.is_video :
-            gst.element_link_many(self.videoq,self.vtee)
+            gst.element_link_many(self.videoq, self.vtee)
         if self.is_audio:
-            gst.element_link_many(self.audioq,self.atee)
+            gst.element_link_many(self.audioq, self.atee)
 
 
         self.decodebin.connect("new-decoded-pad",

Modified: trunk/pitivi/ui/netstream_managerdialog.py
==============================================================================
--- trunk/pitivi/ui/netstream_managerdialog.py	(original)
+++ trunk/pitivi/ui/netstream_managerdialog.py	Fri Sep 26 17:15:44 2008
@@ -22,16 +22,9 @@
 import os
 import gtk
 import gtk.glade
-import pango
-import gobject
-import time
 import gst
 import tempfile
-from gettext import gettext as _
-from pitivi import instance
 from sourcefactories import SourceFactoriesWidget
-from pitivi.sourcelist import SourceList
-from pitivi.objectfactory import FileSourceFactory
 from pitivi.bin import SmartStreamBin, SinkBin
 from pitivi.settings import ExportSettings
 
@@ -58,18 +51,20 @@
         self.udp_radiobtn = self.objectpool_ui.get_widget("udp")
         self.rtsp_radiobtn = self.objectpool_ui.get_widget("rtsp")
 
-        self.http_radiobtn.connect("toggled",self.on_protocol_toggled,"http")
-        self.udp_radiobtn.connect("toggled",self.on_protocol_toggled,"udp")
-        self.rtsp_radiobtn.connect("toggled",self.on_protocol_toggled,"rtsp")
-        self.address.connect("changed",self.on_address_port_changed,"address")
-        self.port.connect("changed",self.on_address_port_changed,"port")
+        self.http_radiobtn.connect("toggled", self.on_protocol_toggled, "http")
+        self.udp_radiobtn.connect("toggled", self.on_protocol_toggled, "udp")
+        self.rtsp_radiobtn.connect("toggled", self.on_protocol_toggled, "rtsp")
+        self.address.connect("changed", self.on_address_port_changed, "address")
+        self.port.connect("changed", self.on_address_port_changed, "port")
 
 
-        self.close_btn.connect("clicked",self.close)
-        self.stream_window.connect("destroy",self.close)
+        self.close_btn.connect("clicked", self.close)
+        self.stream_window.connect("destroy", self.close)
 
 
-        dic = { "on_close_clicked" : self.close, "on_preview_btn_clicked":self.live_pipeline,"on_capture_btn_clicked":self.capture_pipeline}
+        dic = { "on_close_clicked" : self.close,
+                "on_preview_btn_clicked" : self.live_pipeline,
+                "on_capture_btn_clicked" : self.capture_pipeline }
 
         self.objectpool_ui.signal_autoconnect(dic)
 
@@ -81,11 +76,11 @@
 
 
     # For Setting up audio,video sinks
-    def setSinks(self,uri):
+    def setSinks(self, uri):
         gst.debug("SmartStreamBin player created")
-        self.player=SmartStreamBin(uri)
+        self.player = SmartStreamBin(uri)
         sink = SinkBin()
-        sink.connectSink(self.player,self.player.is_video,self.player.is_audio)
+        sink.connectSink(self.player, self.player.is_video, self.player.is_audio)
         self.player.set_state(gst.STATE_PLAYING)
 
 
@@ -96,7 +91,7 @@
 
 
     # Create live display pipeline
-    def live_pipeline(self,w=None):
+    def live_pipeline(self, w=None):
 
         if self.player:
             self.player.set_state(gst.STATE_NULL)
@@ -109,10 +104,11 @@
                 self.status.set_label("Invalid URI. Please verify.")
                 gst.debug("Invalid URI")
                 return 
-            if gst.uri_protocol_is_supported(gst.URI_SRC,uri.split('://')[0]):
+            if gst.uri_protocol_is_supported(gst.URI_SRC,
+                                             uri.split('://')[0]):
                 self.setSinks(uri)
                 self.player.set_state(gst.STATE_PLAYING)
-                self.status.push(self.status_id,"")
+                self.status.push(self.status_id, "")
             else:
                 self.status.set_label("Unsupported Protocol. Please verify the URI.")
                 gst.debug("Unsupported Protocol")
@@ -120,11 +116,11 @@
 
 
     # Stream capture pipeline
-    def capture_pipeline(self,w=None):
+    def capture_pipeline(self, w=None):
 
         uri = self.uri.get_text()
         if self.capture_btn.get_label() == "Capture":
-            if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC,uri.split('://')[0]) is False :
+            if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC, uri.split('://')[0]) is False :
                 self.status.set_label("Unsupported Protocol. Please verify the URI.")
                 return
             elif self.player is False:
@@ -134,7 +130,7 @@
 
             gst.debug("recording started")
             self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
-            self.player.record(self.filepath,ExportSettings())
+            self.player.record(self.filepath, ExportSettings())
             self.capture_btn.set_label("Stop")
 
 
@@ -144,7 +140,7 @@
             self.sourcefactories.sourcelist.addFiles([self.filepath])
             self.capture_btn.set_label("Capture")
 
-    def on_message(self,bus,message):
+    def on_message(self, bus, message):
         t = message.type
         if t == gst.MESSAGE_EOS:
             if self.player:
@@ -152,32 +148,32 @@
             self.capture_btn.set_label("Capture")
 
         elif t == gst.MESSAGE_ERROR:
-            err,debug = message.parse_error()
-            print "Error: %s" %err, debug
+            err, debug = message.parse_error()
+            print "Error: %s" % err, debug
             if self.player:
                 self.player.set_state(gst.STATE_NULL)
             self.capture_btn.set_label("Capture")
 
 
-    def on_sync_message(self,bus,message):
+    def on_sync_message(self, bus, message):
         if message.structure is None :
             return
         message_name = message.structure.get_name()
         if message_name == 'prepare-xwindow-id':
             imagesink = message.src
-            imagesink.set_property('force-aspect-ratio',True)
+            imagesink.set_property('force-aspect-ratio', True)
             imagesink.set_xwindow_id(self.screen.window.xid)
 
     # radio buttons address set callback
-    def on_protocol_toggled(self,widget,data=None):
+    def on_protocol_toggled(self, widget, data=None):
         self.uri.set_text(data+"://"+self.uri.get_text().split('://')[1])
 
-    def on_address_port_changed(self,widget,data=None):
-        self.uri.set_text(self.uri.get_text().split('://')[0] + '://' + self.address.get_text() + ['',':'][self.port.get_text().isdigit()] + self.port.get_text())
+    def on_address_port_changed(self, widget, data=None):
+        self.uri.set_text(self.uri.get_text().split('://')[0] + '://' + self.address.get_text() + ['', ':'][self.port.get_text().isdigit()] + self.port.get_text())
 
 
 
-    def close(self,w):
+    def close(self, w):
         self.stream_window.destroy()
         if self.player:
             self.player.set_state(gst.STATE_NULL)

Modified: trunk/pitivi/ui/pluginmanagerdialog.py
==============================================================================
--- trunk/pitivi/ui/pluginmanagerdialog.py	(original)
+++ trunk/pitivi/ui/pluginmanagerdialog.py	Fri Sep 26 17:15:44 2008
@@ -67,7 +67,7 @@
     def _initialize_plugin_tree(self, tree):
         """ Perform treeview initialization """
 
-        self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, 
+        self.model = gtk.ListStore(gobject.TYPE_BOOLEAN,
                                     gobject.TYPE_STRING,
                                     gobject.TYPE_STRING,
                                     object)
@@ -77,7 +77,7 @@
         tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
 
         # Enable Drag&Drop
-        tree.enable_model_drag_dest([("text/uri-list", 0, 1)],\
+        tree.enable_model_drag_dest([("text/uri-list", 0, 1)], \
                                     gtk.gdk.ACTION_DEFAULT)
         tree.connect("drag-data-received", self.drag_data_received_cb)
 
@@ -252,7 +252,7 @@
 
         for plugin in self._get_selected_plugins():
             dialog = gtk.AboutDialog()
-            dialog.connect("response", lambda x,y: dialog.destroy())
+            dialog.connect("response", lambda x, y: dialog.destroy())
             dialog.set_name(plugin.name)
             dialog.set_version(plugin.version)
             dialog.set_authors(plugin.authors.split(","))

Modified: trunk/pitivi/ui/screencast_managerdialog.py
==============================================================================
--- trunk/pitivi/ui/screencast_managerdialog.py	(original)
+++ trunk/pitivi/ui/screencast_managerdialog.py	Fri Sep 26 17:15:44 2008
@@ -24,15 +24,9 @@
 import gtk.glade
 from pitivi import instance
 import gst
-import tempfile
-from gettext import gettext as _
-import plumber
-from pitivi.settings import ExportSettings
-from sourcefactories import SourceFactoriesWidget
 import dbus
 import dbus.service
 import dbus.glib
-import gobject
 import thread
 import time
 

Modified: trunk/pitivi/ui/webcam_managerdialog.py
==============================================================================
--- trunk/pitivi/ui/webcam_managerdialog.py	(original)
+++ trunk/pitivi/ui/webcam_managerdialog.py	Fri Sep 26 17:15:44 2008
@@ -22,15 +22,12 @@
 import gtk
 import os
 import gtk.glade
-from pitivi import instance
 import gst
 import tempfile
-from gettext import gettext as _
 from pitivi.settings import ExportSettings
 from sourcefactories import SourceFactoriesWidget
-from pitivi.bin import SmartCaptureBin,SinkBin
+from pitivi.bin import SmartCaptureBin, SinkBin
 from pitivi.threads import CallbackThread
-from pitivi.playground import PlayGround
 
 
 class WebcamManagerDialog(object):
@@ -46,9 +43,9 @@
         self.record_btn = self.cam_ui.get_widget("record_btn")
         self.close_btn = self.cam_ui.get_widget("close_btn")
 
-        self.close_btn.connect("clicked",self.close)
+        self.close_btn.connect("clicked", self.close)
         self.record_btn.connect("clicked", self.threaded_recording)
-        self.cam_window.connect("destroy",self.close)
+        self.cam_window.connect("destroy", self.close)
 
         self.record_btn = self.record_btn.get_children()[0]
         self.record_btn = self.record_btn.get_children()[0].get_children()[1]
@@ -60,13 +57,14 @@
         self.player = SmartCaptureBin()
         self.setSinks()
 
+        self.filepath = None
 
-
+        # Not a good idea to do this at this point
         self.player.set_state(gst.STATE_PLAYING)
 
     # Perform record in a seperate thread
-    def threaded_recording(self,w):
-        CallbackThread(self.do_recording,w).start()
+    def threaded_recording(self, w):
+        CallbackThread(self.do_recording, w).start()
 
 
     # Record button action callback
@@ -74,7 +72,7 @@
         if self.record_btn.get_label() == "Start Recording":
             gst.debug("recording started")
             self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
-            self.player.record(self.filepath,ExportSettings())
+            self.player.record(self.filepath, ExportSettings())
             self.record_btn.set_label("Stop Recording")
             self.player.set_state(gst.STATE_PLAYING)
 
@@ -90,14 +88,14 @@
     # For Setting up audio,video sinks
     def setSinks(self):
         sink = SinkBin()
-        sink.connectSink(self.player,True,True)
+        sink.connectSink(self.player, True, True)
         bus = self.player.get_bus()
         bus.add_signal_watch()
         bus.enable_sync_message_emission()
         bus.connect('sync-message::element', self.on_sync_message)
 
     # Close the Webcamdialog
-    def close(self,w):
+    def close(self, w):
         self.cam_window.destroy()
         self.player.set_state(gst.STATE_NULL)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]