From 2636bc63d0d4c2227455925b7df9ad81d8691acb Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 12 Aug 2006 14:19:47 +0000 Subject: Split the console service out of the shell, to remove dep --- (limited to 'shell') diff --git a/shell/ConsoleWindow.py b/shell/ConsoleWindow.py index 3cbd792..be2e4a5 100644 --- a/shell/ConsoleWindow.py +++ b/shell/ConsoleWindow.py @@ -1,6 +1,8 @@ import logging import gtk +import dbus +import dbus.service class Console(gtk.ScrolledWindow): def __init__(self): @@ -36,7 +38,16 @@ class Console(gtk.ScrolledWindow): buf.insert_with_tags(it, msg, self._debug_tag) else: buf.insert(it, msg) - + +class ConsoleDbusService(dbus.service.Object): + def __init__(self, console, bus_name): + dbus.service.Object.__init__(self, bus_name, '/org/laptop/Sugar/Console') + self._console = console + + @dbus.service.method('org.laptop.Sugar.Console') + def log(self, level, module_id, message): + self._console.log(level, module_id, message) + class ConsoleWindow(gtk.Window): def __init__(self): gtk.Window.__init__(self) @@ -69,6 +80,10 @@ class ConsoleWindow(gtk.Window): self._consoles = {} + session_bus = dbus.SessionBus() + bus_name = dbus.service.BusName('org.laptop.Sugar.Console', bus=session_bus) + ConsoleDbusService(self, bus_name) + def _add_console(self, page_id): console = Console() page = self._nb.append_page(console, gtk.Label(page_id)) diff --git a/shell/Shell.py b/shell/Shell.py index db21135..614e1d1 100755 --- a/shell/Shell.py +++ b/shell/Shell.py @@ -7,11 +7,9 @@ import gtk import gobject import wnck -from sugar.LogWriter import LogWriter from ActivityRegistry import ActivityRegistry from HomeWindow import HomeWindow from sugar import env -from ConsoleWindow import ConsoleWindow from Owner import ShellOwner from sugar.presence.PresenceService import PresenceService from ActivityHost import ActivityHost @@ -39,10 +37,6 @@ class ShellDbusService(dbus.service.Object): def show_console(self): gobject.idle_add(self.__show_console_idle) - @dbus.service.method('com.redhat.Sugar.Shell') - def log(self, level, module_id, message): - self._shell.log(level, module_id, message) - class Shell(gobject.GObject): __gsignals__ = { 'activity-closed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str])) @@ -60,10 +54,6 @@ class Shell(gobject.GObject): bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus) ShellDbusService(self, bus_name) - self._console = ConsoleWindow() - - sugar.logger.start('Shell', self) - self._owner = ShellOwner() self._owner.announce() @@ -76,6 +66,9 @@ class Shell(gobject.GObject): self._screen.connect('window-opened', self.__window_opened_cb) self._screen.connect('window-closed', self.__window_closed_cb) + def set_console(self, console): + self._console = console + def __window_opened_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: self._hosts[window.get_xid()] = ActivityHost(self, window) @@ -155,9 +148,6 @@ class Shell(gobject.GObject): else: logging.error('No such activity in the directory') return None - - def log(self, level, module_id, message): - self._console.log(level, module_id, message) def get_registry(self): return self._registry diff --git a/shell/session/Session.py b/shell/session/Session.py index aac6576..578fe72 100644 --- a/shell/session/Session.py +++ b/shell/session/Session.py @@ -9,6 +9,7 @@ import dbus.dbus_bindings from sugar.presence import PresenceService from Shell import Shell +from ConsoleWindow import ConsoleWindow from session.Process import Process import sugar.env @@ -69,6 +70,9 @@ class Session: process = DbusProcess() process.start() + console = ConsoleWindow() + sugar.logger.start('Shell', console) + process = MatchboxProcess() process.start() @@ -76,6 +80,7 @@ class Session: process.start() shell = Shell(self._registry) + shell.set_console(console) shell.start() try: -- cgit v0.9.1