diff options
author | Felix Riemann <[email protected]> | 2012-09-23 17:50:02 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-07-08 12:19:44 +0200 |
commit | 4817ee9e8d7f9d854870aa10085f3b6f1da3eadf (patch) | |
tree | 9ce442ddbe53e0543676323043401874c5b9e437 | |
parent | 9e687fad2c7fc2a874c41090ad3a9ba8dc7b2c4e (diff) | |
download | eom-4817ee9e8d7f9d854870aa10085f3b6f1da3eadf.tar.bz2 eom-4817ee9e8d7f9d854870aa10085f3b6f1da3eadf.tar.xz |
Use GtkApplication to inhibit the screensaver during slideshows
Realized in a similar fashion as in Evince and Totem.
https://bugzilla.gnome.org/show_bug.cgi?id=684581
origin commit:
https://gitlab.gnome.org/GNOME/eog/commit/e8b50ab
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/eom-application.c | 30 | ||||
-rw-r--r-- | src/eom-application.h | 7 | ||||
-rw-r--r-- | src/eom-window.c | 39 |
4 files changed, 37 insertions, 44 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 66db511..8b3539c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,8 +4,6 @@ endif toolbar_LIB = $(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la -screensaver_LIB = $(top_builddir)/cut-n-paste/totem-screensaver/libtotemscrsaver.la - noinst_LTLIBRARIES = libeom.la bin_PROGRAMS = eom @@ -128,7 +126,6 @@ endif HAVE_EXEMPI libeom_la_CPPFLAGS = \ -I$(top_srcdir)/jpegutils \ -I$(top_srcdir)/cut-n-paste/toolbar-editor \ - -I$(top_srcdir)/cut-n-paste/totem-screensaver \ -DG_LOG_DOMAIN=\"EOM\" \ -DEOM_DATA_DIR=\""$(pkgdatadir)"\" \ -DEOM_LOCALE_DIR=\""$(datadir)/locale"\" \ @@ -154,7 +151,6 @@ eom_SOURCES = main.c eom_CFLAGS = \ -I$(top_srcdir)/cut-n-paste/toolbar-editor \ - -I$(top_srcdir)/cut-n-paste/totem-screensaver \ $(EOM_CFLAGS) \ -DEOM_DATA_DIR=\""$(pkgdatadir)"\" \ -DEOM_LOCALE_DIR=\""$(datadir)/locale"\" \ @@ -165,7 +161,6 @@ eom_LDADD = \ $(EOM_LIBS) \ $(LIBJPEG) \ $(toolbar_LIB) \ - $(screensaver_LIB) \ $(jpeg_LIB) \ $(INTROSPECTION_LIBS) diff --git a/src/eom-application.c b/src/eom-application.c index dbf1cb1..6135ae1 100644 --- a/src/eom-application.c +++ b/src/eom-application.c @@ -32,8 +32,6 @@ #include "eom-application.h" #include "eom-util.h" -#include "totem-scrsaver.h" - #include <string.h> #include <glib.h> #include <glib/gi18n.h> @@ -485,34 +483,6 @@ eom_application_reset_toolbars_model (EomApplication *app) EGG_TB_MODEL_NOT_REMOVABLE); } -/** - * eom_application_screensaver_enable: - * @application: an #EomApplication. - * - * Enables the screensaver. Usually necessary after a call to - * eom_application_screensaver_disable(). - **/ -void -eom_application_screensaver_enable (EomApplication *application) -{ - if (application->scr_saver) - totem_scrsaver_enable (application->scr_saver); -} - -/** - * eom_application_screensaver_disable: - * @application: an #EomApplication. - * - * Disables the screensaver. Useful when the application is in fullscreen or - * similar mode. - **/ -void -eom_application_screensaver_disable (EomApplication *application) -{ - if (application->scr_saver) - totem_scrsaver_disable (application->scr_saver); -} - static void eom_application_load_accelerators (void) { diff --git a/src/eom-application.h b/src/eom-application.h index 7741d50..16c4419 100644 --- a/src/eom-application.h +++ b/src/eom-application.h @@ -29,8 +29,6 @@ #include "eom-plugin-engine.h" #include "egg-toolbars-model.h" -#include "totem-scrsaver.h" - #include <glib.h> #include <glib-object.h> @@ -57,7 +55,6 @@ struct _EomApplication { EomPluginEngine *plugin_engine; - TotemScrsaver *scr_saver; EomStartupFlags flags; }; @@ -98,10 +95,6 @@ void eom_application_save_toolbars_model (EomApplication *applicati void eom_application_reset_toolbars_model (EomApplication *app); -void eom_application_screensaver_enable (EomApplication *application); - -void eom_application_screensaver_disable (EomApplication *application); - G_END_DECLS #endif /* __EOM_APPLICATION_H__ */ diff --git a/src/eom-window.c b/src/eom-window.c index 329b6da..a7c3575 100644 --- a/src/eom-window.c +++ b/src/eom-window.c @@ -161,6 +161,8 @@ struct _EomWindowPrivate { gint slideshow_switch_timeout; GSource *slideshow_switch_source; + guint fullscreen_idle_inhibit_cookie; + guint recent_menu_id; EomJob *load_job; @@ -1973,6 +1975,37 @@ update_ui_visibility (EomWindow *window) } static void +eom_window_inhibit_screensaver (EomWindow *window) +{ + EomWindowPrivate *priv = window->priv; + + g_return_if_fail (priv->fullscreen_idle_inhibit_cookie == 0); + + eom_debug (DEBUG_WINDOW); + + window->priv->fullscreen_idle_inhibit_cookie = + gtk_application_inhibit (GTK_APPLICATION (EOM_APP), + GTK_WINDOW (window), + GTK_APPLICATION_INHIBIT_IDLE, + _("Viewing a slideshow")); +} + +static void +eom_window_uninhibit_screensaver (EomWindow *window) +{ + EomWindowPrivate *priv = window->priv; + + if (G_UNLIKELY (priv->fullscreen_idle_inhibit_cookie == 0)) + return; + + eom_debug (DEBUG_WINDOW); + + gtk_application_uninhibit (GTK_APPLICATION (EOM_APP), + priv->fullscreen_idle_inhibit_cookie); + priv->fullscreen_idle_inhibit_cookie = 0; +} + +static void eom_window_run_fullscreen (EomWindow *window, gboolean slideshow) { static const GdkRGBA black = { 0., 0., 0., 1.}; @@ -2057,7 +2090,7 @@ eom_window_run_fullscreen (EomWindow *window, gboolean slideshow) gtk_window_fullscreen (GTK_WINDOW (window)); eom_window_update_fullscreen_popup (window); - eom_application_screensaver_disable (EOM_APP); + eom_window_inhibit_screensaver (window); /* Update both actions as we could've already been in one those modes */ eom_window_update_slideshow_action (window); @@ -2122,7 +2155,7 @@ eom_window_stop_fullscreen (EomWindow *window, gboolean slideshow) eom_scroll_view_show_cursor (EOM_SCROLL_VIEW (priv->view)); - eom_application_screensaver_enable (EOM_APP); + eom_window_uninhibit_screensaver (window); } static void @@ -4542,6 +4575,7 @@ eom_window_init (EomWindow *window) window->priv->slideshow_loop = FALSE; window->priv->slideshow_switch_timeout = 0; window->priv->slideshow_switch_source = NULL; + window->priv->fullscreen_idle_inhibit_cookie = 0; gtk_window_set_geometry_hints (GTK_WINDOW (window), GTK_WIDGET (window), @@ -4666,6 +4700,7 @@ eom_window_dispose (GObject *object) } slideshow_clear_timeout (window); + eom_window_uninhibit_screensaver (window); g_signal_handlers_disconnect_by_func (gtk_recent_manager_get_default (), G_CALLBACK (eom_window_recent_manager_changed_cb), |