On Wed, Apr 26, 2006 at 04:31:04PM +0200, Piotr Kaczuba wrote:
On Wed, Apr 26, 2006 at 04:08:32PM +0200, Attila Kinali wrote:
On Wed, 26 Apr 2006 15:50:17 +0200 Piotr Kaczuba <pepe@attika.ath.cx> wrote:
+#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 + }
Shouldn't you check whether the screensaver is actualy running before disabling it, to prevent enabling it when it wasnt enabled?
And how does your patch behave, when gnome is installed, but not running ?
Actually, I'm sending an InhibitActivation message to the screensaver, it's not a real disable. So, when it's not enabled, InhibitActivation doesn't do anything. Similarly, AllowActivation is sent when stopping playing: it won't enable/start the screensaver when it isn't running. See the last question at http://live.gnome.org/GnomeScreensaver/FrequentlyAskedQuestions, which gives some examples of how to do it.
Attached there is the proper patch, as the previous one has two files missing.
diff -uNr main/Makefile main.new/Makefile --- main/Makefile 2006-04-25 04:01:21.000000000 +0200 +++ main.new/Makefile 2006-04-26 14:44:57.303825307 +0200 @@ -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 diff -uNr main/configure main.new/configure --- main/configure 2006-04-26 03:59:05.000000000 +0200 +++ main.new/configure 2006-04-26 14:40:07.527783461 +0200 @@ -6815,6 +6815,23 @@ fi echores "$_gethostbyname2"
+# Check for D-BUS GLib interface +echocheck "D-BUS GLib interface" +if 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' +else + _dbus_glib=no + _def_dbus_glib='#undef HAVE_DBUS_GLIB' +fi +echores "$_dbus_glib" + +if test "$_x11" = yes -a "$_dbus_glib" = yes; then + _vosrc="$_vosrc gnome_screensaver.c" +fi + # --------------- GUI specific tests begin ------------------- echocheck "GUI" echo "$_gui" @@ -7290,6 +7307,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 +8135,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" diff -uNr main/libvo/gnome_screensaver.c main.new/libvo/gnome_screensaver.c --- main/libvo/gnome_screensaver.c 1970-01-01 01:00:00.000000000 +0100 +++ main.new/libvo/gnome_screensaver.c 2006-04-26 13:39:18.290095378 +0200 @@ -0,0 +1,98 @@ +#include <stdlib.h> +#include <unistd.h> +#include <dbus/dbus-glib.h> + +#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",
see bellow
+ 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",
see bellow
+ dbus_g_error_get_name(error), error->message); + else + g_printerr("Error: %s\n", error->message);
see bellow
+ + g_error_free(error); + } + else { + g_print("Gnome screensaver enabled\n");
see bellow
+ } + + 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",
see bellow
+ 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",
see bellow
+ dbus_g_error_get_name(error), error->message); + else + g_printerr("Error: %s\n", error->message);
see bellow
+ + g_error_free(error); + } + else { + g_print("Gnome screensaver disabled\n");
see bellow or you hack your way around some kind of g_set_print_handler call or you replace g_printerr/g_print ocurrences with our messaging routines, this is a big patch stoper. Best regards Reynaldo