Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Dan Williams 2007-03-09 10:18:37 -05:00
commit f1aa2cf11a
33 changed files with 189 additions and 133 deletions

View File

@ -1,10 +1,9 @@
SUBDIRS = lib po shell sugar services tools SUBDIRS = emulator lib po shell sugar services tools
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
bin_SCRIPTS = \ bin_SCRIPTS = \
sugar-emulator \ sugar-emulator
sugar-emulator-shutdown
DISTCLEANFILES = \ DISTCLEANFILES = \
intltool-extract \ intltool-extract \

View File

@ -104,6 +104,7 @@ AM_GLIB_GNU_GETTEXT
AC_OUTPUT([ AC_OUTPUT([
Makefile Makefile
emulator/Makefile
lib/Makefile lib/Makefile
lib/data/Makefile lib/data/Makefile
lib/src/Makefile lib/src/Makefile
@ -116,7 +117,6 @@ services/clipboard/Makefile
services/datastore/Makefile services/datastore/Makefile
shell/Makefile shell/Makefile
shell/intro/Makefile shell/intro/Makefile
shell/data/Makefile
shell/hardware/Makefile shell/hardware/Makefile
shell/view/Makefile shell/view/Makefile
shell/view/devices/Makefile shell/view/devices/Makefile
@ -138,7 +138,6 @@ services/console/interface/memphis/Makefile
services/console/interface/logviewer/Makefile services/console/interface/logviewer/Makefile
services/console/interface/terminal/Makefile services/console/interface/terminal/Makefile
sugar/Makefile sugar/Makefile
sugar/__installed__.py
sugar/activity/Makefile sugar/activity/Makefile
sugar/chat/Makefile sugar/chat/Makefile
sugar/chat/sketchpad/Makefile sugar/chat/sketchpad/Makefile

4
emulator/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
confdir = $(pkgdatadir)/emulator
conf_DATA = kbdconfig
EXTRA_DIST = $(conf_DATA)

View File

@ -5,5 +5,3 @@
<Alt>n=next <Alt>n=next
<Alt>p=prev <Alt>p=prev
<Alt>c=close <Alt>c=close
<Alt>q=!sugar-emulator-shutdown

View File

@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys import sys
import os
import logging import logging
from sugar import logger from sugar import logger
@ -31,9 +32,9 @@ import dbus.glib
from sugar import env 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.') logging.info('Starting clipboard service.')

View File

@ -3,9 +3,10 @@
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import os, sys import os
import sys
from sugar import env 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

View File

@ -18,16 +18,17 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys import sys
import os
import logging import logging
from sugar import logger from sugar import logger
from sugar import env 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') logger.start('data-store')
logging.info('Starting the data store...') logging.info('Starting the data store...')
from datastore import datastore import datastore
datastore.main() datastore.main()

View File

@ -24,11 +24,11 @@ import os
from sugar import logger from sugar import logger
from sugar import env from sugar import env
sys.path.insert(0, env.get_services_dir()) sys.path.insert(0, env.get_service_path('presence'))
logger.start('presenceservice') logger.start('presenceservice')
from presence import PresenceService import PresenceService
logging.info('Starting presence service') logging.info('Starting presence service')

View File

@ -24,11 +24,11 @@ import os
from sugar import logger from sugar import logger
from sugar import env from sugar import env
sys.path.insert(0, env.get_services_dir()) sys.path.insert(0, env.get_service_path('presence2'))
logger.start('presenceservice') logger.start('presenceservice')
from presence2 import presenceservice import presenceservice
logging.info('Starting presence service') logging.info('Starting presence service')

View File

@ -1,4 +1,4 @@
SUBDIRS = data hardware model view intro SUBDIRS = hardware model view intro
bin_SCRIPTS = \ bin_SCRIPTS = \
sugar-activity \ sugar-activity \

View File

@ -1,7 +0,0 @@
confdir = $(pkgdatadir)
conf_DATA = kbdconfig
imagedir = $(pkgdatadir)
image_DATA = default-picture.png
EXTRA_DIST = $(conf_DATA) $(image_DATA)

View File

@ -1,3 +1,7 @@
imagedir = $(pkgdatadir)/shell/intro
image_DATA = default-picture.png
EXTRA_DIST = $(conf_DATA) $(image_DATA)
sugardir = $(pkgdatadir)/shell/intro sugardir = $(pkgdatadir)/shell/intro
sugar_PYTHON = \ sugar_PYTHON = \
__init__.py \ __init__.py \

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -143,7 +143,8 @@ class VideoBox(hippo.CanvasBox, hippo.CanvasItem):
self._img_widget.props.widget = self._img self._img_widget.props.widget = self._img
if not has_webcam: 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) self._video.load_image(path)
def _clear_image_cb(self, widget, event): def _clear_image_cb(self, widget, event):

View File

@ -36,7 +36,7 @@ logger.cleanup()
logger.start('shell') logger.start('shell')
if len(sys.argv) == 1: 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 view.Shell import Shell
from model.ShellModel import ShellModel from model.ShellModel import ShellModel

View File

@ -1,3 +1,6 @@
import os
import signal
import dbus import dbus
import gobject import gobject
@ -34,7 +37,8 @@ _actions_table = {
'0xEB' : 'rotate', '0xEB' : 'rotate',
'<alt>r' : 'rotate', '<alt>r' : 'rotate',
'0xEC' : 'keyboard_brightness', '0xEC' : 'keyboard_brightness',
'<alt>Tab' : 'home' '<alt>Tab' : 'home',
'<alt>q' : 'quit_emulator',
} }
class KeyHandler(object): class KeyHandler(object):
@ -149,6 +153,11 @@ class KeyHandler(object):
gobject.spawn_async(['xrandr', '-o', states[self._screen_rotation]], gobject.spawn_async(['xrandr', '-o', states[self._screen_rotation]],
flags=gobject.SPAWN_SEARCH_PATH) 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): def handle_home(self):
# FIXME: finish alt+tab support # FIXME: finish alt+tab support
pass pass

View File

@ -47,17 +47,21 @@ else:
program = sys.argv[1] program = sys.argv[1]
if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900: if gtk.gdk.screen_width() < 1200 or gtk.gdk.screen_height() < 900:
fullscreen = True
width = -1 width = -1
height = -1 height = -1
else: else:
fullscreen = False
width = 1200 width = 1200
height = 900 height = 900
dpi = min(_sugar.get_screen_dpi(), 96) 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() emulator.start()
if sourcedir: if sourcedir:

View File

@ -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)

View File

@ -3,7 +3,6 @@ SUBDIRS = activity chat clipboard graphics p2p presence datastore
sugardir = $(pythondir)/sugar sugardir = $(pythondir)/sugar
sugar_PYTHON = \ sugar_PYTHON = \
__init__.py \ __init__.py \
__installed__.py \
date.py \ date.py \
emulator.py \ emulator.py \
env.py \ env.py \
@ -12,5 +11,3 @@ sugar_PYTHON = \
simulator.py \ simulator.py \
TracebackUtils.py \ TracebackUtils.py \
util.py util.py
EXTRA_DIST = __uninstalled__.py

View File

@ -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'

View File

@ -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')

View File

@ -44,8 +44,7 @@ class Bundle:
if cp.has_option(section, 'class'): if cp.has_option(section, 'class'):
self._class = cp.get(section, 'class') self._class = cp.get(section, 'class')
self._exec = '%s %s --bundle-path="%s"' % ( self._exec = '%s %s --bundle-path="%s"' % (
os.path.join(env.get_shell_bin_dir(), _PYTHON_FACTORY), env.get_bin_path(_PYTHON_FACTORY), self._class, self.get_path())
self._class, self.get_path())
elif cp.has_option(section, 'exec'): elif cp.has_option(section, 'exec'):
self._class = None self._class = None
self._exec = cp.get(section, 'exec') self._exec = cp.get(section, 'exec')

View File

@ -93,7 +93,7 @@ def _get_install_dir(prefix):
return os.path.join(prefix, 'share/activities') return os.path.join(prefix, 'share/activities')
def _get_bundle_path(): 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(): def _get_package_name():
bundle = Bundle(_get_source_path()) bundle = Bundle(_get_source_path())
@ -120,7 +120,7 @@ setup.py help - print this message \n\
' '
def cmd_dev(): 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: try:
os.symlink(_get_source_path(), bundle_path) os.symlink(_get_source_path(), bundle_path)
except OSError: except OSError:

View File

@ -1,14 +1,26 @@
import os import os
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
import gobject import gobject
from sugar.activity.bundle import Bundle from sugar.activity.bundle import Bundle
from sugar import env from sugar import env
from sugar import util 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): class _ServiceManager(object):
def __init__(self): 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): def add(self, bundle):
util.write_service(bundle.get_service_name(), util.write_service(bundle.get_service_name(),
@ -74,8 +86,8 @@ def get_registry():
_bundle_registry = BundleRegistry() _bundle_registry = BundleRegistry()
for path in env.get_data_dirs(): for path in _get_data_dirs():
bundles_path = os.path.join(path, 'activities') bundles_path = os.path.join(path, 'activities')
_bundle_registry.add_search_path(bundles_path) _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())

View File

@ -64,13 +64,13 @@ class Process:
self._stdout = result[2] self._stdout = result[2]
class MatchboxProcess(Process): class MatchboxProcess(Process):
def __init__(self): def __init__(self, kbd_config):
kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig') options = '-use_titlebar no '
options = '-kbdconfig %s ' % kbd_config
options += '-use_titlebar no '
options += '-theme olpc ' options += '-theme olpc '
if kbd_config:
options += '-kbdconfig %s ' % kbd_config
command = 'matchbox-window-manager %s ' % options command = 'matchbox-window-manager %s ' % options
Process.__init__(self, command) Process.__init__(self, command)
@ -78,15 +78,14 @@ class MatchboxProcess(Process):
return 'Matchbox' return 'Matchbox'
class XephyrProcess(Process): class XephyrProcess(Process):
def __init__(self, width, height, fullscreen, dpi): def __init__(self, width, height, dpi):
self._display = get_display_number() self._display = get_display_number()
cmd = 'Xephyr :%d -ac ' % (self._display) cmd = 'Xephyr :%d -ac ' % (self._display)
if fullscreen:
cmd += ' -fullscreen '
if width > 0 and height > 0: if width > 0 and height > 0:
cmd += ' -screen %dx%d' % (width, height) cmd += ' -screen %dx%d' % (width, height)
else:
cmd += ' -fullscreen '
if dpi > 0: if dpi > 0:
cmd += ' -dpi %d' % (dpi) cmd += ' -dpi %d' % (dpi)
@ -99,24 +98,26 @@ class XephyrProcess(Process):
def start(self, standard_output=False): def start(self, standard_output=False):
Process.start(self) Process.start(self)
os.environ['DISPLAY'] = ":%d" % (self._display) 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): class Emulator(object):
"""The OLPC emulator""" """The OLPC emulator"""
def __init__(self, width, height, fullscreen, dpi): def __init__(self, width, height, dpi):
self._fullscreen = fullscreen self._keyboard_config = None
self._width = width self._width = width
self._height = height self._height = height
self._dpi = dpi self._dpi = dpi
def set_keyboard_config(self, config):
self._keyboard_config = config
def start(self): def start(self):
try: try:
process = XephyrProcess(self._width, self._height, process = XephyrProcess(self._width, self._height, self._dpi)
self._fullscreen, self._dpi)
process.start() process.start()
except: except:
print 'Cannot run the emulator. You need to install Xephyr' print 'Cannot run the emulator. You need to install Xephyr'
sys.exit(0) sys.exit(0)
process = MatchboxProcess() process = MatchboxProcess(self._keyboard_config)
process.start() process.start()

