source: epoptes/trunk/fuentes/epoptes/ui/notifications.py @ 295

Last change on this file since 295 was 295, checked in by mabarracus, 3 years ago

copy trusty epoptes code

File size: 1.8 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4###########################################################################
5# Notifications.
6#
7# Copyright (C) 2010 Fotis Tsamis <ftsamis@gmail.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FINESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22# On Debian GNU/Linux systems, the complete text of the GNU General
23# Public License can be found in `/usr/share/common-licenses/GPL".
24###########################################################################
25
26import pynotify
27import os
28
29if not pynotify.init("epoptes-notifications"):
30    sys.exit(1)
31
32append = 'x-canonical-append' in pynotify.get_server_caps()
33
34def notify(title, body, icon):
35    if not append:
36        return False
37    n = pynotify.Notification(title, body, icon)
38    n.set_hint_string("x-canonical-append", "true")
39    n.show()
40
41def shutdownNotify(host):
42    notify(_("Shut down:"), "%s" %(host), "notification-message-im")
43
44def loginNotify(user, host):
45    notify(_("Connected:"), _("%(user)s on %(host)s") %{"user":user, "host":host}, 
46                                "notification-message-im")
47def logoutNotify(user, host):
48    notify(_("Disconnected:"), _("%(user)s from %(host)s") %{"user":user, "host":host}, 
49                                "notification-message-im")
50
Note: See TracBrowser for help on using the repository browser.