2007-01-02 02:39:01 +01:00
|
|
|
# Copyright (C) 2006, Eduardo Silva (edsiper@gmail.com).
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2007-01-07 18:23:53 +01:00
|
|
|
import dbus
|
2007-01-08 18:06:59 +01:00
|
|
|
import dbus.glib
|
2007-01-07 18:23:53 +01:00
|
|
|
import dbus.service
|
|
|
|
import os
|
|
|
|
import sys
|
2006-11-16 13:09:07 +01:00
|
|
|
import gtk
|
2007-01-07 18:23:53 +01:00
|
|
|
import gobject
|
2006-11-16 13:09:07 +01:00
|
|
|
|
2007-03-10 23:16:40 +01:00
|
|
|
sys.path.append(os.path.dirname(__file__))
|
2007-01-03 00:24:44 +01:00
|
|
|
sys.path.append(os.path.dirname(__file__) + '/lib')
|
|
|
|
sys.path.append(os.path.dirname(__file__) + '/interface')
|
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
CONSOLE_BUS = 'org.laptop.sugar.Console'
|
|
|
|
CONSOLE_PATH = '/org/laptop/sugar/Console'
|
|
|
|
CONSOLE_IFACE = 'org.laptop.sugar.Console'
|
2007-01-07 18:23:53 +01:00
|
|
|
|
2007-01-04 03:51:08 +01:00
|
|
|
class Console:
|
2007-01-04 20:17:10 +01:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
# Main Window
|
|
|
|
self.window = gtk.Window()
|
|
|
|
self.window.set_title('Developer console')
|
2007-01-08 18:06:59 +01:00
|
|
|
self.window.connect("delete-event", self._delete_event_cb)
|
2007-01-04 20:17:10 +01:00
|
|
|
|
|
|
|
self.default_width = gtk.gdk.screen_width() * 95 / 100
|
|
|
|
self.default_height = gtk.gdk.screen_height() * 95 / 100
|
|
|
|
|
|
|
|
self.window.set_default_size(self.default_width, self.default_height)
|
|
|
|
|
|
|
|
self.window.realize()
|
|
|
|
self.window.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
|
|
|
|
|
|
|
# Notebook
|
|
|
|
self.notebook = gtk.Notebook()
|
2007-06-11 07:47:18 +02:00
|
|
|
|
2007-01-04 20:17:10 +01:00
|
|
|
self._load_interface('xo', 'XO Resources')
|
|
|
|
self._load_interface('memphis', 'Memphis')
|
|
|
|
self._load_interface('logviewer', 'Log Viewer')
|
|
|
|
self._load_interface('terminal', 'Terminal')
|
2007-07-25 16:30:15 +02:00
|
|
|
self._load_interface('ps_watcher', 'Presence')
|
2007-01-04 20:17:10 +01:00
|
|
|
|
|
|
|
main_hbox = gtk.HBox()
|
|
|
|
main_hbox.pack_start(self.notebook, True, True, 0)
|
|
|
|
main_hbox.show()
|
|
|
|
|
|
|
|
self.notebook.show()
|
|
|
|
self.window.add(main_hbox)
|
2007-06-11 07:47:18 +02:00
|
|
|
|
2007-01-04 20:17:10 +01:00
|
|
|
def _load_interface(self, interface, label):
|
|
|
|
mod = __import__(interface)
|
|
|
|
widget = mod.Interface().widget
|
|
|
|
widget.show()
|
|
|
|
|
|
|
|
self.notebook.append_page(widget, gtk.Label(label))
|
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
def _delete_event_cb(self, window, gdkevent):
|
2007-03-10 23:16:40 +01:00
|
|
|
gtk.main_quit()
|
2007-01-04 20:17:10 +01:00
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
class Service(dbus.service.Object):
|
2007-01-07 18:23:53 +01:00
|
|
|
def __init__(self, bus, object_path=CONSOLE_PATH):
|
|
|
|
dbus.service.Object.__init__(self, bus, object_path)
|
2007-01-08 18:06:59 +01:00
|
|
|
self._console = Console()
|
|
|
|
|
|
|
|
@dbus.service.method(CONSOLE_IFACE)
|
2007-01-10 17:12:23 +01:00
|
|
|
def toggle_visibility(self):
|
|
|
|
window = self._console.window
|
|
|
|
if not window.props.visible:
|
|
|
|
window.present()
|
|
|
|
else:
|
|
|
|
window.hide()
|
2007-01-07 18:23:53 +01:00
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
bus = dbus.SessionBus()
|
|
|
|
name = dbus.service.BusName(CONSOLE_BUS, bus)
|
2007-07-25 16:30:15 +02:00
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
obj = Service(name)
|
2007-01-07 18:23:53 +01:00
|
|
|
|
2007-01-08 18:06:59 +01:00
|
|
|
gtk.main()
|