Mercurial > projects > pk-update-icon
annotate notify.c @ 10:fe1a21ab4f69
add a man page
author | Guido Berhoerster <guido@berhoerster.name> |
---|---|
date | Tue, 11 Oct 2011 17:07:49 +0200 |
parents | 58a3312a1c59 |
children | 2da5037fdfad |
rev | line source |
---|---|
2 | 1 /* |
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 | 4 * |
5 * Licensed under the GNU General Public License Version 2 | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
20 */ | |
21 | |
0 | 22 #include "notify.h" |
23 | |
24 void init_notify() | |
25 { | |
8
58a3312a1c59
add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents:
3
diff
changeset
|
26 notify_init(PACKAGE); |
0 | 27 } |
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 | 30 { |
31 NotifyNotification *ntfy; | |
8
58a3312a1c59
add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents:
3
diff
changeset
|
32 ntfy = notify_notification_new(_("Software Update(s)"), notify_text(info), info->critical > 0 ? "software-update-urgent" : "software-update-available"); |
0 | 33 notify_notification_set_timeout(ntfy, 3000); |
3
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
34 notify_notification_set_urgency(ntfy, info->critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL); |
0 | 35 notify_notification_show(ntfy, NULL); |
36 } | |
3
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
37 |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
38 const char *notify_text(struct UpdatesInfo *info) |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
39 { |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
40 static char buf[128]; |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
41 if (info->critical > 0) { |
8
58a3312a1c59
add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents:
3
diff
changeset
|
42 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
|
43 } else { |
8
58a3312a1c59
add internationalization support
Guido Berhoerster <guido@berhoerster.name>
parents:
3
diff
changeset
|
44 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
|
45 } |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
46 return buf; |
f8ad23e60000
code rework, show notify window just once
Pavol Rusnak <stick@gk2.sk>
parents:
2
diff
changeset
|
47 } |