diff options
author | Martin Abente <martin.abente.lahaye@gmail.com> | 2010-12-20 17:27:32 (GMT) |
---|---|---|
committer | Anish Mangal <anish@activitycentral.com> | 2012-02-01 12:33:29 (GMT) |
commit | 97ffa6507b4735dbdf9a14c67b5dcf644ea68f0c (patch) | |
tree | ab616d0fb3e3bb756652de30b514e66f572a678f | |
parent | ff5ae4b970cc49140d53a9eda42879f45c147d55 (diff) |
Improve message notification behaviour
Corner's notification icon will use the same icon
as the frame notification button.
Frame's notification button will pulse until
the messages are read.
-rw-r--r-- | src/jarabe/frame/frame.py | 9 | ||||
-rw-r--r-- | src/jarabe/frame/notification.py | 26 |
2 files changed, 23 insertions, 12 deletions
diff --git a/src/jarabe/frame/frame.py b/src/jarabe/frame/frame.py index 96e848b..6a9735b 100644 --- a/src/jarabe/frame/frame.py +++ b/src/jarabe/frame/frame.py @@ -380,22 +380,23 @@ class Frame(object): button = self._notif_by_message.get(corner, None) if button is None: - button = NotificationButton(xo_color) + button = NotificationButton(_DEFAULT_ICON, xo_color) button.show() self._add_message_button(button, corner) self._notif_by_message[corner] = button - button.start_pulsing() - palette = button.get_palette() if palette is None: palette = HistoryPalette() palette.set_group_id('frame') palette.connect('clear-messages', self.remove_message, corner) + palette.connect('notice-messages', button.stop_pulsing) button.set_palette(palette) + button.start_pulsing() + palette.push_message(body, summary, icon_name, xo_color) - self._launch_notification_icon(icon_name, xo_color, corner, duration) + self._launch_notification_icon(_DEFAULT_ICON, xo_color, corner, duration) def remove_message(self, palette, corner): diff --git a/src/jarabe/frame/notification.py b/src/jarabe/frame/notification.py index b5724d5..99030e5 100644 --- a/src/jarabe/frame/notification.py +++ b/src/jarabe/frame/notification.py @@ -38,17 +38,18 @@ _PULSE_TIMEOUT = 3 _PULSE_COLOR = XoColor('%s,%s' % \ (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg())) _BODY_FILTERS = "<img.*?/>" -_NOTIFICATION_ICON = 'emblem-notification' -def _create_pulsing_icon(icon_name, xo_color): +def _create_pulsing_icon(icon_name, xo_color, timeout=None): icon = PulsingIcon( pixel_size=style.STANDARD_ICON_SIZE, pulse_color=_PULSE_COLOR, - base_color=xo_color, - timeout=_PULSE_TIMEOUT, + base_color=xo_color ) + if timeout is not None: + icon.timeout = timeout + if icon_name.startswith(os.sep): icon.props.file = icon_name else: @@ -61,7 +62,7 @@ class _HistoryIconWidget(gtk.Alignment): __gtype_name__ = 'SugarHistoryIconWidget' def __init__(self, icon_name, xo_color): - icon = _create_pulsing_icon(icon_name, xo_color) + icon = _create_pulsing_icon(icon_name, xo_color, _PULSE_TIMEOUT) icon.props.pulsing = True gtk.Alignment.__init__(self, xalign=0.5, yalign=0.0) @@ -154,7 +155,8 @@ class HistoryPalette(Palette): __gtype_name__ = 'SugarHistoryPalette' __gsignals__ = { - 'clear-messages': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) + 'clear-messages': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), + 'notice-messages': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])) } def __init__(self): @@ -177,18 +179,23 @@ class HistoryPalette(Palette): self.menu.append(clear_option) + self.connect('popup', self.__notice_messages_cb) + def __clear_messages_cb(self, clear_option): self.emit('clear-messages') + def __notice_messages_cb(self, palette): + self.emit('notice-messages') + def push_message(self, body, summary, icon_name, xo_color): self._messages_box.push_message(body, summary, icon_name, xo_color) class NotificationButton(ToolButton): - def __init__(self, xo_color): + def __init__(self, icon_name, xo_color): ToolButton.__init__(self) - self._icon = _create_pulsing_icon(_NOTIFICATION_ICON, xo_color) + self._icon = _create_pulsing_icon(icon_name, xo_color) self.set_icon_widget(self._icon) self._icon.show() self.set_palette_invoker(FrameWidgetInvoker(self)) @@ -196,6 +203,9 @@ class NotificationButton(ToolButton): def start_pulsing(self): self._icon.props.pulsing = True + def stop_pulsing(self, widget): + self._icon.props.pulsing = False + class NotificationIcon(gtk.EventBox): __gtype_name__ = 'SugarNotificationIcon' |