comparison notify.c @ 8:58a3312a1c59

add internationalization support add German translation --HG-- rename : pk-update-icon.desktop => pk-update-icon.desktop.in
author Guido Berhoerster <guido@berhoerster.name>
date Tue, 11 Oct 2011 17:07:49 +0200
parents f8ad23e60000
children 2da5037fdfad
comparison
equal deleted inserted replaced
7:56a7ed833d0a 8:58a3312a1c59
1 /* 1 /*
2 * Copyright (C) 2011 Pavol Rusnak <stick@gk2.sk> 2 * Copyright (C) 2011 Pavol Rusnak <stick@gk2.sk>
3 * Copyright (C) 2011 Guido Berhoerster <gber@opensuse.org>
3 * 4 *
4 * Licensed under the GNU General Public License Version 2 5 * Licensed under the GNU General Public License Version 2
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * 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 * it under the terms of the GNU General Public License as published by
16 * You should have received a copy of the GNU General Public License 17 * 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 * 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 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */ 20 */
20 21
21 #include <libnotify/notify.h>
22 #include "notify.h" 22 #include "notify.h"
23
24 #define NOTIFY_NAME "Software Update"
25 23
26 void init_notify() 24 void init_notify()
27 { 25 {
28 notify_init(NOTIFY_NAME); 26 notify_init(PACKAGE);
29 } 27 }
30 28
31 void send_notify(struct UpdatesInfo *info) 29 void send_notify(struct UpdatesInfo *info)
32 { 30 {
33 NotifyNotification *ntfy; 31 NotifyNotification *ntfy;
34 ntfy = notify_notification_new(NOTIFY_NAME, notify_text(info), info->critical > 0 ? "software-update-urgent" : "software-update-available"); 32 ntfy = notify_notification_new(_("Software Update(s)"), notify_text(info), info->critical > 0 ? "software-update-urgent" : "software-update-available");
35 notify_notification_set_timeout(ntfy, 3000); 33 notify_notification_set_timeout(ntfy, 3000);
36 notify_notification_set_urgency(ntfy, info->critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL); 34 notify_notification_set_urgency(ntfy, info->critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
37 notify_notification_show(ntfy, NULL); 35 notify_notification_show(ntfy, NULL);
38 } 36 }
39 37
40 const char *notify_text(struct UpdatesInfo *info) 38 const char *notify_text(struct UpdatesInfo *info)
41 { 39 {
42 static char buf[128]; 40 static char buf[128];
43 if (info->critical > 0) { 41 if (info->critical > 0) {
44 snprintf(buf, sizeof(buf), "There are %d software updates available, %d of them critical.", info->normal + info->critical, info->critical); 42 snprintf(buf, sizeof(buf), _("There are %d software updates available, %d of them critical."), info->normal + info->critical, info->critical);
45 } else { 43 } else {
46 snprintf(buf, sizeof(buf), "There are %d software updates available.", info->normal); 44 snprintf(buf, sizeof(buf), _("There are %d software updates available."), info->normal);
47 } 45 }
48 return buf; 46 return buf;
49 } 47 }