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

This commit is contained in:
Mike C. Fletcher
2007-04-21 14:05:08 -04:00
73 changed files with 2200 additions and 1149 deletions
+7 -6
View File
@@ -1,10 +1,11 @@
SUBDIRS = activity browser clipboard graphics p2p presence datastore
sugardir = $(pythondir)/sugar
sugar_PYTHON = \
__init__.py \
date.py \
env.py \
logger.py \
profile.py \
sugar_PYTHON = \
__init__.py \
date.py \
env.py \
logger.py \
ltihooks.py \
profile.py \
util.py
+1 -1
View File
@@ -140,7 +140,7 @@ def run_with_args(args):
run(options.bundle_path)
def run(bundle_path):
sys.path.insert(0, bundle_path)
sys.path.append(bundle_path)
bundle = Bundle(bundle_path)
+6 -1
View File
@@ -3,4 +3,9 @@
XUL Runner and gtkmozembed and is produced by the PyGTK
.defs system.
"""
from sugar.browser._sugarbrowser import *
try:
from sugar.browser._sugarbrowser import *
except ImportError:
from sugar import ltihooks
from sugar.browser._sugarbrowser import *
+17 -6
View File
@@ -29,6 +29,17 @@ def _get_prefix_path(base, path=None):
else:
return os.path.join(prefix, base)
def _get_sugar_path(base, path=None):
if os.environ.has_key('SUGAR_PATH'):
sugar_path = os.environ['SUGAR_PATH']
else:
sugar_path = _get_prefix_path('share/sugar')
if path:
return os.path.join(sugar_path, base, path)
else:
return os.path.join(sugar_path, base)
def is_emulator():
if os.environ.has_key('SUGAR_EMULATOR'):
if os.environ['SUGAR_EMULATOR'] == 'yes':
@@ -56,17 +67,17 @@ def get_profile_path(path=None):
def get_user_activities_path():
return os.path.expanduser('~/Activities')
def get_bin_path(path=None):
return _get_prefix_path('bin', path)
def get_locale_path(path=None):
return _get_prefix_path('share/locale', path)
def get_bin_path(path=None):
return _get_sugar_path('bin', path)
def get_service_path(name):
return _get_prefix_path('share/sugar/services', name)
return _get_sugar_path('services', name)
def get_shell_path(path=None):
return _get_prefix_path('share/sugar/shell', path)
return _get_sugar_path('shell', path)
def get_data_path(path=None):
return _get_prefix_path('share/sugar', path)
return _get_sugar_path('data', path)
+6 -2
View File
@@ -28,7 +28,7 @@ class Animator(gobject.GObject):
gobject.TYPE_NONE, ([])),
}
def __init__(self, time, fps, easing=EASE_OUT_EXPO):
def __init__(self, time, fps=20, easing=EASE_OUT_EXPO):
gobject.GObject.__init__(self)
self._animations = []
self._time = time
@@ -39,6 +39,10 @@ class Animator(gobject.GObject):
def add(self, animation):
self._animations.append(animation)
def remove_all(self):
self.stop()
self._animations = []
def start(self):
if self._timeout_sid:
self.stop()
@@ -51,7 +55,7 @@ class Animator(gobject.GObject):
if self._timeout_sid:
gobject.source_remove(self._timeout_sid)
self._timeout_sid = 0
self.emit('completed')
self.emit('completed')
def _next_frame_cb(self):
current_time = min(self._time, time.time() - self._start_time)
+5
View File
@@ -369,6 +369,11 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
if not self._popup:
return
if not self.get_context():
# If we have been detached from our parent, don't show up the popup
# in this case.
return
popup_context = self.get_popup_context()
[x, y] = [None, None]
+11 -2
View File
@@ -20,9 +20,11 @@ import math
import cairo
import hippo
_BASE_RADIUS = 65
from sugar.graphics import units
_BASE_RADIUS = units.points_to_pixels(20)
_CHILDREN_FACTOR = 1
_FLAKE_DISTANCE = 6
_FLAKE_DISTANCE = units.points_to_pixels(4)
class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarSnowflakeBox'
@@ -67,6 +69,13 @@ class SnowflakeBox(hippo.CanvasBox, hippo.CanvasItem):
self.set_position(child, int(x), int(y))
def do_get_height_request(self, for_width):
hippo.CanvasBox.do_get_height_request(self, for_width)
height = for_width
return (height, height)
def do_get_width_request(self):
hippo.CanvasBox.do_get_width_request(self)
+22 -3
View File
@@ -22,20 +22,31 @@ import gtk
from sugar.graphics import units
_WIDTH = gtk.gdk.screen_width()
_HEIGHT = gtk.gdk.screen_height()
_CELL_WIDTH = units.grid_to_pixels(1)
_CELL_HEIGHT = units.grid_to_pixels(1)
_GRID_WIDTH = gtk.gdk.screen_width() / _CELL_WIDTH
_GRID_HEIGHT = gtk.gdk.screen_height() / _CELL_HEIGHT
_GRID_WIDTH = _WIDTH / _CELL_WIDTH
_GRID_HEIGHT = _HEIGHT / _CELL_HEIGHT
class SpreadBox(hippo.CanvasBox):
class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'SugarSpreadBox'
def __init__(self, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
self._grid = []
self._center = None
for i in range(0, _GRID_WIDTH * _GRID_HEIGHT):
self._grid.append(None)
def set_center_item(self, item):
if self._center:
self.remove(self._center)
self._center = item
self.append(item, hippo.PACK_FIXED)
def add_item(self, item):
start_pos = int(random.random() * len(self._grid))
@@ -60,3 +71,11 @@ class SpreadBox(hippo.CanvasBox):
if self._grid[i] == item:
self._grid[i] = None
self.remove(item)
def do_allocate(self, width, height, origin_changed):
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
if self._center:
[icon_width, icon_height] = self._center.get_allocation()
self.set_position(self._center, (width - icon_width) / 2,
(height - icon_height) / 2)
+5
View File
@@ -0,0 +1,5 @@
sugardir = $(pythondir)/sugar/graphics2
sugar_PYTHON = \
__init__.py \
window.py \
toolbox.py
View File
+32
View File
@@ -0,0 +1,32 @@
# Copyright (C) 2007, Red Hat, Inc.
#
# 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 gtk
class Toolbox(gtk.VBox):
__gtype_name__ = 'SugarToolbox'
def __init__(self):
gtk.VBox.__init__(self)
self._notebook = gtk.Notebook()
self._notebook.set_tab_pos(gtk.POS_BOTTOM)
self._notebook.set_show_border(False)
self.pack_start(self._notebook)
self._notebook.show()
def add_toolbar(self, name, toolbar):
self._notebook.append_page(toolbar, gtk.Label(name))
+49
View File
@@ -0,0 +1,49 @@
# Copyright (C) 2007, Red Hat, Inc.
#
# 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 gtk
import hippo
from sugar.graphics2.toolbox import Toolbox
class Window(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
vbox = gtk.VBox()
self.add(vbox)
self.toolbox = Toolbox()
vbox.pack_start(self.toolbox, False)
self.toolbox.show()
self._canvas_box = gtk.VBox()
vbox.pack_start(self._canvas_box)
self._canvas_box.show()
self.canvas = hippo.Canvas()
self._canvas_box.pack_start(self.canvas)
self.canvas.show()
vbox.show()
def set_canvas(self, canvas):
if self.canvas:
self._canvas_box.remove(self.canvas)
self._canvas_box.add(canvas)
self.canvas = canvas
+72
View File
@@ -0,0 +1,72 @@
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
# ltihooks.py: python import hooks that understand libtool libraries.
# Copyright (C) 2000 James Henstridge.
# renamed to gstltihooks.py so it does not accidentally get imported by
# an installed copy of gtk
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os, ihooks
class LibtoolHooks(ihooks.Hooks):
def get_suffixes(self):
"""Like normal get_suffixes, but adds .la suffixes to list"""
ret = ihooks.Hooks.get_suffixes(self)
ret.insert(0, ('module.la', 'rb', 3))
ret.insert(0, ('.la', 'rb', 3))
return ret
def load_dynamic(self, name, filename, file=None):
"""Like normal load_dynamic, but treat .la files specially"""
if len(filename) > 3 and filename[-3:] == '.la':
fp = open(filename, 'r')
dlname = ''
installed = 1
line = fp.readline()
while line:
# dlname: the name that we can dlopen
if len(line) > 7 and line[:7] == 'dlname=':
dlname = line[8:-2]
# installed: whether it's already installed
elif len(line) > 10 and line[:10] == 'installed=':
installed = line[10:-1] == 'yes'
line = fp.readline()
fp.close()
if dlname:
if installed:
filename = os.path.join(os.path.dirname(filename),
dlname)
else:
# if .libs already there, don't need to add it again
if os.path.dirname(filename).endswith('.libs'):
filename = os.path.join(os.path.dirname(filename),
dlname)
else:
filename = os.path.join(os.path.dirname(filename),
'.libs', dlname)
return ihooks.Hooks.load_dynamic(self, name, filename, file)
importer = ihooks.ModuleImporter()
importer.set_hooks(LibtoolHooks())
def install():
print 'Installed ltihooks.'
importer.install()
def uninstall():
importer.uninstall()
install()
+13
View File
@@ -337,6 +337,19 @@ class PresenceService(gobject.GObject):
reply_handler=lambda *args: self._share_activity_cb(activity, *args),
error_handler=lambda *args: self._share_activity_error_cb(activity, *args))
def get_preferred_connection(self):
"""Gets the preferred telepathy connection object that an activity
should use when talking directly to telepathy
returns the bus name and the object path of the Telepathy connection"""
try:
bus_name, object_path = self._ps.GetPreferredConnection()
except dbus.exceptions.DBusException:
return None
return bus_name, object_path
class _MockPresenceService(gobject.GObject):
"""Test fixture allowing testing of items that use PresenceService