diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/model/Makefile.am | 1 | ||||
-rw-r--r-- | shell/model/MeshModel.py | 26 | ||||
-rw-r--r-- | shell/model/bundleregistry.py | 118 | ||||
-rw-r--r-- | shell/model/homeactivity.py | 18 | ||||
-rw-r--r-- | shell/model/homemodel.py | 200 | ||||
-rw-r--r-- | shell/shellservice.py | 69 | ||||
-rw-r--r-- | shell/view/BuddyMenu.py | 9 | ||||
-rw-r--r-- | shell/view/Shell.py | 23 | ||||
-rw-r--r-- | shell/view/clipboardicon.py | 10 | ||||
-rw-r--r-- | shell/view/clipboardmenu.py | 35 | ||||
-rw-r--r-- | shell/view/frame/ActivitiesBox.py | 43 | ||||
-rw-r--r-- | shell/view/home/FriendView.py | 18 | ||||
-rw-r--r-- | shell/view/home/HomeBox.py | 2 | ||||
-rw-r--r-- | shell/view/home/activitiesdonut.py | 8 |
14 files changed, 211 insertions, 369 deletions
diff --git a/shell/model/Makefile.am b/shell/model/Makefile.am index 486ad09..0b7d14c 100644 --- a/shell/model/Makefile.am +++ b/shell/model/Makefile.am @@ -4,7 +4,6 @@ sugardir = $(pkgdatadir)/shell/model sugar_PYTHON = \ __init__.py \ accesspointmodel.py \ - bundleregistry.py \ BuddyModel.py \ Friends.py \ Invites.py \ diff --git a/shell/model/MeshModel.py b/shell/model/MeshModel.py index 44974e2..82980c3 100644 --- a/shell/model/MeshModel.py +++ b/shell/model/MeshModel.py @@ -18,29 +18,29 @@ import gobject from sugar.graphics.xocolor import XoColor from sugar.presence import presenceservice +from sugar import activity -from model import bundleregistry from model.BuddyModel import BuddyModel from model.accesspointmodel import AccessPointModel from hardware import hardwaremanager from hardware import nmclient class ActivityModel: - def __init__(self, activity, bundle): + def __init__(self, activity, activity_info): self._activity = activity - self._bundle = bundle + self._activity_info = activity_info def get_id(self): return self._activity.props.id def get_icon_name(self): - return self._bundle.get_icon() + return self._activity_info.icon def get_color(self): return XoColor(self._activity.props.color) def get_service_name(self): - return self._bundle.get_service_name() + return self._activity_info.service_name def get_title(self): return self._activity.props.name @@ -75,7 +75,6 @@ class MeshModel(gobject.GObject): self._buddies = {} self._access_points = {} self._mesh = None - self._bundle_registry = bundleregistry.get_registry() self._pservice = presenceservice.get_instance() self._pservice.connect("activity-appeared", @@ -196,13 +195,14 @@ class MeshModel(gobject.GObject): def _activity_appeared_cb(self, pservice, activity): self._check_activity(activity) - def _check_activity(self, activity): - bundle = self._bundle_registry.get_bundle(activity.props.type) - if not bundle: + def _check_activity(self, presence_activity): + registry = activity.get_registry() + activity_info = registry.get_activity(presence_activity.props.type) + if not activity_info: return - if self.has_activity(activity.props.id): + if self.has_activity(presence_activity.props.id): return - self.add_activity(bundle, activity) + self.add_activity(activity_info, presence_activity) def has_activity(self, activity_id): return self._activities.has_key(activity_id) @@ -213,8 +213,8 @@ class MeshModel(gobject.GObject): else: return None - def add_activity(self, bundle, activity): - model = ActivityModel(activity, bundle) + def add_activity(self, activity_info, activity): + model = ActivityModel(activity, activity_info) self._activities[model.get_id()] = model self.emit('activity-added', model) diff --git a/shell/model/bundleregistry.py b/shell/model/bundleregistry.py deleted file mode 100644 index bc8eec9..0000000 --- a/shell/model/bundleregistry.py +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright (C) 2006-2007 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 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): - """Internal class responsible for creating dbus service files - - DBUS services are defined in files which bind a service name - to the name of an executable which provides the service name. - - In Sugar, the service files are automatically generated from - the activity registry (by this class). When an activity's - dbus launch service is requested, dbus will launch the - specified executable in order to allow it to provide the - requested activity-launching service. - - In the case of activities which provide a "class", instead of - an "exec" attribute in their activity.info, the - sugar-activity-factory script is used with an appropriate - argument to service that bundle. - """ - SERVICE_DIRECTORY = '~/.local/share/dbus-1/services' - def __init__(self): - service_dir = os.path.expanduser(self.SERVICE_DIRECTORY) - 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(), - bundle.get_exec(), self._path) - -class BundleRegistry(gobject.GObject): - """Service that tracks the available activity bundles""" - - __gsignals__ = { - 'bundle-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])) - } - - def __init__(self): - gobject.GObject.__init__(self) - - self._bundles = {} - self._search_path = [] - self._service_manager = _ServiceManager() - - def get_bundle(self, service_name): - """Returns an bundle given his service name""" - if self._bundles.has_key(service_name): - return self._bundles[service_name] - else: - return None - - def add_search_path(self, path): - """Add a directory to the bundles search path""" - self._search_path.append(path) - self._scan_directory(path) - - def __iter__(self): - return self._bundles.values().__iter__() - - def _scan_directory(self, path): - if os.path.isdir(path): - for f in os.listdir(path): - bundle_dir = os.path.join(path, f) - if os.path.isdir(bundle_dir) and \ - bundle_dir.endswith('.activity'): - self.add_bundle(bundle_dir) - - def add_bundle(self, bundle_path): - bundle = Bundle(bundle_path) - if bundle.is_valid(): - self._bundles[bundle.get_service_name()] = bundle - self._service_manager.add(bundle) - self.emit('bundle-added', bundle) - return True - else: - return False - -def get_registry(): - return _bundle_registry - -_bundle_registry = BundleRegistry() - -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_path()) diff --git a/shell/model/homeactivity.py b/shell/model/homeactivity.py index c45e5c7..e95fe9a 100644 --- a/shell/model/homeactivity.py +++ b/shell/model/homeactivity.py @@ -44,10 +44,10 @@ class HomeActivity(gobject.GObject): gobject.PARAM_READWRITE), } - def __init__(self, bundle, activity_id): + def __init__(self, activity_info, activity_id): """Initialise the HomeActivity - bundle -- sugar.activity.bundle.Bundle instance, + activity_info -- sugar.activity.registry.ActivityInfo instance, provides the information required to actually create the new instance. This is, in effect, the "type" of activity being created. @@ -61,7 +61,7 @@ class HomeActivity(gobject.GObject): self._pid = None self._service = None self._activity_id = activity_id - self._bundle = bundle + self._activity_info = activity_info self._launch_time = time.time() self._launching = False @@ -99,9 +99,9 @@ class HomeActivity(gobject.GObject): return self._window.get_name() def get_icon_name(self): - """Retrieve the bundle's icon (file) name""" - if self._bundle: - return self._bundle.get_icon() + """Retrieve the activity's icon (file) name""" + if self._activity_info: + return self._activity_info.icon else: return 'theme:stock-missing' @@ -156,9 +156,9 @@ class HomeActivity(gobject.GObject): return self._window def get_type(self): - """Retrieve bundle's "service_name" for future reference""" - if self._bundle: - return self._bundle.get_service_name() + """Retrieve activity_info's "service_name" for future reference""" + if self._activity_info: + return self._activity_info.service_name else: return None diff --git a/shell/model/homemodel.py b/shell/model/homemodel.py index 7d1039b..dac434a 100644 --- a/shell/model/homemodel.py +++ b/shell/model/homemodel.py @@ -21,9 +21,9 @@ import wnck import dbus from sugar import wm +from sugar import activity from model.homeactivity import HomeActivity -from model import bundleregistry class HomeModel(gobject.GObject): """Model of the "Home" view (activity management) @@ -51,15 +51,18 @@ class HomeModel(gobject.GObject): ([gobject.TYPE_PYOBJECT])), 'active-activity-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])) + ([gobject.TYPE_PYOBJECT])), + 'pending-activity-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([gobject.TYPE_PYOBJECT])) } def __init__(self): gobject.GObject.__init__(self) self._activities = [] - self._bundle_registry = bundleregistry.get_registry() - self._current_activity = None + self._active_activity = None + self._pending_activity = None screen = wnck.screen_get_default() screen.connect('window-opened', self._window_opened_cb) @@ -67,8 +70,55 @@ class HomeModel(gobject.GObject): screen.connect('active-window-changed', self._active_window_changed_cb) - def get_current_activity(self): - return self._current_activity + def get_pending_activity(self): + """Returns the activity that would be seen in the Activity zoom level + + In the Home (or Neighborhood or Groups) zoom level, this + indicates the activity that would become active if the user + switched to the Activity zoom level. (In the Activity zoom + level, this just returns the currently-active activity.) + Unlike get_active_activity(), this never returns None as long + as there is any activity running. + """ + return self._pending_activity + + def _set_pending_activity(self, home_activity): + if self._pending_activity == home_activity: + return + + self._pending_activity = home_activity + self.emit('pending-activity-changed', self._pending_activity) + + def get_active_activity(self): + """Returns the activity that the user is currently working in + + In the Activity zoom level, this returns the currently-active + activity. In the other zoom levels, it returns the activity + that was most-recently active in the Activity zoom level, or + None if the most-recently-active activity is no longer + running. + """ + return self._active_activity + + def _set_active_activity(self, home_activity): + if self._active_activity == home_activity: + return + + if self._active_activity: + service = self._active_activity.get_service() + if service: + service.set_active(False, + reply_handler=self._set_active_success, + error_handler=self._set_active_error) + if home_activity: + service = home_activity.get_service() + if service: + service.set_active(True, + reply_handler=self._set_active_success, + error_handler=self._set_active_error) + + self._active_activity = home_activity + self.emit('active-activity-changed', self._active_activity) def __iter__(self): return iter(self._activities) @@ -84,65 +134,48 @@ class HomeModel(gobject.GObject): def _window_opened_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: - activity = None + home_activity = None activity_id = wm.get_activity_id(window) - bundle_id = wm.get_bundle_id(window) - if bundle_id: - bundle = self._bundle_registry.get_bundle(bundle_id) + service_name = wm.get_bundle_id(window) + if service_name: + registry = activity.get_registry() + activity_info = registry.get_activity(service_name) else: - bundle = None + activity_info = None if activity_id: - activity = self._get_activity_by_id(activity_id) + home_activity = self._get_activity_by_id(activity_id) - if not activity: - activity = HomeActivity(bundle, activity_id) - self._add_activity(activity) + if not home_activity: + home_activity = HomeActivity(activity_info, activity_id) + self._add_activity(home_activity) - activity.set_window(window) + home_activity.set_window(window) - activity.props.launching = False - self.emit('activity-started', activity) + home_activity.props.launching = False + self.emit('activity-started', home_activity) + + if self._pending_activity is None: + self._set_pending_activity(home_activity) def _window_closed_cb(self, screen, window): if window.get_window_type() == wnck.WINDOW_NORMAL: self._remove_activity_by_xid(window.get_xid()) - if not self._activities: - self.emit('active-activity-changed', None) - self._notify_activity_activation(self._current_activity, None) def _get_activity_by_xid(self, xid): - for activity in self._activities: - if activity.get_xid() == xid: - return activity + for home_activity in self._activities: + if home_activity.get_xid() == xid: + return home_activity return None def _get_activity_by_id(self, activity_id): - for activity in self._activities: - if activity.get_activity_id() == activity_id: - return activity + for home_activity in self._activities: + if home_activity.get_activity_id() == activity_id: + return home_activity return None - def _notify_activity_activation(self, old_activity, new_activity): - if old_activity == new_activity: - return - - if old_activity: - service = old_activity.get_service() - if service: - service.set_active(False, - reply_handler=self._set_active_success, - error_handler=self._set_active_error) - - if new_activity: - service = new_activity.get_service() - if service: - service.set_active(True, - reply_handler=self._set_active_success, - error_handler=self._set_active_error) - def _set_active_success(self): pass @@ -151,55 +184,58 @@ class HomeModel(gobject.GObject): def _active_window_changed_cb(self, screen): window = screen.get_active_window() - if window == None: - self.emit('active-activity-changed', None) - self._notify_activity_activation(self._current_activity, None) - return - if window.get_window_type() != wnck.WINDOW_NORMAL: + if window is None or window.get_window_type() != wnck.WINDOW_NORMAL: return xid = window.get_xid() - act = self._get_activity_by_xid(window.get_xid()) - if act: - self._notify_activity_activation(self._current_activity, act) - self._current_activity = act - else: - self._notify_activity_activation(self._current_activity, None) - self._current_activity = None + act = self._get_activity_by_xid(xid) + if act is None: logging.error('Model for window %d does not exist.' % xid) - - self.emit('active-activity-changed', self._current_activity) - - def _add_activity(self, activity): - self._activities.append(activity) - self.emit('activity-added', activity) - - def _remove_activity(self, activity): - if activity == self._current_activity: - self._current_activity = None - - self.emit('activity-removed', activity) - self._activities.remove(activity) + self._set_pending_activity(act) + self._set_active_activity(act) + + def _add_activity(self, home_activity): + self._activities.append(home_activity) + self.emit('activity-added', home_activity) + + def _remove_activity(self, home_activity): + if home_activity == self._active_activity: + self._set_active_activity(None) + # Figure out the new _pending_activity. + windows = wnck.screen_get_default().get_windows_stacked() + windows.reverse() + for window in windows: + new_activity = self._get_activity_by_xid(window.get_xid()) + if new_activity is not None: + self._set_pending_activity(new_activity) + break + else: + logging.error('No activities are running') + self._set_pending_activity(None) + + self.emit('activity-removed', home_activity) + self._activities.remove(home_activity) def _remove_activity_by_xid(self, xid): - activity = self._get_activity_by_xid(xid) - if activity: - self._remove_activity(activity) + home_activity = self._get_activity_by_xid(xid) + if home_activity: + self._remove_activity(home_activity) else: logging.error('Model for window %d does not exist.' % xid) def notify_activity_launch(self, activity_id, service_name): - bundle = self._bundle_registry.get_bundle(service_name) - if not bundle: + registry = activity.get_registry() + activity_info = registry.get_activity(service_name) + if not activity_info: raise ValueError("Activity service name '%s' was not found in the bundle registry." % service_name) - activity = HomeActivity(bundle, activity_id) - activity.props.launching = True - self._add_activity(activity) + home_activity = HomeActivity(activity_info, activity_id) + home_activity.props.launching = True + self._add_activity(home_activity) def notify_activity_launch_failed(self, activity_id): - activity = self._get_activity_by_id(activity_id) - if activity: - logging.debug("Activity %s (%s) launch failed" % (activity_id, activity.get_type())) - self._remove_activity(activity) + home_activity = self._get_activity_by_id(activity_id) + if home_activity: + logging.debug("Activity %s (%s) launch failed" % (activity_id, home_activity.get_type())) + self._remove_activity(home_activity) else: logging.error('Model for activity id %s does not exist.' % activity_id) diff --git a/shell/shellservice.py b/shell/shellservice.py index 5728e44..d577a44 100644 --- a/shell/shellservice.py +++ b/shell/shellservice.py @@ -17,10 +17,7 @@ """D-bus service providing access to the shell's functionality""" import dbus -from model import bundleregistry - _DBUS_SERVICE = "org.laptop.Shell" -_DBUS_ACTIVITY_REGISTRY_IFACE = "org.laptop.Shell.ActivityRegistry" _DBUS_SHELL_IFACE = "org.laptop.Shell" _DBUS_OWNER_IFACE = "org.laptop.Shell.Owner" _DBUS_PATH = "/org/laptop/Shell" @@ -56,9 +53,6 @@ class ShellService(dbus.service.Object): self._home_model.connect('active-activity-changed', self._cur_activity_changed_cb) - bundle_registry = bundleregistry.get_registry() - bundle_registry.connect('bundle-added', self._bundle_added_cb) - bus = dbus.SessionBus() bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus) dbus.service.Object.__init__(self, bus_name, _DBUS_PATH) @@ -83,60 +77,6 @@ class ShellService(dbus.service.Object): def NotifyLaunchFailure(self, activity_id): self._shell.notify_launch_failure(activity_id) - @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, - that is, the directory with activity/activity.info as a - child of the directory. - - The bundleregistry.BundleRegistry is responsible for setting - up a set of d-bus service mappings for each available activity. - """ - registry = bundleregistry.get_registry() - return registry.add_bundle(bundle_path) - - @dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE, - in_signature="s", out_signature="a{sv}") - def GetActivity(self, service_name): - registry = bundleregistry.get_registry() - bundle = registry.get_bundle(service_name) - if not bundle: - return {} - - return self._bundle_to_dict(bundle) - - @dbus.service.method(_DBUS_ACTIVITY_REGISTRY_IFACE, - in_signature="s", out_signature="aa{sv}") - def FindActivity(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: - result.append(self._bundle_to_dict(bundle)) - - 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 bundle.get_mime_types() and mime_type in bundle.get_mime_types(): - result.append(self._bundle_to_dict(bundle)) - - return result - - @dbus.service.signal(_DBUS_ACTIVITY_REGISTRY_IFACE, signature="a{sv}") - def ActivityAdded(self, activity_info): - pass - @dbus.service.signal(_DBUS_OWNER_IFACE, signature="s") def ColorChanged(self, color): pass @@ -169,12 +109,3 @@ class ShellService(dbus.service.Object): if new_id: self.CurrentActivityChanged(new_id) - def _bundle_to_dict(self, bundle): - return {'name': bundle.get_name(), - 'icon': bundle.get_icon(), - 'service_name': bundle.get_service_name(), - 'path': bundle.get_path()} - - def _bundle_added_cb(self, bundle_registry, bundle): - self.ActivityAdded(self._bundle_to_dict(bundle)) - diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index 3162ab1..e3efb5c 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -85,18 +85,19 @@ class BuddyMenu(Palette): else: menu_item = MenuItem(_('Make friend'), 'stock-add') menu_item.connect('activate', self._make_friend_cb) - self.append_menu_item(menu_item) + + self.menu.append(menu_item) menu_item.show() - activity = shell_model.get_home().get_current_activity() + activity = self._shell.get_current_activity() if activity != None: - activity_ps = pservice.get_activity(activity.get_activity_id()) + activity_ps = pservice.get_activity(activity.get_id()) # FIXME check that the buddy is not in the activity already menu_item = MenuItem(_('Invite'), 'stock-invite') menu_item.connect('activate', self._invite_friend_cb) - self.append_menu_item(menu_item) + self.menu.append(menu_item) menu_item.show() def _buddy_icon_changed_cb(self, buddy): diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 697dc1c..044cbde 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -26,6 +26,7 @@ import gtk import wnck from sugar.activity.activityhandle import ActivityHandle +from sugar import activity from sugar.activity import activityfactory from sugar.datastore import datastore from sugar import profile @@ -34,7 +35,6 @@ from view.ActivityHost import ActivityHost from view.frame.frame import Frame from view.keyhandler import KeyHandler from view.home.HomeWindow import HomeWindow -from model import bundleregistry from model.shellmodel import ShellModel from hardware import hardwaremanager @@ -47,6 +47,7 @@ class Shell(gobject.GObject): self._hosts = {} self._screen = wnck.screen_get_default() self._current_host = None + self._pending_host = None self._screen_rotation = 0 self._key_handler = KeyHandler(self) @@ -65,6 +66,8 @@ class Shell(gobject.GObject): home_model.connect('activity-removed', self._activity_removed_cb) home_model.connect('active-activity-changed', self._active_activity_changed_cb) + home_model.connect('pending-activity-changed', + self._pending_activity_changed_cb) # Unfreeze the display when it's stable hw_manager = hardwaremanager.get_manager() @@ -100,6 +103,12 @@ class Shell(gobject.GObject): self._current_host = host + def _pending_activity_changed_cb(self, home_model, home_activity): + if home_activity: + self._pending_host = self._hosts[home_activity.get_xid()] + else: + self._pending_host = None + def get_model(self): return self._model @@ -107,16 +116,16 @@ class Shell(gobject.GObject): return self._frame def join_activity(self, bundle_id, activity_id): - activity = self.get_activity(activity_id) - if activity: - activity.present() + activity_host = self.get_activity(activity_id) + if activity_host: + activity_host.present() return # Get the service name for this activity, if # we have a bundle on the system capable of handling # this activity type - breg = bundleregistry.get_registry() - bundle = breg.get_bundle(bundle_id) + registry = activity.get_registry() + bundle = registry.get_activity(bundle_id) if not bundle: logging.error("Couldn't find activity for type %s" % bundle_id) return @@ -156,6 +165,8 @@ class Shell(gobject.GObject): return if level == ShellModel.ZOOM_ACTIVITY: + if self._pending_host is not None: + self._pending_host.present() self._screen.toggle_showing_desktop(False) else: self._model.set_zoom_level(level) diff --git a/shell/view/clipboardicon.py b/shell/view/clipboardicon.py index a47104d..2e60e36 100644 --- a/shell/view/clipboardicon.py +++ b/shell/view/clipboardicon.py @@ -73,9 +73,9 @@ class ClipboardIcon(CanvasIcon): self._selected = selected if selected: if not self._hover: - self.props.background_color = style.COLOR_PANEL_GREY.get_int() + self.props.background_color = style.COLOR_SELECTION_GREY.get_int() else: - self.props.background_color = style.COLOR_TOOLBAR_GREY.get_int() + self.props.background_color = style.COLOR_PANEL_GREY.get_int() def set_state(self, name, percent, icon_name, preview, activity): cb_service = clipboardservice.get_instance() @@ -107,11 +107,11 @@ class ClipboardIcon(CanvasIcon): def prelight(self, enter): if enter: self._hover = True - self.props.background_color = color.BLACK.get_int() + self.props.background_color = style.COLOR_BLACK.get_int() else: self._hover = False if self._selected: - self.props.background_color = color.DESKTOP_BACKGROUND.get_int() + self.props.background_color = style.COLOR_SELECTION_GREY.get_int() else: - self.props.background_color = color.TOOLBAR_BACKGROUND.get_int() + self.props.background_color = style.COLOR_PANEL_GREY.get_int() diff --git a/shell/view/clipboardmenu.py b/shell/view/clipboardmenu.py index 35802dc..28ea0bb 100644 --- a/shell/view/clipboardmenu.py +++ b/shell/view/clipboardmenu.py @@ -64,11 +64,13 @@ class ClipboardMenu(Palette): self._remove_item = MenuItem(_('Remove'), 'stock-remove') self._remove_item.connect('activate', self._remove_item_activate_cb) - self.append_menu_item(self._remove_item) + self.menu.append(self._remove_item) + self._remove_item.show() self._open_item = MenuItem(_('Open'), 'stock-keep') self._open_item.connect('activate', self._open_item_activate_cb) - self.append_menu_item(self._open_item) + self.menu.append(self._open_item) + self._open_item.show() #self._stop_item = MenuItem(_('Stop download'), 'stock-close') # TODO: Implement stopping downloads @@ -77,7 +79,8 @@ class ClipboardMenu(Palette): self._journal_item = MenuItem(_('Add to journal'), 'document-save') self._journal_item.connect('activate', self._journal_item_activate_cb) - self.append_menu_item(self._journal_item) + self.menu.append(self._journal_item) + self._journal_item.show() self._update_items_visibility(installable) @@ -120,32 +123,8 @@ class ClipboardMenu(Palette): def _open_item_activate_cb(self, menu_item): if self._percent < 100: return - jobject = self._copy_to_journal() - # TODO: we cannot simply call resume() right now because we would lock - # the shell as we are sharing the same loop as the shell service. - #jobject.resume() - - # TODO: take this out when we fix the mess that is the shell/shellservice. - from model import bundleregistry - from sugar.activity.bundle import Bundle - from sugar.activity import activityfactory - if jobject.is_bundle(): - bundle = Bundle(jobject.file_path) - if not bundle.is_installed(): - bundle.install() - - activityfactory.create(bundle.get_service_name()) - else: - service_name = None - mime_type = jobject.metadata['mime_type'] - for bundle in bundleregistry.get_registry(): - if bundle.get_mime_types() and mime_type in bundle.get_mime_types(): - service_name = bundle.get_service_name() - break - if service_name: - activityfactory.create_with_object_id(service_name, - jobject.object_id) + jobject.resume() def _remove_item_activate_cb(self, menu_item): cb_service = clipboardservice.get_instance() diff --git a/shell/view/frame/ActivitiesBox.py b/shell/view/frame/ActivitiesBox.py index a46e8e9..909a5f2 100644 --- a/shell/view/frame/ActivitiesBox.py +++ b/shell/view/frame/ActivitiesBox.py @@ -20,30 +20,33 @@ import logging from sugar.graphics.palette import Palette from sugar.graphics.xocolor import XoColor from sugar.graphics.iconbutton import IconButton +from sugar.graphics import style from sugar import profile +from sugar import activity -from model import bundleregistry from frameinvoker import FrameCanvasInvoker class ActivityButton(IconButton): - def __init__(self, activity): - IconButton.__init__(self, icon_name=activity.get_icon()) + def __init__(self, activity_info): + IconButton.__init__(self, icon_name=activity_info.icon, + stroke_color=style.COLOR_WHITE, + fill_color=style.COLOR_TRANSPARENT) - palette = Palette(activity.get_name()) + palette = Palette(activity_info.name) palette.props.invoker = FrameCanvasInvoker(self) palette.set_group_id('frame') self.set_palette(palette) - self._activity = activity + self._activity_info = activity_info def get_bundle_id(self): - return self._activity.get_service_name() + return self._activity_info.service_name class InviteButton(IconButton): - def __init__(self, activity, invite): - IconButton.__init__(self, icon_name=activity.get_icon()) + def __init__(self, activity_model, invite): + IconButton.__init__(self, icon_name=activity_model.get_color()) - self.props.xo_color = activity.get_color() + self.props.xo_color = activity_model.get_color() self._invite = invite def get_activity_id(self): @@ -64,12 +67,12 @@ class ActivitiesBox(hippo.CanvasBox): self._invite_to_item = {} self._invites = self._shell_model.get_invites() - bundle_registry = bundleregistry.get_registry() - for bundle in bundle_registry: - if bundle.get_show_launcher(): - self.add_activity(bundle) + registry = activity.get_registry() + for activity_info in registry.get_activities(): + if activity_info.show_launcher: + self.add_activity(activity_info) - bundle_registry.connect('bundle-added', self._bundle_added_cb) + registry.connect('activity-added', self._activity_added_cb) for invite in self._invites: self.add_invite(invite) @@ -90,19 +93,19 @@ class ActivitiesBox(hippo.CanvasBox): def _invite_removed_cb(self, invites, invite): self.remove_invite(invite) - def _bundle_added_cb(self, bundle_registry, bundle): - self.add_activity(bundle) + def _activity_added_cb(self, activity_registry, activity_info): + self.add_activity(activity_info) - def add_activity(self, activity): - item = ActivityButton(activity) + def add_activity(self, activity_info): + item = ActivityButton(activity_info) item.connect('activated', self._activity_clicked_cb) self.append(item, 0) def add_invite(self, invite): mesh = self._shell_model.get_mesh() - activity = mesh.get_activity(invite.get_activity_id()) + activity_model = mesh.get_activity(invite.get_activity_id()) if activity: - item = InviteButton(activity, invite) + item = InviteButton(activity_model, invite) item.connect('activated', self._invite_clicked_cb) self.append(item, 0) diff --git a/shell/view/home/FriendView.py b/shell/view/home/FriendView.py index c585312..ed05892 100644 --- a/shell/view/home/FriendView.py +++ b/shell/view/home/FriendView.py @@ -20,8 +20,8 @@ import gobject from sugar.graphics.canvasicon import CanvasIcon from sugar.graphics import style from sugar.presence import presenceservice +from sugar import activity -from model import bundleregistry from view.BuddyIcon import BuddyIcon class FriendView(hippo.CanvasBox): @@ -46,9 +46,9 @@ class FriendView(hippo.CanvasBox): self._buddy.connect('disappeared', self._buddy_disappeared_cb) self._buddy.connect('color-changed', self._buddy_color_changed_cb) - def _get_new_icon_name(self, activity): - registry = bundleregistry.get_registry() - bundle = registry.get_bundle(activity.get_type()) + def _get_new_icon_name(self, home_activity): + registry = activity.get_registry() + bundle = registry.get_bundle(home_activity.get_type()) if bundle: return bundle.get_icon() return None @@ -58,14 +58,14 @@ class FriendView(hippo.CanvasBox): self.remove(self._activity_icon) self._activity_icon_visible = False - def _buddy_activity_changed_cb(self, buddy, activity=None): - if not activity: + def _buddy_activity_changed_cb(self, buddy, home_activity=None): + if not home_activity: self._remove_activity_icon() return # FIXME: use some sort of "unknown activity" icon rather # than hiding the icon? - name = self._get_new_icon_name(activity) + name = self._get_new_icon_name(home_activity) if name: self._activity_icon.props.icon_name = name self._activity_icon.props.xo_color = buddy.get_color() @@ -76,8 +76,8 @@ class FriendView(hippo.CanvasBox): self._remove_activity_icon() def _buddy_appeared_cb(self, buddy): - activity = self._buddy.get_current_activity() - self._buddy_activity_changed_cb(buddy, activity) + home_activity = self._buddy.get_current_activity() + self._buddy_activity_changed_cb(buddy, home_activity) def _buddy_disappeared_cb(self, buddy): self._buddy_activity_changed_cb(buddy, None) diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py index bfb4265..2fa2183 100644 --- a/shell/view/home/HomeBox.py +++ b/shell/view/home/HomeBox.py @@ -130,7 +130,7 @@ class HomeMyIcon(MyIcon): shutdown_menu_item = gtk.MenuItem(_('Shutdown')) shutdown_menu_item.connect('activate', self._shutdown_activate_cb) - palette.append_menu_item(shutdown_menu_item) + palette.menu.append(shutdown_menu_item) shutdown_menu_item.show() self.set_palette(palette) diff --git a/shell/view/home/activitiesdonut.py b/shell/view/home/activitiesdonut.py index 0c690b2..3b12a09 100644 --- a/shell/view/home/activitiesdonut.py +++ b/shell/view/home/activitiesdonut.py @@ -88,14 +88,14 @@ class ActivityIcon(CanvasIcon): resume_menu_item = gtk.MenuItem(_('Resume')) resume_menu_item.connect('activate', self._resume_activate_cb) - palette.append_menu_item(resume_menu_item) + palette.menu.append(resume_menu_item) resume_menu_item.show() # FIXME: kludge if self._activity.get_type() != "org.laptop.JournalActivity": stop_menu_item = gtk.MenuItem(_('Stop')) stop_menu_item.connect('activate', self._stop_activate_cb) - palette.append_menu_item(stop_menu_item) + palette.menu.append(stop_menu_item) stop_menu_item.show() def _launching_changed_cb(self, activity, pspec): @@ -189,7 +189,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): self._model = shell.get_model().get_home() self._model.connect('activity-added', self._activity_added_cb) self._model.connect('activity-removed', self._activity_removed_cb) - self._model.connect('active-activity-changed', self._activity_changed_cb) + self._model.connect('pending-activity-changed', self._activity_changed_cb) self.connect('button-release-event', self._button_release_event_cb) @@ -385,7 +385,7 @@ class ActivitiesDonut(hippo.CanvasBox, hippo.CanvasItem): cr.fill() # Selected Wedge - current_activity = self._model.get_current_activity() + current_activity = self._model.get_pending_activity() if current_activity is not None: selected_index = self._model.index(current_activity) [angle_start, angle_end] = self._get_angles(selected_index) |