View File

@ -16,13 +16,17 @@
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
import os import os
import sys
import pwd
try: def _get_prefix_path(base, path=None):
from sugar.__uninstalled__ import * if os.environ.has_key('SUGAR_PREFIX'):
except ImportError: prefix = os.environ['SUGAR_PREFIX']
from sugar.__installed__ import * else:
prefix = '/usr'
if path:
return os.path.join(prefix, base, path)
else:
return os.path.join(prefix, base)
def is_emulator(): def is_emulator():
if os.environ.has_key('SUGAR_EMULATOR'): if os.environ.has_key('SUGAR_EMULATOR'):
@ -45,31 +49,20 @@ def get_profile_path():
return path return path
def get_data_dir(): def get_user_activities_path():
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():
path = os.path.expanduser('~/Activities') path = os.path.expanduser('~/Activities')
if not os.path.isdir(path): if not os.path.isdir(path):
os.mkdir(path) os.mkdir(path)
return 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)

View File

@ -20,6 +20,7 @@ sugar_PYTHON = \
snowflakebox.py \ snowflakebox.py \
spreadbox.py \ spreadbox.py \
timeline.py \ timeline.py \
toggleiconbutton.py \
toolbar.py \ toolbar.py \
units.py \ units.py \
window.py \ window.py \

