Index: Makefile =================================================================== RCS file: /cvsroot/mplayer/main/Makefile,v retrieving revision 1.367 diff -u -r1.367 Makefile --- Makefile 25 Apr 2006 02:01:21 -0000 1.367 +++ Makefile 26 Apr 2006 18:11:41 -0000 @@ -74,6 +74,7 @@ $(DIRECTFB_LIB) \ $(CACA_LIB) \ $(VESA_LIB) \ + $(DBUS_GLIB_LIB) \ ifeq ($(EXTERNAL_VIDIX),yes) VO_LIBS += $(EXTERNAL_VIDIX_LIB) @@ -307,7 +308,7 @@ $(MAKE) -C libmpeg2 libvo/libvo.a: - $(MAKE) -C libvo + $(MAKE) -C libvo all libao2/libao2.a: $(MAKE) -C libao2 Index: configure =================================================================== RCS file: /cvsroot/mplayer/main/configure,v retrieving revision 1.1179 diff -u -r1.1179 configure --- configure 26 Apr 2006 01:59:05 -0000 1.1179 +++ configure 26 Apr 2006 18:11:41 -0000 @@ -222,6 +222,7 @@ --disable-ftp Disable ftp support [enabled] --disable-vstream Disable tivo vstream client support [autodetect] --disable-pthreads Disable Posix threads support [autodetect] + --disable-dbus-glib Disable D-BUS GLib interface (required for GNOME screensaver support) [autodetect] Codecs: --enable-gif enable gif support [autodetect] @@ -1601,6 +1602,7 @@ _musepack=auto _vstream=auto _pthreads=yes +_dbus_glib=auto for ac_option do case "$ac_option" in # Skip 1st pass @@ -1878,6 +1880,8 @@ --disable-vstream) _vstream=no ;; --enable-pthreads) _pthreads=yes ;; --disable-pthreads) _pthreads=no ;; + --enable-dbus-glib) _dbus_glib=yes ;; + --disable-dbus-glib) _dbus_glib=no ;; --enable-fribidi) _fribidi=yes ;; --disable-fribidi) _fribidi=no ;; @@ -6815,6 +6819,22 @@ fi echores "$_gethostbyname2" +echocheck "D-BUS GLib interface" +if test "$_dbus_glib" != no && pkg-config --exists dbus-glib-1; then + _dbus_glib=yes + _inc_dbus_glib=`pkg-config --cflags dbus-glib-1 2>/dev/null` + _ld_dbus_glib=`pkg-config --libs dbus-glib-1 2>/dev/null` + _def_dbus_glib='#define HAVE_DBUS_GLIB 1' + # Enable GNOME screensaver support if both D-BUS GLib and X11 are present + if test "$_x11" = yes; then + _vosrc="$_vosrc gnome_screensaver.c" + fi +else + _dbus_glib=no + _def_dbus_glib='#undef HAVE_DBUS_GLIB' +fi +echores "$_dbus_glib" + # --------------- GUI specific tests begin ------------------- echocheck "GUI" echo "$_gui" @@ -7290,6 +7310,8 @@ AA_LIB = $_ld_aa CACA_INC = $_inc_caca CACA_LIB = $_ld_caca +DBUS_GLIB_INC = $_inc_dbus_glib +DBUS_GLIB_LIB = $_ld_dbus_glib # audio output ALSA_LIB = $_ld_alsa @@ -8116,6 +8138,14 @@ OPTIONAL_OBJS = $_voobj EOF +if test "$_x11" = yes -a "$_dbus_glib" = yes; then + cat >> libvo/config.mak << EOF + +gnome_screensaver.o: gnome_screensaver.c + \$(CC) -c \$(CFLAGS) \$(DBUS_GLIB_INC) -o \$@ $< +EOF +fi + ############################################################################# echo "Creating libao2/config.mak" Index: libvo/gnome_screensaver.c =================================================================== RCS file: libvo/gnome_screensaver.c diff -N libvo/gnome_screensaver.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libvo/gnome_screensaver.c 26 Apr 2006 18:11:42 -0000 @@ -0,0 +1,98 @@ +#include +#include +#include + +#include "gnome_screensaver.h" + +#define GS_SERVICE "org.gnome.ScreenSaver" +#define GS_PATH "/org/gnome/ScreenSaver" +#define GS_INTERFACE "org.gnome.ScreenSaver" + +void gnome_screensaver_enable() +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *proxy; + + g_type_init(); + + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + g_printerr("Failed to open connection to bus: %s\n", + error->message); + g_error_free(error); + return; + } + + /* Create a proxy object */ + + proxy = dbus_g_proxy_new_for_name(connection, + GS_SERVICE, GS_PATH, GS_INTERFACE); + + /* Call method, wait for reply */ + error = NULL; + if (!dbus_g_proxy_call + (proxy, "AllowActivation", &error, G_TYPE_INVALID, + G_TYPE_INVALID)) { + /* Just do demonstrate remote exceptions versus regular GError */ + if (error->domain == DBUS_GERROR + && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + g_printerr("Caught remote method exception %s: %s", + dbus_g_error_get_name(error), error->message); + else + g_printerr("Error: %s\n", error->message); + + g_error_free(error); + } + else { + g_print("Gnome screensaver enabled\n"); + } + + g_object_unref(proxy); +} + + +void gnome_screensaver_disable() +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *proxy; + + g_type_init(); + + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + g_printerr("Failed to open connection to bus: %s\n", + error->message); + g_error_free(error); + return; + } + + /* Create a proxy object */ + + proxy = dbus_g_proxy_new_for_name(connection, + GS_SERVICE, GS_PATH, GS_INTERFACE); + + /* Call method, wait for reply */ + error = NULL; + if (!dbus_g_proxy_call + (proxy, "InhibitActivation", &error, G_TYPE_STRING, + "Playing a movie", G_TYPE_INVALID, G_TYPE_INVALID)) { + /* Just do demonstrate remote exceptions versus regular GError */ + if (error->domain == DBUS_GERROR + && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + g_printerr("Caught remote method exception %s: %s", + dbus_g_error_get_name(error), error->message); + else + g_printerr("Error: %s\n", error->message); + + g_error_free(error); + } + else { + g_print("Gnome screensaver disabled\n"); + } + + g_object_unref(proxy); +} Index: libvo/gnome_screensaver.h =================================================================== RCS file: libvo/gnome_screensaver.h diff -N libvo/gnome_screensaver.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libvo/gnome_screensaver.h 26 Apr 2006 18:11:42 -0000 @@ -0,0 +1,7 @@ +#ifndef _GNOME_SCREENSAVER_H +#define _GNOME_SCREENSAVER_H + +extern void gnome_screensaver_enable(); +extern void gnome_screensaver_disable(); + +#endif /* !_GNOME_SCREENSAVER_H */ Index: libvo/x11_common.c =================================================================== RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v retrieving revision 1.210 diff -u -r1.210 x11_common.c --- libvo/x11_common.c 25 Apr 2006 21:36:02 -0000 1.210 +++ libvo/x11_common.c 26 Apr 2006 18:11:42 -0000 @@ -58,6 +58,10 @@ #include "mplayer.h" #endif +#ifdef HAVE_DBUS_GLIB +#include "gnome_screensaver.h" +#endif + #define WIN_LAYER_ONBOTTOM 2 #define WIN_LAYER_NORMAL 4 #define WIN_LAYER_ONTOP 6 @@ -1692,8 +1696,12 @@ timeout_save = 0; } - if (stop_xscreensaver) + if (stop_xscreensaver) { xscreensaver_enable(); +#ifdef HAVE_DBUS_GLIB + gnome_screensaver_enable(); +#endif + } if (kdescreensaver_was_running && stop_xscreensaver) { system @@ -1738,8 +1746,12 @@ allow_exp); } // turning off screensaver - if (stop_xscreensaver) + if (stop_xscreensaver) { xscreensaver_disable(mDisplay); +#ifdef HAVE_DBUS_GLIB + gnome_screensaver_disable(); +#endif + } if (stop_xscreensaver && !kdescreensaver_was_running) { kdescreensaver_was_running =