diff --git a/Makefile.am b/Makefile.am index ac05c5d6..7394eac3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,9 @@ -SUBDIRS = lib po shell sugar services tools +SUBDIRS = emulator lib po shell sugar services tools ACLOCAL_AMFLAGS = -I m4 bin_SCRIPTS = \ - sugar-emulator \ - sugar-emulator-shutdown + sugar-emulator DISTCLEANFILES = \ intltool-extract \ diff --git a/configure.ac b/configure.ac index 0ae1e154..ac02df8f 100644 --- a/configure.ac +++ b/configure.ac @@ -104,6 +104,7 @@ AM_GLIB_GNU_GETTEXT AC_OUTPUT([ Makefile +emulator/Makefile lib/Makefile lib/data/Makefile lib/src/Makefile @@ -116,7 +117,6 @@ services/clipboard/Makefile services/datastore/Makefile shell/Makefile shell/intro/Makefile -shell/data/Makefile shell/hardware/Makefile shell/view/Makefile shell/view/devices/Makefile @@ -138,7 +138,6 @@ services/console/interface/memphis/Makefile services/console/interface/logviewer/Makefile services/console/interface/terminal/Makefile sugar/Makefile -sugar/__installed__.py sugar/activity/Makefile sugar/chat/Makefile sugar/chat/sketchpad/Makefile diff --git a/emulator/Makefile.am b/emulator/Makefile.am new file mode 100644 index 00000000..d0386c71 --- /dev/null +++ b/emulator/Makefile.am @@ -0,0 +1,4 @@ +confdir = $(pkgdatadir)/emulator +conf_DATA = kbdconfig + +EXTRA_DIST = $(conf_DATA) diff --git a/shell/data/kbdconfig b/emulator/kbdconfig similarity index 79% rename from shell/data/kbdconfig rename to emulator/kbdconfig index 287de527..415c69ff 100644 --- a/shell/data/kbdconfig +++ b/emulator/kbdconfig @@ -5,5 +5,3 @@ n=next p=prev c=close - -q=!sugar-emulator-shutdown diff --git a/services/clipboard/sugar-clipboard b/services/clipboard/sugar-clipboard index acc86571..9ee32e70 100755 --- a/services/clipboard/sugar-clipboard +++ b/services/clipboard/sugar-clipboard @@ -18,6 +18,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import sys +import os import logging from sugar import logger @@ -31,9 +32,9 @@ import dbus.glib from sugar import env -sys.path.insert(0, env.get_services_dir()) +sys.path.insert(0, env.get_service_path('clipboard')) -from clipboard.clipboardservice import ClipboardService +from clipboardservice import ClipboardService logging.info('Starting clipboard service.') diff --git a/services/console/sugar-console b/services/console/sugar-console index 78ea3a2c..d4d7af02 100755 --- a/services/console/sugar-console +++ b/services/console/sugar-console @@ -3,9 +3,10 @@ import pygtk pygtk.require('2.0') -import os, sys +import os +import sys from sugar import env -sys.path.insert(0, env.get_services_dir()) +sys.path.insert(0, env.get_service_path('console')) -import console.console +import console diff --git a/services/datastore/sugar-data-store b/services/datastore/sugar-data-store index b4a728bd..003e2739 100755 --- a/services/datastore/sugar-data-store +++ b/services/datastore/sugar-data-store @@ -18,16 +18,17 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import sys +import os import logging from sugar import logger from sugar import env -sys.path.insert(0, env.get_services_dir()) +sys.path.insert(0, env.get_service_path('datastore')) logger.start('data-store') logging.info('Starting the data store...') -from datastore import datastore +import datastore datastore.main() diff --git a/services/presence/sugar-presence-service b/services/presence/sugar-presence-service index b98db9a6..be9c0e0a 100755 --- a/services/presence/sugar-presence-service +++ b/services/presence/sugar-presence-service @@ -24,11 +24,11 @@ import os from sugar import logger from sugar import env -sys.path.insert(0, env.get_services_dir()) +sys.path.insert(0, env.get_service_path('presence')) logger.start('presenceservice') -from presence import PresenceService +import PresenceService logging.info('Starting presence service') diff --git a/services/presence2/sugar-presence-service2 b/services/presence2/sugar-presence-service2 index 5b5afd1e..83ff58d0 100755 --- a/services/presence2/sugar-presence-service2 +++ b/services/presence2/sugar-presence-service2 @@ -24,11 +24,11 @@ import os from sugar import logger from sugar import env -sys.path.insert(0, env.get_services_dir()) +sys.path.insert(0, env.get_service_path('presence2')) logger.start('presenceservice') -from presence2 import presenceservice +import presenceservice logging.info('Starting presence service') diff --git a/shell/Makefile.am b/shell/Makefile.am index c1185b30..0d881ed3 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = data hardware model view intro +SUBDIRS = hardware model view intro bin_SCRIPTS = \ sugar-activity \ diff --git a/shell/data/Makefile.am b/shell/data/Makefile.am deleted file mode 100644 index 2709c921..00000000 --- a/shell/data/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -confdir = $(pkgdatadir) -conf_DATA = kbdconfig - -imagedir = $(pkgdatadir) -image_DATA = default-picture.png - -EXTRA_DIST = $(conf_DATA) $(image_DATA) diff --git a/shell/intro/Makefile.am b/shell/intro/Makefile.am index cc11aa90..3b92ea0a 100644 --- a/shell/intro/Makefile.am +++ b/shell/intro/Makefile.am @@ -1,3 +1,7 @@ +imagedir = $(pkgdatadir)/shell/intro +image_DATA = default-picture.png + +EXTRA_DIST = $(conf_DATA) $(image_DATA) sugardir = $(pkgdatadir)/shell/intro sugar_PYTHON = \ __init__.py \ diff --git a/shell/data/default-picture.png b/shell/intro/default-picture.png similarity index 100% rename from shell/data/default-picture.png rename to shell/intro/default-picture.png diff --git a/shell/intro/intro.py b/shell/intro/intro.py index 55aa1354..cdcc2a3d 100644 --- a/shell/intro/intro.py +++ b/shell/intro/intro.py @@ -143,7 +143,8 @@ class VideoBox(hippo.CanvasBox, hippo.CanvasItem): self._img_widget.props.widget = self._img if not has_webcam: - path = os.path.join(env.get_data_dir(),'default-picture.png') + path = os.path.join(os.path.dirname(__file__), + 'default-picture.png') self._video.load_image(path) def _clear_image_cb(self, widget, event): diff --git a/shell/sugar-shell b/shell/sugar-shell index 92cefc32..4b67e963 100755 --- a/shell/sugar-shell +++ b/shell/sugar-shell @@ -36,7 +36,7 @@ logger.cleanup() logger.start('shell') if len(sys.argv) == 1: - sys.path.insert(0, os.path.join(env.get_data_dir(), 'shell')) + sys.path.insert(0, env.get_shell_path()) from view.Shell import Shell from model.ShellModel import ShellModel diff --git a/shell/view/keyhandler.py b/shell/view/keyhandler.py index 085b51c0..0ef963ac 100644 --- a/shell/view/keyhandler.py +++ b/shell/view/keyhandler.py @@ -1,3 +1,6 @@ +import os +import signal + import dbus import gobject @@ -34,7 +37,8 @@ _actions_table = { '0xEB' : 'rotate', 'r' : 'rotate', '0xEC' : 'keyboard_brightness', - 'Tab' : 'home' + 'Tab' : 'home', + 'q' : 'quit_emulator', } class KeyHandler(object): @@ -149,6 +153,11 @@ class KeyHandler(object): gobject.spawn_async(['xrandr', '-o', states[self._screen_rotation]], flags=gobject.SPAWN_SEARCH_PATH) + def handle_quit_emulator(self): + if os.environ.has_key('SUGAR_EMULATOR_PID'): + pid = int(os.environ['SUGAR_EMULATOR_PID']) + os.kill(pid, signal.SIGTERM) + def handle_home(self): # FIXME: finish alt+tab support pass diff --git a/sugar-emulator b/sugar-emulator index 98e51d36..d31010d0 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -47,17 +47,21 @@ else: program = sys.argv[1] if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900: - fullscreen = True width = -1 height = -1 else: - fullscreen = False width = 1200 height = 900 dpi = min(_sugar.get_screen_dpi(), 96) -emulator = Emulator(width, height, fullscreen, dpi) +if sourcedir: + kbd_config = os.path.join(sourcedir, 'emulator/kbdconfig') +else: + kbd_config = os.path.join(env.get_emulator_path('kbdconfig')) + +emulator = Emulator(width, height, dpi) +emulator.set_keyboard_config(kbd_config) emulator.start() if sourcedir: diff --git a/sugar-emulator-shutdown b/sugar-emulator-shutdown deleted file mode 100755 index 75f6de08..00000000 --- a/sugar-emulator-shutdown +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2006, Red Hat, Inc. -# -# 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 - -import os -import signal - -if os.environ.has_key('SUGAR_XEPHYR_PID'): - pid = int(os.environ['SUGAR_XEPHYR_PID']) - os.kill(pid, signal.SIGTERM) diff --git a/sugar/Makefile.am b/sugar/Makefile.am index 93c07692..0642fbd8 100644 --- a/sugar/Makefile.am +++ b/sugar/Makefile.am @@ -3,7 +3,6 @@ SUBDIRS = activity chat clipboard graphics p2p presence datastore sugardir = $(pythondir)/sugar sugar_PYTHON = \ __init__.py \ - __installed__.py \ date.py \ emulator.py \ env.py \ @@ -12,5 +11,3 @@ sugar_PYTHON = \ simulator.py \ TracebackUtils.py \ util.py - -EXTRA_DIST = __uninstalled__.py diff --git a/sugar/__installed__.py.in b/sugar/__installed__.py.in deleted file mode 100644 index def17e03..00000000 --- a/sugar/__installed__.py.in +++ /dev/null @@ -1,5 +0,0 @@ -sugar_source_dir = None -sugar_data_dir = '@prefix@/share/sugar' -sugar_activity_info_dir = '@prefix@/share/sugar/activities' -sugar_services_dir = '@prefix@/share/sugar/services' -sugar_shell_bin_dir = '@prefix@/bin' diff --git a/sugar/__uninstalled__.py b/sugar/__uninstalled__.py deleted file mode 100644 index 7dc2f384..00000000 --- a/sugar/__uninstalled__.py +++ /dev/null @@ -1,7 +0,0 @@ -import os - -_sourcedir = os.path.dirname(os.path.dirname(__file__)) - -sugar_data_dir = os.path.join(_sourcedir, 'shell/data') -sugar_services_dir = os.path.join(_sourcedir, 'services') -sugar_shell_bin_dir = os.path.join(_sourcedir, 'shell') diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py index 283204f3..8980a115 100644 --- a/sugar/activity/bundle.py +++ b/sugar/activity/bundle.py @@ -44,8 +44,7 @@ class Bundle: if cp.has_option(section, 'class'): self._class = cp.get(section, 'class') self._exec = '%s %s --bundle-path="%s"' % ( - os.path.join(env.get_shell_bin_dir(), _PYTHON_FACTORY), - self._class, self.get_path()) + env.get_bin_path(_PYTHON_FACTORY), self._class, self.get_path()) elif cp.has_option(section, 'exec'): self._class = None self._exec = cp.get(section, 'exec') diff --git a/sugar/activity/bundlebuilder.py b/sugar/activity/bundlebuilder.py index c223bfa1..120e7b8c 100644 --- a/sugar/activity/bundlebuilder.py +++ b/sugar/activity/bundlebuilder.py @@ -93,7 +93,7 @@ def _get_install_dir(prefix): return os.path.join(prefix, 'share/activities') def _get_bundle_path(): - return os.path.join(env.get_user_activities_dir(), _get_bundle_dir()) + return os.path.join(env.get_user_activities_path(), _get_bundle_dir()) def _get_package_name(): bundle = Bundle(_get_source_path()) @@ -120,7 +120,7 @@ setup.py help - print this message \n\ ' def cmd_dev(): - bundle_path = os.path.join(env.get_user_activities_dir(), _get_bundle_dir()) + bundle_path = os.path.join(env.get_user_activities_path(), _get_bundle_dir()) try: os.symlink(_get_source_path(), bundle_path) except OSError: diff --git a/sugar/activity/bundleregistry.py b/sugar/activity/bundleregistry.py index 08f543ff..2ad68ed5 100644 --- a/sugar/activity/bundleregistry.py +++ b/sugar/activity/bundleregistry.py @@ -1,14 +1,26 @@ import os from ConfigParser import ConfigParser + import gobject from sugar.activity.bundle import Bundle from sugar import env from sugar import util +# http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html +def _get_data_dirs(): + if os.environ.has_key('XDG_DATA_DIRS'): + return os.environ['XDG_DATA_DIRS'].split(':') + else: + return [ '/usr/local/share/', '/usr/share/' ] + class _ServiceManager(object): def __init__(self): - self._path = env.get_user_service_dir() + service_dir = os.path.expanduser('~/.local/share/dbus-1/services') + if not os.path.isdir(service_dir): + os.makedirs(service_dir) + + self._path = service_dir def add(self, bundle): util.write_service(bundle.get_service_name(), @@ -74,8 +86,8 @@ def get_registry(): _bundle_registry = BundleRegistry() -for path in env.get_data_dirs(): +for path in _get_data_dirs(): bundles_path = os.path.join(path, 'activities') _bundle_registry.add_search_path(bundles_path) -_bundle_registry.add_search_path(env.get_user_activities_dir()) +_bundle_registry.add_search_path(env.get_user_activities_path()) diff --git a/sugar/emulator.py b/sugar/emulator.py index 8491dbfd..53732554 100644 --- a/sugar/emulator.py +++ b/sugar/emulator.py @@ -64,13 +64,13 @@ class Process: self._stdout = result[2] class MatchboxProcess(Process): - def __init__(self): - kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig') - options = '-kbdconfig %s ' % kbd_config - - options += '-use_titlebar no ' + def __init__(self, kbd_config): + options = '-use_titlebar no ' options += '-theme olpc ' + if kbd_config: + options += '-kbdconfig %s ' % kbd_config + command = 'matchbox-window-manager %s ' % options Process.__init__(self, command) @@ -78,15 +78,14 @@ class MatchboxProcess(Process): return 'Matchbox' class XephyrProcess(Process): - def __init__(self, width, height, fullscreen, dpi): + def __init__(self, width, height, dpi): self._display = get_display_number() cmd = 'Xephyr :%d -ac ' % (self._display) - if fullscreen: - cmd += ' -fullscreen ' - if width > 0 and height > 0: cmd += ' -screen %dx%d' % (width, height) + else: + cmd += ' -fullscreen ' if dpi > 0: cmd += ' -dpi %d' % (dpi) @@ -99,24 +98,26 @@ class XephyrProcess(Process): def start(self, standard_output=False): Process.start(self) os.environ['DISPLAY'] = ":%d" % (self._display) - os.environ['SUGAR_XEPHYR_PID'] = '%d' % self.pid + os.environ['SUGAR_EMULATOR_PID'] = '%d' % self.pid class Emulator(object): """The OLPC emulator""" - def __init__(self, width, height, fullscreen, dpi): - self._fullscreen = fullscreen + def __init__(self, width, height, dpi): + self._keyboard_config = None self._width = width self._height = height self._dpi = dpi + def set_keyboard_config(self, config): + self._keyboard_config = config + def start(self): try: - process = XephyrProcess(self._width, self._height, - self._fullscreen, self._dpi) + process = XephyrProcess(self._width, self._height, self._dpi) process.start() except: print 'Cannot run the emulator. You need to install Xephyr' sys.exit(0) - process = MatchboxProcess() + process = MatchboxProcess(self._keyboard_config) process.start() diff --git a/sugar/env.py b/sugar/env.py index afaa5653..65fd1fe5 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -16,13 +16,17 @@ # Boston, MA 02111-1307, USA. import os -import sys -import pwd -try: - from sugar.__uninstalled__ import * -except ImportError: - from sugar.__installed__ import * +def _get_prefix_path(base, path=None): + if os.environ.has_key('SUGAR_PREFIX'): + prefix = os.environ['SUGAR_PREFIX'] + else: + prefix = '/usr' + + if path: + return os.path.join(prefix, base, path) + else: + return os.path.join(prefix, base) def is_emulator(): if os.environ.has_key('SUGAR_EMULATOR'): @@ -45,31 +49,20 @@ def get_profile_path(): return path -def get_data_dir(): - return sugar_data_dir - -def get_services_dir(): - return sugar_services_dir - -def get_shell_bin_dir(): - return sugar_shell_bin_dir - -# http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html -def get_data_dirs(): - if os.environ.has_key('XDG_DATA_DIRS'): - return os.environ['XDG_DATA_DIRS'].split(':') - else: - return [ '/usr/local/share/', '/usr/share/' ] - -def get_user_service_dir(): - service_dir = os.path.expanduser('~/.local/share/dbus-1/services') - if not os.path.isdir(service_dir): - os.makedirs(service_dir) - return service_dir - -def get_user_activities_dir(): +def get_user_activities_path(): path = os.path.expanduser('~/Activities') if not os.path.isdir(path): os.mkdir(path) return path +def get_bin_path(path=None): + return _get_prefix_path('bin', path) + +def get_service_path(name): + return _get_prefix_path('share/sugar/services', name) + +def get_shell_path(path=None): + return _get_prefix_path('share/sugar/shell', path) + +def get_emulator_path(path=None): + return _get_prefix_path('share/sugar/emulator', path) diff --git a/sugar/graphics/Makefile.am b/sugar/graphics/Makefile.am index 6a45b3c7..9479ea23 100644 --- a/sugar/graphics/Makefile.am +++ b/sugar/graphics/Makefile.am @@ -20,6 +20,7 @@ sugar_PYTHON = \ snowflakebox.py \ spreadbox.py \ timeline.py \ + toggleiconbutton.py \ toolbar.py \ units.py \ window.py \ diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py index 3438c829..a805087f 100644 --- a/sugar/graphics/canvasicon.py +++ b/sugar/graphics/canvasicon.py @@ -176,7 +176,6 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): hippo.CanvasBox.__init__(self, **kwargs) - self.connect_after('button-press-event', self._button_press_event_cb) self.connect_after('motion-notify-event', self._motion_notify_event_cb) def _clear_buffers(self): @@ -326,9 +325,9 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): [width, height] = self._get_icon_size() return height - def _button_press_event_cb(self, item, event): - item.emit_activated() - return False + def do_button_press_event(self, event): + self.emit_activated() + return True def get_popup(self): if self._tooltip: diff --git a/sugar/graphics/color.py b/sugar/graphics/color.py index 068aa160..1aa0b916 100644 --- a/sugar/graphics/color.py +++ b/sugar/graphics/color.py @@ -21,7 +21,8 @@ _system_colors = { 'button-hover' : '#808080', 'button-background-hover' : '#000000', 'icon-stroke-inactive' : '#757575', - 'icon-fill-inactive' : '#9D9FA1' + 'icon-fill-inactive' : '#9D9FA1', + 'toggle-button-background' : '#A1A5A8' } def _html_to_rgb(html_color): @@ -100,3 +101,4 @@ BUTTON_HOVER = SystemColor('button-hover') BUTTON_BACKGROUND_HOVER = SystemColor('button-background-hover') ICON_FILL_INACTIVE = SystemColor('icon-fill-inactive') ICON_STROKE_INACTIVE = SystemColor('icon-stroke-inactive') +TOGGLE_BUTTON_BACKGROUND = SystemColor('toggle-button-background') diff --git a/sugar/graphics/iconbutton.py b/sugar/graphics/iconbutton.py index 822ddf1f..be08ead8 100644 --- a/sugar/graphics/iconbutton.py +++ b/sugar/graphics/iconbutton.py @@ -27,7 +27,7 @@ from sugar.graphics import color STANDARD_SIZE = 0 SMALL_SIZE = 1 -class IconButton(CanvasIcon): +class IconButton(CanvasIcon, hippo.CanvasItem): __gtype_name__ = 'SugarIconButton' __gproperties__ = { @@ -45,9 +45,6 @@ class IconButton(CanvasIcon): self._set_size(STANDARD_SIZE) - self.connect('button-press-event', - self._icon_button_button_press_event_cb) - def _set_size(self, size): if size == SMALL_SIZE: self.props.box_width = -1 @@ -72,7 +69,7 @@ class IconButton(CanvasIcon): else: return CanvasIcon.do_get_property(self, pspec) - def _icon_button_button_press_event_cb(self, widget, event): + def do_button_press_event(self, event): if self._active: self.emit_activated() return True diff --git a/sugar/graphics/toggleiconbutton.py b/sugar/graphics/toggleiconbutton.py new file mode 100644 index 00000000..06f55217 --- /dev/null +++ b/sugar/graphics/toggleiconbutton.py @@ -0,0 +1,69 @@ +# Copyright (C) 2007, Red Hat +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import gobject +import hippo + +from sugar.graphics.iconbutton import IconButton +from sugar.graphics import color + +class ToggleIconButton(IconButton, hippo.CanvasItem): + __gtype_name__ = 'SugarToggleIconButton' + + __gproperties__ = { + 'toggled' : (bool, None, None, False, + gobject.PARAM_READWRITE) + } + + def __init__(self, **kwargs): + self._toggled = False + + IconButton.__init__(self, **kwargs) + + def _get_bg_color(self): + if self._toggled: + col = color.TOGGLE_BUTTON_BACKGROUND + else: + col = color.BUTTON_BACKGROUND_NORMAL + + return col.get_int() + + def _set_toggled(self, toggled): + self._toggled = toggled + self.props.background_color = self._get_bg_color() + + def do_set_property(self, pspec, value): + if pspec.name == 'toggled': + self._set_toggled(value) + else: + IconButton.do_set_property(self, pspec, value) + + def do_get_property(self, pspec): + if pspec.name == 'toggled': + return self._toggled + + return IconButton.do_get_property(self, pspec) + + def do_button_press_event(self, event): + self.props.toggled = not self._toggled + return True + + def prelight(self, enter): + if enter: + IconButton.prelight(self, enter) + else: + self.props.background_color = self._get_bg_color() diff --git a/tests/test-button.py b/tests/test-button.py index 0f3ded26..9cceb92d 100755 --- a/tests/test-button.py +++ b/tests/test-button.py @@ -23,12 +23,16 @@ import hippo from sugar.graphics.toolbar import Toolbar from sugar.graphics.iconbutton import IconButton +from sugar.graphics.toggleiconbutton import ToggleIconButton from sugar.graphics.button import Button from sugar.graphics.entry import Entry def _button_activated_cb(button): print "_button_activated_cb" +def _toggled_changed_cb(button, pspec): + print "Toggle state: %d" % button.props.toggled + window = gtk.Window() window.connect("destroy", lambda w: gtk.main_quit()) window.show() @@ -48,6 +52,10 @@ for i in [1, 2]: icon_button = IconButton(icon_name='theme:stock-close') toolbar.append(icon_button) + toggle = ToggleIconButton(icon_name='theme:stock-back') + toggle.connect('notify::toggled', _toggled_changed_cb) + toolbar.append(toggle) + button = Button(text='Click me!', icon_name='theme:stock-close') button.connect('activated', _button_activated_cb) toolbar.append(button) diff --git a/tools/sugar-install-bundle b/tools/sugar-install-bundle index 971d9743..a66cd81c 100755 --- a/tools/sugar-install-bundle +++ b/tools/sugar-install-bundle @@ -27,7 +27,7 @@ bus = dbus.SessionBus() proxy_obj = bus.get_object(DBUS_SERVICE, DBUS_PATH) dbus_service = dbus.Interface(proxy_obj, DBUS_SERVICE) -bundle_dir = env.get_user_activities_dir() +bundle_dir = env.get_user_activities_path() zip_file = zipfile.ZipFile(sys.argv[1]) file_names = zip_file.namelist()