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 28 Apr 2006 09:32:56 -0000 @@ -74,6 +74,7 @@ $(DIRECTFB_LIB) \ $(CACA_LIB) \ $(VESA_LIB) \ + $(DBUS_GLIB_LIB) \ ifeq ($(EXTERNAL_VIDIX),yes) VO_LIBS += $(EXTERNAL_VIDIX_LIB) 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 28 Apr 2006 09:32:57 -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,24 @@ fi echores "$_gethostbyname2" +echocheck "D-BUS GLib interface" +if test "$_dbus_glib" = auto && 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` +fi + +if test "$_dbus_glib" = yes; then + _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 + _def_dbus_glib='#undef HAVE_DBUS_GLIB' +fi +echores "$_dbus_glib" + # --------------- GUI specific tests begin ------------------- echocheck "GUI" echo "$_gui" @@ -7290,6 +7312,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 @@ -8095,6 +8119,7 @@ $_def_tga $_def_toolame $_def_twolame +$_def_dbus_glib /* used by GUI: */ $_def_xshape Index: help/help_mp-en.h =================================================================== RCS file: /cvsroot/mplayer/main/help/help_mp-en.h,v retrieving revision 1.249 diff -u -r1.249 help_mp-en.h --- help/help_mp-en.h 27 Apr 2006 03:55:46 -0000 1.249 +++ help/help_mp-en.h 28 Apr 2006 09:32:57 -0000 @@ -676,6 +676,13 @@ #define MSGTR_InsertingAfVolume "[Mixer] No hardware mixing, inserting volume filter.\n" #define MSGTR_NoVolume "[Mixer] No volume control available.\n" +// gnome_screensaver.c +#define MSGTR_OpenBusConnectionError "Failed to open connection to bus: %s\n" +#define MSGTR_RemoteMethodException "Caught remote method exception %s: %s\n" +#define MSGTR_GError "Error: %s\n" +#define MSGTR_GNOMEScreensaverEnabled "GNOME screensaver enabled\n" +#define MSGTR_GNOMEScreensaverDisabled "GNOME screensaver disabled\n" + // ====================== GUI messages/buttons ======================== #ifdef HAVE_NEW_GUI Index: libvo/Makefile =================================================================== RCS file: /cvsroot/mplayer/main/libvo/Makefile,v retrieving revision 1.54 diff -u -r1.54 Makefile --- libvo/Makefile 28 Mar 2006 22:44:16 -0000 1.54 +++ libvo/Makefile 28 Apr 2006 09:32:57 -0000 @@ -62,6 +62,9 @@ vo_mpegpes.o: vo_mpegpes.c $(CC) -c $(CFLAGS) $(DVB_INC) -o $@ $< +gnome_screensaver.o: gnome_screensaver.c + $(CC) -c $(CFLAGS) $(DBUS_GLIB_INC) -o $@ $< + all: $(LIBNAME) clean: 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 28 Apr 2006 09:32:57 -0000 @@ -0,0 +1,110 @@ +#include +#include +#include + +#include "gnome_screensaver.h" +#include "mp_msg.h" +#include "help_mp.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(); + + /* Get a connection to the session bus */ + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_enable(): " MSGTR_OpenBusConnectionError, + 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)) { + /* Check if it's a remote exception or a regular GError */ + if (error->domain == DBUS_GERROR + && error->code == DBUS_GERROR_REMOTE_EXCEPTION) { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_enable(): " MSGTR_RemoteMethodException, + dbus_g_error_get_name(error), error->message); + } + else { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_enable(): " MSGTR_GError, + error->message); + } + g_error_free(error); + } + else { + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_GNOMEScreensaverEnabled); + } + + g_object_unref(proxy); +} + + +void gnome_screensaver_disable() +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *proxy; + + g_type_init(); + + /* Get a connection to the session bus */ + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_disable(): " MSGTR_OpenBusConnectionError, + 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)) { + /* Check if it's a remote exception or a regular GError */ + if (error->domain == DBUS_GERROR + && error->code == DBUS_GERROR_REMOTE_EXCEPTION) { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_disable(): " MSGTR_RemoteMethodException, + dbus_g_error_get_name(error), error->message); + } + else { + mp_msg(MSGT_VO, MSGL_ERR, + "gnome_screensaver_disable(): " MSGTR_GError, + error->message); + } + g_error_free(error); + } + else { + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_GNOMEScreensaverDisabled); + } + + 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 28 Apr 2006 09:32:57 -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 28 Apr 2006 09:32:57 -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 =