[xiph-commits] r14826 - trunk/subtle

jmesquita at svn.xiph.org jmesquita at svn.xiph.org
Fri May 2 16:35:52 PDT 2008


Author: jmesquita
Date: 2008-05-02 16:35:52 -0700 (Fri, 02 May 2008)
New Revision: 14826

Modified:
   trunk/subtle/GPlayer.py
   trunk/subtle/Subtitles.py
   trunk/subtle/Subtle.py
   trunk/subtle/subtle.glade
Log:
After project renaming, a lot of imports got broken.

Modified: trunk/subtle/GPlayer.py
===================================================================
--- trunk/subtle/GPlayer.py	2008-05-02 23:18:52 UTC (rev 14825)
+++ trunk/subtle/GPlayer.py	2008-05-02 23:35:52 UTC (rev 14826)
@@ -25,7 +25,7 @@
 import gtk
 
 ## \file GPlayer.py
-# Documentation for GPlayer module of Souffleur project.
+# Documentation for GPlayer module of Subtle project.
 # \todo Add better seeking.
 
 

Modified: trunk/subtle/Subtitles.py
===================================================================
--- trunk/subtle/Subtitles.py	2008-05-02 23:18:52 UTC (rev 14825)
+++ trunk/subtle/Subtitles.py	2008-05-02 23:35:52 UTC (rev 14826)
@@ -19,6 +19,7 @@
         self.start_time=None
         self.end_time=None
         self.Attributes=None
+	self.number=None
 
 #==============================================================================
     ## Check subtitle time.
@@ -112,6 +113,7 @@
     # Load SRT formated subtitles from given string.
     # \param DATA - string of SRT subtitles.
     def _subSRTLoadFromString(self, DATA):
+	num_sub = 0
         if (string.find(DATA, "\r\n")==-1):
             DATA=string.split(DATA,"\n")
         else:
@@ -138,9 +140,11 @@
             ET=int(Timing[17:19])*3600000+int(Timing[20:22])*60000+int(Timing[23:25])*1000+int(Timing[26:29])
             
             TS=Sub()
+	    num_sub += 1
             TS.text=Text
             TS.start_time=ST
             TS.end_time=ET
+	    TS.number = num_sub
             self.subs[int(ST)]=TS
         self.updateKeys()
 

Modified: trunk/subtle/Subtle.py
===================================================================
--- trunk/subtle/Subtle.py	2008-05-02 23:18:52 UTC (rev 14825)
+++ trunk/subtle/Subtle.py	2008-05-02 23:35:52 UTC (rev 14826)
@@ -22,7 +22,7 @@
 import os
 
 from MediaInfo import MediaInfo
-from SouffleurXML import ProjectXML
+from SubtleXML import ProjectXML
 
 try:
     import pygtk
@@ -45,13 +45,16 @@
 #Also, we know we are running GTK v2
 import gst
 
-class Souffleur:
+ONLINE_MODE = 1
+EDITING_MODE = 0
+
+class Subtle:
     def __init__(self):
         """
         In this init we are going to display the main
-        Souffleur window
+        Subtle window
         """
-        gladefile="souffleur.glade"
+        gladefile="subtle.glade"
         windowname="MAIN_WINDOW"
         
         self.update_id = -1
@@ -63,6 +66,9 @@
         self.Subtitles = []
 	# Current subtitle being edited
 	self.cur_edit_sub_iter = None
+	#Current editing mode
+	## Refer to globals for values
+	self.mode = ONLINE_MODE
 
         #self.scroll = 0
         self.videoWidgetGst = None
@@ -97,6 +103,7 @@
 	    "on_LIST_SUBS_button_release_event": self.cb_onSubsListSelect,\
 	    "on_LIST_SUBS_button_press_event": self.cb_onSubsListSelect,\
 	    "on_txt_subedit_key_release_event": self.cb_onSubtitleEdit,\
+	    "on_tgl_mode_toggled": self.cb_onModeChanged,\
 	    "on_TOOL_SAVE_STREAM_clicked": self.cb_saveStream,\
 	    "on_TOOL_DEL_SUBS_clicked": self.cb_subDel,\
 	    "on_TOOL_OUT_SUB_clicked": self.cb_subOut,\
