viewgit/index.php:465 Only variables should be passed by reference [2048]

viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]

  1. #
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Interface for RaiTV
  5. #
  6. # This file is part of RaiTV
  7. #
  8. # RaiTV is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # RaiTV is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with RaiTV; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21.  
  22.  
  23. import gtk, pygtk, gobject
  24.  
  25. ## Costruisco un po' di oggeti che poi
  26. ## avrò bisogno di recuperare
  27.  
  28. from VideoWidget import VideoWidget
  29. from ChannelLoader import ChannelList
  30.  
  31. class UI():
  32.  
  33. def __init__(self, loader):
  34. """Recupera tutti gli oggetti necessari aprendo
  35. il file .ui e costruisce quelli che mancano"""
  36.  
  37. self.loader = loader
  38.  
  39. self.builder = gtk.Builder()
  40. self.builder.add_from_file( loader.UIPath("RaiTV.ui") )
  41.  
  42. self.win = self.builder.get_object("win")
  43. self.listacanali = self.builder.get_object("listacanali")
  44.  
  45. ## La liststore dei canali
  46. self.liststore = self.builder.get_object("canalistore")
  47.  
  48. ## Lista dei canali (in astratto)
  49. self.channellist = ChannelList(self.liststore)
  50.  
  51. ## Questo hbox è quello dove dobbiamo inserire
  52. ## la videowidget
  53. self.pannellocentrale = self.builder.get_object("pannellocentrale")
  54.  
  55. ## Gli passiamo anche il loader altrimenti non sa come caricare
  56. ## le immagini! :)
  57. self.videowidget = VideoWidget(self.loader)
  58. self.pannellocentrale.pack2(self.videowidget)
  59.  
  60. ## Visualizziamo il nome del canale
  61. col = gtk.TreeViewColumn("Selezione canale")
  62. cell = gtk.CellRendererText()
  63. col.pack_start(cell,True)
  64. col.set_attributes(cell,text=0)
  65. self.listacanali.append_column(col)
  66.  
  67. ## Qualche setting prima di partire
  68. self.win.resize(740,480)
  69.  
  70. ## Carico i pulsanti
  71. self.stop_btn, self.play_btn, self.pause_btn, self.record_btn, self.updatelist = \
  72. self.builder.get_object("stop"), self.builder.get_object("play"), \
  73. self.builder.get_object("pause"), self.builder.get_object("record"), \
  74. self.builder.get_object("updatelist")
  75.  
  76. ## Colleghiamo il clic sulla lista con il playback del canale
  77. self.listacanali.connect("row-activated", self.row_activated_callback)
  78.  
  79. ## La statusbar
  80. self.statusbar = self.builder.get_object("statusbar")
  81. self.sb_info("Applicazione inizializzata")
  82.  
  83. ## Connette i bottoni di play/pause... alle relative azioni del
  84. ## videowidget
  85. self.connect_buttons()
  86.  
  87.  
  88. ## Connettiamo la richiesta di uscire a qualcosa che lo gestisca
  89. self.win.connect("destroy", self.destroy)
  90.  
  91. def show_all(self):
  92. """Mostra tutta l'interfaccia"""
  93. self.win.show_all()
  94.  
  95. def sb_info(self, text):
  96. """Pubblica delle informazioni nella statusbar"""
  97. assert self.statusbar
  98. id = self.statusbar.get_context_id("info")
  99. self.statusbar.push(id, "Info: " + text)
  100.  
  101. def connect_buttons(self):
  102. """Connette i bottoni con le relative azioni"""
  103. self.stop_btn.connect("clicked", lambda w: self.videowidget.stop() )
  104. self.play_btn.connect("clicked", lambda w: self.play() )
  105. self.pause_btn.connect("clicked", lambda w: self.videowidget.pause() )
  106. self.updatelist.connect("clicked", lambda w: self.updateChannels() )
  107.  
  108. def play(self):
  109. """Controlla se c'è qualcosa di selezionato ed eventualmente
  110. lo comincia a riprodurre"""
  111. if self.videowidget is None:
  112. return
  113.  
  114.  
  115. treeselection = self.listacanali.get_selection()
  116. model, treeiter = treeselection.get_selected()
  117. if treeiter is None:
  118. ## Questo vuol dire che non abbiamo selezionato
  119. ## nulla, e quindi possiamo non fare nulla
  120. return
  121. mmsurl = self.channellist.getChannelFromIter(treeiter)
  122. self.videowidget.load_video(mmsurl)
  123.  
  124.  
  125. def updateChannels(self):
  126. """Aggiorna la lista dei canali scaricandola direttamente da quella
  127. della rai. Si rifiuta di aggiornare se la lista ottenuta è vuota"""
  128. self.sb_info("Aggiornamento canali in corso...")
  129. self.channellist.updateChannels()
  130. self.sb_info("Canali aggiornati")
  131. if not self.channellist == {}:
  132. ## Possiamo permetterci di perdere tutti i canali,
  133. ## perché sembra che l'operazione sia andata a buon
  134. ## fine
  135. self.liststore = self.channellist.getChannelList()
  136.  
  137. def row_activated_callback(self, treeview, path, column):
  138. ## Devo ottenere l'URL da cui prendere lo streaming
  139. mmsurl = self.channellist.getChannelFromPath(path)
  140. self.sb_info("Connessione a %s..." % mmsurl)
  141. self.videowidget.load_video(mmsurl)
  142. self.sb_info("Connessione riuscita")
  143.  
  144.  
  145. def destroy(self, w):
  146. """Chiamata per distruggere l'interfaccia"""
  147.  
  148. ## Fermiamo il video
  149. self.videowidget.stop()
  150.  
  151. ## e ce ne andiamo
  152. gtk.main_quit()
  153.  
  154.  
  155.  
  156.