[gtksourceview] assistants: refuse to show assistants unless parent is mapped



commit 248fb66737ec5af18844cffe725be998d83c972b
Author: Christian Hergert <chergert redhat com>
Date:   Wed Sep 21 20:16:33 2022 -0700

    assistants: refuse to show assistants unless parent is mapped
    
    If our parent widget (the source view) is not mapped, then we really don't
    want to be showing any additional assistants as they'd be displayed over
    the wrong widget (likely in a GtkStack or GtkNotebok, etc).

 gtksourceview/gtksourcecompletion.c     | 5 ++++-
 gtksourceview/gtksourcehoverassistant.c | 7 +++++--
 gtksourceview/gtksourceview-snippets.c  | 5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletion.c b/gtksourceview/gtksourcecompletion.c
index 0dd89a5e..f3a23eb0 100644
--- a/gtksourceview/gtksourcecompletion.c
+++ b/gtksourceview/gtksourcecompletion.c
@@ -213,7 +213,10 @@ display_show (GtkSourceCompletion *self)
                self->hide_tick_handler = 0;
        }
 
-       gtk_widget_show (GTK_WIDGET (_gtk_source_completion_get_display (self)));
+       if (gtk_widget_get_mapped (GTK_WIDGET (self->view)))
+       {
+               gtk_widget_show (GTK_WIDGET (_gtk_source_completion_get_display (self)));
+       }
 }
 
 static gboolean
diff --git a/gtksourceview/gtksourcehoverassistant.c b/gtksourceview/gtksourcehoverassistant.c
index 49f8591e..47f43a15 100644
--- a/gtksourceview/gtksourcehoverassistant.c
+++ b/gtksourceview/gtksourcehoverassistant.c
@@ -385,8 +385,11 @@ gtk_source_hover_assistant_populate_cb (GObject      *object,
        {
                if (!self->disposed)
                {
-                       gtk_widget_set_visible (GTK_WIDGET (self),
-                                               !_gtk_source_hover_display_is_empty (self->display));
+                       GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (self));
+                       gboolean mapped = parent && gtk_widget_get_mapped (parent);
+                       gboolean empty = _gtk_source_hover_display_is_empty (self->display);
+
+                       gtk_widget_set_visible (GTK_WIDGET (self), mapped && !empty);
                }
        }
 
diff --git a/gtksourceview/gtksourceview-snippets.c b/gtksourceview/gtksourceview-snippets.c
index 60490e6f..7aa27a42 100644
--- a/gtksourceview/gtksourceview-snippets.c
+++ b/gtksourceview/gtksourceview-snippets.c
@@ -367,7 +367,10 @@ gtk_source_view_snippets_update_informative (GtkSourceViewSnippets *snippets)
        }
        else
        {
-               gtk_widget_show (GTK_WIDGET (snippets->informative));
+               if (gtk_widget_get_mapped (GTK_WIDGET (snippets->view)))
+               {
+                       gtk_widget_show (GTK_WIDGET (snippets->informative));
+               }
        }
 
        return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]