Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar/0038-Improve-message-notification-behaviour.patch
blob: b8ae4f3f75df5bf516f5952a46b4995e9786ad4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 2a7d9d90e963e4f7ba4ae28c8fac47176ff94efd Mon Sep 17 00:00:00 2001
From: Martin Abente <martin.abente.lahaye@gmail.com>
Date: Mon, 20 Dec 2010 14:27:32 -0300
Subject: [PATCH sugar 38/74] 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.
---
 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 96e848b..6a9735b 100644
--- a/src/jarabe/frame/frame.py
+++ b/src/jarabe/frame/frame.py
@@ -380,22 +380,23 @@ def add_message(self, body, summary='', icon_name=_DEFAULT_ICON,
 
         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_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 @@ def __init__(self):
 
         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 @@ def __init__(self, xo_color):
     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.6