Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Abente <martin.abente.lahaye@gmail.com>2010-12-20 17:27:32 (GMT)
committer Anish Mangal <anish@sugarlabs.org>2011-08-26 05:55:56 (GMT)
commit65af11c60205501f4895ccf30a2ada481966be01 (patch)
treea9ef26b8e7c5af18825a6757147b1e487f0b84e1
parent279f4f42d5cdc18e81684a39748188e276fa9805 (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. Signed-off-by: Anish Mangal <anish@sugarlabs.org>
-rw-r--r--src/jarabe/frame/frame.py9
-rw-r--r--src/jarabe/frame/notification.py26
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'