diff --git a/configure.ac b/configure.ac index a6c65ab5..59408908 100644 --- a/configure.ac +++ b/configure.ac @@ -117,6 +117,7 @@ services/clipboard/Makefile services/datastore/Makefile shell/Makefile shell/data/Makefile +shell/hardware/Makefile shell/view/Makefile shell/view/devices/Makefile shell/view/frame/Makefile diff --git a/shell/hardware/Makefile.am b/shell/hardware/Makefile.am new file mode 100644 index 00000000..86cc0c75 --- /dev/null +++ b/shell/hardware/Makefile.am @@ -0,0 +1,4 @@ +sugardir = $(pkgdatadir)/shell/hardware +sugar_PYTHON = \ + __init__.py \ + hardwaremanager.py diff --git a/shell/hardware/__init__.py b/shell/hardware/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/shell/view/hardwaremanager.py b/shell/hardware/hardwaremanager.py similarity index 73% rename from shell/view/hardwaremanager.py rename to shell/hardware/hardwaremanager.py index 30b65b0a..39ae767f 100644 --- a/shell/view/hardwaremanager.py +++ b/shell/hardware/hardwaremanager.py @@ -18,20 +18,22 @@ import logging import dbus -HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager' -HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager' -HARDWARE_MANAGER_OBJECT_PATH = '/org/laptop/HardwareManager' +from _sugar import AudioManager + +_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager' +_HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager' +_HARDWARE_MANAGER_OBJECT_PATH = '/org/laptop/HardwareManager' + +COLOR_MODE = 0 +B_AND_W_MODE = 1 class HardwareManager(object): - COLOR_MODE = 0 - B_AND_W_MODE = 1 - def __init__(self): try: bus = dbus.SystemBus() - proxy = bus.get_object(HARDWARE_MANAGER_SERVICE, - HARDWARE_MANAGER_OBJECT_PATH) - self._service = dbus.Interface(proxy, HARDWARE_MANAGER_INTERFACE) + proxy = bus.get_object(_HARDWARE_MANAGER_SERVICE, + _HARDWARE_MANAGER_OBJECT_PATH) + self._service = dbus.Interface(proxy, _HARDWARE_MANAGER_INTERFACE) except dbus.DBusException: self._service = None logging.error('Hardware manager service not found.') @@ -56,3 +58,12 @@ class HardwareManager(object): self._service.set_keyboard_brightness(False) else: self._service.set_keyboard_brightness(True) + +def get_hardware_manager(): + return _hardware_manager + +def get_audio_manager(): + return _audio_manager + +_hardware_manager = HardwareManager() +_audio_manager = AudioManager() diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am index c463084c..7b571ec3 100644 --- a/shell/view/Makefile.am +++ b/shell/view/Makefile.am @@ -11,5 +11,4 @@ sugar_PYTHON = \ clipboardmenu.py \ keyhandler.py \ OverlayWindow.py \ - Shell.py \ - hardwaremanager.py + Shell.py diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 812698fb..c032831d 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -26,8 +26,6 @@ from view.ActivityHost import ActivityHost from sugar.activity import activityfactory from view.frame.frame import Frame from view.keyhandler import KeyHandler -from view.hardwaremanager import HardwareManager -from _sugar import AudioManager import sugar class Shell(gobject.GObject): @@ -40,9 +38,6 @@ class Shell(gobject.GObject): self._current_host = None self._screen_rotation = 0 - self._hw_manager = HardwareManager() - self._audio_manager = AudioManager() - self._home_window = HomeWindow(self) self._home_window.show() self.set_zoom_level(sugar.ZOOM_HOME) @@ -88,12 +83,6 @@ class Shell(gobject.GObject): if self._current_host: self._current_host.set_active(True) - def get_hardware_manager(self): - return self._hw_manager - - def get_audio_manager(self): - return self._audio_manager - def get_model(self): return self._model diff --git a/shell/view/keyhandler.py b/shell/view/keyhandler.py index fb2dfdb9..511e722a 100644 --- a/shell/view/keyhandler.py +++ b/shell/view/keyhandler.py @@ -2,7 +2,7 @@ import dbus import gobject from sugar import env -from view.hardwaremanager import HardwareManager +from hardware import hardwaremanager from model.ShellModel import ShellModel from _sugar import KeyGrabber import sugar @@ -40,8 +40,8 @@ _actions_table = { class KeyHandler(object): def __init__(self, shell): self._shell = shell - self._hw_manager = shell.get_hardware_manager() - self._audio_manager = shell.get_audio_manager() + self._hw_manager = hardwaremanager.get_hardware_manager() + self._audio_manager = hardwaremanager.get_audio_manager() self._screen_rotation = 0 self._key_grabber = KeyGrabber() @@ -90,10 +90,10 @@ class KeyHandler(object): self._audio_manager.set_volume(100) def handle_color_mode(self): - self._hw_manager.set_display_mode(HardwareManager.COLOR_MODE) + self._hw_manager.set_display_mode(hardwaremanager.COLOR_MODE) def handle_b_and_w_mode(self): - self._hw_manager.set_display_mode(HardwareManager.B_AND_W_MODE) + self._hw_manager.set_display_mode(hardwaremanager.B_AND_W_MODE) def handle_console(self): gobject.idle_add(self._toggle_console_visibility_cb)