Commit 50362fdc authored by Tobe Deprez's avatar Tobe Deprez Committed by Lucas Beeler

Adds the ability to display photo titles during slideshows. Closes #1592.

parent 9e8991be
......@@ -150,6 +150,12 @@
<summary>transition effect id</summary>
<description>The name of the transition effect that will be used between photos when running a slideshow</description>
</key>
<key name="show-title" type="b">
<default>false</default>
<summary>Show title</summary>
<description>Whether to show the title of a photo during the slideshow</description>
</key>
</schema>
<schema id="org.yorba.shotwell.preferences.window" path="/apps/shotwell/preferences/window/">
......
......@@ -22,6 +22,7 @@ use-24-hour-time = /apps/shotwell/preferences/ui/twentyfour_hr_time
delay = /apps/shotwell/preferences/slideshow/delay
transition-delay = /apps/shotwell/preferences/slideshow_transition/delay
transition-effect-id = /apps/shotwell/preferences/slideshow_transition/name
show-title = /apps/shotwell/preferences/slideshow/show-title
[org.yorba.shotwell.preferences.window]
direct-height = /apps/shotwell/preferences/window/direct_height
......
......@@ -29,6 +29,7 @@ class SlideshowPage : SinglePhotoPage {
Gtk.Scale transition_effect_hscale;
Gtk.SpinButton transition_effect_entry;
Gtk.Adjustment transition_effect_adjustment;
Gtk.CheckButton show_title_button;
public SettingsDialog() {
double delay = Config.Facade.get_instance().get_slideshow_delay();
......@@ -104,9 +105,13 @@ class SlideshowPage : SinglePhotoPage {
transition_effect_entry.set_activates_default(true);
transition_delay_label.set_mnemonic_widget(transition_effect_hscale);
bool show_title = Config.Facade.get_instance().get_slideshow_show_title();
show_title_button = new Gtk.CheckButton.with_mnemonic(_("Show t_itle"));
show_title_button.active = show_title;
set_default_response(Gtk.ResponseType.OK);
Gtk.Table tbl = new Gtk.Table(3, 4, false);
Gtk.Table tbl = new Gtk.Table(4, 4, false);
tbl.attach(delay_label, 0, 1, 0, 1,
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
......@@ -149,6 +154,10 @@ class SlideshowPage : SinglePhotoPage {
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
3, 0);
tbl.attach(show_title_button, 0, 4, 3, 4,
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL,
3, 0);
((Gtk.Box) get_content_area()).pack_start(tbl, true, false, 6);
......@@ -181,6 +190,10 @@ class SlideshowPage : SinglePhotoPage {
return (id != null) ? id : TransitionEffectsManager.NULL_EFFECT_ID;
}
public bool get_show_title() {
return show_title_button.active;
}
}
public SlideshowPage(SourceCollection sources, ViewCollection controller, Photo start) {
......@@ -426,6 +439,7 @@ class SlideshowPage : SinglePhotoPage {
Config.Facade.get_instance().set_slideshow_transition_delay(settings_dialog.get_transition_delay());
Config.Facade.get_instance().set_slideshow_transition_effect_id(settings_dialog.get_transition_effect_id());
Config.Facade.get_instance().set_slideshow_show_title(settings_dialog.get_show_title());
update_transition_effect();
}
......@@ -441,5 +455,49 @@ class SlideshowPage : SinglePhotoPage {
set_transition(effect_id, (int) (effect_delay * 1000.0));
}
// Paint the title of the photo
private void paint_title(Cairo.Context ctx, Dimensions ctx_dim) {
string? title = current.get_title();
// If the photo doesn't have a title, don't paint anything
if (title == null || title == "")
return;
Pango.Layout layout = create_pango_layout(title);
Pango.AttrList list = new Pango.AttrList();
Pango.Attribute size = Pango.attr_scale_new(3);
list.insert(size.copy());
layout.set_attributes(list);
layout.set_width((int) ((ctx_dim.width * 0.9) * Pango.SCALE));
// Find the right position
int title_width, title_height;
layout.get_pixel_size(out title_width, out title_height);
double x = ctx_dim.width * 0.2;
double y = ctx_dim.height * 0.90;
// Move the title up if it is too high
if (y + title_height >= ctx_dim.height * 0.95)
y = ctx_dim.height * 0.95 - title_height;
// Move to the left if the title is too long
if (x + title_width >= ctx_dim.width * 0.95)
x = ctx_dim.width / 2 - title_width / 2;
set_source_color_from_string(ctx, "#fff");
ctx.move_to(x, y);
Pango.cairo_show_layout(ctx, layout);
Pango.cairo_layout_path(ctx, layout);
ctx.set_line_width(1.5);
set_source_color_from_string(ctx, "#000");
ctx.stroke();
}
public override void paint(Cairo.Context ctx, Dimensions ctx_dim) {
base.paint(ctx, ctx_dim);
if (Config.Facade.get_instance().get_slideshow_show_title() && !is_transition_in_progress())
paint_title(ctx, ctx_dim);
}
}
......@@ -71,6 +71,7 @@ public enum ConfigurableProperty {
SLIDESHOW_DELAY,
SLIDESHOW_TRANSITION_DELAY,
SLIDESHOW_TRANSITION_EFFECT_ID,
SLIDESHOW_SHOW_TITLE,
USE_24_HOUR_TIME,
USE_LOWERCASE_FILENAMES,
VIDEO_INTERPRETER_STATE_COOKIE,
......@@ -232,6 +233,9 @@ public enum ConfigurableProperty {
case SLIDESHOW_TRANSITION_EFFECT_ID:
return "SLIDESHOW_TRANSITION_EFFECT_ID";
case SLIDESHOW_SHOW_TITLE:
return "SLIDESHOW_SHOW_TITLE";
case USE_24_HOUR_TIME:
return "USE_24_HOUR_TIME";
......@@ -1336,7 +1340,28 @@ public abstract class ConfigurationFacade : Object {
on_configuration_error(err);
}
}
//
// Slideshow show title
//
public virtual bool get_slideshow_show_title() {
try {
return get_engine().get_bool_property(ConfigurableProperty.SLIDESHOW_SHOW_TITLE);
} catch (ConfigurationError err) {
on_configuration_error(err);
return false;
}
}
public virtual void set_slideshow_show_title(bool show_title) {
try {
get_engine().set_bool_property(ConfigurableProperty.SLIDESHOW_SHOW_TITLE, show_title);
} catch (ConfigurationError err) {
on_configuration_error(err);
}
}
//
// use 24 hour time
//
......
......@@ -84,6 +84,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
schema_names[ConfigurableProperty.SLIDESHOW_DELAY] = SLIDESHOW_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = SLIDESHOW_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = SLIDESHOW_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.SLIDESHOW_SHOW_TITLE] = SLIDESHOW_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.USE_24_HOUR_TIME] = UI_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.USE_LOWERCASE_FILENAMES] = FILES_PREFS_SCHEMA_NAME;
schema_names[ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE] = VIDEO_SCHEMA_NAME;
......@@ -141,6 +142,7 @@ public class GSettingsConfigurationEngine : ConfigurationEngine, GLib.Object {
key_names[ConfigurableProperty.SLIDESHOW_DELAY] = "delay";
key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_DELAY] = "transition-delay";
key_names[ConfigurableProperty.SLIDESHOW_TRANSITION_EFFECT_ID] = "transition-effect-id";
key_names[ConfigurableProperty.SLIDESHOW_SHOW_TITLE] = "show-title";
key_names[ConfigurableProperty.USE_24_HOUR_TIME] = "use-24-hour-time";
key_names[ConfigurableProperty.USE_LOWERCASE_FILENAMES] = "use-lowercase-filenames";
key_names[ConfigurableProperty.VIDEO_INTERPRETER_STATE_COOKIE] = "interpreter-state-cookie";
......
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