[evince] Update totem-scrsaver from totem sources



commit e4687a2fc8498ed87b1c2b8f55cb91dfe7c3ff42
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Wed Feb 17 10:13:33 2010 +0100

    Update totem-scrsaver from totem sources
    
    Fixes bug #610173.

 cut-n-paste/totem-screensaver/totem-scrsaver.c |   81 ++++++++++-------------
 cut-n-paste/totem-screensaver/totem-scrsaver.h |   18 ++----
 shell/ev-application.c                         |   12 ++--
 3 files changed, 48 insertions(+), 63 deletions(-)
---
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 <hadess hadess net>
  */
@@ -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 <hadess hadess net>
  */
@@ -22,10 +22,6 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#ifdef ENABLE_DBUS
-#include <dbus/dbus-glib.h>
-#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);
 
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 9fe6596..5a87014 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -853,6 +853,9 @@ ev_application_shutdown (EvApplication *application)
 
 	ev_application_accel_map_save (application);
 
+	g_object_unref (application->scr_saver);
+	application->scr_saver = NULL;
+
 #ifdef ENABLE_DBUS
 	if (application->keys) {
 		g_object_unref (application->keys);
@@ -910,13 +913,14 @@ ev_application_init (EvApplication *ev_application)
 
 	ev_application_accel_map_load (ev_application);
 
+	ev_application->scr_saver = totem_scrsaver_new ();
+
 #ifdef ENABLE_DBUS
 	ev_application->connection = dbus_g_bus_get (DBUS_BUS_STARTER, &error);
 	if (ev_application->connection) {
 		dbus_g_connection_register_g_object (ev_application->connection,
 						     APPLICATION_DBUS_OBJECT_PATH,
 						     G_OBJECT (ev_application));
-		ev_application->scr_saver = totem_scrsaver_new (ev_application->connection);
 	} else {
 		g_warning ("Error connection to DBus: %s\n", error->message);
 		g_error_free (error);
@@ -992,15 +996,13 @@ ev_application_get_filechooser_uri (EvApplication       *application,
 void
 ev_application_screensaver_enable (EvApplication *application)
 {
-	if (application->scr_saver)
-		totem_scrsaver_enable (application->scr_saver);	
+	totem_scrsaver_enable (application->scr_saver);
 }
 
 void
 ev_application_screensaver_disable (EvApplication *application)
 {
-	if (application->scr_saver)
-		totem_scrsaver_disable (application->scr_saver);	
+	totem_scrsaver_disable (application->scr_saver);
 }
 
 const gchar *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]