gnome-power-manager r3024 - in trunk: . data data/sounds po src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r3024 - in trunk: . data data/sounds po src
- Date: Mon, 20 Oct 2008 16:14:25 +0000 (UTC)
Author: rhughes
Date: Mon Oct 20 16:14:25 2008
New Revision: 3024
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3024&view=rev
Log:
2008-10-20 Richard Hughes <richard hughsie com>
* configure.ac:
* data/Makefile.am:
* data/sounds/Makefile.am:
* po/POTFILES.in:
* src/Makefile.am:
* src/gpm-main.c: (main):
* src/gpm-manager.c: (gpm_manager_play), (ac_adapter_changed_cb),
(control_sleep_failure_cb), (gpm_engine_charge_low_cb),
(gpm_engine_charge_critical_cb), (gpm_engine_charge_action_cb),
(gpm_manager_init), (gpm_manager_finalize):
* src/gpm-sound.c:
* src/gpm-sound.h:
Use libcanberra and the sound theme rather than shipping our own
sounds and using gstreamer directly.
Removed:
trunk/data/sounds/Makefile.am
trunk/data/sounds/gpm-critical-power.wav
trunk/data/sounds/gpm-suspend-failure.wav
trunk/data/sounds/gpm-unplugged.wav
trunk/src/gpm-sound.c
trunk/src/gpm-sound.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/data/Makefile.am
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/gpm-main.c
trunk/src/gpm-manager.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Mon Oct 20 16:14:25 2008
@@ -64,9 +64,9 @@
CAIRO_REQUIRED=1.0.0
UNIQUE_REQUIRED=0.9.4
LIBPANEL_REQUIRED=2.0.0
-GSTREAMER_REQUIRED=0.10
XRANDR_REQUIRED=1.2.0
POLKIT_GNOME_REQUIRED=0.8
+CANBERRA_REQUIRED=0.10
dnl ---------------------------------------------------------------------------
dnl - Make above strings available for packaging files (e.g. rpm spec files)
@@ -84,7 +84,6 @@
AC_SUBST(CAIRO_REQUIRED)
AC_SUBST(UNIQUE_REQUIRED)
AC_SUBST(LIBPANEL_REQUIRED)
-AC_SUBST(GSTREAMER_REQUIRED)
AC_SUBST(XRANDR_REQUIRED)
AC_SUBST(POLKIT_GNOME_REQUIRED)
@@ -99,9 +98,9 @@
AC_SUBST(HAL_CFLAGS)
AC_SUBST(HAL_LIBS)
-PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= $GSTREAMER_REQUIRED)
-AC_SUBST(GSTREAMER_CFLAGS)
-AC_SUBST(GSTREAMER_LIBS)
+PKG_CHECK_MODULES(CANBERRA, libcanberra-gtk >= $CANBERRA_REQUIRED)
+AC_SUBST(CANBERRA_CFLAGS)
+AC_SUBST(CANBERRA_LIBS)
PKG_CHECK_MODULES(DBUS,[
dbus-glib-1 >= $DBUS_REQUIRED
@@ -600,7 +599,6 @@
data/gnome-power-manager.desktop.in
data/gnome-power-preferences.desktop.in
data/gnome-power-statistics.desktop.in
-data/sounds/Makefile
data/icons/Makefile
data/icons/16x16/Makefile
data/icons/16x16/actions/Makefile
Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am (original)
+++ trunk/data/Makefile.am Mon Oct 20 16:14:25 2008
@@ -1,4 +1,4 @@
-SUBDIRS = icons sounds
+SUBDIRS = icons
@INTLTOOL_SCHEMAS_RULE@
schemadir = $(sysconfdir)/gconf/schemas
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Mon Oct 20 16:14:25 2008
@@ -70,8 +70,6 @@
src/gpm-prefs.h
src/gpm-screensaver.c
src/gpm-screensaver.h
-src/gpm-sound.c
-src/gpm-sound.h
src/gpm-statistics.c
src/gpm-statistics-core.c
src/gpm-statistics-core.h
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon Oct 20 16:14:25 2008
@@ -17,6 +17,7 @@
$(UNIQUE_CFLAGS) \
$(XRANDR_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
+ $(CANBERRA_CFLAGS) \
$(UNIQUE_CFLAGS) \
$(GSTREAMER_CFLAGS) \
$(POLKIT_CFLAGS) \
@@ -206,8 +207,6 @@
gpm-common.c \
gpm-screensaver.h \
gpm-screensaver.c \
- gpm-sound.h \
- gpm-sound.c \
gpm-networkmanager.h \
gpm-networkmanager.c \
gpm-stock-icons.h \
@@ -233,6 +232,7 @@
$(POLKIT_LIBS) \
$(DBUS_LIBS) \
$(XRANDR_LIBS) \
+ $(CANBERRA_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
$(LOCAL_LIBDBUS_LIBS) \
@@ -298,8 +298,6 @@
gpm-marshal.c \
gpm-common.h \
gpm-common.c \
- gpm-sound.h \
- gpm-sound.c \
gpm-info.h \
gpm-info.c \
gpm-array.h \
Modified: trunk/src/gpm-main.c
==============================================================================
--- trunk/src/gpm-main.c (original)
+++ trunk/src/gpm-main.c Mon Oct 20 16:14:25 2008
@@ -33,7 +33,6 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <libgnomeui/libgnomeui.h>
#include <glade/glade.h>
-#include <gst/gst.h>
#include "gpm-stock-icons.h"
#include "gpm-common.h"
@@ -230,9 +229,6 @@
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
GPM_DATA G_DIR_SEPARATOR_S "icons");
- /* initialise gstreamer */
- gst_init (&argc, &argv);
-
/* create a new gui object */
manager = gpm_manager_new ();
@@ -255,8 +251,6 @@
g_main_loop_unref (loop);
- /* rip down gstreamer */
- gst_deinit ();
g_object_unref (manager);
unref_program:
g_object_unref (program);
Modified: trunk/src/gpm-manager.c
==============================================================================
--- trunk/src/gpm-manager.c (original)
+++ trunk/src/gpm-manager.c Mon Oct 20 16:14:25 2008
@@ -39,6 +39,8 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <libgnomeui/gnome-client.h>
+#include <gconf/gconf-client.h>
+#include <canberra-gtk.h>
#include <libhal-gpower.h>
#include <libhal-gmanager.h>
@@ -62,7 +64,6 @@
#include "gpm-srv-screensaver.h"
#include "gpm-stock-icons.h"
#include "gpm-prefs-server.h"
-#include "gpm-sound.h"
#include "gpm-tray-icon.h"
#include "gpm-engine.h"
@@ -90,11 +91,11 @@
GpmNotify *notify;
GpmControl *control;
GpmScreensaver *screensaver;
- GpmSound *sound;
GpmTrayIcon *tray_icon;
GpmEngine *engine;
HalGPower *hal_power;
gboolean low_power;
+ GConfClient *gconf_client;
/* interactive services */
GpmBacklight *backlight;
@@ -113,6 +114,20 @@
LAST_SIGNAL
};
+typedef enum {
+ GPM_MANAGER_SOUND_POWER_PLUG,
+ GPM_MANAGER_SOUND_POWER_UNPLUG,
+ GPM_MANAGER_SOUND_LID_OPEN,
+ GPM_MANAGER_SOUND_LID_CLOSE,
+ GPM_MANAGER_SOUND_BATTERY_CAUTION,
+ GPM_MANAGER_SOUND_BATTERY_LOW,
+ GPM_MANAGER_SOUND_BATTERY_FULL,
+ GPM_MANAGER_SOUND_SUSPEND_START,
+ GPM_MANAGER_SOUND_SUSPEND_RESUME,
+ GPM_MANAGER_SOUND_SUSPEND_ERROR,
+ GPM_MANAGER_SOUND_LAST
+} GpmManagerSound;
+
static guint signals [LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GpmManager, gpm_manager, G_TYPE_OBJECT)
@@ -153,6 +168,77 @@
}
/**
+ * gpm_manager_play:
+ **/
+static gboolean
+gpm_manager_play (GpmManager *manager, GpmManagerSound action, gboolean force)
+{
+ const gchar *id = NULL;
+ const gchar *desc = NULL;
+ gboolean ret;
+
+ ret = gconf_client_get_bool (manager->priv->gconf_client, GPM_CONF_UI_ENABLE_BEEPING, NULL);
+ if (!ret && !force) {
+ egg_debug ("ignoring sound due to policy");
+ return FALSE;
+ }
+
+ if (action == GPM_MANAGER_SOUND_POWER_PLUG) {
+ id = "power-plug";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Power plugged in");
+ } else if (action == GPM_MANAGER_SOUND_POWER_UNPLUG) {
+ id = "power-unplug";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Power unplugged");
+ } else if (action == GPM_MANAGER_SOUND_LID_OPEN) {
+ id = "lid-open";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Lid has opened");
+ } else if (action == GPM_MANAGER_SOUND_LID_CLOSE) {
+ id = "lid-close";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Lid has closed");
+ } else if (action == GPM_MANAGER_SOUND_BATTERY_CAUTION) {
+ id = "battery-caution";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Battery is low");
+ } else if (action == GPM_MANAGER_SOUND_BATTERY_LOW) {
+ id = "battery-low";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Battery is very low");
+ } else if (action == GPM_MANAGER_SOUND_BATTERY_FULL) {
+ id = "battery-full";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Battery is full");
+ } else if (action == GPM_MANAGER_SOUND_SUSPEND_START) {
+ id = "suspend-start";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Suspend started");
+ } else if (action == GPM_MANAGER_SOUND_SUSPEND_RESUME) {
+ id = "suspend-resume";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Resumed");
+ } else if (action == GPM_MANAGER_SOUND_SUSPEND_ERROR) {
+ id = "suspend-error";
+ /* TRANSLATORS: this is the sound description */
+ desc = _("Suspend failed");
+ }
+
+ /* no match */
+ if (id == NULL) {
+ egg_warning ("no match");
+ return FALSE;
+ }
+
+ /* play the sound, using sounds from the naming spec */
+ ca_context_play (ca_gtk_context_get (), 0,
+ CA_PROP_EVENT_ID, id,
+ CA_PROP_EVENT_DESCRIPTION, desc, NULL);
+ return TRUE;
+}
+
+/**
* gpm_manager_is_inhibit_valid:
* @manager: This class instance
* @action: The action we want to do, e.g. "suspend"
@@ -1004,7 +1090,7 @@
gpm_manager_sync_policy_sleep (manager);
if (on_ac == FALSE)
- gpm_sound_event (manager->priv->sound, GPM_SOUND_AC_UNPLUGGED);
+ gpm_manager_play (manager, GPM_MANAGER_SOUND_POWER_UNPLUG, FALSE);
egg_debug ("emitting on-ac-changed : %i", on_ac);
if (on_ac) {
@@ -1342,7 +1428,7 @@
/* only show this if specified in gconf */
gpm_conf_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_SLEEP_FAILED, &show_sleep_failed);
- gpm_sound_event (manager->priv->sound, GPM_SOUND_SUSPEND_FAILURE);
+ gpm_manager_play (manager, GPM_MANAGER_SOUND_SUSPEND_ERROR, TRUE);
/* only emit if in GConf */
if (show_sleep_failed) {
@@ -1399,7 +1485,7 @@
gpm_notify_display (manager->priv->notify,
title, message, GPM_NOTIFY_TIMEOUT_LONG,
icon, GPM_NOTIFY_URGENCY_NORMAL);
- gpm_sound_event (manager->priv->sound, GPM_SOUND_POWER_LOW);
+ gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
g_free (message);
}
@@ -1507,7 +1593,7 @@
gpm_notify_display (manager->priv->notify,
title, message, GPM_NOTIFY_TIMEOUT_LONG,
icon, GPM_NOTIFY_URGENCY_CRITICAL);
- gpm_sound_event (manager->priv->sound, GPM_SOUND_POWER_LOW);
+ gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
g_free (message);
}
@@ -1592,7 +1678,7 @@
gpm_notify_display (manager->priv->notify,
title, message, GPM_NOTIFY_TIMEOUT_LONG,
icon, GPM_NOTIFY_URGENCY_CRITICAL);
- gpm_sound_event (manager->priv->sound, GPM_SOUND_POWER_LOW);
+ gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
g_free (message);
}
@@ -1673,6 +1759,7 @@
manager->priv->prefs_server = gpm_prefs_server_new ();
manager->priv->notify = gpm_notify_new ();
+ manager->priv->gconf_client = gconf_client_get_default ();
manager->priv->conf = gpm_conf_new ();
g_signal_connect (manager->priv->conf, "value-changed",
G_CALLBACK (conf_key_changed_cb), manager);
@@ -1708,7 +1795,6 @@
G_CALLBACK (button_pressed_cb), manager);
manager->priv->hal_power = hal_gpower_new ();
- manager->priv->sound = gpm_sound_new ();
/* try and start an interactive service */
manager->priv->screensaver = gpm_screensaver_new ();
@@ -1824,7 +1910,6 @@
/* compulsory gobjects */
g_object_unref (manager->priv->conf);
g_object_unref (manager->priv->hal_power);
- g_object_unref (manager->priv->sound);
g_object_unref (manager->priv->dpms);
g_object_unref (manager->priv->idle);
g_object_unref (manager->priv->info);
@@ -1836,6 +1921,7 @@
g_object_unref (manager->priv->srv_screensaver);
g_object_unref (manager->priv->prefs_server);
g_object_unref (manager->priv->control);
+ g_object_unref (manager->priv->gconf_client);
/* optional gobjects */
if (manager->priv->button) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]