Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
5dacfdd365
@ -20,6 +20,7 @@ import sys
|
||||
import os
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
from sugar.activity import ActivityRegistry
|
||||
from sugar import env
|
||||
|
||||
# Setup the environment so that we run inside the Sugar shell
|
||||
@ -33,7 +34,6 @@ import gtk
|
||||
import dbus
|
||||
import dbus.glib
|
||||
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar.activity import activityfactory
|
||||
from sugar.activity import activityfactoryservice
|
||||
|
||||
@ -48,13 +48,15 @@ def _error_cb(handler, err):
|
||||
def print_help(self):
|
||||
sys.exit(0)
|
||||
|
||||
bundle = None
|
||||
activity_info = None
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
registry = bundleregistry.get_registry()
|
||||
bundle = registry.find_bundle(sys.argv[1])
|
||||
registry = ActivityRegistry()
|
||||
activities = registry.get_activities_for_name(sys.argv[1])
|
||||
if len(activities) > 0:
|
||||
activity_info = activities[0]
|
||||
|
||||
if bundle == None:
|
||||
if activity_info == None:
|
||||
print 'Usage:\n\n' \
|
||||
'sugar-activity [bundle]\n\n' \
|
||||
'Bundle can be a part of the service name or of bundle name.'
|
||||
@ -64,16 +66,16 @@ bus = dbus.SessionBus()
|
||||
bus_object = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
|
||||
try:
|
||||
name = bus_object.GetNameOwner(
|
||||
bundle.get_service_name(), dbus_interface='org.freedesktop.DBus')
|
||||
activity_info.service_name, dbus_interface='org.freedesktop.DBus')
|
||||
except dbus.DBusException:
|
||||
name = None
|
||||
|
||||
if name:
|
||||
print '%s is already running, creating a new instance.' % bundle.get_service_name()
|
||||
else:
|
||||
activityfactoryservice.run(bundle.get_path())
|
||||
activityfactoryservice.run(activity_info.path)
|
||||
|
||||
handler = activityfactory.create(bundle.get_service_name())
|
||||
handler = activityfactory.create(activity_info.service_name)
|
||||
handler.connect('success', _success_cb, name != None)
|
||||
handler.connect('error', _error_cb)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
a#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
import zipfile
|
||||
@ -44,7 +44,7 @@ if os.spawnlp(os.P_WAIT, 'unzip', 'unzip', sys.argv[1], '-d', bundle_dir):
|
||||
raise RuntimeError, 'An error occurred while extracting the .xo contents.'
|
||||
|
||||
# notify shell of new bundle
|
||||
if not dbus_service.add_bundle(bundle_path):
|
||||
if not dbus_service.AddBundle(bundle_path):
|
||||
# error, let's delete the just expanded bundle.
|
||||
for root, dirs, files in os.walk(bundle_path, topdown=False):
|
||||
for name in files:
|
||||
|
@ -173,7 +173,7 @@ class TestPresenceService(PresenceService):
|
||||
self.__test_num, self.__randomize)
|
||||
|
||||
def internal_get_activity(self, actid):
|
||||
return self._activities.get(actid, None):
|
||||
return self._activities.get(actid, None)
|
||||
|
||||
|
||||
def _extract_public_key(keyfile):
|
||||
|
@ -117,6 +117,9 @@ class IP4AddressMonitor(gobject.GObject):
|
||||
|
||||
sys_bus = dbus.SystemBus()
|
||||
self._watch = sys_bus.watch_name_owner(NM_SERVICE, self._nm_owner_cb)
|
||||
if not sys_bus.name_has_owner(NM_SERVICE):
|
||||
addr = self._get_address_fallback()
|
||||
self._update_address(addr)
|
||||
|
||||
def do_get_property(self, pspec):
|
||||
if pspec.name == "address":
|
||||
|
@ -4,6 +4,7 @@ sugardir = $(pkgdatadir)/shell/model
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
accesspointmodel.py \
|
||||
bundleregistry.py \
|
||||
BuddyModel.py \
|
||||
Friends.py \
|
||||
Invites.py \
|
||||
|
@ -18,7 +18,8 @@ import gobject
|
||||
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity import bundleregistry
|
||||
|
||||
from model import bundleregistry
|
||||
from model.BuddyModel import BuddyModel
|
||||
from model.accesspointmodel import AccessPointModel
|
||||
from hardware import hardwaremanager
|
||||
|
@ -1,19 +1,18 @@
|
||||
# Copyright (C) 2007, Red Hat, Inc.
|
||||
# Copyright (C) 2006, 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 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 library is distributed in the hope that it will be useful,
|
||||
# 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
|
||||
# Lesser General Public License for more details.
|
||||
# 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 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.
|
||||
# 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
|
||||
|
||||
@ -74,18 +73,6 @@ class BundleRegistry(gobject.GObject):
|
||||
self._search_path = []
|
||||
self._service_manager = _ServiceManager()
|
||||
|
||||
def find_bundle(self, key):
|
||||
"""Find a bundle in the registry"""
|
||||
key = key.lower()
|
||||
|
||||
for bundle in self._bundles.values():
|
||||
name = bundle.get_name().lower()
|
||||
service_name = bundle.get_service_name().lower()
|
||||
if name.find(key) != -1 or service_name.find(key) != -1:
|
||||
return bundle
|
||||
|
||||
return None
|
||||
|
||||
def get_bundle(self, service_name):
|
||||
"""Returns an bundle given his service name"""
|
||||
if self._bundles.has_key(service_name):
|
@ -22,7 +22,7 @@ import dbus
|
||||
|
||||
from model.homeactivity import HomeActivity
|
||||
from model.homerawwindow import HomeRawWindow
|
||||
from sugar.activity import bundleregistry
|
||||
from model import bundleregistry
|
||||
|
||||
_SERVICE_NAME = "org.laptop.Activity"
|
||||
_SERVICE_PATH = "/org/laptop/Activity"
|
||||
|
@ -1,11 +1,30 @@
|
||||
# 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
|
||||
|
||||
"""D-bus service providing access to the shell's functionality"""
|
||||
import dbus
|
||||
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar.activity import ActivityRegistry
|
||||
from sugar.activity import ActivityInfo
|
||||
|
||||
from model import bundleregistry
|
||||
|
||||
_DBUS_SERVICE = "org.laptop.Shell"
|
||||
_DBUS_INTERFACE = "org.laptop.Shell"
|
||||
_DBUS_OWNER_INTERFACE = "org.laptop.Shell.Owner"
|
||||
_DBUS_ACTIVITY_REGISTRY_IFACE = "org.laptop.Shell.ActivityRegistry"
|
||||
_DBUS_OWNER_IFACE = "org.laptop.Shell.Owner"
|
||||
_DBUS_PATH = "/org/laptop/Shell"
|
||||
|
||||
class ShellService(dbus.service.Object):
|
||||
@ -35,14 +54,16 @@ class ShellService(dbus.service.Object):
|
||||
self._owner.connect('color-changed', self._owner_color_changed_cb)
|
||||
|
||||
self._home_model = self._shell_model.get_home()
|
||||
self._home_model.connect('active-activity-changed', self._cur_activity_changed_cb)
|
||||
self._home_model.connect('active-activity-changed',
|
||||
self._cur_activity_changed_cb)
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
|
||||
dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
|
||||
|
||||
@dbus.service.method(_DBUS_INTERFACE, in_signature="s", out_signature="b")
|
||||
def add_bundle(self, bundle_path):
|
||||
@dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature="s", out_signature="b")
|
||||
def AddBundle(self, bundle_path):
|
||||
"""Register the activity bundle with the global registry
|
||||
|
||||
bundle_path -- path to the activity bundle's root directory,
|
||||
@ -55,28 +76,55 @@ class ShellService(dbus.service.Object):
|
||||
registry = bundleregistry.get_registry()
|
||||
return registry.add_bundle(bundle_path)
|
||||
|
||||
@dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
|
||||
@dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature="s", out_signature="aa{sv}")
|
||||
def GetActivitiesForName(self, name):
|
||||
result = []
|
||||
key = name.lower()
|
||||
|
||||
for bundle in bundleregistry.get_registry():
|
||||
name = bundle.get_name().lower()
|
||||
service_name = bundle.get_service_name().lower()
|
||||
if name.find(key) != -1 or service_name.find(key) != -1:
|
||||
info = self._bundle_to_activity_info(bundle)
|
||||
result.append(info.to_dict())
|
||||
|
||||
return result
|
||||
|
||||
@dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE,
|
||||
in_signature="s", out_signature="aa{sv}")
|
||||
def GetActivitiesForType(self, mime_type):
|
||||
result = []
|
||||
|
||||
for bundle in bundleregistry.get_registry():
|
||||
if mime_type in bundle.get_mime_types():
|
||||
info = self._bundle_to_activity_info(bundle)
|
||||
result.append(info.to_dict())
|
||||
|
||||
return result
|
||||
|
||||
@dbus.service.signal(_DBUS_OWNER_IFACE, signature="s")
|
||||
def ColorChanged(self, color):
|
||||
pass
|
||||
|
||||
def _owner_color_changed_cb(self, new_color):
|
||||
self.ColorChanged(new_color.to_string())
|
||||
|
||||
@dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
|
||||
@dbus.service.signal(_DBUS_OWNER_IFACE, signature="s")
|
||||
def NickChanged(self, nick):
|
||||
pass
|
||||
|
||||
def _owner_nick_changed_cb(self, new_nick):
|
||||
self.NickChanged(new_nick)
|
||||
|
||||
@dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="ay")
|
||||
@dbus.service.signal(_DBUS_OWNER_IFACE, signature="ay")
|
||||
def IconChanged(self, icon_data):
|
||||
pass
|
||||
|
||||
def _owner_icon_changed_cb(self, new_icon):
|
||||
self.IconChanged(dbus.ByteArray(new_icon))
|
||||
|
||||
@dbus.service.signal(_DBUS_OWNER_INTERFACE, signature="s")
|
||||
@dbus.service.signal(_DBUS_OWNER_IFACE, signature="s")
|
||||
def CurrentActivityChanged(self, activity_id):
|
||||
pass
|
||||
|
||||
@ -85,3 +133,7 @@ class ShellService(dbus.service.Object):
|
||||
if new_activity:
|
||||
new_id = new_activity.get_activity_id()
|
||||
self.CurrentActivityChanged(new_id)
|
||||
|
||||
def _bundle_to_activity_info(self, bundle):
|
||||
return ActivityInfo(bundle.get_name(), bundle.get_icon(),
|
||||
bundle.get_service_name(), bundle.get_path())
|
||||
|
@ -20,14 +20,16 @@ import logging
|
||||
import gobject
|
||||
import wnck
|
||||
|
||||
from view.home.HomeWindow import HomeWindow
|
||||
from sugar.activity.activityhandle import ActivityHandle
|
||||
from sugar.graphics.popupcontext import PopupContext
|
||||
from sugar.activity import activityfactory
|
||||
import sugar
|
||||
|
||||
from view.ActivityHost import ActivityHost
|
||||
from sugar.activity import activityfactory, bundleregistry
|
||||
from view.frame.frame import Frame
|
||||
from view.keyhandler import KeyHandler
|
||||
import sugar
|
||||
from view.home.HomeWindow import HomeWindow
|
||||
from model import bundleregistry
|
||||
|
||||
class Shell(gobject.GObject):
|
||||
def __init__(self, model):
|
||||
|
@ -20,9 +20,10 @@ import logging
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.graphics.iconbutton import IconButton
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar import profile
|
||||
|
||||
from model import bundleregistry
|
||||
|
||||
class ActivityButton(IconButton):
|
||||
def __init__(self, activity, popup_context):
|
||||
IconButton.__init__(self, icon_name=activity.get_icon(),
|
||||
|
@ -17,11 +17,12 @@
|
||||
import hippo
|
||||
import gobject
|
||||
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity import bundleregistry
|
||||
|
||||
from model import bundleregistry
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
|
||||
class FriendView(hippo.CanvasBox):
|
||||
def __init__(self, shell, menu_shell, buddy, **kwargs):
|
||||
|
@ -8,4 +8,4 @@ sugar_PYTHON = \
|
||||
activityservice.py \
|
||||
bundle.py \
|
||||
bundlebuilder.py \
|
||||
bundleregistry.py
|
||||
registry.py
|
||||
|
@ -10,16 +10,7 @@ takes a small dictionary with values corresponding to a
|
||||
|
||||
sugar.activity.activityhandle.ActivityHandle
|
||||
|
||||
describing an individual instance of the activity. The
|
||||
ActivityFactory service is registered with dbus using the
|
||||
global
|
||||
|
||||
sugar.activity.bundleregistry.BundleRegistry
|
||||
|
||||
service, which creates dbus .service files in a well known
|
||||
directory. Those files tell dbus what executable to run
|
||||
in order to load the ActivityFactory which will provide
|
||||
the creation service.
|
||||
describing an individual instance of the activity.
|
||||
|
||||
Each activity so registered is described by a
|
||||
|
||||
@ -45,3 +36,6 @@ class. This class allows for querying the ID of the root
|
||||
window, requesting sharing across the network, and basic
|
||||
"what type of application are you" queries.
|
||||
"""
|
||||
|
||||
from sugar.activity.registry import ActivityRegistry
|
||||
from sugar.activity.registry import ActivityInfo
|
||||
|
@ -28,7 +28,6 @@ import gtk, gobject
|
||||
|
||||
from sugar.presence import presenceservice
|
||||
from sugar.activity.activityservice import ActivityService
|
||||
from sugar.activity import bundleregistry
|
||||
from sugar.graphics.window import Window
|
||||
from sugar.graphics.toolbox import Toolbox
|
||||
from sugar.graphics.toolbutton import ToolButton
|
||||
@ -209,7 +208,6 @@ class Activity(Window, gtk.Container):
|
||||
self.jobject = datastore.create()
|
||||
self.jobject['title'] = '%s %s' % (get_bundle_name(), 'Activity')
|
||||
self.jobject['activity'] = self.get_service_name()
|
||||
self.jobject['icon'] = self._get_icon()
|
||||
self.jobject['keep'] = '0'
|
||||
self.jobject['buddies'] = ''
|
||||
self.jobject['preview'] = ''
|
||||
@ -332,10 +330,6 @@ class Activity(Window, gtk.Container):
|
||||
raise
|
||||
self.destroy()
|
||||
|
||||
def _get_icon(self):
|
||||
registry = bundleregistry.get_registry()
|
||||
return registry.get_bundle(self.get_service_name()).get_icon()
|
||||
|
||||
def get_bundle_name():
|
||||
"""Return the bundle name for the current process' bundle
|
||||
"""
|
||||
|
@ -89,8 +89,7 @@ class ActivityCreationHandler(gobject.GObject):
|
||||
|
||||
The specific service which creates new instances of this
|
||||
particular type of activity is created during the activity
|
||||
registration process in
|
||||
sugar.activity.bundleregistry.BundleRegistry which creates
|
||||
registration process in shell bundle registry which creates
|
||||
service definition files for each registered bundle type.
|
||||
"""
|
||||
gobject.GObject.__init__(self)
|
||||
|
@ -151,10 +151,6 @@ class Bundle:
|
||||
"""Get the activity service name"""
|
||||
return self._service_name
|
||||
|
||||
def get_object_path(self):
|
||||
"""Get the path to the service object"""
|
||||
return '/' + self._service_name.replace('.', '/')
|
||||
|
||||
def get_icon(self):
|
||||
"""Get the activity icon name"""
|
||||
return self._icon
|
||||
|
62
sugar/activity/registry.py
Normal file
62
sugar/activity/registry.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright (C) 2006, 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 dbus
|
||||
|
||||
_SHELL_SERVICE = "org.laptop.Shell"
|
||||
_SHELL_PATH = "/org/laptop/Shell"
|
||||
_REGISTRY_IFACE = "org.laptop.Shell.ActivityRegistry"
|
||||
|
||||
def _activity_info_from_dict(info_dict):
|
||||
return ActivityInfo(info_dict['name'], info_dict['icon'],
|
||||
info_dict['service_name'], info_dict['path'])
|
||||
|
||||
class ActivityInfo(object):
|
||||
def __init__(self, name, icon, service_name, path):
|
||||
self.name = name
|
||||
self.icon = icon
|
||||
self.service_name = service_name
|
||||
self.path = path
|
||||
|
||||
def to_dict(self):
|
||||
return { 'name' : self.name,
|
||||
'icon' : self.icon,
|
||||
'service_name' : self.service_name,
|
||||
'path' : self.path
|
||||
}
|
||||
|
||||
class ActivityRegistry(object):
|
||||
def __init__(self):
|
||||
bus = dbus.SessionBus()
|
||||
bus_object = bus.get_object(_SHELL_SERVICE, _SHELL_PATH)
|
||||
self._registry = dbus.Interface(bus_object, _REGISTRY_IFACE)
|
||||
|
||||
def _convert_info_list(self, info_list):
|
||||
result = []
|
||||
|
||||
for info_dict in info_list:
|
||||
result.append(_activity_info_from_dict(info_dict))
|
||||
|
||||
return result
|
||||
|
||||
def get_activities_for_name(self, name):
|
||||
info_list = self._registry.GetActivitiesForName(name)
|
||||
return self._convert_info_list(info_list)
|
||||
|
||||
def get_activities_for_type(self, mime_type):
|
||||
info_list = self._registry.GetActivitiesForType(mime_type)
|
||||
return self._convert_info_list(info_list)
|
@ -27,12 +27,8 @@ DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore"
|
||||
DS_DBUS_PATH = "/org/laptop/sugar/DataStore"
|
||||
|
||||
_bus = dbus.SessionBus()
|
||||
try:
|
||||
_data_store = dbus.Interface(_bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH),
|
||||
DS_DBUS_INTERFACE)
|
||||
except Exception, e:
|
||||
_data_store = None
|
||||
logging.error(e)
|
||||
_data_store = dbus.Interface(_bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH),
|
||||
DS_DBUS_INTERFACE)
|
||||
|
||||
def create(properties, filename):
|
||||
object_id = _data_store.create(dbus.Dictionary(properties), filename)
|
||||
|
@ -13,6 +13,7 @@ sugar_PYTHON = \
|
||||
menushell.py \
|
||||
notebook.py \
|
||||
roundbox.py \
|
||||
palette.py \
|
||||
panel.py \
|
||||
popup.py \
|
||||
popupcontext.py \
|
||||
|
@ -44,8 +44,8 @@ class Palette(gtk.Window):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
gobject.GObject.__init__(self)
|
||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||
gobject.GObject.__init__(self, type=gtk.WINDOW_POPUP)
|
||||
gtk.Window.__init__(self)
|
||||
|
||||
self._palette_label = gtk.Label()
|
||||
self._palette_label.set_ellipsize(pango.ELLIPSIZE_START)
|
||||
@ -74,14 +74,9 @@ class Palette(gtk.Window):
|
||||
|
||||
self.set_border_width(self._WIN_BORDER)
|
||||
self.add(vbox)
|
||||
self.show()
|
||||
|
||||
# Set the palette position using as reference the
|
||||
# parent widget
|
||||
self._set_palette_position()
|
||||
|
||||
def do_set_property(self, pspec, value):
|
||||
|
||||
|
||||
if pspec.name == 'parent':
|
||||
self._parent_widget = value
|
||||
elif pspec.name == 'alignment':
|
||||
@ -89,7 +84,7 @@ class Palette(gtk.Window):
|
||||
else:
|
||||
raise AssertionError
|
||||
|
||||
def _set_palette_position(self):
|
||||
def set_position(self):
|
||||
|
||||
window_axis = self._parent_widget.window.get_origin()
|
||||
parent_rectangle = self._parent_widget.get_allocation()
|
||||
@ -156,3 +151,6 @@ class Palette(gtk.Window):
|
||||
self._button_bar.pack_start(button, True, True, self._PADDING)
|
||||
button.show()
|
||||
|
||||
def display(self, button):
|
||||
self.show()
|
||||
self.set_position()
|
||||
|
@ -18,6 +18,7 @@
|
||||
import gtk
|
||||
|
||||
from sugar.graphics.icon import Icon
|
||||
from sugar.graphics.palette import *
|
||||
|
||||
class ToolButton(gtk.ToolButton):
|
||||
def __init__(self, named_icon=None):
|
||||
@ -27,4 +28,12 @@ class ToolButton(gtk.ToolButton):
|
||||
def set_named_icon(self, named_icon):
|
||||
icon = Icon(named_icon)
|
||||
self.set_icon_widget(icon)
|
||||
icon.show()
|
||||
icon.show()
|
||||
|
||||
def set_palette(self, palette):
|
||||
self.connect('clicked', palette.display)
|
||||
palette.props.parent = self
|
||||
palette.props.alignment = ALIGNMENT_BOTTOM_LEFT
|
||||
|
||||
def set_tooltip(self, text):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user