diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:17 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:17 +0200 |
commit | 31804433d72460cbe0a39f9f8ea5e76058d84cda (patch) | |
tree | 2084a84c39f159c6aea254775dc0880d52579d45 /src/searches/SavedSearchDialog.vala | |
parent | a9898fb3f39c44a85876930ef6b2558052569ae6 (diff) | |
parent | d443a3c2509889533ca812c163056bace396b586 (diff) |
Update upstream source from tag 'upstream/0.32.1'
Update to upstream version '0.32.1'
with Debian dir c460ad6e13d3c39eaa2d5399059385e64e6fba4c
Diffstat (limited to 'src/searches/SavedSearchDialog.vala')
-rw-r--r-- | src/searches/SavedSearchDialog.vala | 37 |
1 files changed, 32 insertions, 5 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. |