[gnome-games/sudoku-tube] Move tube-handler creation code into __init__
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/sudoku-tube] Move tube-handler creation code into __init__
- Date: Tue, 23 Jun 2009 09:04:11 -0400 (EDT)
commit 4094686afe80857da78e296de832e2b8a422ac15
Author: Zhang Sen <zh jesse gmail com>
Date: Tue Jun 23 21:03:20 2009 +0800
Move tube-handler creation code into __init__
gnome-sudoku/src/lib/main.py | 3 +--
gnome-sudoku/src/lib/tp_tube.py | 32 ++++++++++++++++----------------
2 files changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 48e9e6a..be4dd4b 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -137,8 +137,7 @@ class UI (gconf_wrapper.GConfWrapper):
)
self.setup_gui()
- bus_name, tube_handler = tp_tube.create_tube_handler(self.tube_service)
- self.bus_name, self.tube_handler = bus_name, tube_handler
+ self.tube_handler = tp_tube.TubeHandler(self.tube_service)
self.timer = timer.ActiveTimer(self.w)
self.won = False
diff --git a/gnome-sudoku/src/lib/tp_tube.py b/gnome-sudoku/src/lib/tp_tube.py
index bfd1d1e..0393839 100644
--- a/gnome-sudoku/src/lib/tp_tube.py
+++ b/gnome-sudoku/src/lib/tp_tube.py
@@ -23,26 +23,26 @@ DBusGMainLoop(set_as_default=True)
logger = logging.getLogger("main.tp_tube")
-def create_tube_handler(service_name):
- """Create a DBus service on SessionBus and create tube handler on it
-
- Return the created BusName and the TubeHandler"""
- logger.info("creating TubeHandler")
- tmp = service_name.replace('.', '_')
- handler_busname = "org.gnome.Empathy.DTubeHandler." + tmp
- handler_path = "/org/gnome/Empathy/DTubeHandler/" + tmp
- logger.debug("Bus name: %s" % handler_busname)
- logger.debug("Object path: %s" % handler_path)
-
- bus = dbus.SessionBus()
- bus_name = dbus.service.BusName(handler_busname, bus)
- tube_handler = TubeHandler(bus, handler_path)
- return bus_name, tube_handler
-
class TubeHandler(dbus.service.Object):
"""Listen to coming tube and emit a signal for it"""
+ def __init__(self, service_name):
+ """Create a DBus service on SessionBus and create tube handler on it
+
+ Return the created BusName and the TubeHandler"""
+ logger.info("creating TubeHandler")
+ tmp = service_name.replace('.', '_')
+ handler_busname = "org.gnome.Empathy.DTubeHandler." + tmp
+ handler_path = "/org/gnome/Empathy/DTubeHandler/" + tmp
+ logger.debug("Bus name: %s" % handler_busname)
+ logger.debug("Object path: %s" % handler_path)
+
+ bus = dbus.SessionBus()
+ # this bus_name has to be retained, so make it a instance attribute
+ self.bus_name = dbus.service.BusName(handler_busname, bus)
+ super(TubeHandler, self).__init__(bus, handler_path)
+
@dbus.service.method(dbus_interface="org.gnome.Empathy.TubeHandler",
in_signature='soouu', out_signature='')
def HandleTube(self, bus_name, connection, channel, handle_type, handle):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]