[shotwell] Extract SetBackgroundSlideshow dialog



commit 3b177a6a7d37016b92bf98e0f3021eb31353f15a
Author: Jens Georg <mail jensge org>
Date:   Wed Dec 20 16:40:05 2017 +0100

    Extract SetBackgroundSlideshow dialog

 shotwell.am                             |    1 +
 src/Dialogs.vala                        |   72 ---------------------------
 src/dialogs/SetBackgroundSlideshow.vala |   80 +++++++++++++++++++++++++++++++
 src/meson.build                         |    1 +
 4 files changed, 82 insertions(+), 72 deletions(-)
---
diff --git a/shotwell.am b/shotwell.am
index e7d0655..e058138 100644
--- a/shotwell.am
+++ b/shotwell.am
@@ -63,6 +63,7 @@ shotwell_SOURCES = \
        src/db/VersionTable.vala \
        src/db/SavedSearchDBTable.vala \
        src/dialogs/SetBackground.vala \
+       src/dialogs/SetBackgroundSlideshow.vala \
        src/editing_tools/EditingTools.vala \
        src/editing_tools/RGBHistogramManipulator.vala \
        src/editing_tools/StraightenTool.vala \
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index 5439426..21954e2 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -1081,79 +1081,7 @@ public class EntryMultiCompletion : Gtk.EntryCompletion {
 }
 
 
