diff options
Diffstat (limited to 'src/searches')
-rw-r--r-- | src/searches/SavedSearchDialog.vala | 37 | ||||
-rw-r--r-- | src/searches/SearchBoolean.vala | 6 |
2 files changed, 35 insertions, 8 deletions
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala index 526da35..b08c8a8 100644 --- a/src/searches/SavedSearchDialog.vala +++ b/src/searches/SavedSearchDialog.vala @@ -641,18 +641,19 @@ public class SavedSearchDialog : Gtk.Dialog { } [GtkChild] - private Gtk.Button add_criteria; + private unowned Gtk.Button add_criteria; [GtkChild] - private Gtk.ComboBoxText operator; + private unowned Gtk.ComboBoxText operator; [GtkChild] - private Gtk.Entry search_title; + private unowned Gtk.Entry search_title; [GtkChild] - private Gtk.ListBox row_listbox; + private unowned Gtk.ListBox row_listbox; private Gee.ArrayList<SearchRowContainer> row_list = new Gee.ArrayList<SearchRowContainer>(); private bool edit_mode = false; private SavedSearch? previous_search = null; private bool valid = false; + private ulong notify_id = 0; public SavedSearchDialog() { Object (use_header_bar : Resources.use_header_bar()); @@ -701,6 +702,12 @@ public class SavedSearchDialog : Gtk.Dialog { add_criteria.clicked.connect(on_add_criteria); search_title.changed.connect(on_title_changed); + if (Resources.use_header_bar() == 1) { + var box = search_title.get_parent(); + box.remove(search_title); + box.get_parent().remove(box); + ((Gtk.HeaderBar) get_header_bar()).set_custom_title(search_title); + } } // Displays the dialog. @@ -709,9 +716,14 @@ public class SavedSearchDialog : Gtk.Dialog { destroy(); } + double upper; // Adds a row of search criteria. private void on_add_criteria() { + this.upper = row_listbox.get_adjustment().upper; + this.notify_id = row_listbox.get_adjustment().notify["upper"].connect(on_scroll); add_text_search(); + // Wait for upper to change. Then scroll to it, disconnect afterwards + // Otherwise the ListBox will randomly scroll to the bottom } private void add_text_search() { @@ -723,11 +735,26 @@ public class SavedSearchDialog : Gtk.Dialog { private void add_row(SearchRowContainer row) { if (row_list.size == 1) row_list.get(0).allow_removal(true); - row_listbox.add(row.get_widget()); + row_listbox.insert(row.get_widget(), row_list.size); row_list.add(row); row.remove.connect(on_remove_row); row.changed.connect(on_row_changed); set_valid(row.is_complete()); + + } + + private void on_scroll() { + var adj = row_listbox.get_adjustment(); + if (adj.upper < this.upper) { + return; + } + + if (this.notify_id != 0) { + adj.disconnect(this.notify_id); + this.notify_id = 0; + } + + adj.value = adj.upper; } // Removes a row of search criteria. diff --git a/src/searches/SearchBoolean.vala b/src/searches/SearchBoolean.vala index 5e69e57..fc83e04 100644 --- a/src/searches/SearchBoolean.vala +++ b/src/searches/SearchBoolean.vala @@ -776,11 +776,11 @@ public class SearchConditionDate : SearchCondition { // Determines whether the source is included. public override bool predicate(MediaSource source) { - time_t exposure_time = source.get_exposure_time(); - if (exposure_time == 0) + var exposure_time = source.get_exposure_time(); + if (exposure_time == null) return context == Context.IS_NOT_SET; - DateTime dt = new DateTime.from_unix_local(exposure_time); + var dt = exposure_time.to_local(); switch (context) { case Context.EXACT: DateTime second = date_one.add_days(1); |