Aggiunto scaricamento dei canali (anche se ancora non possono

Leonardo Robol [2009-11-01 09:55]
Aggiunto scaricamento dei canali (anche se ancora non possono
essere selezionati per il playback)
Filename
RaiTV/ChannelLoader.py
RaiTV/Interface.py
RaiTV/VideoWidget.py
ui/RaiTV.ui
diff --git a/RaiTV/ChannelLoader.py b/RaiTV/ChannelLoader.py
index ab5c971..b3fc24f 100644
--- a/RaiTV/ChannelLoader.py
+++ b/RaiTV/ChannelLoader.py
@@ -51,6 +51,9 @@ class ChannelList():
         mms = r.read()
         mms = re.search(r"HREF=\"(\S*)\"", mms).group(1)
         return mms
+
+    def getChannelList(self):
+        return self.channels



diff --git a/RaiTV/Interface.py b/RaiTV/Interface.py
index c1e162a..c62f141 100644
--- a/RaiTV/Interface.py
+++ b/RaiTV/Interface.py
@@ -4,7 +4,7 @@
 # Interface for RaiTV
 #

-import gtk, pygtk
+import gtk, pygtk, gobject

 ## Costruisco un po' di oggeti che poi
 ## avrò bisogno di recuperare
@@ -26,7 +26,6 @@ class UI():

         ## Lista dei canali (in astratto)
         self.channellist = ChannelList()
-

         ## Questo hbox è quello dove dobbiamo inserire
         ## la videowidget
@@ -34,6 +33,16 @@ class UI():

         self.videowidget = VideoWidget()
         self.hbox1.pack_start(self.videowidget)
+
+        ## La liststore dei canali
+        self.liststore = self.builder.get_object("canalistore")
+
+        ## Visualizziamo il nome del canale
+        col = gtk.TreeViewColumn("Selezione canale")
+        cell = gtk.CellRendererText()
+        col.pack_start(cell,True)
+        col.set_attributes(cell,text=0)
+        self.listacanali.append_column(col)

         ## Qualche setting prima di partire
         self.win.resize(640,480)
@@ -48,6 +57,8 @@ class UI():
         self.statusbar = self.builder.get_object("statusbar")
         self.sb_info("Applicazione inizializzata")

+        ## Connette i bottoni di play/pause... alle relative azioni del
+        ## videowidget
         self.connect_buttons()


@@ -69,7 +80,16 @@ class UI():
         self.stop_btn.connect("clicked", lambda w: self.videowidget.stop() )
         self.play_btn.connect("clicked", lambda w: self.videowidget.play() )
         self.pause_btn.connect("clicked", lambda w: self.videowidget.pause() )
-        self.updatelist.connect("clicked", lambda w: self.channellist.updateChannels() )
+        self.updatelist.connect("clicked", lambda w: self.updateChannels() )
+
+    def updateChannels(self):
+        """Aggiorna la lista dei canali scaricandola direttamente da quella
+        della rai. Si rifiuta di aggiornare se la lista ottenuta è vuota"""
+        self.channellist.updateChannels()
+        self.sb_info("Canali aggiornati")
+        if not self.channellist == {}:
+            for channel, url in self.channellist.getChannelList().items():
+                self.liststore.append( (channel, url) )

     def start_video(self):
         """Avvia il video"""
diff --git a/RaiTV/VideoWidget.py b/RaiTV/VideoWidget.py
index d4a93f7..2322166 100644
--- a/RaiTV/VideoWidget.py
+++ b/RaiTV/VideoWidget.py
@@ -26,7 +26,6 @@ class VideoWidget(gtk.DrawingArea):
         bus.connect("message", self.on_message)


-
     def do_expose_event(self, event):
         if self.imagesink:
             self.imagesink.expose()
diff --git a/ui/RaiTV.ui b/ui/RaiTV.ui
index c5537cd..2b3c7f5 100644
--- a/ui/RaiTV.ui
+++ b/ui/RaiTV.ui
@@ -156,26 +156,25 @@
           <object class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
             <child>
-              <object class="GtkTreeView" id="listacanali">
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="model">canalistore</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <child>
+                  <object class="GtkTreeView" id="listacanali">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="model">canalistore</property>
+                    <property name="search_column">0</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkVSeparator" id="vseparator1">
-                <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
               <placeholder/>
             </child>
           </object>
@@ -271,27 +270,20 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVolumeButton" id="volumebutton">
-                <property name="label" translatable="yes">Volume</property>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkHScale" id="volumescale">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="relief">none</property>
-                <property name="focus_on_click">False</property>
-                <property name="orientation">vertical</property>
-                <property name="icons">audio-volume-muted
-audio-volume-high
-audio-volume-low
-audio-volume-medium</property>
+                <property name="digits">0</property>
+                <property name="draw_value">False</property>
+                <property name="value_pos">left</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
+                <property name="position">2</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="expand">False</property>
ViewGit