From e4687a2fc8498ed87b1c2b8f55cb91dfe7c3ff42 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Wed, 17 Feb 2010 09:13:33 +0000 Subject: Update totem-scrsaver from totem sources Fixes bug #610173. --- (limited to 'cut-n-paste') diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.c b/cut-n-paste/totem-screensaver/totem-scrsaver.c index 0339171..6c0ba44 100644 --- a/cut-n-paste/totem-screensaver/totem-scrsaver.c +++ b/cut-n-paste/totem-screensaver/totem-scrsaver.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU Library General Public License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA. Author: Bastien Nocera */ @@ -50,8 +50,6 @@ #define XSCREENSAVER_MIN_TIMEOUT 60 static GObjectClass *parent_class = NULL; -static void totem_scrsaver_class_init (TotemScrsaverClass *class); -static void totem_scrsaver_init (TotemScrsaver *parser); static void totem_scrsaver_finalize (GObject *object); @@ -132,10 +130,12 @@ screensaver_inhibit_dbus (TotemScrsaver *scr, /* try the old API */ res = dbus_g_proxy_call (scr->priv->gs_proxy, "InhibitActivation", - &error, + NULL, G_TYPE_STRING, reason, G_TYPE_INVALID, G_TYPE_INVALID); + if (res) + g_error_free (error); } g_free (reason); @@ -155,9 +155,11 @@ screensaver_inhibit_dbus (TotemScrsaver *scr, /* try the old API */ res = dbus_g_proxy_call (scr->priv->gs_proxy, "AllowActivation", - &error, + NULL, G_TYPE_INVALID, G_TYPE_INVALID); + if (res) + g_error_free (error); } } @@ -194,16 +196,13 @@ gs_proxy_destroy_cb (GObject *proxy, } #endif -#ifdef ENABLE_DBUS static void -screensaver_init_dbus (TotemScrsaver *scr, DBusGConnection *connection) +screensaver_init_dbus (TotemScrsaver *scr) { +#ifdef ENABLE_DBUS GError *error = NULL; - if (!connection) - scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - else - scr->priv->connection = connection; + scr->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (! scr->priv->connection) { if (error) { @@ -226,9 +225,8 @@ screensaver_init_dbus (TotemScrsaver *scr, DBusGConnection *connection) 0); } - -} #endif /* ENABLE_DBUS */ +} static void screensaver_finalize_dbus (TotemScrsaver *scr) @@ -299,13 +297,12 @@ screensaver_disable_x11 (TotemScrsaver *scr) &scr->priv->allow_exposures); XUnlockDisplay (GDK_DISPLAY()); - if (scr->priv->timeout != 0) - { + if (scr->priv->timeout != 0) { g_timeout_add_seconds (scr->priv->timeout / 2, (GSourceFunc) fake_event, scr); } else { g_timeout_add_seconds (XSCREENSAVER_MIN_TIMEOUT / 2, - (GSourceFunc) fake_event, scr); + (GSourceFunc) fake_event, scr); } return; @@ -366,45 +363,23 @@ totem_scrsaver_class_init (TotemScrsaverClass *klass) object_class->finalize = totem_scrsaver_finalize; } -#ifdef ENABLE_DBUS TotemScrsaver * -totem_scrsaver_new (DBusGConnection *connection) +totem_scrsaver_new (void) { - TotemScrsaver * scr; - scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); - - screensaver_init_dbus (scr, connection); -#ifdef GDK_WINDOWING_X11 - screensaver_init_x11 (scr); -#else -#warning Unimplemented -#endif - - return scr; + return TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); } -#else -TotemScrsaver * -totem_scrsaver_new() + +static void +totem_scrsaver_init (TotemScrsaver *scr) { - TotemScrsaver * scr; - scr = TOTEM_SCRSAVER (g_object_new (TOTEM_TYPE_SCRSAVER, NULL)); + scr->priv = g_new0 (TotemScrsaverPrivate, 1); + screensaver_init_dbus (scr); #ifdef GDK_WINDOWING_X11 screensaver_init_x11 (scr); #else #warning Unimplemented #endif - - return scr; -} -#endif - -static void -totem_scrsaver_init (TotemScrsaver *scr) -{ - scr->priv = g_new0 (TotemScrsaverPrivate, 1); - - } void @@ -449,6 +424,20 @@ totem_scrsaver_enable (TotemScrsaver *scr) #endif } +void +totem_scrsaver_set_state (TotemScrsaver *scr, gboolean enable) +{ + g_return_if_fail (TOTEM_SCRSAVER (scr)); + + if (scr->priv->disabled == !enable) + return; + + if (enable == FALSE) + totem_scrsaver_disable (scr); + else + totem_scrsaver_enable (scr); +} + static void totem_scrsaver_finalize (GObject *object) { diff --git a/cut-n-paste/totem-screensaver/totem-scrsaver.h b/cut-n-paste/totem-screensaver/totem-scrsaver.h index e84299a..ab9c820 100644 --- a/cut-n-paste/totem-screensaver/totem-scrsaver.h +++ b/cut-n-paste/totem-screensaver/totem-scrsaver.h @@ -13,8 +13,8 @@ You should have received a copy of the GNU Library General Public License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA. Author: Bastien Nocera */ @@ -22,10 +22,6 @@ #include #include -#ifdef ENABLE_DBUS -#include -#endif - #define TOTEM_TYPE_SCRSAVER (totem_scrsaver_get_type ()) #define TOTEM_SCRSAVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOTEM_TYPE_SCRSAVER, TotemScrsaver)) #define TOTEM_SCRSAVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOTEM_TYPE_SCRSAVER, TotemScrsaverClass)) @@ -46,12 +42,10 @@ struct TotemScrsaverClass { GObjectClass parent_class; }; -GType totem_scrsaver_get_type (void); -#ifdef ENABLE_DBUS -TotemScrsaver *totem_scrsaver_new (DBusGConnection *connection); -#else -TotemScrsaver *totem_scrsaver_new (); -#endif +GType totem_scrsaver_get_type (void) G_GNUC_CONST; +TotemScrsaver *totem_scrsaver_new (void); void totem_scrsaver_enable (TotemScrsaver *scr); void totem_scrsaver_disable (TotemScrsaver *scr); +void totem_scrsaver_set_state (TotemScrsaver *scr, + gboolean enable); -- cgit v0.9.1