changeset 19:38b37e4a4d63

added a button for installing updates to the notification
author Guido Berhoerster <guido@berhoerster.name>
date Thu, 20 Oct 2011 13:37:50 +0200
parents 9537882d759f
children d95c601ac333
files pkui-icon.c po/de.po po/id.po
diffstat 3 files changed, 74 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/pkui-icon.c	Thu Oct 20 13:03:37 2011 +0200
+++ b/pkui-icon.c	Thu Oct 20 13:37:50 2011 +0200
@@ -43,7 +43,9 @@
 static void icon_popup_menu_popup(GtkStatusIcon *status_icon, guint button,
     guint activate_time, gpointer user_data);
 static void icon_activated(GtkStatusIcon *status_icon, gpointer user_data);
+static void hide_notification(PkuiIcon *self);
 static void backend_state_changed(PkuiBackend *backend, gpointer user_data);
+static void update_viewer_exited(GPid pid, gint status, gpointer user_data);
 
 static void
 pkui_icon_finalize(GObject *gobject)
@@ -98,6 +100,29 @@
 }
 
 static void
+exec_update_viewer(PkuiIcon *self)
+{
+	static const gchar *argv[] = { UPDATE_VIEWER_COMMAND, NULL };
+	GPid		pid;
+	gboolean	retval;
+
+	g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend));
+
+	g_debug("executing " UPDATE_VIEWER_COMMAND);
+
+	retval = g_spawn_async(NULL, (gchar **)argv, NULL,
+	    G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL);
+	if (!retval) {
+		g_warning("Could not execute" UPDATE_VIEWER_COMMAND);
+		return;
+	}
+	g_child_watch_add(pid, (GChildWatchFunc)update_viewer_exited, self);
+
+	pkui_backend_set_inhibit_check(self->priv->backend, TRUE);
+	hide_notification(self);
+}
+
+static void
 about_dialog_show(GtkMenuItem *item, gpointer user_data)
 {
 	static const gchar *copyright = "Copyright \xc2\xa9 2011 Guido "
@@ -184,6 +209,16 @@
 }
 
 static void
+notification_handle_action(NotifyNotification *notification, gchar *action,
+    gpointer user_data)
+{
+	PkuiIcon *self = PKUI_ICON(user_data);
+
+	if (strcmp(action, "install-updates") == 0)
+		exec_update_viewer(self);
+}
+
+static void
 update_notification(PkuiIcon *self, guint updates_normal,
     guint updates_important)
 {
@@ -219,14 +254,18 @@
 	gtk_status_icon_set_from_icon_name(self->priv->status_icon, icon);
 	gtk_status_icon_set_visible(self->priv->status_icon, TRUE);
 
-	if (self->priv->notification == NULL)
+	if (self->priv->notification == NULL) {
 		self->priv->notification = notify_notification_new(title,
 		    message, icon
 #if (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
 		    , NULL
 #endif
 		    );
-	else
+		notify_notification_add_action(self->priv->notification,
+		     "install-updates", ngettext("Install Update",
+		     "Install Updates", updates_normal + updates_important),
+		     notification_handle_action, self, NULL);
+	} else
 		notify_notification_update(self->priv->notification, title,
 		    message, icon);
 
@@ -282,22 +321,8 @@
 icon_activated(GtkStatusIcon *status_icon, gpointer user_data)
 {
 	PkuiIcon	*self = PKUI_ICON(user_data);
-	static const gchar *argv[] = { UPDATE_VIEWER_COMMAND, NULL };
-	GPid		pid;
-	gboolean	retval;
 
-	g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend));
-
-	retval = g_spawn_async(NULL, (gchar **)argv, NULL,
-	    G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL);
-	if (!retval) {
-		g_warning("Could not execute" UPDATE_VIEWER_COMMAND);
-		return;
-	}
-	g_child_watch_add(pid, (GChildWatchFunc)update_viewer_exited, self);
-
-	pkui_backend_set_inhibit_check(self->priv->backend, TRUE);
-	hide_notification(self);
+	exec_update_viewer(self);
 }
 
 PkuiIcon *
--- a/po/de.po	Thu Oct 20 13:03:37 2011 +0200
+++ b/po/de.po	Thu Oct 20 13:37:50 2011 +0200
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: pk-update-icon 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-20 12:32+0200\n"
+"POT-Creation-Date: 2011-10-20 13:27+0200\n"
 "PO-Revision-Date: 2011-10-10 19:21+0200\n"
 "Last-Translator: Guido Berhoerster <gber@opensuse.org>\n"
 "Language-Team: German\n"
@@ -37,35 +37,35 @@
 msgid "- display notifications about software updates"
 msgstr "- zeige Benachrichtigungen über Softwareaktualisierungen"
 
-#: ../pkui-icon.c:88
+#: ../pkui-icon.c:90
 msgid "Software Updates"
 msgstr "Softwareaktualisierungen"
 
-#: ../pkui-icon.c:127
+#: ../pkui-icon.c:152
 msgid "translators"
 msgstr "Guido Berhörster <gber@opensuse.org>"
 
-#: ../pkui-icon.c:154
+#: ../pkui-icon.c:180
 msgid "_Check for Updates"
 msgstr "Nach Aktualisierungen _Suchen"
 
-#: ../pkui-icon.c:162
+#: ../pkui-icon.c:188
 msgid "_About"
 msgstr "_Info"
 
