From 9a57dc812810c2d155b7ff13ec509d83950e22cb Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Thu, 4 Jan 2024 18:49:39 +0000 Subject: [PATCH 1/2] Associate popover with foldermanager --- .../fuzzy-search/fuzzy-search-popover.vala | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/fuzzy-search/fuzzy-search-popover.vala b/plugins/fuzzy-search/fuzzy-search-popover.vala index 98273e17f..9a99bdad2 100644 --- a/plugins/fuzzy-search/fuzzy-search-popover.vala +++ b/plugins/fuzzy-search/fuzzy-search-popover.vala @@ -20,7 +20,8 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { private bool should_distinguish_projects; private Gtk.EventControllerKey search_term_entry_key_controller; private Gtk.Label title_label; - private Scratch.MainWindow current_window; + public Scratch.MainWindow current_window { get; construct; } + public bool sidebar_is_visible { get; set; } public signal void open_file (string filepath); public signal void close_search (); @@ -28,13 +29,12 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { public FuzzySearchPopover (Gee.HashMap pps, Scratch.MainWindow window) { Object ( modal: true, - relative_to: window.toolbar, + relative_to: window.sidebar, constrain_to: Gtk.PopoverConstraint.WINDOW, - width_request: 500 + width_request: 500, + current_window: window ); - current_window = window; - int height; current_window.get_size (null, out height); window_height = height; @@ -253,6 +253,20 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { scrolled.hide (); this.add (box); + + closed.connect (() => { + current_window.sidebar.visible = sidebar_is_visible; + }); + } + + // Ensure popover has something to point to + public new void popup () { + sidebar_is_visible = current_window.sidebar.visible; + if (!sidebar_is_visible) { + current_window.sidebar.show (); + } + + base.popup (); } private void handle_item_selection (int index) { From 4e6b46fcfd50860765ac8e5bd2289fb5878c224f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sat, 6 Jan 2024 16:45:31 +0000 Subject: [PATCH 2/2] Simpler solution. Remove deprecated PopoverConstraint --- plugins/fuzzy-search/fuzzy-search-popover.vala | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/fuzzy-search/fuzzy-search-popover.vala b/plugins/fuzzy-search/fuzzy-search-popover.vala index 9a99bdad2..07d58589f 100644 --- a/plugins/fuzzy-search/fuzzy-search-popover.vala +++ b/plugins/fuzzy-search/fuzzy-search-popover.vala @@ -29,8 +29,7 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { public FuzzySearchPopover (Gee.HashMap pps, Scratch.MainWindow window) { Object ( modal: true, - relative_to: window.sidebar, - constrain_to: Gtk.PopoverConstraint.WINDOW, + relative_to: window.document_view, width_request: 500, current_window: window ); @@ -85,6 +84,7 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { } construct { + pointing_to = { 0, 32, 1, 1 }; this.get_style_context ().add_class ("fuzzy-popover"); title_label = new Gtk.Label (_("Find project files")); @@ -253,20 +253,6 @@ public class Scratch.FuzzySearchPopover : Gtk.Popover { scrolled.hide (); this.add (box); - - closed.connect (() => { - current_window.sidebar.visible = sidebar_is_visible; - }); - } - - // Ensure popover has something to point to - public new void popup () { - sidebar_is_visible = current_window.sidebar.visible; - if (!sidebar_is_visible) { - current_window.sidebar.show (); - } - - base.popup (); } private void handle_item_selection (int index) {