Mercurial > projects > pk-update-icon
annotate notify.c @ 13:dca97330d81e
fix the locale path
author | Guido Berhoerster <guido@berhoerster.name> |
---|---|
date | Tue, 11 Oct 2011 17:36:32 +0200 |
parents | 2da5037fdfad |
children |
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; | |
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 | 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 | 42 notify_notification_show(ntfy, NULL); |
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 } |