-#: ../pkui-icon.c:191
+#: ../pkui-icon.c:227
 msgid "Important Software Update"
 msgid_plural "Important Software Updates"
 msgstr[0] "Wichtige Aktualisierung"
 msgstr[1] "Wichtige Aktualisierungen"
 
-#: ../pkui-icon.c:193
+#: ../pkui-icon.c:229
 msgid "Software Update"
 msgid_plural "Software Updates"
 msgstr[0] "Softwareaktualisierung"
 msgstr[1] "Softwareaktualisierungen"
 
-#: ../pkui-icon.c:200
+#: ../pkui-icon.c:236
 #, c-format
 msgid "There are %d software updates available, %d of them is important."
 msgid_plural ""
@@ -75,20 +75,26 @@
 msgstr[1] ""
 "Es sind %d Softwareaktualisierungen verfügbar, davon sind %d wichtig."
 
-#: ../pkui-icon.c:208
+#: ../pkui-icon.c:244
 #, c-format
 msgid "There is an important software update available."
 msgid_plural "There are %d important software updates available."
 msgstr[0] "Es ist eine wichtige Softwareaktualisierung verfügbar."
 msgstr[1] "Es sind %d wichtige Softwareaktualisierungen verfügbar."
 
-#: ../pkui-icon.c:213
+#: ../pkui-icon.c:249
 #, c-format
 msgid "There is a software update available."
 msgid_plural "There are %d software updates available."
 msgstr[0] "Eine Softwareaktualisierung ist verfügbar."
 msgstr[1] "Es sind %d Softwareaktualisierungen verfügbar."
 
+#: ../pkui-icon.c:265
+msgid "Install Update"
+msgid_plural "Install Updates"
+msgstr[0] "Aktualisierung Installieren"
+msgstr[1] "Aktualisierungen Installieren"
+
 #: ../pk-update-icon.desktop.in.h:1
 msgid "PackageKit Update Applet"
 msgstr "PackageKit Aktualisierungsapplet"
--- a/po/id.po	Thu Oct 20 13:03:37 2011 +0200
+++ b/po/id.po	Thu Oct 20 13:37:50 2011 +0200
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: pk-update-icon 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-20 12:32+0200\n"
+"POT-Creation-Date: 2011-10-20 13:27+0200\n"
 "PO-Revision-Date: 2011-10-20 10:50+0200\n"
 "Last-Translator: Guido Berhoerster <gber@opensuse.org>\n"
 "Language-Team: Indonesian\n"
@@ -38,35 +38,35 @@
 msgid "- display notifications about software updates"
 msgstr ""
 
-#: ../pkui-icon.c:88
+#: ../pkui-icon.c:90
 msgid "Software Updates"
 msgstr "Perangkat Lunak Pembaharuan-Pembaharuan"
 
-#: ../pkui-icon.c:127
+#: ../pkui-icon.c:152
 msgid "translators"
 msgstr "Guido Berhörster <gber@opensuse.org>"
 
-#: ../pkui-icon.c:154
+#: ../pkui-icon.c:180
 msgid "_Check for Updates"
 msgstr "Pemeriksaan untuk Pembaharuan-Pembaharuan"
 
-#: ../pkui-icon.c:162
+#: ../pkui-icon.c:188
 msgid "_About"
 msgstr "Tent_ang"
 
-#: ../pkui-icon.c:191
+#: ../pkui-icon.c:227
 msgid "Important Software Update"
 msgid_plural "Important Software Updates"
 msgstr[0] "Perangkat Lunak Pembaharuan yang penting"
 msgstr[1] "Perangkat Lunak Pembaharuan-Pembaharuan yang penting"
 
-#: ../pkui-icon.c:193
+#: ../pkui-icon.c:229
 msgid "Software Update"
 msgid_plural "Software Updates"
 msgstr[0] "Pembaharuan Perangkat Lunak"
 msgstr[1] "Pembaharuan-Pembaharuan Perangkat Lunak"
 
-#: ../pkui-icon.c:200
+#: ../pkui-icon.c:236
 #, c-format
 msgid "There are %d software updates available, %d of them is important."
 msgid_plural ""
@@ -75,20 +75,26 @@
 msgstr[1] ""
 "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak, diantaranya adalah penting."
 
-#: ../pkui-icon.c:208
+#: ../pkui-icon.c:244
 #, c-format
 msgid "There is an important software update available."
 msgid_plural "There are %d important software updates available."
 msgstr[0] "Tersedia sebuah Pembaharuan Perangkat Lunak yang penting."
 msgstr[1] "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak yang penting."
 
-#: ../pkui-icon.c:213
+#: ../pkui-icon.c:249
 #, c-format
 msgid "There is a software update available."
 msgid_plural "There are %d software updates available."
 msgstr[0] "Tersedia sebuah Pembaharuan Perangkat Lunak."
 msgstr[1] "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak."
 
+#: ../pkui-icon.c:265
+msgid "Install Update"
+msgid_plural "Install Updates"
+msgstr[0] "Pasang Perangkat Lunak Pembaharuan"
+msgstr[1] "Pasang Perangkat Lunak Pembaharuan-Pembaharuan"
+
 #: ../pk-update-icon.desktop.in.h:1
 msgid "PackageKit Update Applet"
 msgstr "PackageKit Update Applet"