[totem] plugins: Port all the Python plugins to use GObject from GIR
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] plugins: Port all the Python plugins to use GObject from GIR
- Date: Tue, 5 Apr 2011 00:15:22 +0000 (UTC)
commit 1b221443abb992ebacbb0aa6c0e9c8313f1518e7
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Apr 4 22:26:51 2011 +0100
plugins: Port all the Python plugins to use GObject from GIR
â?¦instead of the old pygobject bindings. This appears to work OK. This commit
also adds pylint annotations to stop it complaining about the GIR modules
being dynamically loaded (as it can't see them).
Helps: bgo#645739
src/plugins/coherence_upnp/coherence_upnp.py | 11 ++++-----
src/plugins/dbusservice/dbusservice.py | 10 ++++----
src/plugins/iplayer/iplayer.py | 22 ++++++++++----------
src/plugins/jamendo/jamendo.py | 25 ++++++++++-------------
src/plugins/opensubtitles/opensubtitles.py | 27 ++++++++++++-------------
src/plugins/pythonconsole/console.py | 15 +++++--------
src/plugins/pythonconsole/pythonconsole.py | 16 +++++++-------
src/plugins/sample-python/sample-python.py | 8 ++----
8 files changed, 62 insertions(+), 72 deletions(-)
---
diff --git a/src/plugins/coherence_upnp/coherence_upnp.py b/src/plugins/coherence_upnp/coherence_upnp.py
index c903b07..51147f5 100644
--- a/src/plugins/coherence_upnp/coherence_upnp.py
+++ b/src/plugins/coherence_upnp/coherence_upnp.py
@@ -7,10 +7,7 @@
import gettext
-import gobject
-from gi.repository import Peas
-from gi.repository import Gtk
-from gi.repository import Totem
+from gi.repository import GObject, Peas, Gtk, Totem # pylint: disable-msg=E0611
from coherence.ui.av_widgets import TreeWidget
from coherence.ui.av_widgets import UDN_COLUMN, UPNP_CLASS_COLUMN
@@ -21,12 +18,14 @@ gettext.textdomain ("totem")
D_ = gettext.dgettext
_ = gettext.gettext
-class UPnPClient (gobject.GObject, Peas.Activatable):
+class UPnPClient (GObject.Object, Peas.Activatable):
__gtype_name__ = 'UPnPClient'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.totem_object = None
self.uiw = TreeWidget ()
self.uiw.window.set_shadow_type (gtk.SHADOW_IN)
diff --git a/src/plugins/dbusservice/dbusservice.py b/src/plugins/dbusservice/dbusservice.py
index 3550616..f0cba0c 100644
--- a/src/plugins/dbusservice/dbusservice.py
+++ b/src/plugins/dbusservice/dbusservice.py
@@ -20,18 +20,18 @@
## Sunday 13th May 2007: Bastien Nocera: Add exception clause.
## See license_change file for details.
-import gobject
-from gi.repository import Peas
-from gi.repository import Totem
+from gi.repository import GObject, Peas, Totem # pylint: disable-msg=E0611
import dbus, dbus.service
from dbus.mainloop.glib import DBusGMainLoop
-class DbusService (gobject.GObject, Peas.Activatable):
+class DbusService (GObject.Object, Peas.Activatable):
__gtype_name__ = 'DbusService'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.root = None
self.player = None
self.track_list = None
diff --git a/src/plugins/iplayer/iplayer.py b/src/plugins/iplayer/iplayer.py
index 140bca8..130641b 100644
--- a/src/plugins/iplayer/iplayer.py
+++ b/src/plugins/iplayer/iplayer.py
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
import gettext
-import gobject
-from gi.repository import Peas
-from gi.repository import Totem
+from gi.repository import GObject, Peas, Totem # pylint: disable-msg=E0611
import iplayer2
import threading
@@ -12,12 +10,14 @@ gettext.textdomain ("totem")
D_ = gettext.dgettext
_ = gettext.gettext
-class IplayerPlugin (gobject.GObject, Peas.Activatable):
+class IplayerPlugin (GObject.Object, Peas.Activatable):
__gtype_name__ = 'IplayerPlugin'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.debug = False
self.totem = None
self.programme_download_lock = threading.Lock ()
@@ -183,14 +183,14 @@ class PopulateChannelsThread (threading.Thread):
# invalidating an iter
for name, _count in self.feed.get (channel_id).categories ():
category_id = category_name_to_id (name)
- gobject.idle_add (self.plugin._populate_channel_list_cb,
+ GObject.idle_add (self.plugin._populate_channel_list_cb,
self.tree_model, parent_path,
[name, category_id, None])
except:
# Only show the error once, rather than for each channel
# (it gets a bit grating)
if not shown_error:
- gobject.idle_add (self.plugin._populate_channel_list_cb,
+ GObject.idle_add (self.plugin._populate_channel_list_cb,
self.tree_model, parent_path, None)
shown_error = True
@@ -211,7 +211,7 @@ class PopulateProgrammesThread (threading.Thread):
category_iter = self.tree_model.get_iter (self.category_path)
if category_iter == None:
- gobject.idle_add (self.plugin._populate_programme_list_cb,
+ GObject.idle_add (self.plugin._populate_programme_list_cb,
self.tree_model, self.category_path, None, False)
self.plugin.programme_download_lock.release ()
return
@@ -223,7 +223,7 @@ class PopulateProgrammesThread (threading.Thread):
# Retrieve the programmes and return them
feed = self.feed.get (channel_id).get (category_id)
if feed == None:
- gobject.idle_add (self.plugin._populate_programme_list_cb,
+ GObject.idle_add (self.plugin._populate_programme_list_cb,
self.tree_model, self.category_path, None, False)
self.plugin.programme_download_lock.release ()
return
@@ -232,7 +232,7 @@ class PopulateProgrammesThread (threading.Thread):
try:
programmes = feed.list ()
except:
- gobject.idle_add (self.plugin._populate_programme_list_cb,
+ GObject.idle_add (self.plugin._populate_programme_list_cb,
self.tree_model, self.category_path, None, False)
self.plugin.programme_download_lock.release ()
return
@@ -253,7 +253,7 @@ class PopulateProgrammesThread (threading.Thread):
print "Programme has no HTTP streams"
continue
- gobject.idle_add (self.plugin._populate_programme_list_cb,
+ GObject.idle_add (self.plugin._populate_programme_list_cb,
self.tree_model, self.category_path,
[programme.get_title (), programme.get_summary (),
media.url],
diff --git a/src/plugins/jamendo/jamendo.py b/src/plugins/jamendo/jamendo.py
index ad909c4..bf996ab 100644
--- a/src/plugins/jamendo/jamendo.py
+++ b/src/plugins/jamendo/jamendo.py
@@ -33,14 +33,9 @@ TODO:
import os
import gettext
-import gobject
-from gi.repository import Gio
-from gi.repository import Peas
-from gi.repository import PeasGtk
-from gi.repository import Gtk
-from gi.repository import GdkPixbuf
-from gi.repository import Totem
-from gi.repository import Pango
+from gi.repository import GObject # pylint: disable-msg=E0611
+from gi.repository import Gio, Peas, PeasGtk, Gtk # pylint: disable-msg=E0611
+from gi.repository import GdkPixbuf, Totem, Pango # pylint: disable-msg=E0611
import socket
import threading
@@ -70,12 +65,12 @@ except ImportError:
raise
socket.setdefaulttimeout (30)
-gobject.threads_init ()
+GObject.threads_init ()
-class JamendoPlugin (gobject.GObject, Peas.Activatable, PeasGtk.Configurable):
+class JamendoPlugin (GObject.Object, Peas.Activatable, PeasGtk.Configurable):
__gtype_name__ = 'JamendoPlugin'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
"""
Jamendo totem plugin GUI.
@@ -87,6 +82,8 @@ class JamendoPlugin (gobject.GObject, Peas.Activatable, PeasGtk.Configurable):
TAB_LATEST = 2
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.debug = True
self.gstreamer_plugins_present = True
self.totem = None
@@ -735,10 +732,10 @@ class JamendoService (threading.Thread):
# If Jamendo doesn't support your language, *do not translate
# this string*!
album['url'] = url.replace ('/en/', '/' + _('en') + '/')
- gobject.idle_add (self.loop_cb[0], self.loop_cb[1], album)
- gobject.idle_add (self.done_cb[0], self.done_cb[1], albums)
+ GObject.idle_add (self.loop_cb[0], self.loop_cb[1], album)
+ GObject.idle_add (self.done_cb[0], self.done_cb[1], albums)
except Exception as exc:
- gobject.idle_add (self.error_cb[0], self.error_cb[1], exc)
+ GObject.idle_add (self.error_cb[0], self.error_cb[1], exc)
finally:
self.lock.release ()
diff --git a/src/plugins/opensubtitles/opensubtitles.py b/src/plugins/opensubtitles/opensubtitles.py
index fa3de18..a0ffa3a 100644
--- a/src/plugins/opensubtitles/opensubtitles.py
+++ b/src/plugins/opensubtitles/opensubtitles.py
@@ -1,13 +1,8 @@
# -*- coding: utf-8 -*-
-from gi.repository import Peas
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import Gio
-from gi.repository import Pango
-from gi.repository import Totem
-import gobject
-gobject.threads_init ()
+from gi.repository import GObject, Peas, Gtk, Gdk # pylint: disable-msg=E0611
+from gi.repository import Gio, Pango, Totem # pylint: disable-msg=E0611
+
import xmlrpclib
import threading
import xdg.BaseDirectory
@@ -21,6 +16,8 @@ gettext.textdomain ("totem")
D_ = gettext.dgettext
_ = gettext.gettext
+GObject.threads_init ()
+
USER_AGENT = 'Totem'
OK200 = '200 OK'
TOTEM_REMOTE_COMMAND_REPLACE = 14
@@ -303,12 +300,14 @@ class OpenSubtitlesModel (object):
return None
-class OpenSubtitles (gobject.GObject, Peas.Activatable):
+class OpenSubtitles (GObject.Object, Peas.Activatable):
__gtype_name__ = 'OpenSubtitles'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.dialog = None
self.totem = None
schema = 'org.gnome.totem.plugins.opensubtitles'
@@ -521,10 +520,10 @@ class OpenSubtitles (gobject.GObject, Peas.Activatable):
thread = SearchThread (self.model)
thread.start ()
- gobject.idle_add (self.os_populate_treeview)
+ GObject.idle_add (self.os_populate_treeview)
self.progress.set_text (_(u'Searching subtitlesâ?¦'))
- gobject.timeout_add (350, self.os_progress_bar_increment, thread)
+ GObject.timeout_add (350, self.os_progress_bar_increment, thread)
def os_populate_treeview (self):
"""
@@ -588,10 +587,10 @@ class OpenSubtitles (gobject.GObject, Peas.Activatable):
thread = DownloadThread (self.model, subtitle_id)
thread.start ()
- gobject.idle_add (self.os_save_subtitles, filename)
+ GObject.idle_add (self.os_save_subtitles, filename)
self.progress.set_text (_(u'Downloading the subtitlesâ?¦'))
- gobject.timeout_add (350, self.os_progress_bar_increment, thread)
+ GObject.timeout_add (350, self.os_progress_bar_increment, thread)
else:
#warn user!
pass
diff --git a/src/plugins/pythonconsole/console.py b/src/plugins/pythonconsole/console.py
index 6a71183..8bbfb9f 100644
--- a/src/plugins/pythonconsole/console.py
+++ b/src/plugins/pythonconsole/console.py
@@ -36,10 +36,7 @@ import string
import sys
import re
import traceback
-import gobject
-from gi.repository import Pango
-from gi.repository import Gtk
-from gi.repository import Gdk
+from gi.repository import GObject, Pango, Gtk, Gdk # pylint: disable-msg=E0611
class PythonConsole(Gtk.ScrolledWindow):
def __init__(self, namespace = {}, destroy_cb = None):
@@ -117,7 +114,7 @@ class PythonConsole(Gtk.ScrolledWindow):
cur = buffer.get_end_iter()
buffer.place_cursor(cur)
- gobject.idle_add(self.scroll_to_end)
+ GObject.idle_add(self.scroll_to_end)
return True
elif event.keyval == Gdk.KEY_Return:
@@ -161,21 +158,21 @@ class PythonConsole(Gtk.ScrolledWindow):
cur = buffer.get_end_iter()
buffer.move_mark(inp_mark, cur)
buffer.place_cursor(cur)
- gobject.idle_add(self.scroll_to_end)
+ GObject.idle_add(self.scroll_to_end)
return True
elif event.keyval == Gdk.KEY_KP_Down or event.keyval == Gdk.KEY_Down:
# Next entry from history
view.emit_stop_by_name("key_press_event")
self.history_down()
- gobject.idle_add(self.scroll_to_end)
+ GObject.idle_add(self.scroll_to_end)
return True
elif event.keyval == Gdk.KEY_KP_Up or event.keyval == Gdk.KEY_Up:
# Previous entry from history
view.emit_stop_by_name("key_press_event")
self.history_up()
- gobject.idle_add(self.scroll_to_end)
+ GObject.idle_add(self.scroll_to_end)
return True
elif event.keyval == Gdk.KEY_KP_Left or event.keyval == Gdk.KEY_Left or \
@@ -246,7 +243,7 @@ class PythonConsole(Gtk.ScrolledWindow):
else:
buf.insert_with_tags(buf.get_end_iter(), text, tag)
- gobject.idle_add(self.scroll_to_end)
+ GObject.idle_add(self.scroll_to_end)
def eval(self, command, display_command = False):
buffer = self.view.get_buffer()
diff --git a/src/plugins/pythonconsole/pythonconsole.py b/src/plugins/pythonconsole/pythonconsole.py
index bc1187d..e105037 100644
--- a/src/plugins/pythonconsole/pythonconsole.py
+++ b/src/plugins/pythonconsole/pythonconsole.py
@@ -37,11 +37,9 @@ from console import PythonConsole
__all__ = ('PythonConsole', 'OutFile')
-from gi.repository import Peas
-from gi.repository import Gtk
-from gi.repository import Totem
-from gi.repository import Gio
-import gobject
+from gi.repository import GObject, Peas, Gtk, Totem # pylint: disable-msg=E0611
+from gi.repository import Gio # pylint: disable-msg=E0611
+
try:
import rpdb2
HAVE_RPDB2 = True
@@ -67,12 +65,14 @@ UI_STR = """
</ui>
"""
-class PythonConsolePlugin (gobject.GObject, Peas.Activatable):
+class PythonConsolePlugin (GObject.Object, Peas.Activatable):
__gtype_name__ = 'PythonConsolePlugin'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def __init__ (self):
+ GObject.Object.__init__ (self)
+
self.totem = None
self.window = None
@@ -149,7 +149,7 @@ class PythonConsolePlugin (gobject.GObject, Peas.Activatable):
rpdb2.start_embedded_debugger (password)
return False
- gobject.idle_add (start_debugger, password)
+ GObject.idle_add (start_debugger, password)
dialog.destroy ()
def destroy_console (self, *_args):
diff --git a/src/plugins/sample-python/sample-python.py b/src/plugins/sample-python/sample-python.py
index 025c13d..41db84a 100644
--- a/src/plugins/sample-python/sample-python.py
+++ b/src/plugins/sample-python/sample-python.py
@@ -1,13 +1,11 @@
# From code by James Livingston
-import gobject
-from gi.repository import Peas
-from gi.repository import Totem
+from gi.repository import GObject, Peas, Totem # pylint: disable-msg=E0611
-class SamplePython (gobject.GObject, Peas.Activatable):
+class SamplePython (GObject.Object, Peas.Activatable):
__gtype_name__ = 'SamplePython'
- object = gobject.property (type = gobject.GObject)
+ object = GObject.property (type = GObject.Object)
def do_activate (self):
print "Activating sample Python plugin"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]