[xiph-commits] r11693 - trunk/souffleur
daraku at svn.xiph.org
daraku at svn.xiph.org
Tue Jul 4 10:09:26 PDT 2006
Author: daraku
Date: 2006-07-04 10:09:19 -0700 (Tue, 04 Jul 2006)
New Revision: 11693
Modified:
trunk/souffleur/Souffleur.py
trunk/souffleur/Subtitles.py
trunk/souffleur/souffleur.glade
Log:
Save function now add new sub record if sub don't exist. Add delete function. Some GUI clean
Modified: trunk/souffleur/Souffleur.py
===================================================================
--- trunk/souffleur/Souffleur.py 2006-07-04 04:32:47 UTC (rev 11692)
+++ trunk/souffleur/Souffleur.py 2006-07-04 17:09:19 UTC (rev 11693)
@@ -82,7 +82,6 @@
"on_main_file_quit_activate": (gtk.main_quit), \
"on_main_file_open_activate": self.mainFileOpen, \
"on_TOOL_PLAY_clicked": self.playerPlay,\
- "on_TOOL_PAUSE_clicked": self.playerPause,\
"on_TOOL_STOP_clicked": self.playerStop,\
"on_MEDIA_ADJUSTMENT_button_press_event": self.buttonPressAdjustment,\
"on_MEDIA_ADJUSTMENT_button_release_event": self.buttonReleaseAdjustment,\
@@ -90,7 +89,8 @@
"on_VIDEO_OUT_PUT_expose_event": self.exposeEventVideoOut,\
"on_TOOL_START_clicked": self.cb_setSubStartTime,\
"on_TOOL_END_clicked": self.cb_setSubEndTime,\
- "on_TOOL_SAVE_clicked": self.cb_subChangeSave}
+ "on_TOOL_SAVE_clicked": self.cb_subChangeSave,\
+ "on_TOOL_DELETE_clicked": self.cb_subDel}
self.wTree.signal_autoconnect (dic)
self.windowFileOpen=None
@@ -115,16 +115,33 @@
self.labelMSec = self.wTree.get_widget("LABEL_MSEC")
self.subStartTime = self.wTree.get_widget("SUB_START_TIME")
self.subEndTime = self.wTree.get_widget("SUB_END_TIME")
+ self.playButton = self.wTree.get_widget("TOOL_PLAY")
return
#==============================================================================
+ def cb_subDel(self, widget):
+ if (self.Subtitle != None) and (self.curSub != -1):
+ self.Subtitle.subDel(self.curSub)
+#==============================================================================
def cb_subChangeSave(self, widget):
- if (self.curSub != -1) and (self.Subtitle != None):
- BUF = self.SubEdit.get_buffer()
- TEXT = BUF.get_text(BUF.get_start_iter(), BUF.get_end_iter())
- self.Subtitle.subs[int(self.curSub)].text = str(TEXT)
- self.Subtitle.subs[int(self.curSub)].start_time=self.subStartTime.get_value_as_int()
- self.Subtitle.subs[int(self.curSub)].end_time=self.subEndTime.get_value_as_int()
+ if (self.Subtitle != None):
+ if (self.curSub != -1):
+ BUF = self.SubEdit.get_buffer()
+ TEXT = BUF.get_text(BUF.get_start_iter(), BUF.get_end_iter())
+ self.Subtitle.subs[int(self.curSub)].text = str(TEXT)
+ self.Subtitle.subs[int(self.curSub)].start_time=self.subStartTime.get_value_as_int()
+ self.Subtitle.subs[int(self.curSub)].end_time=self.subEndTime.get_value_as_int()
+ else:
+ self.subAdd()
#==============================================================================
+ def subAdd(self):
+ ST = self.subStartTime.get_value()
+ ET = self.subEndTime.get_value()
+ BUF = self.SubEdit.get_buffer()
+ Text = BUF.get_text(BUF.get_start_iter(), BUF.get_end_iter())
+ if (( ST > 0 ) and ( ET > ST ) and ( Text != "" )):
+ self.Subtitle.subAdd(ST, ET, Text, None, 1)
+ self.curSub = ST
+#==============================================================================
def cb_setSubStartTime(self, widget):
self.subStartTime.set_value(self.p_position/1000000)
#==============================================================================
@@ -157,15 +174,13 @@
#==============================================================================
def playerStop(self, widget):
if self.player:
+ if self.player.is_playing():
+ self.play_toggled()
self.player.stop()
#==============================================================================
- def playerPause(self, widget):
- if self.player:
- self.player.pause()
-#==============================================================================
def playerPlay(self, widget):
if self.player:
- self.player.play()
+ self.play_toggled()
#==============================================================================
def mainFileOpen(self, widget):
if(self.windowFileOpen==None):
@@ -239,13 +254,14 @@
def play_toggled(self):
if self.player.is_playing():
self.player.pause()
- #self.button.set_label(gtk.STOCK_MEDIA_PLAY)
+ self.playButton.set_stock_id(gtk.STOCK_MEDIA_PLAY)
+ #self.playButton.set_icon_name(gtk.STOCK_MEDIA_PLAY)
else:
self.player.play()
if self.update_id == -1:
self.update_id = gobject.timeout_add(self.UPDATE_INTERVAL,
self.update_scale_cb)
- #self.button.set_label(gtk.STOCK_MEDIA_PAUSE)
+ self.playButton.set_stock_id(gtk.STOCK_MEDIA_PAUSE)
#==============================================================================
def update_scale_cb(self):
had_duration = self.p_duration != gst.CLOCK_TIME_NONE
@@ -256,7 +272,7 @@
Sec = tmSec%60
tmSec = tmSec/60
Min = tmSec%60
- Hour=tmSec/60
+ Hour = tmSec/60
if self.Subtitle:
TText = self.Subtitle.getSub(MSec)
if TText:
@@ -278,8 +294,6 @@
if (self.p_position != gst.CLOCK_TIME_NONE):# and (not self.scroll):
value = self.p_position * 100.0 / self.p_duration
self.adjustment.set_value(value)
- #if not had_duration:
- # self.cutin.set_time(0)
self.labelHour.set_text(str(Hour))
self.labelMin.set_text(str(Min))
self.labelSec.set_text(str(Sec))
Modified: trunk/souffleur/Subtitles.py
===================================================================
--- trunk/souffleur/Subtitles.py 2006-07-04 04:32:47 UTC (rev 11692)
+++ trunk/souffleur/Subtitles.py 2006-07-04 17:09:19 UTC (rev 11693)
@@ -12,7 +12,6 @@
self.start_time=None
self.end_time=None
self.subType=SUB_NONE
- #self.N=0
self.Attributes=None
def isInTime(self, time):
@@ -26,7 +25,7 @@
def __init__(self):
self.subs={}
self.subSource=None
- self.subType=SUB_SRT
+ self.subType=SUB_NONE
self.subKeys=[]
def subLoad(self, fileName):
@@ -40,6 +39,7 @@
self.subSource=fileName
def _subSRTLoadFromString(self, DATA):
+ self.subType=SUB_SRT
if (string.find(DATA, "\r\n")==-1):
DATA=string.split(DATA,"\n")
else:
@@ -62,8 +62,6 @@
Text=Text+DATA[i]+"\n"
i+=1
i+=1
- #ST=time(int(Timing[0:2]), int(Timing[3:5]), int(Timing[6:8]), int(Timing[9:12])*1000)
- #ET=time(int(Timing[17:19]), int(Timing[20:22]), int(Timing[23:25]), int(Timing[26:29])*1000)
ST=int(Timing[0:2])*3600000+int(Timing[3:5])*60000+int(Timing[6:8])*1000+int(Timing[9:12])
ET=int(Timing[17:19])*3600000+int(Timing[20:22])*60000+int(Timing[23:25])*1000+int(Timing[26:29])
@@ -73,10 +71,24 @@
TS.start_time=ST
TS.end_time=ET
TS.subType=self.subType
- #TS.N=N
self.subs[int(ST)]=TS
self.updateKeys()
+ def subDel(self, time):
+ del self.subs[time]
+ self.updateKeys()
+
+ def subAdd(self, STime, ETime, Text, Attrs, isUpdate=0):
+ TS=Sub()
+ TS.text=Text
+ TS.start_time=STime
+ TS.end_time=ETime
+ TS.subType=self.subType
+ TS.Attributes=Attrs
+ self.subs[int(STime)]=TS
+ if isUpdate==1:
+ self.updateKeys()
+
def updateKeys(self):
self.subKeys=self.subs.keys()
self.subKeys.sort()
Modified: trunk/souffleur/souffleur.glade
===================================================================
--- trunk/souffleur/souffleur.glade 2006-07-04 04:32:47 UTC (rev 11692)
+++ trunk/souffleur/souffleur.glade 2006-07-04 17:09:19 UTC (rev 11693)
@@ -288,21 +288,6 @@
</child>
<child>
- <widget class="GtkToolButton" id="TOOL_PAUSE">
- <property name="visible">True</property>
- <property name="stock_id">gtk-media-pause</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_TOOL_PAUSE_clicked" last_modification_time="Sun, 02 Jul 2006 17:29:05 GMT"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
-
- <child>
<widget class="GtkToolButton" id="TOOL_STOP">
<property name="visible">True</property>
<property name="stock_id">gtk-media-stop</property>
@@ -376,12 +361,13 @@
</child>
<child>
- <widget class="GtkToolButton" id="TOOL_ADD">
+ <widget class="GtkToolButton" id="TOOL_SAVE">
<property name="visible">True</property>
- <property name="stock_id">gtk-add</property>
+ <property name="stock_id">gtk-save</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
+ <signal name="clicked" handler="on_TOOL_SAVE_clicked" last_modification_time="Mon, 03 Jul 2006 18:18:30 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -396,6 +382,7 @@
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
+ <signal name="clicked" handler="on_TOOL_DELETE_clicked" last_modification_time="Tue, 04 Jul 2006 16:54:36 GMT"/>
</widget>
<packing>
<property name="expand">False</property>
@@ -451,34 +438,6 @@
<property name="homogeneous">True</property>
</packing>
</child>
-
- <child>
- <widget class="GtkSeparatorToolItem" id="separatortoolitem5">
- <property name="visible">True</property>
- <property name="draw">True</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkToolButton" id="TOOL_SAVE">
- <property name="visible">True</property>
- <property name="stock_id">gtk-save</property>
- <property name="visible_horizontal">True</property>
- <property name="visible_vertical">True</property>
- <property name="is_important">False</property>
- <signal name="clicked" handler="on_TOOL_SAVE_clicked" last_modification_time="Mon, 03 Jul 2006 18:18:30 GMT"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
</widget>
<packing>
<property name="padding">0</property>
More information about the commits
mailing list