From 99c48b1ee683814d250e06da860d484b408866a5 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Thu, 30 Jan 2014 15:14:28 +0100 Subject: Add random mode in slideshow mode Closes #20 https://github.com/mate-desktop/eom/issues/20 --- data/eom-preferences-dialog.ui | 17 ++++++++++++++++- data/org.mate.eom.gschema.xml.in.in | 5 +++++ src/eom-config-keys.h | 1 + src/eom-preferences-dialog.c | 21 +++++++++++++++++++++ src/eom-window.c | 12 ++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/data/eom-preferences-dialog.ui b/data/eom-preferences-dialog.ui index 6509845..fff0a3e 100644 --- a/data/eom-preferences-dialog.ui +++ b/data/eom-preferences-dialog.ui @@ -522,6 +522,21 @@ 0 + + + _Random sequence + True + True + False + True + True + + + False + False + 1 + + _Loop sequence @@ -534,7 +549,7 @@ False False - 1 + 2 diff --git a/data/org.mate.eom.gschema.xml.in.in b/data/org.mate.eom.gschema.xml.in.in index 80b0369..92ede90 100644 --- a/data/org.mate.eom.gschema.xml.in.in +++ b/data/org.mate.eom.gschema.xml.in.in @@ -53,6 +53,11 @@ + + false + <_summary>Randomize the image sequence + <_description>Whether the sequence of images should be shown in an random loop. + true <_summary>Loop through the image sequence diff --git a/src/eom-config-keys.h b/src/eom-config-keys.h index c4a35ae..c69d0cf 100644 --- a/src/eom-config-keys.h +++ b/src/eom-config-keys.h @@ -47,6 +47,7 @@ #define EOM_CONF_VIEW_USE_BG_COLOR "use-background-color" #define EOM_CONF_FULLSCREEN_SCHEMA "org.mate.eom.full-screen" +#define EOM_CONF_FULLSCREEN_RANDOM "random" #define EOM_CONF_FULLSCREEN_LOOP "loop" #define EOM_CONF_FULLSCREEN_UPSCALE "upscale" #define EOM_CONF_FULLSCREEN_SECONDS "seconds" diff --git a/src/eom-preferences-dialog.c b/src/eom-preferences-dialog.c index e11847b..0a46606 100644 --- a/src/eom-preferences-dialog.c +++ b/src/eom-preferences-dialog.c @@ -94,6 +94,12 @@ pd_radio_toggle_cb (GtkWidget *widget, GSettings *settings) g_settings_set_string (settings, key, value); } +static void +random_change_cb (GSettings *settings, gchar *key, GtkWidget *widget) +{ + gtk_widget_set_sensitive (widget, !g_settings_get_boolean (settings, key)); +} + static void eom_preferences_response_cb (GtkDialog *dlg, gint res_id, gpointer data) { @@ -125,6 +131,7 @@ eom_preferences_dialog_constructor (GType type, GtkWidget *background_radio; GtkWidget *color_button; GtkWidget *upscale_check; + GtkWidget *random_check; GtkWidget *loop_check; GtkWidget *seconds_spin; GtkWidget *plugin_manager; @@ -154,6 +161,7 @@ eom_preferences_dialog_constructor (GType type, "background_radio", &background_radio, "color_button", &color_button, "upscale_check", &upscale_check, + "random_check", &random_check, "loop_check", &loop_check, "seconds_spin", &seconds_spin, "plugin_manager_container", &plugin_manager_container, @@ -287,6 +295,19 @@ eom_preferences_dialog_constructor (GType type, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind (priv->fullscreen_settings, + EOM_CONF_FULLSCREEN_RANDOM, + G_OBJECT (random_check), + "active", + G_SETTINGS_BIND_DEFAULT); + g_signal_connect (priv->fullscreen_settings, + "changed::" EOM_CONF_FULLSCREEN_RANDOM, + G_CALLBACK (random_change_cb), + loop_check); + random_change_cb (priv->fullscreen_settings, + EOM_CONF_FULLSCREEN_RANDOM, + loop_check); + g_settings_bind (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_SECONDS, G_OBJECT (seconds_spin), diff --git a/src/eom-window.c b/src/eom-window.c index b159e13..366b2dc 100644 --- a/src/eom-window.c +++ b/src/eom-window.c @@ -153,6 +153,7 @@ struct _EomWindowPrivate { GtkWidget *fullscreen_popup; GSource *fullscreen_timeout_source; + gboolean slideshow_random; gboolean slideshow_loop; gint slideshow_switch_timeout; GSource *slideshow_switch_source; @@ -1918,6 +1919,12 @@ slideshow_switch_cb (gpointer data) eom_debug (DEBUG_WINDOW); + if (priv->slideshow_random) { + eom_thumb_view_select_single (EOM_THUMB_VIEW (priv->thumbview), + EOM_THUMB_VIEW_SELECT_RANDOM); + return TRUE; + } + if (!priv->slideshow_loop && slideshow_is_loop_end (window)) { eom_window_stop_fullscreen (window, TRUE); return FALSE; @@ -2239,6 +2246,10 @@ eom_window_run_fullscreen (EomWindow *window, gboolean slideshow) fullscreen_set_timeout (window); if (slideshow) { + priv->slideshow_random = + g_settings_get_boolean (priv->fullscreen_settings, + EOM_CONF_FULLSCREEN_RANDOM); + priv->slideshow_loop = g_settings_get_boolean (priv->fullscreen_settings, EOM_CONF_FULLSCREEN_LOOP); @@ -4653,6 +4664,7 @@ eom_window_init (EomWindow *window) window->priv->fullscreen_popup = NULL; window->priv->fullscreen_timeout_source = NULL; + window->priv->slideshow_random = FALSE; window->priv->slideshow_loop = FALSE; window->priv->slideshow_switch_timeout = 0; window->priv->slideshow_switch_source = NULL; -- cgit v1.2.1