[evince/wip/app] shell: Use GtkApplication to inhibit the screensaver



commit 77ebbab963000d34f9653e7a59a463ab59ec87da
Author: Christian Persch <chpe gnome org>
Date:   Wed Jun 13 00:25:29 2012 +0200

    shell: Use GtkApplication to inhibit the screensaver
    
    Remove TotemScrsaver copy, and use GtkApplication inhibition instead.

 cut-n-paste/Makefile.am                        |    2 +-
 cut-n-paste/totem-screensaver/Makefile.am      |   16 -
 cut-n-paste/totem-screensaver/README           |    3 -
 cut-n-paste/totem-screensaver/totem-scrsaver.c |  539 ------------------------
 cut-n-paste/totem-screensaver/totem-scrsaver.h |   57 ---
 shell/Makefile.am                              |    2 -
 shell/ev-application.c                         |   24 -
 shell/ev-application.h                         |    2 -
 shell/ev-window.c                              |   40 ++-
 9 files changed, 37 insertions(+), 648 deletions(-)
---
diff --git a/cut-n-paste/Makefile.am b/cut-n-paste/Makefile.am
index b53b9b9..98f134a 100644
--- a/cut-n-paste/Makefile.am
+++ b/cut-n-paste/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = zoom-control toolbar-editor totem-screensaver smclient gimpcellrenderertoggle synctex
+SUBDIRS = zoom-control toolbar-editor smclient gimpcellrenderertoggle synctex
 
 -include $(top_srcdir)/git.mk
diff --git a/shell/Makefile.am b/shell/Makefile.am
index e1f816a..7477ef6 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -5,7 +5,6 @@ INCLUDES=							\
 	-I$(top_builddir)					\
 	-I$(top_srcdir)/cut-n-paste/zoom-control/		\
 	-I$(top_srcdir)/cut-n-paste/toolbar-editor/		\
-	-I$(top_srcdir)/cut-n-paste/totem-screensaver/		\
 	-I$(top_srcdir)/cut-n-paste/gimpcellrenderertoggle/	\
 	-I$(top_srcdir)/cut-n-paste/smclient/			\
 	-I$(top_srcdir)/libdocument				\
@@ -113,7 +112,6 @@ endif
 evince_LDADD=										\
 	$(top_builddir)/cut-n-paste/zoom-control/libephyzoom.la				\
 	$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la			\
-	$(top_builddir)/cut-n-paste/totem-screensaver/libtotemscrsaver.la		\
 	$(top_builddir)/cut-n-paste/gimpcellrenderertoggle/libgimpcellrenderertoggle.la	\
 	$(top_builddir)/cut-n-paste/smclient/libsmclient.la				\
 	$(top_builddir)/properties/libevproperties.la					\
diff --git a/shell/ev-application.c b/shell/ev-application.c
index f977cbd..3bfb64a 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -35,8 +35,6 @@
 #endif
 #include <unistd.h>
 
-#include "totem-scrsaver.h"
-
 #ifdef WITH_SMCLIENT
 #include "eggsmclient.h"
 #endif
@@ -64,8 +62,6 @@ struct _EvApplication {
 	gboolean doc_registered;
 #endif
 
-	TotemScrsaver *scr_saver;
-
 #ifdef WITH_SMCLIENT
 	EggSMClient *smclient;
 #endif
@@ -964,9 +960,6 @@ ev_application_shutdown (GApplication *gapplication)
 
 	ev_application_accel_map_save (application);
 
-	g_object_unref (application->scr_saver);
-	application->scr_saver = NULL;
-
         g_free (application->dot_dir);
         application->dot_dir = NULL;
 
@@ -1071,11 +1064,6 @@ ev_application_init (EvApplication *ev_application)
 	ev_application_init_session (ev_application);
 
 	ev_application_accel_map_load (ev_application);
-
-	ev_application->scr_saver = totem_scrsaver_new ();
-	g_object_set (ev_application->scr_saver,
-		      "reason", _("Running in presentation mode"),
-		      NULL);
 }
 
 gboolean
@@ -1135,18 +1123,6 @@ ev_application_get_media_keys (EvApplication *application)
 #endif /* ENABLE_DBUS */
 }
 
