From 8b581435ab8b4f591b7f03aaaa7e78384ee7f763 Mon Sep 17 00:00:00 2001
From: Wade Brainerd <wadetb@gmail.com>
Date: Tue, 29 Sep 2009 08:46:02 -0400
Subject: [PATCH] Display error message when activity fails to launch.
Added new NotifyActivityEnded DBus method to the shell, which is called by the activityfactory when an
activity's process ends. If the activity is still launching, this triggers a notify-launch-failed signal.
When the signal is received, the launcher window now displays a simple error message with a Close button.
Also corrected a minor bug in ShellModel.notify_launch_failed.
---
src/jarabe/model/shell.py | 18 ++++++++++++++++--
src/jarabe/view/launcher.py | 43 ++++++++++++++++++++++++++++++++++++++++---
src/jarabe/view/service.py | 5 +++++
3 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/src/jarabe/model/shell.py b/src/jarabe/model/shell.py
index ef2268d..3b87fce 100644
a
|
b
|
class ShellModel(gobject.GObject): |
572 | 572 | home_activity.get_type()) |
573 | 573 | home_activity.props.launching = False |
574 | 574 | self._remove_activity(home_activity) |
| 575 | self.emit('launch-failed', home_activity) |
575 | 576 | else: |
576 | 577 | logging.error('Model for activity id %s does not exist.', |
577 | 578 | activity_id) |
578 | 579 | |
579 | | self.emit('launch-failed', home_activity) |
580 | | |
| 580 | def notify_activity_ended(self, activity_id): |
| 581 | home_activity = self.get_activity_by_id(activity_id) |
| 582 | if home_activity: |
| 583 | if home_activity.props.launching: |
| 584 | logging.debug('Activity %s (%s) ended while still launching, '\ |
| 585 | 'assuming it failed.', activity_id, |
| 586 | home_activity.get_type()) |
| 587 | self.notify_launch_failed(activity_id) |
| 588 | else: |
| 589 | logging.debug("Activity %s ended", activity_id) |
| 590 | self._remove_activity(home_activity) |
| 591 | else: |
| 592 | # The activity may have already been removed when its window closed. |
| 593 | pass |
| 594 | |
581 | 595 | def _check_activity_launched(self, activity_id): |
582 | 596 | home_activity = self.get_activity_by_id(activity_id) |
583 | 597 | |
diff --git a/src/jarabe/view/launcher.py b/src/jarabe/view/launcher.py
index d4b9967..1e9f38a 100644
a
|
b
|
|
15 | 15 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
16 | 16 | |
17 | 17 | import logging |
| 18 | from gettext import gettext as _ |
18 | 19 | |
19 | 20 | import gtk |
20 | 21 | import hippo |
21 | 22 | import gobject |
22 | 23 | |
23 | 24 | from sugar import wm |
| 25 | from sugar.presence import presenceservice |
24 | 26 | from sugar.graphics import style |
25 | 27 | from sugar.graphics import animator |
26 | 28 | from sugar.graphics.xocolor import XoColor |
| 29 | from sugar.graphics.icon import Icon |
27 | 30 | |
28 | 31 | from jarabe.model import shell |
29 | 32 | from jarabe.view.pulsingicon import CanvasPulsingIcon |
… |
… |
class LaunchWindow(gtk.Window): |
66 | 69 | def __size_changed_cb(self, screen): |
67 | 70 | self._update_size() |
68 | 71 | |
| 72 | def show_failed(self, home_activity): |
| 73 | self._box.show_failed(home_activity) |
| 74 | |
69 | 75 | class LaunchBox(hippo.CanvasBox): |
70 | 76 | def __init__(self, activity_id, icon_path, icon_color): |
71 | 77 | gobject.GObject.__init__(self, orientation=hippo.ORIENTATION_VERTICAL) |
72 | 78 | |
| 79 | self.props.spacing = style.DEFAULT_SPACING |
| 80 | self.props.yalign = hippo.ALIGNMENT_CENTER |
| 81 | |
73 | 82 | self._activity_id = activity_id |
74 | 83 | self._activity_icon = CanvasPulsingIcon( |
75 | 84 | file_name=icon_path, |
76 | 85 | pulse_color=icon_color, |
77 | 86 | background_color=style.COLOR_WHITE.get_gdk_color()) |
78 | | self.append(self._activity_icon, hippo.PACK_EXPAND) |
| 87 | self.append(self._activity_icon) |
79 | 88 | |
80 | 89 | # FIXME support non-xo colors in CanvasPulsingIcon |
81 | 90 | self._activity_icon.props.base_color = \ |
… |
… |
class LaunchBox(hippo.CanvasBox): |
110 | 119 | else: |
111 | 120 | self._activity_icon.props.paused = True |
112 | 121 | |
| 122 | def show_failed(self, home_activity): |
| 123 | logging.debug("Displaying failure message on launcher") |
| 124 | |
| 125 | self._activity_icon.props.pulsing = False |
| 126 | self._animator.stop() |
| 127 | |
| 128 | text = hippo.CanvasText(text=_('%s failed to start.') % \ |
| 129 | home_activity.get_activity_name(), |
| 130 | xalign=hippo.ALIGNMENT_CENTER, |
| 131 | font_desc=style.FONT_BOLD.get_pango_desc(), |
| 132 | color = style.COLOR_BUTTON_GREY.get_int()) |
| 133 | self.append(text) |
| 134 | |
| 135 | button = gtk.Button(label=_('Close')) |
| 136 | button.connect('clicked', self.__close_button_clicked_cb, home_activity) |
| 137 | button.props.image = Icon(icon_name='dialog-cancel', |
| 138 | icon_size=gtk.ICON_SIZE_BUTTON) |
| 139 | canvas_button = hippo.CanvasWidget(widget=button, |
| 140 | xalign=hippo.ALIGNMENT_CENTER) |
| 141 | self.append(canvas_button) |
| 142 | |
| 143 | def __close_button_clicked_cb(self, button, home_activity): |
| 144 | _destroy_launcher(home_activity) |
| 145 | |
113 | 146 | class _Animation(animator.Animation): |
114 | 147 | def __init__(self, icon, start_size, end_size): |
115 | 148 | animator.Animation.__init__(self, 0.0, 1.0) |
… |
… |
def setup(): |
131 | 164 | model.connect('launch-completed', __launch_completed_cb) |
132 | 165 | |
133 | 166 | def add_launcher(activity_id, icon_path, icon_color): |
134 | | |
135 | 167 | if activity_id in _launchers: |
136 | 168 | return |
137 | 169 | |
… |
… |
def __launch_started_cb(home_model, home_activity): |
145 | 177 | home_activity.get_icon_color()) |
146 | 178 | |
147 | 179 | def __launch_failed_cb(home_model, home_activity): |
148 | | _destroy_launcher(home_activity) |
| 180 | activity_id = home_activity.get_activity_id() |
| 181 | |
| 182 | if activity_id in _launchers: |
| 183 | _launchers[activity_id].show_failed(home_activity) |
| 184 | else: |
| 185 | logging.error('Launcher for %s is missing', activity_id) |
149 | 186 | |
150 | 187 | def __launch_completed_cb(home_model, home_activity): |
151 | 188 | _destroy_launcher(home_activity) |
diff --git a/src/jarabe/view/service.py b/src/jarabe/view/service.py
index 2b91437..c1da23c 100644
a
|
b
|
class UIService(dbus.service.Object): |
98 | 98 | def NotifyLaunchFailure(self, activity_id): |
99 | 99 | shell.get_model().notify_launch_failed(activity_id) |
100 | 100 | |
| 101 | @dbus.service.method(_DBUS_SHELL_IFACE, |
| 102 | in_signature="s", out_signature="") |
| 103 | def NotifyActivityEnded(self, activity_id): |
| 104 | shell.get_model().notify_activity_ended(activity_id) |
| 105 | |
101 | 106 | @dbus.service.signal(_DBUS_OWNER_IFACE, signature="s") |
102 | 107 | def ColorChanged(self, color): |
103 | 108 | pass |