Commit 5d3d128f authored by Jim Nelson's avatar Jim Nelson

#148: View/Titles checkbox.

parent c36e7a84
......@@ -13,6 +13,8 @@ public abstract class LayoutItem : Gtk.Alignment {
protected Gtk.Frame frame = new Gtk.Frame(null);
private bool selected = false;
private Gtk.VBox vbox = new Gtk.VBox(false, 0);
private bool titleDisplayed = true;
public LayoutItem() {
// bottom-align everything
......@@ -27,7 +29,6 @@ public abstract class LayoutItem : Gtk.Alignment {
// store everything in a vbox, with the expandable image on top followed by a widget
// on the bottom for display and controls
Gtk.VBox vbox = new Gtk.VBox(false, 0);
vbox.set_border_width(FRAME_PADDING);
vbox.pack_start(image, false, false, 0);
vbox.pack_end(title, false, false, LABEL_PADDING);
......@@ -58,6 +59,16 @@ public abstract class LayoutItem : Gtk.Alignment {
public virtual void unexposed() {
}
public void display_title(bool display) {
if (display && !titleDisplayed) {
vbox.pack_end(title, false, false, LABEL_PADDING);
titleDisplayed = true;
} else if (!display && titleDisplayed) {
vbox.remove(title);
titleDisplayed = false;
}
}
public virtual void select() {
selected = true;
......
......@@ -16,7 +16,6 @@ public class CollectionPage : CheckerboardPage {
private Gtk.ToolButton rotateButton = null;
private int scale = Thumbnail.DEFAULT_SCALE;
private bool improval_scheduled = false;
private bool displayTitles = true;
// TODO: Mark fields for translation
private const Gtk.ActionEntry[] ACTIONS = {
......@@ -34,11 +33,14 @@ public class CollectionPage : CheckerboardPage {
{ "Mirror", null, "_Mirror", "<Ctrl>M", "Make mirror images of the selected photos", on_mirror },
{ "ViewMenu", null, "_View", null, null, null },
{ "ViewTitle", null, "_Titles", "<Ctrl><Shift>T", "Display the title of each photo", on_display_titles },
{ "HelpMenu", null, "_Help", null, null, null }
};
private const Gtk.ToggleActionEntry[] TOGGLE_ACTIONS = {
{ "ViewTitle", null, "_Titles", "<Ctrl><Shift>T", "Display the title of each photo", on_display_titles, true }
};
// TODO: Mark fields for translation
/*
private const Gtk.ActionEntry[] RIGHT_CLICK_ACTIONS = {
......@@ -50,7 +52,7 @@ public class CollectionPage : CheckerboardPage {
*/
construct {
init_ui("collection.ui", "/CollectionMenuBar", "CollectionActionGroup", ACTIONS);
init_ui("collection.ui", "/CollectionMenuBar", "CollectionActionGroup", ACTIONS, TOGGLE_ACTIONS);
init_context_menu("/CollectionContextMenu");
// set up page's toolbar (used by AppWindow for layout)
......@@ -149,7 +151,7 @@ public class CollectionPage : CheckerboardPage {
public void add_photo(PhotoID photoID, File file) {
Thumbnail thumbnail = Thumbnail.create(photoID, file, scale);
thumbnail.display_title(displayTitles);
thumbnail.display_title(display_titles());
add_item(thumbnail);
}
......@@ -312,11 +314,17 @@ public class CollectionPage : CheckerboardPage {
});
}
private void on_display_titles() {
displayTitles = (displayTitles) ? false : true;
private bool display_titles() {
Gtk.ToggleAction action = (Gtk.ToggleAction) ui.get_action("/CollectionMenuBar/ViewMenu/ViewTitle");
return action.get_active();
}
private void on_display_titles(Gtk.Action action) {
bool display = ((Gtk.ToggleAction) action).get_active();
foreach (LayoutItem item in get_items()) {
((Thumbnail) item).display_title(displayTitles);
item.display_title(display);
}
refresh();
......
......@@ -101,7 +101,7 @@ public abstract class Page : Gtk.ScrolledWindow {
}
protected void init_ui(string uiFilename, string menuBarPath, string actionGroupName,
Gtk.ActionEntry[] entries) {
Gtk.ActionEntry[]? entries = null, Gtk.ToggleActionEntry[]? toggleEntries = null) {
File uiFile = data_dir.get_child(uiFilename);
try {
......@@ -111,7 +111,10 @@ public abstract class Page : Gtk.ScrolledWindow {
}
actionGroup = new Gtk.ActionGroup(actionGroupName);
actionGroup.add_actions(entries, this);
if (entries != null)
actionGroup.add_actions(entries, this);
if (toggleEntries != null)
actionGroup.add_toggle_actions(toggleEntries, this);
ui.insert_action_group(actionGroup, 0);
ui.insert_action_group(AppWindow.get_instance().get_common_action_group(), 0);
......
......@@ -136,10 +136,6 @@ public class Thumbnail : LayoutItem {
}
}
public void display_title(bool display) {
title.visible = display;
}
public time_t get_time_t() {
return time;
}
......
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