projects/pk-update-icon

changeset 19:38b37e4a4d63

added a button for installing updates to the notification
author Guido Berhoerster <guido@berhoerster.name>
date Thu Oct 20 13:37:50 2011 +0200 (2011-10-20)
parents 9537882d759f
children d95c601ac333
files pkui-icon.c po/de.po po/id.po
line diff
     1.1 --- a/pkui-icon.c	Thu Oct 20 13:03:37 2011 +0200
     1.2 +++ b/pkui-icon.c	Thu Oct 20 13:37:50 2011 +0200
     1.3 @@ -43,7 +43,9 @@
     1.4  static void icon_popup_menu_popup(GtkStatusIcon *status_icon, guint button,
     1.5      guint activate_time, gpointer user_data);
     1.6  static void icon_activated(GtkStatusIcon *status_icon, gpointer user_data);
     1.7 +static void hide_notification(PkuiIcon *self);
     1.8  static void backend_state_changed(PkuiBackend *backend, gpointer user_data);
     1.9 +static void update_viewer_exited(GPid pid, gint status, gpointer user_data);
    1.10  
    1.11  static void
    1.12  pkui_icon_finalize(GObject *gobject)
    1.13 @@ -98,6 +100,29 @@
    1.14  }
    1.15  
    1.16  static void
    1.17 +exec_update_viewer(PkuiIcon *self)
    1.18 +{
    1.19 +	static const gchar *argv[] = { UPDATE_VIEWER_COMMAND, NULL };
    1.20 +	GPid		pid;
    1.21 +	gboolean	retval;
    1.22 +
    1.23 +	g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend));
    1.24 +
    1.25 +	g_debug("executing " UPDATE_VIEWER_COMMAND);
    1.26 +
    1.27 +	retval = g_spawn_async(NULL, (gchar **)argv, NULL,
    1.28 +	    G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL);
    1.29 +	if (!retval) {
    1.30 +		g_warning("Could not execute" UPDATE_VIEWER_COMMAND);
    1.31 +		return;
    1.32 +	}
    1.33 +	g_child_watch_add(pid, (GChildWatchFunc)update_viewer_exited, self);
    1.34 +
    1.35 +	pkui_backend_set_inhibit_check(self->priv->backend, TRUE);
    1.36 +	hide_notification(self);
    1.37 +}
    1.38 +
    1.39 +static void
    1.40  about_dialog_show(GtkMenuItem *item, gpointer user_data)
    1.41  {
    1.42  	static const gchar *copyright = "Copyright \xc2\xa9 2011 Guido "
    1.43 @@ -184,6 +209,16 @@
    1.44  }
    1.45  
    1.46  static void
    1.47 +notification_handle_action(NotifyNotification *notification, gchar *action,
    1.48 +    gpointer user_data)
    1.49 +{
    1.50 +	PkuiIcon *self = PKUI_ICON(user_data);
    1.51 +
    1.52 +	if (strcmp(action, "install-updates") == 0)
    1.53 +		exec_update_viewer(self);
    1.54 +}
    1.55 +
    1.56 +static void
    1.57  update_notification(PkuiIcon *self, guint updates_normal,
    1.58      guint updates_important)
    1.59  {
    1.60 @@ -219,14 +254,18 @@
    1.61  	gtk_status_icon_set_from_icon_name(self->priv->status_icon, icon);
    1.62  	gtk_status_icon_set_visible(self->priv->status_icon, TRUE);
    1.63  
    1.64 -	if (self->priv->notification == NULL)
    1.65 +	if (self->priv->notification == NULL) {
    1.66  		self->priv->notification = notify_notification_new(title,
    1.67  		    message, icon
    1.68  #if (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
    1.69  		    , NULL
    1.70  #endif
    1.71  		    );
    1.72 -	else
    1.73 +		notify_notification_add_action(self->priv->notification,
    1.74 +		     "install-updates", ngettext("Install Update",
    1.75 +		     "Install Updates", updates_normal + updates_important),
    1.76 +		     notification_handle_action, self, NULL);
    1.77 +	} else
    1.78  		notify_notification_update(self->priv->notification, title,
    1.79  		    message, icon);
    1.80  
    1.81 @@ -282,22 +321,8 @@
    1.82  icon_activated(GtkStatusIcon *status_icon, gpointer user_data)
    1.83  {
    1.84  	PkuiIcon	*self = PKUI_ICON(user_data);
    1.85 -	static const gchar *argv[] = { UPDATE_VIEWER_COMMAND, NULL };
    1.86 -	GPid		pid;
    1.87 -	gboolean	retval;
    1.88  
    1.89 -	g_return_if_fail(PKUI_IS_BACKEND(self->priv->backend));
    1.90 -
    1.91 -	retval = g_spawn_async(NULL, (gchar **)argv, NULL,
    1.92 -	    G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, NULL);
    1.93 -	if (!retval) {
    1.94 -		g_warning("Could not execute" UPDATE_VIEWER_COMMAND);
    1.95 -		return;
    1.96 -	}
    1.97 -	g_child_watch_add(pid, (GChildWatchFunc)update_viewer_exited, self);
    1.98 -
    1.99 -	pkui_backend_set_inhibit_check(self->priv->backend, TRUE);
   1.100 -	hide_notification(self);
   1.101 +	exec_update_viewer(self);
   1.102  }
   1.103  
   1.104  PkuiIcon *
     2.1 --- a/po/de.po	Thu Oct 20 13:03:37 2011 +0200
     2.2 +++ b/po/de.po	Thu Oct 20 13:37:50 2011 +0200
     2.3 @@ -7,7 +7,7 @@
     2.4  msgstr ""
     2.5  "Project-Id-Version: pk-update-icon 0.1\n"
     2.6  "Report-Msgid-Bugs-To: \n"
     2.7 -"POT-Creation-Date: 2011-10-20 12:32+0200\n"
     2.8 +"POT-Creation-Date: 2011-10-20 13:27+0200\n"
     2.9  "PO-Revision-Date: 2011-10-10 19:21+0200\n"
    2.10  "Last-Translator: Guido Berhoerster <gber@opensuse.org>\n"
    2.11  "Language-Team: German\n"
    2.12 @@ -37,35 +37,35 @@
    2.13  msgid "- display notifications about software updates"
    2.14  msgstr "- zeige Benachrichtigungen über Softwareaktualisierungen"
    2.15  
    2.16 -#: ../pkui-icon.c:88
    2.17 +#: ../pkui-icon.c:90
    2.18  msgid "Software Updates"
    2.19  msgstr "Softwareaktualisierungen"
    2.20  
    2.21 -#: ../pkui-icon.c:127
    2.22 +#: ../pkui-icon.c:152
    2.23  msgid "translators"
    2.24  msgstr "Guido Berhörster <gber@opensuse.org>"
    2.25  
    2.26 -#: ../pkui-icon.c:154
    2.27 +#: ../pkui-icon.c:180
    2.28  msgid "_Check for Updates"
    2.29  msgstr "Nach Aktualisierungen _Suchen"
    2.30  
    2.31 -#: ../pkui-icon.c:162
    2.32 +#: ../pkui-icon.c:188
    2.33  msgid "_About"
    2.34  msgstr "_Info"
    2.35  
    2.36 -#: ../pkui-icon.c:191
    2.37 +#: ../pkui-icon.c:227
    2.38  msgid "Important Software Update"
    2.39  msgid_plural "Important Software Updates"
    2.40  msgstr[0] "Wichtige Aktualisierung"
    2.41  msgstr[1] "Wichtige Aktualisierungen"
    2.42  
    2.43 -#: ../pkui-icon.c:193
    2.44 +#: ../pkui-icon.c:229
    2.45  msgid "Software Update"
    2.46  msgid_plural "Software Updates"
    2.47  msgstr[0] "Softwareaktualisierung"
    2.48  msgstr[1] "Softwareaktualisierungen"
    2.49  
    2.50 -#: ../pkui-icon.c:200
    2.51 +#: ../pkui-icon.c:236
    2.52  #, c-format
    2.53  msgid "There are %d software updates available, %d of them is important."
    2.54  msgid_plural ""
    2.55 @@ -75,20 +75,26 @@
    2.56  msgstr[1] ""
    2.57  "Es sind %d Softwareaktualisierungen verfügbar, davon sind %d wichtig."
    2.58  
    2.59 -#: ../pkui-icon.c:208
    2.60 +#: ../pkui-icon.c:244
    2.61  #, c-format
    2.62  msgid "There is an important software update available."
    2.63  msgid_plural "There are %d important software updates available."
    2.64  msgstr[0] "Es ist eine wichtige Softwareaktualisierung verfügbar."
    2.65  msgstr[1] "Es sind %d wichtige Softwareaktualisierungen verfügbar."
    2.66  
    2.67 -#: ../pkui-icon.c:213
    2.68 +#: ../pkui-icon.c:249
    2.69  #, c-format
    2.70  msgid "There is a software update available."
    2.71  msgid_plural "There are %d software updates available."
    2.72  msgstr[0] "Eine Softwareaktualisierung ist verfügbar."
    2.73  msgstr[1] "Es sind %d Softwareaktualisierungen verfügbar."
    2.74  
    2.75 +#: ../pkui-icon.c:265
    2.76 +msgid "Install Update"
    2.77 +msgid_plural "Install Updates"
    2.78 +msgstr[0] "Aktualisierung Installieren"
    2.79 +msgstr[1] "Aktualisierungen Installieren"
    2.80 +
    2.81  #: ../pk-update-icon.desktop.in.h:1
    2.82  msgid "PackageKit Update Applet"
    2.83  msgstr "PackageKit Aktualisierungsapplet"
     3.1 --- a/po/id.po	Thu Oct 20 13:03:37 2011 +0200
     3.2 +++ b/po/id.po	Thu Oct 20 13:37:50 2011 +0200
     3.3 @@ -8,7 +8,7 @@
     3.4  msgstr ""
     3.5  "Project-Id-Version: pk-update-icon 0.1\n"
     3.6  "Report-Msgid-Bugs-To: \n"
     3.7 -"POT-Creation-Date: 2011-10-20 12:32+0200\n"
     3.8 +"POT-Creation-Date: 2011-10-20 13:27+0200\n"
     3.9  "PO-Revision-Date: 2011-10-20 10:50+0200\n"
    3.10  "Last-Translator: Guido Berhoerster <gber@opensuse.org>\n"
    3.11  "Language-Team: Indonesian\n"
    3.12 @@ -38,35 +38,35 @@
    3.13  msgid "- display notifications about software updates"
    3.14  msgstr ""
    3.15  
    3.16 -#: ../pkui-icon.c:88
    3.17 +#: ../pkui-icon.c:90
    3.18  msgid "Software Updates"
    3.19  msgstr "Perangkat Lunak Pembaharuan-Pembaharuan"
    3.20  
    3.21 -#: ../pkui-icon.c:127
    3.22 +#: ../pkui-icon.c:152
    3.23  msgid "translators"
    3.24  msgstr "Guido Berhörster <gber@opensuse.org>"
    3.25  
    3.26 -#: ../pkui-icon.c:154
    3.27 +#: ../pkui-icon.c:180
    3.28  msgid "_Check for Updates"
    3.29  msgstr "Pemeriksaan untuk Pembaharuan-Pembaharuan"
    3.30  
    3.31 -#: ../pkui-icon.c:162
    3.32 +#: ../pkui-icon.c:188
    3.33  msgid "_About"
    3.34  msgstr "Tent_ang"
    3.35  
    3.36 -#: ../pkui-icon.c:191
    3.37 +#: ../pkui-icon.c:227
    3.38  msgid "Important Software Update"
    3.39  msgid_plural "Important Software Updates"
    3.40  msgstr[0] "Perangkat Lunak Pembaharuan yang penting"
    3.41  msgstr[1] "Perangkat Lunak Pembaharuan-Pembaharuan yang penting"
    3.42  
    3.43 -#: ../pkui-icon.c:193
    3.44 +#: ../pkui-icon.c:229
    3.45  msgid "Software Update"
    3.46  msgid_plural "Software Updates"
    3.47  msgstr[0] "Pembaharuan Perangkat Lunak"
    3.48  msgstr[1] "Pembaharuan-Pembaharuan Perangkat Lunak"
    3.49  
    3.50 -#: ../pkui-icon.c:200
    3.51 +#: ../pkui-icon.c:236
    3.52  #, c-format
    3.53  msgid "There are %d software updates available, %d of them is important."
    3.54  msgid_plural ""
    3.55 @@ -75,20 +75,26 @@
    3.56  msgstr[1] ""
    3.57  "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak, diantaranya adalah penting."
    3.58  
    3.59 -#: ../pkui-icon.c:208
    3.60 +#: ../pkui-icon.c:244
    3.61  #, c-format
    3.62  msgid "There is an important software update available."
    3.63  msgid_plural "There are %d important software updates available."
    3.64  msgstr[0] "Tersedia sebuah Pembaharuan Perangkat Lunak yang penting."
    3.65  msgstr[1] "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak yang penting."
    3.66  
    3.67 -#: ../pkui-icon.c:213
    3.68 +#: ../pkui-icon.c:249
    3.69  #, c-format
    3.70  msgid "There is a software update available."
    3.71  msgid_plural "There are %d software updates available."
    3.72  msgstr[0] "Tersedia sebuah Pembaharuan Perangkat Lunak."
    3.73  msgstr[1] "Tersedia Pembaharuan-Pembaharuan Perangkat Lunak."
    3.74  
    3.75 +#: ../pkui-icon.c:265
    3.76 +msgid "Install Update"
    3.77 +msgid_plural "Install Updates"
    3.78 +msgstr[0] "Pasang Perangkat Lunak Pembaharuan"
    3.79 +msgstr[1] "Pasang Perangkat Lunak Pembaharuan-Pembaharuan"
    3.80 +
    3.81  #: ../pk-update-icon.desktop.in.h:1
    3.82  msgid "PackageKit Update Applet"
    3.83  msgstr "PackageKit Update Applet"