3 # notify.py is a simple notification program displaying a message on the
6 # Copyright (C) 2011-2012 Simon Ruderich
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 pygtk.require('2.0') # there might be a GTK 1 version installed, ignore it
32 # Pressing the mouse inside the window quits notify.
33 def mouse_press_callback(widget, event):
37 if __name__ == '__main__':
38 # Display configuration.
43 # We need a popup so the window manager doesn't touch our window.
44 window = gtk.Window(gtk.WINDOW_POPUP)
45 # No window border or close/resize buttons.
46 window.set_decorated(False)
47 # In case set_decorated(False) doesn't work with the used window manager.
48 window.connect('delete-event', gtk.main_quit)
49 # Enable mouse click events, by default windows don't receive them.
50 window.add_events(gtk.gdk.BUTTON_PRESS_MASK)
51 window.connect('button-press-event', mouse_press_callback)
54 window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(BG_COLOR))
56 string = sys.argv[1].decode(locale.getdefaultlocale()[1])
58 # Colored message string.
59 label_message = gtk.Label(string)
60 label_message.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(FG_COLOR))
61 window.add(label_message)
64 attributes = pango.AttrList()
65 attributes.insert(pango.AttrWeight(pango.WEIGHT_HEAVY, end_index=-1))
66 label_message.set_attributes(attributes)
68 # Display at the top at full screen width.
69 screen = window.get_screen()
70 window.resize(screen.get_width(), 30)