Rework the console to use autoactivation, move it in services/
This commit is contained in:
parent
764eee81e5
commit
cae78d7041
1
.gitignore
vendored
1
.gitignore
vendored
@ -53,3 +53,4 @@ lib/src/sugar-marshal.h
|
||||
lib/src/stamp-sugar-marshal.c
|
||||
lib/src/stamp-sugar-marshal.h
|
||||
services/clipboard/org.laptop.Clipboard.service
|
||||
services/console/org.laptop.sugar.Console.service
|
||||
|
26
configure.ac
26
configure.ac
@ -68,19 +68,19 @@ shell/view/Makefile
|
||||
shell/view/home/Makefile
|
||||
shell/view/frame/Makefile
|
||||
shell/model/Makefile
|
||||
shell/console/lib/Makefile
|
||||
shell/console/lib/procmem/Makefile
|
||||
shell/console/Makefile
|
||||
shell/console/interface/Makefile
|
||||
shell/console/interface/xo/Makefile
|
||||
shell/console/interface/memphis/plugins/clean_size/Makefile
|
||||
shell/console/interface/memphis/plugins/dirty_size/Makefile
|
||||
shell/console/interface/memphis/plugins/Makefile
|
||||
shell/console/interface/memphis/plugins/memphis_init/Makefile
|
||||
shell/console/interface/memphis/plugins/cpu/Makefile
|
||||
shell/console/interface/memphis/Makefile
|
||||
shell/console/interface/logviewer/Makefile
|
||||
shell/console/interface/terminal/Makefile
|
||||
services/console/lib/Makefile
|
||||
services/console/lib/procmem/Makefile
|
||||
services/console/Makefile
|
||||
services/console/interface/Makefile
|
||||
services/console/interface/xo/Makefile
|
||||
services/console/interface/memphis/plugins/clean_size/Makefile
|
||||
services/console/interface/memphis/plugins/dirty_size/Makefile
|
||||
services/console/interface/memphis/plugins/Makefile
|
||||
services/console/interface/memphis/plugins/memphis_init/Makefile
|
||||
services/console/interface/memphis/plugins/cpu/Makefile
|
||||
services/console/interface/memphis/Makefile
|
||||
services/console/interface/logviewer/Makefile
|
||||
services/console/interface/terminal/Makefile
|
||||
sugar/Makefile
|
||||
sugar/__installed__.py
|
||||
sugar/activity/Makefile
|
||||
|
@ -1 +1 @@
|
||||
SUBDIRS = presence nm clipboard datastore
|
||||
SUBDIRS = presence nm clipboard datastore console
|
||||
|
17
services/console/Makefile.am
Normal file
17
services/console/Makefile.am
Normal file
@ -0,0 +1,17 @@
|
||||
SUBDIRS = interface lib
|
||||
|
||||
servicedir = $(datadir)/dbus-1/services
|
||||
service_in_files = org.laptop.sugar.Console.service.in
|
||||
service_DATA = $(service_in_files:.service.in=.service)
|
||||
|
||||
$(service_DATA): $(service_in_files) Makefile
|
||||
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
console.py
|
||||
|
||||
bin_SCRIPTS = sugar-console
|
||||
|
||||
DISTCLEANFILES = $(service_DATA)
|
@ -17,6 +17,7 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import dbus
|
||||
import dbus.glib
|
||||
import dbus.service
|
||||
import os
|
||||
import sys
|
||||
@ -26,12 +27,9 @@ import gobject
|
||||
sys.path.append(os.path.dirname(__file__) + '/lib')
|
||||
sys.path.append(os.path.dirname(__file__) + '/interface')
|
||||
|
||||
DBUS_BUS = 'org.freedesktop.DBus'
|
||||
DBUS_PATH = '/org/freedesktop/DBus'
|
||||
|
||||
CONSOLE_BUS = 'org.laptop.Sugar.DeveloperConsole'
|
||||
CONSOLE_PATH = '/org/laptop/Sugar/DeveloperConsole'
|
||||
CONSOLE_IFACE = 'org.laptop.Sugar.DeveloperConsole'
|
||||
CONSOLE_BUS = 'org.laptop.sugar.Console'
|
||||
CONSOLE_PATH = '/org/laptop/sugar/Console'
|
||||
CONSOLE_IFACE = 'org.laptop.sugar.Console'
|
||||
|
||||
class Console:
|
||||
|
||||
@ -40,33 +38,16 @@ class Console:
|
||||
# Main Window
|
||||
self.window = gtk.Window()
|
||||
self.window.set_title('Developer console')
|
||||
self.window.connect("delete-event", self._minimize_main_window)
|
||||
self.window.connect("delete-event", self._delete_event_cb)
|
||||
|
||||
self.default_width = gtk.gdk.screen_width() * 95 / 100
|
||||
self.default_height = gtk.gdk.screen_height() * 95 / 100
|
||||
self.default_mini_width = 150
|
||||
self.default_mini_height = 30
|
||||
|
||||
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)
|
||||
|
||||
# Minimize Window
|
||||
self.mini_fixed = gtk.Fixed()
|
||||
|
||||
# Minimize buttons
|
||||
button_restore = gtk.Button('Restore')
|
||||
button_restore.connect("clicked", self._restore_window)
|
||||
|
||||
button_quit = gtk.Button('Quit')
|
||||
button_quit.connect("clicked", gtk.main_quit)
|
||||
|
||||
mini_hbox = gtk.HBox()
|
||||
mini_hbox.pack_start(button_restore, True, True, 0)
|
||||
mini_hbox.pack_start(button_quit, True, True, 0)
|
||||
self.mini_fixed.add(mini_hbox)
|
||||
|
||||
# Notebook
|
||||
self.notebook = gtk.Notebook()
|
||||
|
||||
@ -77,14 +58,10 @@ class Console:
|
||||
|
||||
main_hbox = gtk.HBox()
|
||||
main_hbox.pack_start(self.notebook, True, True, 0)
|
||||
main_hbox.pack_start(self.mini_fixed, True, True, 0)
|
||||
main_hbox.show()
|
||||
|
||||
self.notebook.show()
|
||||
self.window.add(main_hbox)
|
||||
self.window.show()
|
||||
|
||||
self.mini_fixed.hide()
|
||||
|
||||
def _load_interface(self, interface, label):
|
||||
mod = __import__(interface)
|
||||
@ -93,36 +70,21 @@ class Console:
|
||||
|
||||
self.notebook.append_page(widget, gtk.Label(label))
|
||||
|
||||
|
||||
def _restore_window(self, button):
|
||||
self.mini_fixed.hide_all()
|
||||
self.window.resize(self.default_mini_width, self.default_mini_height)
|
||||
self.notebook.show_all()
|
||||
|
||||
def _minimize_main_window(self, window, gdkevent):
|
||||
self.notebook.hide_all()
|
||||
window.resize(self.default_mini_width, self.default_mini_height)
|
||||
self.mini_fixed.show_all()
|
||||
def _delete_event_cb(self, window, gdkevent):
|
||||
window.hide()
|
||||
return True
|
||||
|
||||
# We're using a DBUS-Service to avoid open devconsole more than one time
|
||||
class Init_Service(dbus.service.Object):
|
||||
|
||||
class Service(dbus.service.Object):
|
||||
def __init__(self, bus, object_path=CONSOLE_PATH):
|
||||
dbus.service.Object.__init__(self, bus, object_path)
|
||||
CS = Console()
|
||||
self._console = Console()
|
||||
|
||||
@dbus.service.method(CONSOLE_IFACE)
|
||||
def show(self):
|
||||
self._console.window.present()
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
obj = bus.get_object(DBUS_BUS, DBUS_PATH)
|
||||
|
||||
dbus_iface = dbus.Interface(obj, DBUS_BUS)
|
||||
services = dbus_iface.ListNames()
|
||||
|
||||
# A temporal way to check if the service is running
|
||||
if not CONSOLE_BUS in services:
|
||||
name = dbus.service.BusName(CONSOLE_BUS, bus)
|
||||
obj = Init_Service(name)
|
||||
gtk.main()
|
||||
else:
|
||||
sys.exit(1)
|
||||
name = dbus.service.BusName(CONSOLE_BUS, bus)
|
||||
obj = Service(name)
|
||||
|
||||
gtk.main()
|
4
services/console/org.laptop.sugar.Console.service.in
Normal file
4
services/console/org.laptop.sugar.Console.service.in
Normal file
@ -0,0 +1,4 @@
|
||||
[D-BUS Service]
|
||||
Name = org.laptop.Console
|
||||
Exec = @bindir@/sugar-console
|
||||
|
11
services/console/sugar-console
Executable file
11
services/console/sugar-console
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
||||
import os, sys
|
||||
from sugar import env
|
||||
|
||||
sys.path.insert(0, os.path.join(env.get_data_dir(), 'services/console'))
|
||||
|
||||
import console
|
@ -1,11 +1,9 @@
|
||||
SUBDIRS = data model view console
|
||||
SUBDIRS = data model view
|
||||
|
||||
bin_SCRIPTS = \
|
||||
sugar-activity \
|
||||
sugar-activity-factory \
|
||||
sugar-shell \
|
||||
sugar-shutdown \
|
||||
sugar-devel-console
|
||||
sugar-shell
|
||||
|
||||
sugardir = $(pkgdatadir)/shell
|
||||
sugar_PYTHON = \
|
||||
|
@ -1,6 +0,0 @@
|
||||
SUBDIRS = interface lib
|
||||
|
||||
sugardir = $(pkgdatadir)/shell/console
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
console.py
|
@ -6,6 +6,4 @@
|
||||
<Alt>p=prev
|
||||
<Alt>c=close
|
||||
|
||||
<Alt><Shift>F12=!sugar-devel-console
|
||||
<Alt>q=!sugar-emulator-shutdown
|
||||
<Alt><Shift>Escape=!sugar-shutdown
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Sugar developer console launcher
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
||||
import os, sys
|
||||
from sugar import env
|
||||
|
||||
sys.path.insert(0, os.path.join(env.get_data_dir(), 'shell'))
|
||||
|
||||
import console.console
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
|
||||
/org/freedesktop/Hal/devices/computer \
|
||||
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
|
@ -94,6 +94,8 @@ class Shell(gobject.GObject):
|
||||
self._key_grabber.grab('F12')
|
||||
self._key_grabber.grab('<alt>F5')
|
||||
self._key_grabber.grab('<alt>F8')
|
||||
self._key_grabber.grab('<alt>=')
|
||||
self._key_grabber.grab('<alt>0')
|
||||
|
||||
self._key_grabber.grab('0xDC') # Camera key
|
||||
self._key_grabber.grab('0xE0') # Overlay key
|
||||
@ -135,6 +137,8 @@ class Shell(gobject.GObject):
|
||||
self._hw_manager.set_display_mode(HardwareManager.COLOR_MODE)
|
||||
elif key == '<alt>F8':
|
||||
self._hw_manager.set_display_mode(HardwareManager.B_AND_W_MODE)
|
||||
elif key == '<alt>=' or key == '<alt>0':
|
||||
self._show_console()
|
||||
elif key == '<shft><alt>F9':
|
||||
self._frame.notify_key_press()
|
||||
elif key == '<shft><alt>F10':
|
||||
@ -154,6 +158,13 @@ class Shell(gobject.GObject):
|
||||
box = self._home_window.get_home_box()
|
||||
box.grab_and_rotate()
|
||||
|
||||
def _show_console(self):
|
||||
bus = dbus.SessionBus()
|
||||
proxy = bus.get_object('org.laptop.sugar.Console',
|
||||
'/org/laptop/sugar/Console')
|
||||
mgr = dbus.Interface(proxy, 'org.laptop.sugar.Console')
|
||||
mgr.show()
|
||||
|
||||
def _shutdown(self):
|
||||
bus = dbus.SystemBus()
|
||||
proxy = bus.get_object('org.freedesktop.Hal',
|
||||
|
@ -63,6 +63,11 @@ if sourcedir:
|
||||
util.write_service('org.laptop.sugar.DataStore', bin,
|
||||
env.get_user_service_dir())
|
||||
|
||||
bin = os.path.join(sourcedir,
|
||||
'services/console/sugar-console')
|
||||
util.write_service('org.laptop.sugar.Console', bin,
|
||||
env.get_user_service_dir())
|
||||
|
||||
from sugar.emulator import Emulator
|
||||
|
||||
program = 'sugar-shell'
|
||||
|
Loading…
Reference in New Issue
Block a user