@@ -109,6 +116,7 @@
 	self.windowMainWindow=self.wTree.get_widget("MAIN_WINDOW")
         self.windowProjectOpen=None
         self.windowProjectSO=None
+	self.windowNewSubFile=None
         self.PFileName=None
         self.windowMediaOpen=None
         #self.windowStreams=gtk.glade.XML (self.gladefile,"STREAM_WINDOW")
@@ -177,10 +185,27 @@
 	self.streams_pane = self.wTree.get_widget("streams_pane")
 	self.subtitle_pane = self.wTree.get_widget("subtitle_pane")
 	self.txt_subedit = self.wTree.get_widget("txt_subedit")
+	self.tgl_mode = self.wTree.get_widget("tgl_mode")
 	self.subList = SUBLIST
 	#self.windowMainWindow.maximize()
         return
 #==============================================================================
+    def cb_onModeChanged(self, widget):
+	"""
+	    Change from online mode to editing mode
+	    and vice versa
+	"""
+	# Online mode
+	if self.tgl_mode.get_active():
+	    self.mode = ONLINE_MODE
+	    self.txt_subedit.set_sensitive(False)
+	    return
+	# Editing mode
+	else:
+	    self.mode = EDITING_MODE
+	    self.txt_subedit.set_sensitive(True)
+	    return
+#==============================================================================
     def cb_hideSubPane(self, widget):
 	"""
 	    Hide the subtitles pane
@@ -368,8 +393,20 @@
 	"""
 	   Create a new subtitle
 	"""
-	print "Create a new stream"
 	#TODO: Lets popup something that will let us choose sub type
+        if(self.windowNewSubFile==None):
+            self.windowNewSubFile=gtk.glade.XML (self.gladefile,"NEW_SUBTITLE")
+            #dic={"on_OPEN_BUTTON_CANCEL_clicked": self.cb_openMediaCancel,\
+            #    "on_OPEN_BUTTON_OPEN_clicked": self.cb_openMediaOpen }
+            #self.windowMediaOpen.signal_autoconnect(dic)
+            WND=self.windowNewSubFile.get_widget("NEW_SUBTITLE")
+	    WND.show()
+        else:
+            WND=self.windowNewSubFile.get_widget("NEW_SUBTITLE")
+            if not WND:
+                self.windowNewSubFile=None
+            else:
+                WND.show()
 	return
 #==============================================================================
     def setSubtitle(self):
@@ -490,6 +527,8 @@
 	    return
 	Model, Rows = Selection.get_selected_rows()
 	if Rows != None:
+	    #FIXME: Buggy solution!! Has something to do with
+	    # button press release event generated...
 	    Row = Model[Rows[0][0]]
 	    if self.Subtitle:
 		Sub = self.Subtitle.subs[Row[1]]
@@ -607,7 +646,7 @@
             OKB.set_label("gtk-save")
             OKB.set_use_stock(True)
             Filter=gtk.FileFilter()
-            Filter.set_name("Souffleur project file")
+            Filter.set_name("Subtle project file")
             Filter.add_pattern("*.spf")
             WND.add_filter(Filter)
         else:
@@ -681,7 +720,7 @@
 #==============================================================================
     def playerSeekRewind(self, widget):
 	"""
