vcl/unx/gtk3/gtkinst.cxx |  100 +++++++++++++++++++++++++----------------------
 1 file changed, 55 insertions(+), 45 deletions(-)

New commits:
commit 8faeb46a5d4bb7301968281a1edf5fc0b6278e53
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Dec 14 10:36:31 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Dec 14 12:11:53 2022 +0000

    Resolves: tdf#152501 forward replacement ComboBox query-tooltip to original
    
    Change-Id: I7c56ce58a00d87ce1699bffdf36c9842ac579161
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144158
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 61d3f001c6d5..f44240e216bc 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -18831,6 +18831,47 @@ public:
 
 #endif
 
+gboolean signalTooltipQuery(GtkWidget* pWidget, gint /*x*/, gint /*y*/,
+                            gboolean /*keyboard_mode*/, GtkTooltip *tooltip)
+{
+    const ImplSVHelpData& aHelpData = ImplGetSVHelpData();
+    if (aHelpData.mbBalloonHelp) // extended tips
+    {
+#if !GTK_CHECK_VERSION(4, 0, 0)
+        // by default use accessible description
+        AtkObject* pAtkObject = gtk_widget_get_accessible(pWidget);
+        const char* pDesc = pAtkObject ? 
atk_object_get_description(pAtkObject) : nullptr;
+        if (pDesc && pDesc[0])
+        {
+            gtk_tooltip_set_text(tooltip, pDesc);
+            return true;
+        }
+#endif
+
+        // fallback to the mechanism which needs help installed
+        OString sHelpId = ::get_help_id(pWidget);
+        Help* pHelp = !sHelpId.isEmpty() ? Application::GetHelp() : nullptr;
+        if (pHelp)
+        {
+            OUString sHelpText = pHelp->GetHelpText(OStringToOUString(sHelpId, 
RTL_TEXTENCODING_UTF8), static_cast<weld::Widget*>(nullptr));
+            if (!sHelpText.isEmpty())
+            {
+                gtk_tooltip_set_text(tooltip, OUStringToOString(sHelpText, 
RTL_TEXTENCODING_UTF8).getStr());
+                return true;
+            }
+        }
+    }
+
+    const char* pDesc = gtk_widget_get_tooltip_text(pWidget);
+    if (pDesc && pDesc[0])
+    {
+        gtk_tooltip_set_text(tooltip, pDesc);
+        return true;
+    }
+
+    return false;
+}
+
 #if GTK_CHECK_VERSION(4, 0, 0)
 
 class GtkInstanceComboBox : public GtkInstanceWidget, public 
vcl::ISearchableStringList, public virtual weld::ComboBox
@@ -21647,6 +21688,14 @@ private:
         return true;
     }
 
+    static gboolean signalComboTooltipQuery(GtkWidget* /*pWidget*/, gint x, 
gint y,
+                                            gboolean keyboard_mode, GtkTooltip 
*tooltip,
+                                            gpointer widget)
+    {
+        GtkInstanceComboBox* pThis = static_cast<GtkInstanceComboBox*>(widget);
+        return signalTooltipQuery(GTK_WIDGET(pThis->m_pComboBox), x, y, 
keyboard_mode, tooltip);
+    }
+
     int include_mru(int pos)
     {
         if (m_nMRUCount && pos != -1)
@@ -21696,6 +21745,12 @@ public:
         if 
(gtk_style_context_has_class(gtk_widget_get_style_context(GTK_WIDGET(m_pComboBox)),
 "small-button"))
             
gtk_style_context_add_class(gtk_widget_get_style_context(GTK_WIDGET(getContainer())),
 "small-button");
 
+        if (gtk_widget_get_has_tooltip(GTK_WIDGET(m_pComboBox)))
+        {
+            gtk_widget_set_has_tooltip(GTK_WIDGET(getContainer()), true);
+            g_signal_connect(getContainer(), "query-tooltip", 
G_CALLBACK(signalComboTooltipQuery), this);
+        }
+
         insertAsParent(GTK_WIDGET(m_pComboBox), GTK_WIDGET(getContainer()));
         gtk_widget_set_visible(GTK_WIDGET(m_pComboBox), false);
         gtk_widget_set_no_show_all(GTK_WIDGET(m_pComboBox), true);
@@ -22862,51 +22917,6 @@ public:
 
 }
 
-namespace {
-
-    gboolean signalTooltipQuery(GtkWidget* pWidget, gint /*x*/, gint /*y*/,
-                                         gboolean /*keyboard_mode*/, 
GtkTooltip *tooltip)
-    {
-        const ImplSVHelpData& aHelpData = ImplGetSVHelpData();
-        if (aHelpData.mbBalloonHelp) // extended tips
-        {
-#if !GTK_CHECK_VERSION(4, 0, 0)
-            // by default use accessible description
-            AtkObject* pAtkObject = gtk_widget_get_accessible(pWidget);
-            const char* pDesc = pAtkObject ? 
atk_object_get_description(pAtkObject) : nullptr;
-            if (pDesc && pDesc[0])
-            {
-                gtk_tooltip_set_text(tooltip, pDesc);
-                return true;
-            }
-#endif
-
-            // fallback to the mechanism which needs help installed
-            OString sHelpId = ::get_help_id(pWidget);
-            Help* pHelp = !sHelpId.isEmpty() ? Application::GetHelp() : 
nullptr;
-            if (pHelp)
-            {
-                OUString sHelpText = 
pHelp->GetHelpText(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), 
static_cast<weld::Widget*>(nullptr));
-                if (!sHelpText.isEmpty())
-                {
-                    gtk_tooltip_set_text(tooltip, OUStringToOString(sHelpText, 
RTL_TEXTENCODING_UTF8).getStr());
-                    return true;
-                }
-            }
-        }
-
-        const char* pDesc = gtk_widget_get_tooltip_text(pWidget);
-        if (pDesc && pDesc[0])
-        {
-            gtk_tooltip_set_text(tooltip, pDesc);
-            return true;
-        }
-
-        return false;
-    }
-
-}
-
 namespace {
 
 class GtkInstancePopover : public GtkInstanceContainer, public virtual 
weld::Popover

Reply via email to