-[GtkTemplate (ui = "/org/gnome/Shotwell/ui/set_background_slideshow_dialog.ui")]
-public class SetBackgroundSlideshowDialog : Gtk.Dialog {
-    [GtkChild]
-    private Gtk.CheckButton desktop_background_checkbox;
-    [GtkChild]
-    private Gtk.CheckButton screensaver_checkbox;
-    [GtkChild]
-    private Gtk.Scale delay_scale;
-    [GtkChild]
-    private Gtk.Label delay_value_label;
-
-    private int delay_value = 0;
-
-    public SetBackgroundSlideshowDialog() {
-        bool use_header;
-        Gtk.Settings.get_default ().get ("gtk-dialogs-use-header", out use_header);
-        Object(use_header_bar: use_header ? 1 : 0);
-        this.set_transient_for (AppWindow.get_instance());
-    }
-
-    public override void constructed () {
-        on_delay_scale_value_changed ();
-    }
-
-    [GtkCallback]
-    private void on_checkbox_clicked() {
-        set_response_sensitive (Gtk.ResponseType.OK,
-                                desktop_background_checkbox.active ||
-                                screensaver_checkbox.active);
-    }
-
-    [GtkCallback]
-    private void on_delay_scale_value_changed() {
-        double value = delay_scale.adjustment.value;
 
-        // f(x)=x^5 allows to have fine-grained values (seconds) to the left
-        // and very coarse-grained values (hours) to the right of the slider.
-        // We limit maximum value to 1 day and minimum to 5 seconds.
-        delay_value = (int) (Math.pow(value, 5) / Math.pow(90, 5) * 60 * 60 * 24 + 5);
-
-        // convert to text and remove fractions from values > 1 minute
-        string text;
-        if (delay_value < 60) {
-            text = ngettext("%d second", "%d seconds", delay_value).printf(delay_value);
-        } else if (delay_value < 60 * 60) {
-            int minutes = delay_value / 60;
-            text = ngettext("%d minute", "%d minutes", minutes).printf(minutes);
-            delay_value = minutes * 60; 
-        } else if (delay_value < 60 * 60 * 24) {
-            int hours = delay_value / (60 * 60);
-            text = ngettext("%d hour", "%d hours", hours).printf(hours);
-            delay_value = hours * (60 * 60);
-        } else {
-            text = _("1 day");
-            delay_value = 60 * 60 * 24;
-        }
-
-        delay_value_label.label = text;
-    }
-
-    public bool execute(out int delay_value, out bool desktop_background, out bool screensaver) {
-        this.show_all();
-        var result = this.run() == Gtk.ResponseType.OK;
-        this.hide ();
-
-        delay_value = this.delay_value;
-        desktop_background = desktop_background_checkbox.active;
-        screensaver = screensaver_checkbox.active;
-
-        this.destroy();
-        return result;
-    }
-}
 
 
 public class TextEntryDialog : Gtk.Dialog {
diff --git a/src/dialogs/SetBackgroundSlideshow.vala b/src/dialogs/SetBackgroundSlideshow.vala
new file mode 100644
index 0000000..6aec31b
--- /dev/null
+++ b/src/dialogs/SetBackgroundSlideshow.vala
@@ -0,0 +1,80 @@
+/* Copyright 2016 Software Freedom Conservancy Inc.
+ * Copyright 2017 Jens Georg <mail jensge org>
+ *
+ * This software is licensed under the GNU LGPL (version 2.1 or later).
+ * See the COPYING file in this distribution.
+ */
+
+[GtkTemplate (ui = "/org/gnome/Shotwell/ui/set_background_slideshow_dialog.ui")]
+public class SetBackgroundSlideshowDialog : Gtk.Dialog {
+    [GtkChild]
+    private Gtk.CheckButton desktop_background_checkbox;
+    [GtkChild]
+    private Gtk.CheckButton screensaver_checkbox;
+    [GtkChild]
+    private Gtk.Scale delay_scale;
+    [GtkChild]
+    private Gtk.Label delay_value_label;
+
+    private int delay_value = 0;
+
+    public SetBackgroundSlideshowDialog() {
+        bool use_header;
+        Gtk.Settings.get_default ().get ("gtk-dialogs-use-header", out use_header);
+        Object(use_header_bar: use_header ? 1 : 0);
+        this.set_transient_for (AppWindow.get_instance());
+    }
+
+    public override void constructed () {
+        on_delay_scale_value_changed ();
+    }
+
+    [GtkCallback]
+    private void on_checkbox_clicked() {
+        set_response_sensitive (Gtk.ResponseType.OK,
+                                desktop_background_checkbox.active ||
+                                screensaver_checkbox.active);
+    }
+
+    [GtkCallback]
+    private void on_delay_scale_value_changed() {
+        double value = delay_scale.adjustment.value;
+
+        // f(x)=x^5 allows to have fine-grained values (seconds) to the left
+        // and very coarse-grained values (hours) to the right of the slider.
+        // We limit maximum value to 1 day and minimum to 5 seconds.
+        delay_value = (int) (Math.pow(value, 5) / Math.pow(90, 5) * 60 * 60 * 24 + 5);
+
+        // convert to text and remove fractions from values > 1 minute
+        string text;
+        if (delay_value < 60) {
+            text = ngettext("%d second", "%d seconds", delay_value).printf(delay_value);
+        } else if (delay_value < 60 * 60) {
+            int minutes = delay_value / 60;
+            text = ngettext("%d minute", "%d minutes", minutes).printf(minutes);
+            delay_value = minutes * 60;
+        } else if (delay_value < 60 * 60 * 24) {
+            int hours = delay_value / (60 * 60);
+            text = ngettext("%d hour", "%d hours", hours).printf(hours);
+            delay_value = hours * (60 * 60);
+        } else {
+            text = _("1 day");
+            delay_value = 60 * 60 * 24;
+        }
+
+        delay_value_label.label = text;
+    }
+
+    public bool execute(out int delay_value, out bool desktop_background, out bool screensaver) {
+        this.show_all();
+        var result = this.run() == Gtk.ResponseType.OK;
+        this.hide ();
+
+        delay_value = this.delay_value;
+        desktop_background = desktop_background_checkbox.active;
+        screensaver = screensaver_checkbox.active;
+
+        this.destroy();
+        return result;
+    }
+}
diff --git a/src/meson.build b/src/meson.build
index c471e7d..6911cd5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -192,6 +192,7 @@ executable('shotwell',
             'MediaViewTracker.vala',
             'UnityProgressBar.vala',
             'Upgrades.vala',
+            'dialogs/SetBackgroundSlideshow.vala',
             'dialogs/SetBackground.vala',
             '.unitize/_UnitInternals.vala',
             '.unitize/_UtilInternals.vala',


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