[gtk+/gtk-2-24] Entry: Fix unset icon tooltip hiding Entry tooltip



commit fdb701837f59758e851df866691cd0e8ad2d10fd
Author: Daniel Boles <dboles src gnome org>
Date:   Tue Aug 1 10:09:01 2017 +0100

    Entry: Fix unset icon tooltip hiding Entry tooltip
    
    Our ::query-tooltip handler first checks whether the pointer is over any
    of the icons, returning their tooltip if so, and if not chains up to
    Widget::query-tooltip in order to show the text for the widget overall.
    
    But ensure_has_tooltip(), which exists to update :has-tooltip based on
    whether ::query-tooltip is needed, only set :has-tooltip to TRUE if any
    icon had a tooltip, without caring whether the widget as a whole does.
    
    That is asymmetrical and meant that if the Entry had a tooltip, but
    subsequently all icons had their tooltips unset, :has-tooltip would be
    set to FALSE, and hence the tooltip for the widget would become lost.
    
    The fix is to set :has-tooltip to TRUE if the widget has a tooltip of
    its own, and we only need to check the icons if that is not the case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785672

 gtk/gtkentry.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 98a8cd3..3623488 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -8367,18 +8367,18 @@ gtk_entry_get_icon_window (GtkEntry             *entry,
 static void
 ensure_has_tooltip (GtkEntry *entry)
 {
-  GtkEntryPrivate *priv;
-  EntryIconInfo *icon_info;
-  int i;
-  gboolean has_tooltip = FALSE;
+  gboolean has_tooltip = gtk_widget_get_tooltip_text (GTK_WIDGET (entry)) != NULL;
 
-  priv = GTK_ENTRY_GET_PRIVATE (entry);
-
-  for (i = 0; i < MAX_ICONS; i++)
+  if (!has_tooltip)
     {
-      if ((icon_info = priv->icons[i]) != NULL)
+      GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+      int i;
+
+      for (i = 0; i < MAX_ICONS; i++)
         {
-          if (icon_info->tooltip != NULL)
+          EntryIconInfo *icon_info = priv->icons[i];
+
+          if (icon_info != NULL && icon_info->tooltip != NULL)
             {
               has_tooltip = TRUE;
               break;


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