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
|
# Copyright (C) 2008 One Laptop Per Child
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import gobject
import gtk
from sugar.graphics import style
from sugar.graphics.xocolor import XoColor
from jarabe.view.pulsingicon import PulsingIcon
class NotificationIcon(gtk.EventBox):
__gtype_name__ = 'SugarNotificationIcon'
__gproperties__ = {
'xo-color' : (object, None, None, gobject.PARAM_READWRITE),
'icon-name' : (str, None, None, None, gobject.PARAM_READWRITE),
'icon-filename' : (str, None, None, None, gobject.PARAM_READWRITE)
}
_PULSE_TIMEOUT = 3
def __init__(self, **kwargs):
self._icon = PulsingIcon(pixel_size=style.STANDARD_ICON_SIZE)
gobject.GObject.__init__(self, **kwargs)
self.props.visible_window = False
self._icon.props.pulse_color = \
XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
style.COLOR_TRANSPARENT.get_svg()))
self._icon.props.pulsing = True
self.add(self._icon)
self._icon.show()
gobject.timeout_add_seconds(self._PULSE_TIMEOUT, self.__stop_pulsing_cb)
self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
def __stop_pulsing_cb(self):
self._icon.props.pulsing = False
return False
def do_set_property(self, pspec, value):
if pspec.name == 'xo-color':
if self._icon.props.base_color != value:
self._icon.props.base_color = value
elif pspec.name == 'icon-name':
if self._icon.props.icon_name != value:
self._icon.props.icon_name = value
elif pspec.name == 'icon-filename':
if self._icon.props.file != value:
self._icon.props.file = value
def do_get_property(self, pspec):
if pspec.name == 'xo-color':
return self._icon.props.base_color
elif pspec.name == 'icon-name':
return self._icon.props.icon_name
elif pspec.name == 'icon-filename':
return self._icon.props.file
def _set_palette(self, palette):
self._icon.palette = palette
def _get_palette(self):
return self._icon.palette
palette = property(_get_palette, _set_palette)
class NotificationWindow(gtk.Window):
__gtype_name__ = 'SugarNotificationWindow'
def __init__(self, **kwargs):
gtk.Window.__init__(self, **kwargs)
self.set_decorated(False)
self.set_resizable(False)
self.connect('realize', self._realize_cb)
def _realize_cb(self, widget):
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
self.window.set_accept_focus(False)
color = gtk.gdk.color_parse(style.COLOR_TOOLBAR_GREY.get_html())
self.modify_bg(gtk.STATE_NORMAL, color)
|