Commit 2d51356c authored by Jim Nelson's avatar Jim Nelson

#3188: Added back Ctrl+F to set cursor focus to the text entry box in the...

#3188: Added back Ctrl+F to set cursor focus to the text entry box in the search bar.  This patch also allows the search bar to be hidden and available through View -> Search Bar.
parent 02c69e90
......@@ -127,7 +127,7 @@ RESOURCE_FILES = \
yandex_publish_model.glade \
shotwell.glade \
set_background_dialog.glade \
video.ui
search_bar.ui
SYS_INTEGRATION_FILES = \
shotwell.desktop.head \
......
......@@ -238,7 +238,7 @@ public abstract class CollectionPage : MediaPage {
Gtk.ActionEntry slideshow = { "Slideshow", null, TRANSLATABLE, "F5", TRANSLATABLE,
on_slideshow };
slideshow.label = _("_Slideshow");
slideshow.label = _("S_lideshow");
slideshow.tooltip = _("Play a slideshow");
actions += slideshow;
......
......@@ -152,6 +152,7 @@ public class LibraryWindow : AppWindow {
private SidebarMarker cameras_marker = null;
private SidebarMarker tags_marker = null;
private bool is_search_toolbar_visible = false;
private SearchFilterToolbar search_toolbar = new SearchFilterToolbar();
private Gtk.VBox top_section = new Gtk.VBox(false, 0);
......@@ -217,6 +218,9 @@ public class LibraryWindow : AppWindow {
// monitor cursor changes to select proper page in notebook
sidebar.cursor_changed.connect(on_sidebar_cursor_changed);
// set search bar's visibility to default state
search_toolbar.visible = is_search_toolbar_visible;
create_layout(library_page);
// settings that should persist between sessions
......@@ -369,6 +373,12 @@ public class LibraryWindow : AppWindow {
jump_to_event.tooltip = _("Go to this photo's event");
actions += jump_to_event;
Gtk.ActionEntry find = { "CommonFind", Gtk.STOCK_FIND, TRANSLATABLE, null, null,
on_find };
find.label = _("_Find");
find.tooltip = _("Find photos and videos by search criteria");
actions += find;
return actions;
}
......@@ -386,7 +396,13 @@ public class LibraryWindow : AppWindow {
extended_props.label = _("E_xtended Information");
extended_props.tooltip = _("Display extended information for the selection");
actions += extended_props;
Gtk.ToggleActionEntry searchbar = { "CommonDisplaySearchbar", null, TRANSLATABLE,
"F8", TRANSLATABLE, on_display_searchbar, is_search_toolbar_visible };
searchbar.label = _("_Search Bar");
searchbar.tooltip = _("Display the search bar");
actions += searchbar;
return actions;
}
......@@ -409,18 +425,24 @@ public class LibraryWindow : AppWindow {
return actions;
}
// show_all() may make visible certain items we wish to keep programmatically hidden
public override void show_all() {
base.show_all();
Gtk.ToggleAction basic_properties_action =
(Gtk.ToggleAction) get_current_page().common_action_group.get_action(
"CommonDisplayBasicProperties");
Gtk.ToggleAction? basic_properties_action = get_current_page().get_common_action(
"CommonDisplayBasicProperties") as Gtk.ToggleAction;
assert(basic_properties_action != null);
if (!basic_properties_action.get_active()) {
if (!basic_properties_action.get_active())
bottom_frame.hide();
}
Gtk.ToggleAction? searchbar_action = get_current_page().get_common_action(
"CommonDisplaySearchbar") as Gtk.ToggleAction;
assert(searchbar_action != null);
is_search_toolbar_visible = searchbar_action.get_active();
search_toolbar.visible = searchbar_action.get_active();
}
public static LibraryWindow get_app() {
......@@ -503,7 +525,7 @@ public class LibraryWindow : AppWindow {
public override string get_app_role() {
return Resources.APP_LIBRARY_ROLE;
}
protected override void on_quit() {
Config.get_instance().set_library_window_state(maximized, dimensions);
......@@ -653,6 +675,15 @@ public class LibraryWindow : AppWindow {
switch_to_event(event);
}
private void on_find() {
Gtk.ToggleAction action = (Gtk.ToggleAction) get_current_page().get_common_action(
"CommonDisplaySearchbar");
action.active = true;
// give it focus (which should move cursor to the text entry control)
search_toolbar.take_focus();
}
private void on_media_altered() {
set_common_action_sensitive("CommonJumpToEvent", can_jump_to_event());
}
......@@ -733,7 +764,18 @@ public class LibraryWindow : AppWindow {
extended_properties.hide();
}
}
private void on_display_searchbar(Gtk.Action action) {
bool display = ((Gtk.ToggleAction) action).get_active();
is_search_toolbar_visible = display;
search_toolbar.visible = display;
// if dismissing the toolbar, reset the filter
if (!display)
search_toolbar.reset();
}
private void show_extended_properties() {
sync_extended_properties(true);
}
......@@ -1810,11 +1852,13 @@ public class LibraryWindow : AppWindow {
// Update search filter to new page.
if (page is CheckerboardPage) {
// restore visibility and install filters
search_toolbar.visible = is_search_toolbar_visible;
search_toolbar.set_view_filter(((CheckerboardPage) page).get_search_view_filter());
page.get_view().install_view_filter(((CheckerboardPage) page).get_search_view_filter());
} else {
// Disables the search view filter for non CheckerboardPages.
search_toolbar.unset_view_filter();
// hide search toolbar, but don't reset its CheckboardLayout visibility
search_toolbar.visible = false;
}
sidebar.cursor_changed.disconnect(on_sidebar_cursor_changed);
......@@ -2021,9 +2065,5 @@ public class LibraryWindow : AppWindow {
return false;
}
public void set_search_box_focus() {
search_toolbar.set_search_box_focus();
}
}
......@@ -2484,7 +2484,7 @@ public class LibraryPhotoPage : EditingHostPage {
Gtk.ActionEntry slideshow = { "Slideshow", null, TRANSLATABLE, "F5", TRANSLATABLE,
on_slideshow };
slideshow.label = _("_Slideshow");
slideshow.label = _("S_lideshow");
slideshow.tooltip = _("Play a slideshow");
actions += slideshow;
......
......@@ -700,6 +700,16 @@ public class SearchFilterToolbar : Gtk.Toolbar {
search_filter.refresh();
}
// Reset all controls to default state
public void reset() {
clear_search_text();
set_flagged(false);
set_toggle_media_photos(false);
set_toggle_media_raw(false);
set_toggle_media_video(false);
set_rating_filter(RatingFilter.UNRATED_OR_HIGHER);
}
// Saves settings.
private void save_search_filter() {
Config.get_instance().set_search_text(get_search_text());
......@@ -748,14 +758,23 @@ public class SearchFilterToolbar : Gtk.Toolbar {
protected RatingFilter get_rating_filter() {
// any member of the group knows the current value
Gtk.RadioAction action = (Gtk.RadioAction) ui.get_action(
"/FilterPopupMenu/DisplayRejectedOrHigher");
Gtk.RadioAction? action = ui.get_action("/FilterPopupMenu/DisplayRejectedOrHigher")
as Gtk.RadioAction;
assert(action != null);
return (RatingFilter) action.get_current_value();
}
public void set_rating_filter(RatingFilter filter) {
// any member of the group knows the current value
Gtk.RadioAction? action = ui.get_action("/FilterPopupMenu/DisplayRejectedOrHigher")
as Gtk.RadioAction;
assert(action != null);
RatingFilter filter = (RatingFilter) action.get_current_value();
return filter;
action.set_current_value(filter);
}
public void set_search_box_focus() {
public void take_focus() {
search_box.get_focus();
}
}
......
......@@ -14,6 +14,8 @@
<menuitem name="Undo" action="CommonUndo" />
<menuitem name="Redo" action="CommonRedo" />
<separator />
<menuitem name="Find" action="CommonFind" />
<separator />
<menuitem name="SelectAll" action="CommonSelectAll" />
<separator />
<menuitem name="Preferences" action="CommonPreferences" />
......@@ -22,6 +24,7 @@
<menu name="ViewMenu" action="ViewMenu">
<menuitem name="DisplayBasicProperties" action="CommonDisplayBasicProperties" />
<menuitem name="DisplayExtendedProperties" action="CommonDisplayExtendedProperties" />
<menuitem name="DisplaySearchbar" action="CommonDisplaySearchbar" />
<separator />
<menu name="SortEvents" action="CommonSortEvents">
<menuitem name="SortEventsAscending" action="CommonSortEventsAscending" />
......
......@@ -13,15 +13,22 @@
</menu>
<menu name="EditMenu" action="EditMenu">
<menuitem name="Undo" action="CommonUndo" />
<menuitem name="Redo" action="CommonRedo" />
<separator />
<menuitem name="Find" action="CommonFind" />
<separator />
<menuitem name="SelectAll" action="CommonSelectAll" />
<separator />
<menuitem name="Preferences" action="CommonPreferences" />
</menu>
<menu name="ViewMenu" action="ViewMenu">
<menuitem name="ViewTitle" action="ViewTitle" />
<menuitem name="DisplayBasicProperties" action="CommonDisplayBasicProperties" />
<menuitem name="DisplayExtendedProperties" action="CommonDisplayExtendedProperties" />
<menuitem name="DisplaySearchbar" action="CommonDisplaySearchbar" />
<separator />
<menuitem name="ViewTitle" action="ViewTitle" />
<separator />
<menu name="SortEvents" action="CommonSortEvents">
<menuitem name="SortEventsAscending" action="CommonSortEventsAscending" />
......
......@@ -19,6 +19,8 @@
<menuitem name="Undo" action="CommonUndo" />
<menuitem name="Redo" action="CommonRedo" />
<separator />
<menuitem name="Find" action="CommonFind" />
<separator />
<placeholder name="EditExtrasPlaceholder" />
<menuitem name="RemoveFromLibrary" action="RemoveFromLibrary" />
<menuitem name="MoveToTrash" action="MoveToTrash" />
......@@ -31,6 +33,7 @@
<menu name="ViewMenu" action="ViewMenu">
<menuitem name="DisplayBasicProperties" action="CommonDisplayBasicProperties" />
<menuitem name="DisplayExtendedProperties" action="CommonDisplayExtendedProperties" />
<menuitem name="DisplaySearchbar" action="CommonDisplaySearchbar" />
<separator />
<menuitem name="ViewTitle" action="ViewTitle" />
<menuitem name="ViewTags" action="ViewTags" />
......
......@@ -14,6 +14,8 @@
<menuitem name="Undo" action="CommonUndo" />
<menuitem name="Redo" action="CommonRedo" />
<separator />
<menuitem name="Find" action="CommonFind" />
<separator />
<menuitem name="RemoveFromLibrary" action="RemoveFromLibrary" />
<separator />
<menuitem name="SelectAll" action="CommonSelectAll" />
......@@ -24,6 +26,7 @@
<menu name="ViewMenu" action="ViewMenu">
<menuitem name="DisplayBasicProperties" action="CommonDisplayBasicProperties" />
<menuitem name="DisplayExtendedProperties" action="CommonDisplayExtendedProperties" />
<menuitem name="DisplaySearchbar" action="CommonDisplaySearchbar" />
<separator />
<menu name="SortEvents" action="CommonSortEvents">
<menuitem name="SortEventsAscending" action="CommonSortEventsAscending" />
......
......@@ -15,6 +15,8 @@
<menuitem name="Undo" action="CommonUndo" />
<menuitem name="Redo" action="CommonRedo" />
<separator />
<menuitem name="Find" action="CommonFind" />
<separator />
<menuitem name="Delete" action="Delete" />
<menuitem name="Restore" action="Restore" />
<separator />
......@@ -26,6 +28,7 @@
<menu name="ViewMenu" action="ViewMenu">
<menuitem name="DisplayBasicProperties" action="CommonDisplayBasicProperties" />
<menuitem name="DisplayExtendedProperties" action="CommonDisplayExtendedProperties" />
<menuitem name="DisplaySearchbar" action="CommonDisplaySearchbar" />
<separator />
<menu name="SortEvents" action="CommonSortEvents">
<menuitem name="SortEventsAscending" action="CommonSortEventsAscending" />
......
<ui>
<popup name="VideoContextMenu">
<menuitem name="ContextPlayVideo" action="PlayVideo" />
<separator />
<menuitem name="ContextAddTags" action="AddTags" />
<menuitem name="ContextModifyTags" action="ModifyTags" />
<placeholder name="ContextTagsPlaceholder" />
<separator />
<menuitem name="ContextFlag" action="Flag" />
<menu name="Rate" action="Rate">
<menuitem name="RateFive" action="RateFive" />
<menuitem name="RateFour" action="RateFour" />
<menuitem name="RateThree" action="RateThree" />
<menuitem name="RateTwo" action="RateTwo" />
<menuitem name="RateOne" action="RateOne" />
<menuitem name="RateUnrated" action="RateUnrated" />
<menuitem name="RateRejected" action="RateRejected" />
<separator />
<menuitem name="IncreaseRating" action="IncreaseRating" />
<menuitem name="DecreaseRating" action="DecreaseRating" />
</menu>
<separator />
<menuitem name="ContextEditTitle" action="EditTitle" />
<separator />
<menuitem name="ContextJumpToEvent" action="CommonJumpToEvent" />
<menuitem name="ContextJumpToFile" action="CommonJumpToFile" />
<menuitem name="ContextSendTo" action="SendTo" />
<separator />
<menuitem name="ContextMoveToTrash" action="MoveToTrash" />
</popup>
</ui>
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