summaryrefslogtreecommitdiff
path: root/src/searches/SavedSearchDialog.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
commitb86540b743f1a87a163ffb811c8fe22a01fefa38 (patch)
treeb47cb3bb83c2377234226fb3987ab3320a987dd9 /src/searches/SavedSearchDialog.vala
parentac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff)
parente905d8e16eec152d19797937f13ba3cf4b8f8aca (diff)
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'src/searches/SavedSearchDialog.vala')
-rw-r--r--src/searches/SavedSearchDialog.vala37
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.