annotate notify.c @ 12:db42ea75e9ff

add license header to main.h
author Guido Berhoerster <guido@berhoerster.name>
date Tue, 11 Oct 2011 17:07:49 +0200
parents 2da5037fdfad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
1 /*
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
2 * Copyright (C) 2011 Pavol Rusnak <stick@gk2.sk>
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
3 * Copyright (C) 2011 Guido Berhoerster <gber@opensuse.org>
2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
4 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
5 * Licensed under the GNU General Public License Version 2
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
6 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
7 * This program is free software; you can redistribute it and/or modify
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
8 * it under the terms of the GNU General Public License as published by
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
10 * (at your option) any later version.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
11 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
12 * This program is distributed in the hope that it will be useful,
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
15 * GNU General Public License for more details.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
16 *
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
17 * You should have received a copy of the GNU General Public License
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
18 * along with this program; if not, write to the Free Software
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
20 */
847ae02bc13b added GPLv2 headers
Pavol Rusnak <stick@gk2.sk>
parents: 0
diff changeset
21
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
22 #include "notify.h"
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
23
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
24 void init_notify()
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
25 {
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
26 notify_init(PACKAGE);
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
27 }
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
28
3
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
29 void send_notify(struct UpdatesInfo *info)
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
30 {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
31 NotifyNotification *ntfy;
11
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
32 ntfy = notify_notification_new(
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
33 _("Software Update(s)"),
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
34 _(notify_text(info)),
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
35 info->critical > 0 ? "software-update-urgent" : "software-update-available"
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
36 #if (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
37 , NULL
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
38 #endif
2da5037fdfad add compatibility with libnotify version < 0.7
Guido Berhoerster <guido@berhoerster.name>
parents: 8
diff changeset
39 );
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
40 notify_notification_set_timeout(ntfy, 3000);
3
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
41 notify_notification_set_urgency(ntfy, info->critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
0
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
42 notify_notification_show(ntfy, NULL);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
43 }
3
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
44
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
45 const char *notify_text(struct UpdatesInfo *info)
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
46 {
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
47 static char buf[128];
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
48 if (info->critical > 0) {
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
49 snprintf(buf, sizeof(buf), _("There are %d software updates available, %d of them critical."), info->normal + info->critical, info->critical);
3
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
50 } else {
8
58a3312a1c59 add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents: 3
diff changeset
51 snprintf(buf, sizeof(buf), _("There are %d software updates available."), info->normal);
3
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
52 }
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
53 return buf;
f8ad23e60000 code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents: 2
diff changeset
54 }