View File

@ -176,7 +176,6 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
hippo.CanvasBox.__init__(self, **kwargs) 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) self.connect_after('motion-notify-event', self._motion_notify_event_cb)
def _clear_buffers(self): def _clear_buffers(self):
@ -326,9 +325,9 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
[width, height] = self._get_icon_size() [width, height] = self._get_icon_size()
return height return height
def _button_press_event_cb(self, item, event): def do_button_press_event(self, event):
item.emit_activated() self.emit_activated()
return False return True
def get_popup(self): def get_popup(self):
if self._tooltip: if self._tooltip:

View File

@ -21,7 +21,8 @@ _system_colors = {
'button-hover' : '#808080', 'button-hover' : '#808080',
'button-background-hover' : '#000000', 'button-background-hover' : '#000000',
'icon-stroke-inactive' : '#757575', 'icon-stroke-inactive' : '#757575',
'icon-fill-inactive' : '#9D9FA1' 'icon-fill-inactive' : '#9D9FA1',
'toggle-button-background' : '#A1A5A8'
} }
def _html_to_rgb(html_color): def _html_to_rgb(html_color):
@ -100,3 +101,4 @@ BUTTON_HOVER = SystemColor('button-hover')
BUTTON_BACKGROUND_HOVER = SystemColor('button-background-hover') BUTTON_BACKGROUND_HOVER = SystemColor('button-background-hover')
ICON_FILL_INACTIVE = SystemColor('icon-fill-inactive') ICON_FILL_INACTIVE = SystemColor('icon-fill-inactive')
ICON_STROKE_INACTIVE = SystemColor('icon-stroke-inactive') ICON_STROKE_INACTIVE = SystemColor('icon-stroke-inactive')
TOGGLE_BUTTON_BACKGROUND = SystemColor('toggle-button-background')

