diff options
Diffstat (limited to 'src/jarabe/view')
-rw-r--r-- | src/jarabe/view/launcher.py | 23 | ||||
-rw-r--r-- | src/jarabe/view/palettes.py | 26 | ||||
-rw-r--r-- | src/jarabe/view/service.py | 2 |
3 files changed, 32 insertions, 19 deletions
diff --git a/src/jarabe/view/launcher.py b/src/jarabe/view/launcher.py index 422a49a..89251e5 100644 --- a/src/jarabe/view/launcher.py +++ b/src/jarabe/view/launcher.py @@ -156,9 +156,6 @@ class _Animation(animator.Animation): self._icon.props.size = int(self.start_size + d) -_launchers = {} - - def setup(): model = shell.get_model() model.connect('launch-started', __launch_started_cb) @@ -167,14 +164,15 @@ def setup(): def add_launcher(activity_id, icon_path, icon_color): + model = shell.get_model() - if activity_id in _launchers: + if model.get_launcher(activity_id) is not None: return launch_window = LaunchWindow(activity_id, icon_path, icon_color) launch_window.show() - _launchers[activity_id] = launch_window + model.register_launcher(activity_id, launch_window) def __launch_started_cb(home_model, home_activity): @@ -184,7 +182,7 @@ def __launch_started_cb(home_model, home_activity): def __launch_failed_cb(home_model, home_activity): activity_id = home_activity.get_activity_id() - launcher = _launchers.get(activity_id) + launcher = shell.get_model().get_launcher(activity_id) if launcher is None: logging.error('Launcher for %s is missing', activity_id) @@ -209,8 +207,11 @@ def __launch_completed_cb(home_model, home_activity): def _destroy_launcher(home_activity): activity_id = home_activity.get_activity_id() - if activity_id in _launchers: - _launchers[activity_id].destroy() - del _launchers[activity_id] - else: - logging.error('Launcher for %s is missing', activity_id) + launcher = shell.get_model().get_launcher(activity_id) + if launcher is None: + if not home_activity.is_journal(): + logging.error('Launcher was not registered for %s', activity_id) + return + + shell.get_model().unregister_launcher(activity_id) + launcher.destroy() diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py index 2beceff..ad84f08 100644 --- a/src/jarabe/view/palettes.py +++ b/src/jarabe/view/palettes.py @@ -39,20 +39,32 @@ class BasePalette(Palette): def __init__(self, home_activity): Palette.__init__(self) - if home_activity.props.launching: - home_activity.connect('notify::launching', - self._launching_changed_cb) + self._notify_launch_hid = None + + if home_activity.props.launch_status == shell.Activity.LAUNCHING: + self._notify_launch_hid = home_activity.connect( \ + 'notify::launch-status', self.__notify_launch_status_cb) self.set_primary_text(_('Starting...')) + elif home_activity.props.launch_status == shell.Activity.LAUNCH_FAILED: + self._on_failed_launch() else: self.setup_palette() - def _launching_changed_cb(self, home_activity, pspec): - if not home_activity.props.launching: - self.setup_palette() - def setup_palette(self): raise NotImplementedError + def _on_failed_launch(self): + self.set_primary_text(_('Activity failed to start')) + + def __notify_launch_status_cb(self, home_activity, pspec): + home_activity.disconnect(self._notify_launch_hid) + self._notify_launch_hid = None + if home_activity.props.launch_status == shell.Activity.LAUNCH_FAILED: + self._on_failed_launch() + else: + self.setup_palette() + + class CurrentActivityPalette(BasePalette): def __init__(self, home_activity): self._home_activity = home_activity diff --git a/src/jarabe/view/service.py b/src/jarabe/view/service.py index fbcc961..bb71694 100644 --- a/src/jarabe/view/service.py +++ b/src/jarabe/view/service.py @@ -83,7 +83,7 @@ class UIService(dbus.service.Object): if activity is not None and activity.get_window() is not None: activity.get_window().activate(gtk.get_current_event_time()) - return not activity.props.launching + return self._shell_model.get_launcher(activity_id) is None return False |