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