-	    Jump back som time
+	    Jump back some time
 	"""
 	#TODO: Implement it
 	pass
@@ -698,7 +737,7 @@
             OKB.set_label("gtk-open")
             OKB.set_use_stock(True)
             Filter=gtk.FileFilter()
-            Filter.set_name("Souffleur project file")
+            Filter.set_name("Subtle project file")
             Filter.add_pattern("*.spf")
             WND.add_filter(Filter)
         else:
@@ -785,15 +824,20 @@
             if self.player.is_playing():
                 if TText:
 		    self.player.set_subtitle_text(TText.text)
-		    #TODO: Select the current playing subtitle
-		    # Careful with any processor intesive tasks here
-		    # !!!Critical loop!!!
+		    # Select current playing subtitle
+		    if self.mode == ONLINE_MODE:
+			Selection = self.subList.get_selection() 
+			#FIXME: This sometimes bugs ... Why??
+			Selection.select_path(TText.number-1)
+			self.setSubtitleEdit(TText.text)
                 else:
 		    self.player.set_subtitle_text('')
-		    # Unselect what is not being played
-		    Selection = self.subList.get_selection()
-		    if Selection:
-			Selection.unselect_all()
+		    if self.mode == ONLINE_MODE:
+			self.setSubtitleEdit('')
+			# Unselect what is not being played
+			Selection = self.subList.get_selection()
+			if Selection:
+			    Selection.unselect_all()
         if (self.p_position != gst.CLOCK_TIME_NONE):# and (not self.scroll):
             value = self.p_position
             self.adjustment.set_value(value)
@@ -808,5 +852,5 @@
 #==============================================================================
 #	MAIN:
 #==============================================================================
-souffleur=Souffleur()
+subtle=Subtle()
 gtk.main()

Modified: trunk/subtle/subtle.glade
===================================================================
--- trunk/subtle/subtle.glade	2008-05-02 23:18:52 UTC (rev 14825)
+++ trunk/subtle/subtle.glade	2008-05-02 23:35:52 UTC (rev 14826)
@@ -4,7 +4,7 @@
 <glade-interface>
   <widget class="GtkWindow" id="MAIN_WINDOW">
     <property name="visible">True</property>
-    <property name="title" translatable="yes">Souffleur</property>
+    <property name="title" translatable="yes">Subtle</property>
     <property name="window_position">GTK_WIN_POS_CENTER</property>
     <signal name="destroy" handler="gtk_main_quit"/>
     <child>
@@ -595,7 +595,7 @@
                       <widget class="GtkHScale" id="MEDIA_ADJUSTMENT">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="adjustment">0 0 100 0.10000000149 0 0</property>
+                        <property name="adjustment">0.20000000298000001 0 100 0.10000000149 0 0</property>
                         <property name="draw_value">False</property>
                         <signal name="button_press_event" handler="on_MEDIA_ADJUSTMENT_button_press_event"/>
                         <signal name="change_value" handler="on_MEDIA_ADJUSTMENT_change_value"/>
@@ -627,28 +627,51 @@
                     <property name="visible">True</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                     <child>
-                      <widget class="GtkToolbar" id="toolbar1">
+                      <widget class="GtkHBox" id="hbox3">
                         <property name="visible">True</property>
                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                        <property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
-                        <property name="icon_size">GTK_ICON_SIZE_MENU</property>
                         <child>
-                          <widget class="GtkToolButton" id="TOOL_HIDE_SUBEDIT1">
+                          <widget class="GtkToolbar" id="toolbar1">
                             <property name="visible">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="stock_id">gtk-close</property>
+                            <property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
+                            <property name="icon_size">GTK_ICON_SIZE_MENU</property>
+                            <child>
+                              <widget class="GtkToolButton" id="TOOL_HIDE_SUBEDIT1">
+                                <property name="visible">True</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="stock_id">gtk-close</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkToolButton" id="TOOL_DETACH_SUBEDIT1">
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="stock_id">gtk-leave-fullscreen</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                              </packing>
+                            </child>
                           </widget>
-                          <packing>
-                            <property name="expand">False</property>
-                          </packing>
                         </child>
                         <child>
-                          <widget class="GtkToolButton" id="TOOL_DETACH_SUBEDIT1">
+                          <widget class="GtkToggleButton" id="tgl_mode">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
                             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                            <property name="stock_id">gtk-leave-fullscreen</property>
+                            <property name="label" translatable="yes">Online Mode</property>
+                            <property name="response_id">0</property>
+                            <property name="active">True</property>
+                            <signal name="toggled" handler="on_tgl_mode_toggled"/>
                           </widget>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
                       </widget>
@@ -671,6 +694,7 @@
                               <widget class="GtkTextView" id="txt_subedit">
                                 <property name="height_request">35</property>
                                 <property name="visible">True</property>
+                                <property name="sensitive">False</property>
                                 <property name="can_focus">True</property>
                                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                 <property name="justification">GTK_JUSTIFY_CENTER</property>
@@ -1175,4 +1199,64 @@
       </widget>
     </child>
   </widget>
+  <widget class="GtkDialog" id="NEW_SUBTITLE">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="border_width">5</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox3">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkIconView" id="iconview1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area3">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="btnOK">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>



More information about the commits mailing list