View File

@ -27,7 +27,7 @@ from sugar.graphics import color
STANDARD_SIZE = 0 STANDARD_SIZE = 0
SMALL_SIZE = 1 SMALL_SIZE = 1
class IconButton(CanvasIcon): class IconButton(CanvasIcon, hippo.CanvasItem):
__gtype_name__ = 'SugarIconButton' __gtype_name__ = 'SugarIconButton'
__gproperties__ = { __gproperties__ = {
@ -45,9 +45,6 @@ class IconButton(CanvasIcon):
self._set_size(STANDARD_SIZE) self._set_size(STANDARD_SIZE)
self.connect('button-press-event',
self._icon_button_button_press_event_cb)
def _set_size(self, size): def _set_size(self, size):
if size == SMALL_SIZE: if size == SMALL_SIZE:
self.props.box_width = -1 self.props.box_width = -1
@ -72,7 +69,7 @@ class IconButton(CanvasIcon):
else: else:
return CanvasIcon.do_get_property(self, pspec) 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: if self._active:
self.emit_activated() self.emit_activated()
return True return True

View File

@ -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()

View File

@ -23,12 +23,16 @@ import hippo
from sugar.graphics.toolbar import Toolbar from sugar.graphics.toolbar import Toolbar
from sugar.graphics.iconbutton import IconButton from sugar.graphics.iconbutton import IconButton
from sugar.graphics.toggleiconbutton import ToggleIconButton
from sugar.graphics.button import Button from sugar.graphics.button import Button
from sugar.graphics.entry import Entry from sugar.graphics.entry import Entry
def _button_activated_cb(button): def _button_activated_cb(button):
print "_button_activated_cb" print "_button_activated_cb"
def _toggled_changed_cb(button, pspec):
print "Toggle state: %d" % button.props.toggled
window = gtk.Window() window = gtk.Window()
window.connect("destroy", lambda w: gtk.main_quit()) window.connect("destroy", lambda w: gtk.main_quit())
window.show() window.show()
@ -48,6 +52,10 @@ for i in [1, 2]:
icon_button = IconButton(icon_name='theme:stock-close') icon_button = IconButton(icon_name='theme:stock-close')
toolbar.append(icon_button) 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 = Button(text='Click me!', icon_name='theme:stock-close')
button.connect('activated', _button_activated_cb) button.connect('activated', _button_activated_cb)
toolbar.append(button) toolbar.append(button)

View File

@ -27,7 +27,7 @@ bus = dbus.SessionBus()
proxy_obj = bus.get_object(DBUS_SERVICE, DBUS_PATH) proxy_obj = bus.get_object(DBUS_SERVICE, DBUS_PATH)
dbus_service = dbus.Interface(proxy_obj, DBUS_SERVICE) 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]) zip_file = zipfile.ZipFile(sys.argv[1])
file_names = zip_file.namelist() file_names = zip_file.namelist()