]> www.fi.muni.cz Git - evince.git/commitdiff
Update totem-scrsaver from totem sources
authorCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 17 Feb 2010 09:13:33 +0000 (10:13 +0100)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Wed, 17 Feb 2010 09:13:33 +0000 (10:13 +0100)
Fixes bug #610173.

cut-n-paste/totem-screensaver/totem-scrsaver.c
cut-n-paste/totem-screensaver/totem-scrsaver.h
shell/ev-application.c

index 0339171cecbf214a663a8a029f1c17bd04a6738b..6c0ba44cb8e2f3509ef7d6eb34a1cab718772f87 100644 (file)
@@ -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)
 {
index e84299a072fd35c82350b47c02f4518408fe83ad..ab9c820db7ec6588e6dfc67dff65e4011c723302 100644 (file)
@@ -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>
  */
 #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);
 
index 9fe6596acc64eae059e3c5482b8662940a0f46e7..5a870148fd3c4352fc9e984cc8c5081598987433 100644 (file)
@@ -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 *