Commit 21c159b8 authored by Allison Barlow's avatar Allison Barlow

Added settings toolbar button in slideshow page. Settings dialog allows user

to modify the delay (in seconds) between slideshow frames.  The slideshow
delay and display basic info menu option now persist between sessions.
parent bebebeaa
......@@ -50,7 +50,8 @@ SRC_FILES = \
CameraTable.vala \
DirectWindow.vala \
Properties.vala \
CustomComponents.vala
CustomComponents.vala \
Config.vala
VAPI_FILES = \
libexif.vapi \
......@@ -99,7 +100,8 @@ EXT_PKGS = \
dbus-glib-1 \
unique-1.0 \
libexif \
libgphoto2
libgphoto2 \
gconf-2.0
EXT_PKG_VERSIONS = \
gtk+-2.0 >= 2.14.4 \
......@@ -109,7 +111,8 @@ EXT_PKG_VERSIONS = \
dbus-glib-1 >= 0.76 \
unique-1.0 >= 1.0.0 \
libexif >= 0.6.16 \
libgphoto2 >= 2.4.2
libgphoto2 >= 2.4.2 \
gconf-2.0 >= 2.24.1
PKGS = $(EXT_PKGS) $(LOCAL_PKGS)
......@@ -192,6 +195,8 @@ install:
$(INSTALL_DATA) misc/shotwell.desktop $(DESTDIR)/usr/share/applications
$(INSTALL_DATA) misc/shotwell-viewer.desktop $(DESTDIR)/usr/share/applications
-update-desktop-database
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool --makefile-install-rule misc/shotwell.schemas
killall -HUP gconfd-2
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
......@@ -200,6 +205,8 @@ uninstall:
rm -f $(DESTDIR)/usr/share/applications/shotwell.desktop
rm -f $(DESTDIR)/usr/share/applications/shotwell-viewer.desktop
-update-desktop-database
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool --makefile-uninstall-rule misc/shotwell.schemas
killall -HUP gconfd-2
$(VALA_STAMP): $(EXPANDED_SRC_FILES) $(EXPANDED_VAPI_FILES) $(EXPANDED_SRC_HEADER_FILES) Makefile \
$(CONFIG_IN)
......
<gconfschemafile>
<schemalist>
<schema>
<key>/schemas/apps/shotwell/preferences/ui/display_basic_properties</key>
<applyto>/apps/shotwell/preferences/ui/display_basic_properties</applyto>
<type>bool</type>
<owner>shotwell</owner>
<default>false</default>
<locale name="C">
<short>basic properties display bool</short>
<long>Basic properties display bool. True if the window is displayed, false otherwise.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/shotwell/preferences/slideshow/delay</key>
<applyto>/apps/shotwell/preferences/slideshow/delay</applyto>
<type>float</type>
<owner>shotwell</owner>
<default>5.0</default>
<locale name="C">
<short>delay</short>
<long>Delay (in seconds) between photos in the slideshow.</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>
......@@ -59,7 +59,15 @@ public class FullscreenWindow : PageWindow {
Gtk.Toolbar toolbar = current_page.get_toolbar();
toolbar.set_show_arrow(false);
toolbar.insert(pin_button, -1);
if (page is SlideshowPage) {
// slideshow page doesn't own toolbar to hide it, subscribe to signal instead
((SlideshowPage) current_page).hide_toolbar += hide_toolbar;
} else {
// only non-slideshow pages should have pin button
toolbar.insert(pin_button, -1);
}
toolbar.insert(close_button, -1);
// set up toolbar along bottom of screen
......@@ -85,7 +93,7 @@ public class FullscreenWindow : PageWindow {
}
private void on_close() {
toolbar_window.hide();
hide_toolbar();
toolbar_window = null;
current_page.switching_from();
......@@ -193,11 +201,15 @@ public class FullscreenWindow : PageWindow {
if (now - left_toolbar_time < TOOLBAR_DISMISSAL_SEC)
return true;
toolbar_window.hide();
is_toolbar_shown = false;
hide_toolbar();
return false;
}
private void hide_toolbar() {
toolbar_window.hide();
is_toolbar_shown = false;
}
}
// PageWindow is a Gtk.Window with essential functions for hosting a Page. There may be more than
......@@ -317,6 +329,10 @@ public abstract class AppWindow : PageWindow {
public static AppWindow get_instance() {
return instance;
}
public static FullscreenWindow get_fullscreen() {
return fullscreen_window;
}
public static string[] get_commandline_args() {
return args;
......
......@@ -5,18 +5,85 @@
*/
class SlideshowPage : SinglePhotoPage {
public const int DELAY_SEC = 3;
private const int CHECK_ADVANCE_MSEC = 250;
private CheckerboardPage controller;
private Thumbnail thumbnail;
private Gtk.Toolbar toolbar = new Gtk.Toolbar();
private Gtk.ToolButton play_pause_button;
private Gtk.ToolButton settings_button;
private Timer timer = new Timer();
private bool playing = true;
private bool exiting = false;
public signal void hide_toolbar();
private class SettingsDialog : Gtk.Dialog {
Gtk.Entry delay_entry;
double delay;
Gtk.HScale hscale;
private bool update_entry(Gtk.ScrollType scroll, double new_value) {
new_value = new_value.clamp(Config.SLIDESHOW_DELAY_MIN, Config.SLIDESHOW_DELAY_MAX);
delay_entry.set_text("%.1f".printf(new_value));
return false;
}
private void check_text() { //rename this function
// parse through text, set delay
string delay_text = delay_entry.get_text();
delay_text.canon("0123456789.",'?');
delay_text = delay_text.replace("?","");
delay = delay_text.to_double();
delay_entry.set_text(delay_text);
delay = delay.clamp(Config.SLIDESHOW_DELAY_MIN, Config.SLIDESHOW_DELAY_MAX);
hscale.set_value(delay);
}
public SettingsDialog() {
delay = Config.get_instance().get_slideshow_delay();
set_modal(true);
set_transient_for(AppWindow.get_fullscreen());
add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OK, Gtk.ResponseType.OK);
set_title("Settings");
Gtk.Label delay_label = new Gtk.Label("Delay:");
Gtk.Label units_label = new Gtk.Label("seconds");
delay_entry = new Gtk.Entry();
delay_entry.set_max_length(5);
delay_entry.set_text("%.1f".printf(delay));
delay_entry.set_width_chars(4);
delay_entry.set_activates_default(true);
delay_entry.changed += check_text;
Gtk.Adjustment adjustment = new Gtk.Adjustment(delay, Config.SLIDESHOW_DELAY_MIN, Config.SLIDESHOW_DELAY_MAX + 1, 0.1, 1, 1);
hscale = new Gtk.HScale(adjustment);
hscale.set_draw_value(false);
hscale.set_size_request(150,-1);
hscale.change_value += update_entry;
Gtk.HBox query = new Gtk.HBox(false, 0);
query.pack_start(delay_label, false, false, 3);
query.pack_start(hscale, true, true, 3);
query.pack_start(delay_entry, false, false, 3);
query.pack_start(units_label, false, false, 3);
set_default_response(Gtk.ResponseType.OK);
vbox.pack_start(query, true, false, 6);
}
public double get_delay() {
return delay;
}
}
public SlideshowPage(CheckerboardPage controller, Thumbnail start) {
base("Slideshow");
......@@ -46,6 +113,13 @@ class SlideshowPage : SinglePhotoPage {
next_button.clicked += on_next_manual;
toolbar.insert(next_button, -1);
settings_button = new Gtk.ToolButton.from_stock(Gtk.STOCK_PREFERENCES);
settings_button.set_label("Settings");
settings_button.set_tooltip_text("Change slideshow settings");
settings_button.clicked += on_change_settings;
toolbar.insert(settings_button, -1);
}
public override Gtk.Toolbar get_toolbar() {
......@@ -127,7 +201,7 @@ class SlideshowPage : SinglePhotoPage {
if (!playing)
return true;
if ((int) timer.elapsed() < DELAY_SEC)
if (timer.elapsed() < Config.get_instance().get_slideshow_delay())
return true;
on_next_automatic();
......@@ -163,6 +237,24 @@ class SlideshowPage : SinglePhotoPage {
return (base.key_press_event != null) ? base.key_press_event(event) : true;
}
private void on_change_settings() {
SettingsDialog settings_dialog = new SettingsDialog();
settings_dialog.show_all();
bool slideshow_playing = playing;
playing = false;
hide_toolbar();
int response = settings_dialog.run();
if (response == Gtk.ResponseType.OK) {
// sync with the config setting so it will persist
Config.get_instance().set_slideshow_delay(settings_dialog.get_delay());
}
settings_dialog.destroy();
playing = slideshow_playing;
timer.start();
}
public override int get_queryable_count() {
return 1;
}
......
/* Copyright 2009 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
*/
public class Config {
GConf.Client client;
protected static Config instance = null;
public const double SLIDESHOW_DELAY_MAX = 30;
public const double SLIDESHOW_DELAY_MIN = 1;
public const double SLIDESHOW_DELAY_DEFAULT = 5;
private Config() {
// only one may exist per-process
assert(instance == null);
client = GConf.Client.get_default();
assert(client != null);
}
public static Config get_instance() {
if (instance == null)
instance = new Config();
return instance;
}
public bool set_display_basic_properties(bool display) {
try {
client.set_bool("/apps/shotwell/preferences/ui/display_basic_properties", display);
return true;
} catch (GLib.Error err) {
message("Unable to set GConf value. Error message: %s", err.message);
return false;
}
}
public bool get_display_basic_properties() {
try {
return client.get_bool("/apps/shotwell/preferences/ui/display_basic_properties");
} catch (GLib.Error err) {
message("Unable to get GConf value. Error message: %s", err.message);
return false;
}
}
public bool set_slideshow_delay(double delay) {
try {
client.set_float("/apps/shotwell/preferences/slideshow/delay", delay);
return true;
} catch (GLib.Error err) {
message("Unable to set GConf value. Error message: %s", err.message);
return false;
}
}
public double get_slideshow_delay() {
double delay;
try {
delay = client.get_float("/apps/shotwell/preferences/slideshow/delay");
} catch (GLib.Error err) {
message("Unable to get GConf value. Error message: %s", err.message);
delay = SLIDESHOW_DELAY_DEFAULT;
}
return delay.clamp(SLIDESHOW_DELAY_MIN, SLIDESHOW_DELAY_MAX);
}
}
......@@ -217,6 +217,9 @@ public class LibraryWindow : AppWindow {
create_layout(collection_page);
// settings that should persist between sessions
load_configuration();
// set up main window as a drag-and-drop destination (rather than each page; assume
// a drag and drop is for general library import, which means it goes to collection_page)
Gtk.drag_dest_set(this, Gtk.DestDefaults.ALL, DEST_TARGET_ENTRIES,
......@@ -426,6 +429,9 @@ public class LibraryWindow : AppWindow {
bottom_frame.hide();
}
}
// sync the setting so it will persist
Config.get_instance().set_display_basic_properties(display);
}
public void enqueue_batch_import(BatchImport batch_import) {
......@@ -834,6 +840,15 @@ public class LibraryWindow : AppWindow {
return false;
}
// check for settings that should persist between instances
private void load_configuration() {
Gtk.ToggleAction action =
(Gtk.ToggleAction) current_page.common_action_group.get_action(
"CommonDisplayBasicProperties");
assert(action != null);
action.set_active(Config.get_instance().get_display_basic_properties());
}
private void create_layout(Page start_page) {
// use a Notebook to hold all the pages, which are switched when a sidebar child is selected
notebook.set_show_tabs(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment