Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-03-09 13:57:54 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-03-09 13:57:54 (GMT)
commit57c928916ca7cdacd728834a9b59ecc33b55339e (patch)
tree2cc618248d665cde0790853d0d169754271fd21c
parenta380b7f915ca32293315176027f835fb739bb86b (diff)
Refactor sugar.env and paths
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac2
-rw-r--r--emulator/Makefile.am (renamed from shell/data/Makefile.am)2
-rw-r--r--emulator/kbdconfig (renamed from shell/data/kbdconfig)0
-rwxr-xr-xservices/clipboard/sugar-clipboard2
-rwxr-xr-xservices/console/sugar-console2
-rwxr-xr-xservices/datastore/sugar-data-store2
-rwxr-xr-xservices/presence/sugar-presence-service2
-rwxr-xr-xservices/presence2/sugar-presence-service22
-rw-r--r--shell/Makefile.am2
-rwxr-xr-xshell/sugar-shell2
-rwxr-xr-xsugar-emulator4
-rw-r--r--sugar/activity/bundle.py3
-rw-r--r--sugar/activity/bundlebuilder.py4
-rw-r--r--sugar/activity/bundleregistry.py18
-rw-r--r--sugar/env.py43
-rw-r--r--sugar/graphics/canvasicon.py2
-rwxr-xr-xtools/sugar-install-bundle2
18 files changed, 55 insertions, 41 deletions
diff --git a/Makefile.am b/Makefile.am
index 4606e90..7394eac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = lib po shell sugar services tools
+SUBDIRS = emulator lib po shell sugar services tools
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 0ae1e15..ce30bd7 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
diff --git a/shell/data/Makefile.am b/emulator/Makefile.am
index 1f0f9c0..d0386c7 100644
--- a/shell/data/Makefile.am
+++ b/emulator/Makefile.am
@@ -1,4 +1,4 @@
-confdir = $(pkgdatadir)
+confdir = $(pkgdatadir)/emulator
conf_DATA = kbdconfig
EXTRA_DIST = $(conf_DATA)
diff --git a/shell/data/kbdconfig b/emulator/kbdconfig
index 415c69f..415c69f 100644
--- a/shell/data/kbdconfig
+++ b/emulator/kbdconfig
diff --git a/services/clipboard/sugar-clipboard b/services/clipboard/sugar-clipboard
index 576145c..9ee32e7 100755
--- a/services/clipboard/sugar-clipboard
+++ b/services/clipboard/sugar-clipboard
@@ -32,7 +32,7 @@ import dbus.glib
from sugar import env
-sys.path.insert(0, os.path.join(env.get_data_dir(), 'services/clipboard'))
+sys.path.insert(0, env.get_service_path('clipboard'))
from clipboardservice import ClipboardService
diff --git a/services/console/sugar-console b/services/console/sugar-console
index 2f2fc4f..d4d7af0 100755
--- a/services/console/sugar-console
+++ b/services/console/sugar-console
@@ -7,6 +7,6 @@ import os
import sys
from sugar import env
-sys.path.insert(0, os.path.join(env.get_data_dir(), 'services/console'))
+sys.path.insert(0, env.get_service_path('console'))
import console
diff --git a/services/datastore/sugar-data-store b/services/datastore/sugar-data-store
index 9ab14fe..003e273 100755
--- a/services/datastore/sugar-data-store
+++ b/services/datastore/sugar-data-store
@@ -24,7 +24,7 @@ import logging
from sugar import logger
from sugar import env
-sys.path.insert(0, os.path.join(env.get_data_dir(), 'services/datastore'))
+sys.path.insert(0, env.get_service_path('datastore'))
logger.start('data-store')
logging.info('Starting the data store...')
diff --git a/services/presence/sugar-presence-service b/services/presence/sugar-presence-service
index 50c1217..be9c0e0 100755
--- a/services/presence/sugar-presence-service
+++ b/services/presence/sugar-presence-service
@@ -24,7 +24,7 @@ import os
from sugar import logger
from sugar import env
-sys.path.insert(0, os.path.join(env.get_data_dir(), 'services/presence'))
+sys.path.insert(0, env.get_service_path('presence'))
logger.start('presenceservice')
diff --git a/services/presence2/sugar-presence-service2 b/services/presence2/sugar-presence-service2
index f71344a..83ff58d 100755
--- a/services/presence2/sugar-presence-service2
+++ b/services/presence2/sugar-presence-service2
@@ -24,7 +24,7 @@ import os
from sugar import logger
from sugar import env
-sys.path.insert(0, os.join.path(env.get_data_dir(), 'services/presence2'))
+sys.path.insert(0, env.get_service_path('presence2'))
logger.start('presenceservice')
diff --git a/shell/Makefile.am b/shell/Makefile.am
index c1185b3..0d881ed 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/sugar-shell b/shell/sugar-shell
index 92cefc3..4b67e96 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/sugar-emulator b/sugar-emulator
index c87dc71..d31010d 100755
--- a/sugar-emulator
+++ b/sugar-emulator
@@ -56,9 +56,9 @@ else:
dpi = min(_sugar.get_screen_dpi(), 96)
if sourcedir:
- kbd_config = os.path.join(sourcedir, 'shell/data/kbdconfig')
+ kbd_config = os.path.join(sourcedir, 'emulator/kbdconfig')
else:
- kbd_config = os.path.join(env.get_data_dir(), 'kbdconfig')
+ kbd_config = os.path.join(env.get_emulator_path('kbdconfig'))
emulator = Emulator(width, height, dpi)
emulator.set_keyboard_config(kbd_config)
diff --git a/sugar/activity/bundle.py b/sugar/activity/bundle.py
index 283204f..8980a11 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 c223bfa..120e7b8 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 08f543f..2ad68ed 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/env.py b/sugar/env.py
index 7d6cc7c..d32c1cb 100644
--- a/sugar/env.py
+++ b/sugar/env.py
@@ -24,6 +24,17 @@ try:
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'):
if os.environ['SUGAR_EMULATOR'] == 'yes':
@@ -45,28 +56,20 @@ def get_profile_path():
return path
-def get_data_dir():
- return sugar_data_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/canvasicon.py b/sugar/graphics/canvasicon.py
index 6f7a0a9..a805087 100644
--- a/sugar/graphics/canvasicon.py
+++ b/sugar/graphics/canvasicon.py
@@ -326,7 +326,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
return height
def do_button_press_event(self, event):
- item.emit_activated()
+ self.emit_activated()
return True
def get_popup(self):
diff --git a/tools/sugar-install-bundle b/tools/sugar-install-bundle
index 971d974..a66cd81 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()