Add a gui console so I can see output in
This commit is contained in:
parent
b6d50a215b
commit
8a9d0b657c
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
@ -10,6 +12,7 @@ import gtk
|
|||||||
|
|
||||||
import geckoembed
|
import geckoembed
|
||||||
|
|
||||||
|
from sugar.session.LogWriter import LogWriter
|
||||||
from sugar.shell import activity
|
from sugar.shell import activity
|
||||||
from sugar.p2p.Group import LocalGroup
|
from sugar.p2p.Group import LocalGroup
|
||||||
import sugar.env
|
import sugar.env
|
||||||
@ -315,9 +318,8 @@ class BrowserShell(dbus.service.Object):
|
|||||||
self.__browsers.append(browser)
|
self.__browsers.append(browser)
|
||||||
browser.activity_connect_to_shell()
|
browser.activity_connect_to_shell()
|
||||||
|
|
||||||
def main():
|
sys.stdout = LogWriter("Web Browser")
|
||||||
BrowserShell.get_instance().open_web_activity()
|
sys.stderr = LogWriter("Web Browser")
|
||||||
gtk.main()
|
|
||||||
|
BrowserShell.get_instance().open_web_activity()
|
||||||
if __name__ == "__main__":
|
gtk.main()
|
||||||
main()
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/python -t
|
#!/usr/bin/python -t
|
||||||
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
@ -15,6 +17,7 @@ from sugar.p2p.Group import LocalGroup
|
|||||||
from sugar.p2p.Service import Service
|
from sugar.p2p.Service import Service
|
||||||
from sugar.p2p.StreamReader import StreamReader
|
from sugar.p2p.StreamReader import StreamReader
|
||||||
from sugar.p2p.StreamWriter import StreamWriter
|
from sugar.p2p.StreamWriter import StreamWriter
|
||||||
|
from sugar.session.LogWriter import LogWriter
|
||||||
import sugar.env
|
import sugar.env
|
||||||
|
|
||||||
import richtext
|
import richtext
|
||||||
@ -396,9 +399,8 @@ class ChatShell(dbus.service.Object):
|
|||||||
def send_message(self, message):
|
def send_message(self, message):
|
||||||
self._group_chat.send_message(message)
|
self._group_chat.send_message(message)
|
||||||
|
|
||||||
def main():
|
sys.stdout = LogWriter("Chat")
|
||||||
ChatShell.get_instance().open_group_chat()
|
sys.stderr = LogWriter("Chat")
|
||||||
gtk.main()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
ChatShell.get_instance().open_group_chat()
|
||||||
main()
|
gtk.main()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
@ -9,6 +11,8 @@ pygtk.require('2.0')
|
|||||||
import gtk
|
import gtk
|
||||||
import pango
|
import pango
|
||||||
|
|
||||||
|
from sugar.session.LogWriter import LogWriter
|
||||||
|
|
||||||
activity_counter = 0
|
activity_counter = 0
|
||||||
|
|
||||||
class ActivityHost(dbus.service.Object):
|
class ActivityHost(dbus.service.Object):
|
||||||
@ -287,10 +291,60 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
print " %d: owner=%s activity_object_name=%s" % (i, owner, activity.dbus_object_name)
|
print " %d: owner=%s activity_object_name=%s" % (i, owner, activity.dbus_object_name)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
class ConsoleLogger(dbus.service.Object):
|
||||||
|
def __init__(self):
|
||||||
|
session_bus = dbus.SessionBus()
|
||||||
|
bus_name = dbus.service.BusName('com.redhat.Sugar.Logger', bus=session_bus)
|
||||||
|
object_path = '/com/redhat/Sugar/Logger'
|
||||||
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||||
|
|
||||||
|
self._window = gtk.Window()
|
||||||
|
self._window.set_title("Console")
|
||||||
|
self._window.set_default_size(640, 480)
|
||||||
|
self._window.connect("delete_event", lambda w, e: w.hide_on_delete())
|
||||||
|
|
||||||
|
self._nb = gtk.Notebook()
|
||||||
|
self._window.add(self._nb)
|
||||||
|
self._nb.show()
|
||||||
|
|
||||||
|
self._consoles = {}
|
||||||
|
|
||||||
|
def set_parent_window(self, window):
|
||||||
|
window.connect("key-press-event", self.__key_press_event_cb)
|
||||||
|
self._window.connect("key-press-event", self.__key_press_event_cb)
|
||||||
|
|
||||||
|
def __key_press_event_cb(self, window, event):
|
||||||
|
if event.keyval == gtk.keysyms.d and \
|
||||||
|
event.state & gtk.gdk.CONTROL_MASK:
|
||||||
|
if self._window.get_property('visible'):
|
||||||
|
self._window.hide()
|
||||||
|
else:
|
||||||
|
self._window.show()
|
||||||
|
|
||||||
|
@dbus.service.method('com.redhat.Sugar.Logger')
|
||||||
|
def log(self, application, message):
|
||||||
|
if self._consoles.has_key(application):
|
||||||
|
console = self._consoles[application]
|
||||||
|
else:
|
||||||
|
console = gtk.TextView()
|
||||||
|
self._nb.append_page(console, gtk.Label(application))
|
||||||
|
console.show()
|
||||||
|
self._consoles[application] = console
|
||||||
|
|
||||||
|
buf = console.get_buffer()
|
||||||
|
buf.insert(buf.get_end_iter(), message)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
console = ConsoleLogger()
|
||||||
|
|
||||||
session_bus = dbus.SessionBus()
|
session_bus = dbus.SessionBus()
|
||||||
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
|
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
|
||||||
|
|
||||||
activityContainer = ActivityContainer(service, session_bus)
|
activityContainer = ActivityContainer(service, session_bus)
|
||||||
activityContainer.show()
|
activityContainer.show()
|
||||||
|
|
||||||
|
console.set_parent_window(activityContainer.window)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
gtk.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user