[Dextrose] [PATCH] Improve message notification behaviour
Martin Abente
martin.abente.lahaye at gmail.com
Mon Dec 20 13:32:23 EST 2010
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.
---
src/jarabe/frame/frame.py | 9 +++++----
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 83bff06..4366076 100644
--- a/src/jarabe/frame/frame.py
+++ b/src/jarabe/frame/frame.py
@@ -374,22 +374,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 34b7c1e..51e405d 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:
@@ -60,7 +61,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)
@@ -153,7 +154,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):
@@ -176,17 +178,22 @@ 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))
@@ -194,6 +201,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'
--
1.7.1
More information about the Dextrose
mailing list