Make the console contextual to the activity and use the
window manager to activate it.master
parent
87cb115aa0
commit
d6ec6db880
@ -1,49 +0,0 @@
|
||||
import gtk
|
||||
import dbus.service
|
||||
|
||||
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.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 get_window(self):
|
||||
return self._window
|
||||
|
||||
def _create_console(self, application):
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
|
||||
console = gtk.TextView()
|
||||
console.set_wrap_mode(gtk.WRAP_WORD)
|
||||
|
||||
sw.add(console)
|
||||
console.show()
|
||||
|
||||
self._nb.append_page(sw, gtk.Label(application))
|
||||
sw.show()
|
||||
|
||||
return console
|
||||
|
||||
@dbus.service.method('com.redhat.Sugar.Logger')
|
||||
def log(self, application, message):
|
||||
if self._consoles.has_key(application):
|
||||
console = self._consoles[application]
|
||||
else:
|
||||
console = self._create_console(application)
|
||||
self._consoles[application] = console
|
||||
|
||||
buf = console.get_buffer()
|
||||
buf.insert(buf.get_end_iter(), message)
|
@ -0,0 +1,26 @@
|
||||
import gtk
|
||||
|
||||
class ConsoleWindow(gtk.Window):
|
||||
def __init__(self):
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self.set_default_size(620, 440)
|
||||
self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
self.set_title("Console")
|
||||
self.connect("delete_event", lambda w, e: w.hide_on_delete())
|
||||
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC,
|
||||
gtk.POLICY_AUTOMATIC)
|
||||
|
||||
self._console = gtk.TextView()
|
||||
self._console.set_wrap_mode(gtk.WRAP_WORD)
|
||||
sw.add(self._console)
|
||||
self._console.show()
|
||||
|
||||
self.add(sw)
|
||||
sw.show()
|
||||
|
||||
def log(self, message):
|
||||
buf = self._console.get_buffer()
|
||||
buf.insert(buf.get_end_iter(), message)
|
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import dbus
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
proxy_obj = bus.get_object('com.redhat.Sugar.Shell', '/com/redhat/Sugar/Shell')
|
||||
shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Shell')
|
||||
shell.show_console()
|
@ -1,17 +0,0 @@
|
||||
import gtk
|
||||
import dbus
|
||||
|
||||
# FIXME These should be handled by the wm, but it's incovenient
|
||||
# to do that with matchbox at the moment
|
||||
|
||||
def setup_global_keys(window, shell = None):
|
||||
if not shell:
|
||||
bus = dbus.SessionBus()
|
||||
proxy_obj = bus.get_object('com.redhat.Sugar.Shell', '/com/redhat/Sugar/Shell')
|
||||
shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Shell')
|
||||
|
||||
window.connect("key-press-event", __key_press_event_cb, shell)
|
||||
|
||||
def __key_press_event_cb(window, event, shell):
|
||||
if event.keyval == gtk.keysyms.F3:
|
||||
shell.toggle_console()
|
Loading…
Reference in New Issue