[gtksourceview] hover: don't show assistant if hover display is empty



commit df1a1479c8fdd7942c452cfcaa093e66fa419523
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 11:12:37 2022 -0700

    hover: don't show assistant if hover display is empty

 gtksourceview/gtksourcehoverassistant.c       |  3 ++-
 gtksourceview/gtksourcehoverdisplay-private.h |  3 ++-
 gtksourceview/gtksourcehoverdisplay.c         | 10 +++++++++-
 3 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gtksourceview/gtksourcehoverassistant.c b/gtksourceview/gtksourcehoverassistant.c
index 5e9a32b1..5d0e469c 100644
--- a/gtksourceview/gtksourcehoverassistant.c
+++ b/gtksourceview/gtksourcehoverassistant.c
@@ -196,7 +196,8 @@ gtk_source_hover_assistant_populate_cb (GObject      *object,
 
        if (_gtk_source_hover_context_populate_finish (context, result, &error))
        {
-               gtk_widget_show (GTK_WIDGET (self));
+               gtk_widget_set_visible (GTK_WIDGET (self),
+                                       !_gtk_source_hover_display_is_empty (self->display));
        }
 
        g_clear_object (&self);
diff --git a/gtksourceview/gtksourcehoverdisplay-private.h b/gtksourceview/gtksourcehoverdisplay-private.h
index 3ee9fd08..a91ff0f7 100644
--- a/gtksourceview/gtksourcehoverdisplay-private.h
+++ b/gtksourceview/gtksourcehoverdisplay-private.h
@@ -25,6 +25,7 @@
 
 G_BEGIN_DECLS
 
-void _gtk_source_hover_display_clear (GtkSourceHoverDisplay *self);
+void     _gtk_source_hover_display_clear    (GtkSourceHoverDisplay *self);
+gboolean _gtk_source_hover_display_is_empty (GtkSourceHoverDisplay *self);
 
 G_END_DECLS
diff --git a/gtksourceview/gtksourcehoverdisplay.c b/gtksourceview/gtksourcehoverdisplay.c
index 4422c012..ebfad311 100644
--- a/gtksourceview/gtksourcehoverdisplay.c
+++ b/gtksourceview/gtksourcehoverdisplay.c
@@ -25,7 +25,7 @@
 
 /**
  * GtkSourceHoverDisplay:
- * 
+ *
  * Display for interactive tooltips.
  *
  * `GtkSourceHoverDisplay` is a [class@Gtk.Widget] that may be populated with widgets
@@ -137,3 +137,11 @@ _gtk_source_hover_display_clear (GtkSourceHoverDisplay *self)
                gtk_box_remove (self->vbox, child);
        }
 }
+
+gboolean
+_gtk_source_hover_display_is_empty (GtkSourceHoverDisplay *self)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_HOVER_DISPLAY (self), FALSE);
+
+       return gtk_widget_get_first_child (GTK_WIDGET (self->vbox)) == NULL;
+}


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