Skip to content
Permalink
Browse files

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
  • Loading branch information...
Felix Riemann authored and raveit65 committed Sep 23, 2012
1 parent 9e687fa commit 4817ee9e8d7f9d854870aa10085f3b6f1da3eadf
Showing with 37 additions and 44 deletions.
  1. +0 −5 src/Makefile.am
  2. +0 −30 src/eom-application.c
  3. +0 −7 src/eom-application.h
  4. +37 −2 src/eom-window.c
@@ -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)

@@ -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)
{
@@ -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__ */
@@ -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;
@@ -1972,6 +1974,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)
{
@@ -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),

0 comments on commit 4817ee9

Please sign in to comment.
You can’t perform that action at this time.