-void
-ev_application_screensaver_enable (EvApplication *application)
-{
-	totem_scrsaver_enable (application->scr_saver);
-}
-
-void
-ev_application_screensaver_disable (EvApplication *application)
-{
-	totem_scrsaver_disable (application->scr_saver);
-}
-
 const gchar *
 ev_application_get_dot_dir (EvApplication *application,
                             gboolean create)
diff --git a/shell/ev-application.h b/shell/ev-application.h
index b631127..a18d0e1 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -78,8 +78,6 @@ GList            *ev_application_get_windows         (EvApplication   *applicati
 const gchar *     ev_application_get_uri             (EvApplication   *application);
 GObject		 *ev_application_get_media_keys	     (EvApplication   *application);
 
-void		  ev_application_screensaver_enable  (EvApplication   *application);
-void		  ev_application_screensaver_disable (EvApplication   *application);
 const gchar      *ev_application_get_dot_dir         (EvApplication   *application,
                                                       gboolean         create);
 
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 3448156..d0fb190 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -223,6 +223,8 @@ struct _EvWindowPrivate {
 	EvEvinceWindow *impl;
 	gchar *dbus_object_path;
 #endif
+
+        guint presentation_mode_inhibit_id;
 };
 
 #define EV_WINDOW_GET_PRIVATE(object) \
@@ -4050,6 +4052,35 @@ ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
 }
 
 static void
+ev_window_inhibit_screensaver (EvWindow *window)
+{
+        EvWindowPrivate *priv = window->priv;
+
+        if (priv->presentation_mode_inhibit_id != 0)
+                return;
+
+        priv->presentation_mode_inhibit_id =
+                gtk_application_inhibit (GTK_APPLICATION (g_application_get_default ()),
+                                         GTK_WINDOW (window),
+                                         GTK_APPLICATION_INHIBIT_IDLE,
+                                         _("Running in presentation mode"));
+}
+
+
+static void
+ev_window_uninhibit_screensaver (EvWindow *window)
+{
+        EvWindowPrivate *priv = window->priv;
+
+        if (priv->presentation_mode_inhibit_id == 0)
+                return;
+
+        gtk_application_uninhibit (GTK_APPLICATION (g_application_get_default ()),
+                                   priv->presentation_mode_inhibit_id);
+        priv->presentation_mode_inhibit_id = 0;
+}
+
+static void
 ev_window_update_presentation_action (EvWindow *window)
 {
 	GtkAction *action;
@@ -4072,7 +4103,7 @@ ev_window_view_presentation_finished (EvWindow *window)
 static gboolean
 ev_window_view_presentation_focus_in (EvWindow *window)
 {
-	ev_application_screensaver_disable (EV_APP);
+        ev_window_inhibit_screensaver (window);
 
 	return FALSE;
 }
@@ -4080,7 +4111,7 @@ ev_window_view_presentation_focus_in (EvWindow *window)
 static gboolean
 ev_window_view_presentation_focus_out (EvWindow *window)
 {
-	ev_application_screensaver_enable (EV_APP);
+        ev_window_uninhibit_screensaver (window);
 
 	return FALSE;
 }
@@ -4135,7 +4166,7 @@ ev_window_run_presentation (EvWindow *window)
 
 	gtk_widget_show (window->priv->presentation_view);
 
-	ev_application_screensaver_disable (EV_APP);
+        ev_window_inhibit_screensaver (window);
 
 	if (window->priv->metadata && !ev_window_is_empty (window))
 		ev_metadata_set_boolean (window->priv->metadata, "presentation", TRUE);
@@ -4168,7 +4199,7 @@ ev_window_stop_presentation (EvWindow *window,
 
 	gtk_widget_grab_focus (window->priv->view);
 
-	ev_application_screensaver_enable (EV_APP);
+        ev_window_uninhibit_screensaver (window);
 
 	if (window->priv->metadata && !ev_window_is_empty (window))
 		ev_metadata_set_boolean (window->priv->metadata, "presentation", FALSE);
@@ -7128,6 +7159,7 @@ ev_window_init (EvWindow *ev_window)
 
 	ev_window->priv->page_mode = PAGE_MODE_DOCUMENT;
 	ev_window->priv->chrome = EV_CHROME_NORMAL;
+        ev_window->priv->presentation_mode_inhibit_id = 0;
 	ev_window->priv->title = ev_window_title_new (ev_window);
 
 	ev_window->priv->main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);



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