[gtk/wip/carlosg/for-master: 4/8] gtk/entrycompletion: Ensure to show first row when shown, not allocated
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/for-master: 4/8] gtk/entrycompletion: Ensure to show first row when shown, not allocated
- Date: Sat, 12 Dec 2020 00:43:16 +0000 (UTC)
commit 79090f175599f06feae23adb9ae9ac58a8754853
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Dec 11 23:13:00 2020 +0100
gtk/entrycompletion: Ensure to show first row when shown, not allocated
This code was here in gtk3 to cater for the completion window being
positioned. That was only to meant once as long as the completion window
was shown.
This doesn't work as well for gtk4, ::size-allocate gets propagated from
the toplevel, so happens much more often for the completion window, this
ends up with the completion position being reset to the first row
frequently.
Do this simply once when popping up the completion, instead.
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3083
gtk/gtkentrycompletion.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 6092e036c5..b8732ee55b 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -1099,7 +1099,6 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
GdkSurface *surface;
GtkRequisition entry_req;
GtkRequisition tree_req;
- GtkTreePath *path;
int width;
surface = gtk_native_get_surface (gtk_widget_get_native (completion->entry));
@@ -1143,14 +1142,6 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
gtk_widget_set_size_request (completion->popup_window, width, -1);
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (completion->scrolled_window), items *
height);
- if (matches > 0)
- {
- path = gtk_tree_path_new_from_indices (0, -1);
- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (completion->tree_view), path,
- NULL, FALSE, 0.0, 0.0);
- gtk_tree_path_free (path);
- }
-
gtk_popover_present (GTK_POPOVER (completion->popup_window));
}
@@ -1175,6 +1166,16 @@ gtk_entry_completion_popup (GtkEntryCompletion *completion)
_gtk_entry_completion_resize_popup (completion);
+ if (completion->filter_model)
+ {
+ GtkTreePath *path;
+
+ path = gtk_tree_path_new_from_indices (0, -1);
+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (completion->tree_view), path,
+ NULL, FALSE, 0.0, 0.0);
+ gtk_tree_path_free (path);
+ }
+
gtk_popover_popup (GTK_POPOVER (completion->popup_window));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]