mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
examples/remuxer.py (PlayerWindow.update_scale_cb): Fix a race condition getting the initial cutin time via inserting...
Original commit message from CVS: 2006-05-05 Andy Wingo <wingo@pobox.com> * examples/remuxer.py (PlayerWindow.update_scale_cb): Fix a race condition getting the initial cutin time via inserting whitespace. (all over): UI fixes to make Mike happy.
This commit is contained in:
parent
bf5fe2593e
commit
3aab962a4c
2 changed files with 56 additions and 44 deletions
|
@ -1,8 +1,12 @@
|
||||||
2006-05-05 Andy Wingo <wingo@pobox.com>
|
2006-05-05 Andy Wingo <wingo@pobox.com>
|
||||||
|
|
||||||
|
* examples/remuxer.py (PlayerWindow.update_scale_cb): Fix a race
|
||||||
|
condition getting the initial cutin time via inserting whitespace.
|
||||||
|
(all over): UI fixes to make Mike happy.
|
||||||
|
|
||||||
* examples/remuxer.py: Updates! Nothing gstreamery, it's all ui,
|
* examples/remuxer.py: Updates! Nothing gstreamery, it's all ui,
|
||||||
so I won't bother you with the details.
|
so I won't bother you with the details.
|
||||||
|
|
||||||
2006-04-29 Edward Hervey <edward@fluendo.com>
|
2006-04-29 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* examples/gstfile.py:
|
* examples/gstfile.py:
|
||||||
|
|
|
@ -263,9 +263,9 @@ class ProgressDialog(gtk.Dialog):
|
||||||
vbox.pack_start(progress, False)
|
vbox.pack_start(progress, False)
|
||||||
|
|
||||||
self.progresstext = label = gtk.Label('')
|
self.progresstext = label = gtk.Label('')
|
||||||
|
label.set_line_wrap(True)
|
||||||
label.set_use_markup(True)
|
label.set_use_markup(True)
|
||||||
label.set_alignment(0.0, 0.0)
|
label.set_alignment(0.0, 0.0)
|
||||||
label.set_selectable(True)
|
|
||||||
label.show()
|
label.show()
|
||||||
vbox.pack_start(label)
|
vbox.pack_start(label)
|
||||||
self.set_task(task)
|
self.set_task(task)
|
||||||
|
@ -350,52 +350,53 @@ class Remuxer(gst.Pipeline):
|
||||||
assert stop > start
|
assert stop > start
|
||||||
|
|
||||||
self.fromuri = fromuri
|
self.fromuri = fromuri
|
||||||
self.touri = touri
|
self.touri = None
|
||||||
|
self.start_time = start
|
||||||
|
self.stop_time = stop
|
||||||
|
|
||||||
self.src = gst.element_make_from_uri(gst.URI_SRC, fromuri)
|
self.src = self.remuxbin = self.sink = None
|
||||||
self.remuxbin = RemuxBin(start, stop)
|
self.resolution = UNKNOWN
|
||||||
self.sink = gst.element_make_from_uri(gst.URI_SINK, touri)
|
|
||||||
|
self.window = None
|
||||||
|
self.pdialog = None
|
||||||
|
|
||||||
|
self._query_id = -1
|
||||||
|
|
||||||
|
def do_setup_pipeline(self):
|
||||||
|
self.src = gst.element_make_from_uri(gst.URI_SRC, self.fromuri)
|
||||||
|
self.remuxbin = RemuxBin(self.start_time, self.stop_time)
|
||||||
|
self.sink = gst.element_make_from_uri(gst.URI_SINK, self.touri)
|
||||||
self.resolution = UNKNOWN
|
self.resolution = UNKNOWN
|
||||||
|
|
||||||
if gobject.signal_lookup('allow-overwrite', self.sink.__class__):
|
if gobject.signal_lookup('allow-overwrite', self.sink.__class__):
|
||||||
self.sink.connect('allow-overwrite', self._allow_overwrite)
|
self.sink.connect('allow-overwrite', lambda *x: True)
|
||||||
|
|
||||||
self.add(self.src, self.remuxbin, self.sink)
|
self.add(self.src, self.remuxbin, self.sink)
|
||||||
|
|
||||||
self.src.link(self.remuxbin)
|
self.src.link(self.remuxbin)
|
||||||
self.remuxbin.link(self.sink)
|
self.remuxbin.link(self.sink)
|
||||||
|
|
||||||
self.window = None
|
def do_get_touri(self):
|
||||||
self.pdialog = None
|
chooser = gtk.FileChooserDialog('Save as...',
|
||||||
|
self.window,
|
||||||
|
action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
buttons=(gtk.STOCK_CANCEL,
|
||||||
|
CANCELLED,
|
||||||
|
gtk.STOCK_SAVE,
|
||||||
|
SUCCESS))
|
||||||
|
chooser.set_uri(self.fromuri) # to select the folder
|
||||||
|
chooser.unselect_all()
|
||||||
|
chooser.set_do_overwrite_confirmation(True)
|
||||||
|
name = self.fromuri.split('/')[-1][:-4] + '-remuxed.ogg'
|
||||||
|
chooser.set_current_name(name)
|
||||||
|
resp = chooser.run()
|
||||||
|
uri = chooser.get_uri()
|
||||||
|
chooser.destroy()
|
||||||
|
|
||||||
self.start_time = start
|
if resp == SUCCESS:
|
||||||
self.stop_time = stop
|
return uri
|
||||||
|
else:
|
||||||
self._query_id = -1
|
return None
|
||||||
|
|
||||||
def _allow_overwrite(self, sink, uri):
|
|
||||||
name = self.sink.get_uri()
|
|
||||||
name = (gst.uri_has_protocol(name, 'file')
|
|
||||||
and gst.uri_get_location(name)
|
|
||||||
or name)
|
|
||||||
m = gtk.MessageDialog(self.window,
|
|
||||||
gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
gtk.MESSAGE_QUESTION,
|
|
||||||
gtk.BUTTONS_NONE,
|
|
||||||
("The file %s already exists. Would you "
|
|
||||||
"like to replace it?") % name)
|
|
||||||
b = gtk.Button(stock=gtk.STOCK_CANCEL)
|
|
||||||
b.show()
|
|
||||||
m.add_action_widget(b, CANCELLED)
|
|
||||||
b = gtk.Button('Replace')
|
|
||||||
b.show()
|
|
||||||
m.add_action_widget(b, SUCCESS)
|
|
||||||
txt = ('If you replace an existing file, its contents will be '
|
|
||||||
'overwritten.')
|
|
||||||
m.format_secondary_text(txt)
|
|
||||||
resp = m.run()
|
|
||||||
m.destroy()
|
|
||||||
return resp == SUCCESS
|
|
||||||
|
|
||||||
def _start_queries(self):
|
def _start_queries(self):
|
||||||
def do_query():
|
def do_query():
|
||||||
|
@ -470,10 +471,14 @@ class Remuxer(gst.Pipeline):
|
||||||
self.emit('done', response)
|
self.emit('done', response)
|
||||||
|
|
||||||
def start(self, main_window):
|
def start(self, main_window):
|
||||||
|
self.window = main_window
|
||||||
|
self.touri = self.do_get_touri()
|
||||||
|
if not self.touri:
|
||||||
|
return False
|
||||||
|
self.do_setup_pipeline()
|
||||||
bus = self.get_bus()
|
bus = self.get_bus()
|
||||||
bus.add_signal_watch()
|
bus.add_signal_watch()
|
||||||
bus.connect('message', self._bus_watch)
|
bus.connect('message', self._bus_watch)
|
||||||
self.window = main_window
|
|
||||||
if self.window:
|
if self.window:
|
||||||
# can be None if we are debugging...
|
# can be None if we are debugging...
|
||||||
self.window.set_sensitive(False)
|
self.window.set_sensitive(False)
|
||||||
|
@ -485,12 +490,15 @@ class Remuxer(gst.Pipeline):
|
||||||
self.pdialog.connect('response', lambda w, r: self.response(r))
|
self.pdialog.connect('response', lambda w, r: self.response(r))
|
||||||
|
|
||||||
self.set_state(gst.STATE_PAUSED)
|
self.set_state(gst.STATE_PAUSED)
|
||||||
|
return True
|
||||||
|
|
||||||
def run(self, main_window):
|
def run(self, main_window):
|
||||||
self.start(main_window)
|
if self.start(main_window):
|
||||||
loop = gobject.MainLoop()
|
loop = gobject.MainLoop()
|
||||||
self.connect('done', lambda *x: gobject.idle_add(loop.quit))
|
self.connect('done', lambda *x: gobject.idle_add(loop.quit))
|
||||||
loop.run()
|
loop.run()
|
||||||
|
else:
|
||||||
|
self.resolution = CANCELLED
|
||||||
return self.resolution
|
return self.resolution
|
||||||
|
|
||||||
class RemuxBin(gst.Bin):
|
class RemuxBin(gst.Bin):
|
||||||
|
@ -797,8 +805,8 @@ class PlayerWindow(gtk.Window):
|
||||||
if self.p_position != gst.CLOCK_TIME_NONE:
|
if self.p_position != gst.CLOCK_TIME_NONE:
|
||||||
value = self.p_position * 100.0 / self.p_duration
|
value = self.p_position * 100.0 / self.p_duration
|
||||||
self.adjustment.set_value(value)
|
self.adjustment.set_value(value)
|
||||||
if not had_duration:
|
if not had_duration:
|
||||||
self.cutin.set_time(0)
|
self.cutin.set_time(0)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
|
Loading…
Reference in a new issue