[totem/introspection: 11/17] Port iplayer plugin to libpeas



commit 8014ce3ff6aa7cf4fbf1fbcb8220c478feb4630c
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Jun 27 01:01:28 2010 +0100

    Port iplayer plugin to libpeas
    
    It doesn't currently work due to lack of support for Python threads, but the
    interface loads.

 src/plugins/iplayer/iplayer.py  |   24 ++++++++++++++++--------
 src/plugins/iplayer/iplayer2.py |   10 +++++++---
 2 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/iplayer/iplayer.py b/src/plugins/iplayer/iplayer.py
index 4cdca70..a79dcec 100644
--- a/src/plugins/iplayer/iplayer.py
+++ b/src/plugins/iplayer/iplayer.py
@@ -1,21 +1,29 @@
 # -*- coding: utf-8 -*-
 
-import totem
+import gettext
 import gobject
-import gtk
+from gi.repository import Peas
+from gi.repository import Gtk
+from gi.repository import Totem
 import iplayer2
 import threading
 
-class IplayerPlugin (totem.Plugin):
+gettext.textdomain("totem")
+
+D_ = gettext.dgettext
+_ = gettext.gettext
+
+class IplayerPlugin (gobject.GObject, Peas.Activatable):
+	__gtype_name__ = 'IplayerPlugin'
+
 	def __init__ (self):
-		totem.Plugin.__init__ (self)
 		self.debug = False
 		self.totem = None
 		self.programme_download_lock = threading.Lock ()
 
-	def activate (self, totem_object):
+	def do_activate (self, totem_object):
 		# Build the interface
-		builder = self.load_interface ("iplayer.ui", True, totem_object.get_main_window (), self)
+		builder = Totem.plugin_load_interface ("iplayer", "iplayer.ui", True, totem_object.get_main_window (), self)
 		container = builder.get_object ('iplayer_vbox')
 
 		self.tv_tree_store = builder.get_object ('iplayer_programme_store')
@@ -34,7 +42,7 @@ class IplayerPlugin (totem.Plugin):
 		# Get the channel category listings
 		self.populate_channel_list (self.tv, self.tv_tree_store)
 
-	def deactivate (self, totem_object):
+	def do_deactivate (self, totem_object):
 		totem_object.remove_sidebar_page ("iplayer")
 
 	def populate_channel_list (self, feed, tree_store):
@@ -44,7 +52,7 @@ class IplayerPlugin (totem.Plugin):
 		# Add all the channels as top-level rows in the tree store
 		channels = feed.channels ()
 		for channel_id, title in channels.items ():
-			parent_iter = tree_store.append (None, [title, channel_id, None])
+			parent_iter = tree_store.append (None, (title, channel_id, None))
 
 		# Add the channels' categories in a thread, since they each require a network request
 		parent_path = tree_store.get_path (parent_iter)
diff --git a/src/plugins/iplayer/iplayer2.py b/src/plugins/iplayer/iplayer2.py
index 41f52cf..b2aa9a5 100644
--- a/src/plugins/iplayer/iplayer2.py
+++ b/src/plugins/iplayer/iplayer2.py
@@ -7,8 +7,7 @@ import urllib2
 #from pprint import pformat
 from socket import timeout as SocketTimeoutError
 #from time import time
-
-import totem
+import gettext
 
 # external libs
 import httplib2
@@ -16,6 +15,11 @@ import feedparser
 import listparser
 from BeautifulSoup import BeautifulStoneSoup
 
+gettext.textdomain("totem")
+
+D_ = gettext.dgettext
+_ = gettext.gettext
+
 IMG_DIR = os.path.join(os.getcwd(), 'resources', 'media')
 
 #try:
@@ -1015,4 +1019,4 @@ def test():
     #print tv.get('drama').get_subcategory('period').list()
 
 if __name__ == '__main__':
-    test()
+    test()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]