[gnome-packagekit] Use libcanberra to do event sounds when we succeed in doing an update



commit 838e72cc785dc4e8fd8be6d7912ec1a4eb82e6ff
Author: Richard Hughes <richard hughsie com>
Date:   Wed Apr 22 13:00:37 2009 +0100

    Use libcanberra to do event sounds when we succeed in doing an update
---
 configure.ac                     |    5 +++++
 contrib/gnome-packagekit.spec.in |    2 ++
 src/Makefile.am                  |    2 ++
 src/gpk-check-update.c           |   11 +++++++++++
 src/gpk-update-viewer.c          |   24 ++++++++++++++++++++++++
 5 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7272a95..4da70ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,6 +88,7 @@ POLKIT_GNOME_REQUIRED=0.8
 UNIQUE_REQUIRED=1.0.0
 GNOME_MENUS_REQUIRED=2.24.1
 GIO_REQUIRED=2.18.0
+CANBERRA_REQUIRED=0.10
 
 dnl ---------------------------------------------------------------------------
 dnl - Make above strings available for packaging files (e.g. rpm spec files)
@@ -154,6 +155,10 @@ PKG_CHECK_MODULES(UNIQUE, \
 AC_SUBST(UNIQUE_CFLAGS)
 AC_SUBST(UNIQUE_LIBS)
 
+PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk >= $CANBERRA_REQUIRED)
+AC_SUBST(CANBERRA_CFLAGS)
+AC_SUBST(CANBERRA_LIBS)
+
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
 AM_GCONF_SOURCE_2
 
diff --git a/contrib/gnome-packagekit.spec.in b/contrib/gnome-packagekit.spec.in
index c793e1b..ffbfd8b 100644
--- a/contrib/gnome-packagekit.spec.in
+++ b/contrib/gnome-packagekit.spec.in
@@ -25,6 +25,7 @@ Requires:  PackageKit-libs >= %{packagekit_version}
 Requires:  PackageKit-gtk-module >= %{packagekit_version}
 Requires:  shared-mime-info
 Requires:  iso-codes
+Requires:  libcanberra
 Requires(post):   scrollkeeper
 Requires(pre):    GConf2
 Requires(post):   GConf2
@@ -54,6 +55,7 @@ BuildRequires: unique-devel
 BuildRequires: intltool
 BuildRequires: xorg-x11-proto-devel
 BuildRequires: fontconfig-devel
+BuildRequires: libcanberra-devel
 
 %description
 gnome-packagekit provides session applications for the PackageKit API.
diff --git a/src/Makefile.am b/src/Makefile.am
index e38a7c3..33b9617 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ INCLUDES =						\
 	$(POLKIT_GNOME_CFLAGS)				\
 	$(GTK_CFLAGS)					\
 	$(GNOME_MENUS_CFLAGS)				\
+	$(CANBERRA_CFLAGS)				\
 	-DBINDIR=\"$(bindir)\"			 	\
 	-DDATADIR=\"$(datadir)\"			\
 	-DPREFIX=\""$(prefix)"\" 			\
@@ -112,6 +113,7 @@ shared_LIBS =						\
 	$(UNIQUE_LIBS)					\
 	$(POLKIT_GNOME_LIBS)				\
 	$(GNOME_MENUS_LIBS)				\
+	$(CANBERRA_LIBS)				\
 	$(NULL)
 
 gpk_install_provide_file_SOURCES =			\
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 2277abb..64c32dc 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -38,6 +38,7 @@
 #include <gconf/gconf-client.h>
 #include <libnotify/notify.h>
 #include <packagekit-glib/packagekit.h>
+#include <canberra-gtk.h>
 
 #include "egg-debug.h"
 #include "egg-string.h"
@@ -1396,6 +1397,16 @@ gpk_check_update_finished_cb (PkClient *client, PkExitEnum exit_enum, guint runt
 	if ((role == PK_ROLE_ENUM_UPDATE_PACKAGES ||
 	     role == PK_ROLE_ENUM_UPDATE_SYSTEM) &&
 	    exit_enum == PK_EXIT_ENUM_SUCCESS) {
+
+		/* play the sound, using sounds from the naming spec */
+		ca_context_play (ca_gtk_context_get (), 0,
+				 /* TODO: add a new sound to the spec */
+				 CA_PROP_EVENT_ID, "complete-download",
+				 /* TRANSLATORS: this is the application name for libcanberra */
+				 CA_PROP_APPLICATION_NAME, _("GNOME PackageKit Update Icon"),
+				 /* TRANSLATORS: this is the sound description */
+				 CA_PROP_EVENT_DESCRIPTION, _("Updated successfully"), NULL);
+
 		gpk_check_update_finished_notify (cupdate, client);
 		cupdate->priv->number_updates_critical_last_shown = 0;
 	}
diff --git a/src/gpk-update-viewer.c b/src/gpk-update-viewer.c
index 8759f80..fbaea72 100644
--- a/src/gpk-update-viewer.c
+++ b/src/gpk-update-viewer.c
@@ -32,6 +32,7 @@
 #include <packagekit-glib/packagekit.h>
 #include <libnotify/notify.h>
 #include <unique/unique.h>
+#include <canberra-gtk.h>
 
 #include "egg-debug.h"
 #include "egg-string.h"
@@ -1682,6 +1683,15 @@ gpk_update_viewer_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
 	    (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
 	     role == PK_ROLE_ENUM_UPDATE_PACKAGES)) {
 
+		/* play the sound, using sounds from the naming spec */
+		ca_context_play (ca_gtk_context_get (), 0,
+				 /* TODO: add a new sound to the spec */
+				 CA_PROP_EVENT_ID, "complete-download",
+				 /* TRANSLATORS: this is the application name for libcanberra */
+				 CA_PROP_APPLICATION_NAME, _("GNOME PackageKit Update Viewer"),
+				 /* TRANSLATORS: this is the sound description */
+				 CA_PROP_EVENT_DESCRIPTION, _("Updated successfully"), NULL);
+
 		/* get the worst restart case */
 		restart = pk_client_get_require_restart (client_primary);
 		if (restart > restart_update)
@@ -1732,6 +1742,20 @@ gpk_update_viewer_finished_cb (PkClient *client, PkExitEnum exit, guint runtime,
 		g_main_loop_quit (loop);
 	}
 
+	/* failed sound */
+	if (exit != PK_EXIT_ENUM_SUCCESS &&
+	    (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
+	     role == PK_ROLE_ENUM_UPDATE_PACKAGES)) {
+
+		/* play the sound, using sounds from the naming spec */
+		ca_context_play (ca_gtk_context_get (), 0,
+				 CA_PROP_EVENT_ID, "dialog-warning",
+				 /* TRANSLATORS: this is the application name for libcanberra */
+				 CA_PROP_APPLICATION_NAME, _("GNOME PackageKit Update Viewer"),
+				 /* TRANSLATORS: this is the sound description */
+				 CA_PROP_EVENT_DESCRIPTION, _("Failed to update"), NULL);
+	}
+
 	/* we pressed cancel */
 	if (exit != PK_EXIT_ENUM_SUCCESS) {
 		gpk_update_viewer_undisable_packages ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]