cui/source/inc/border.hxx              |    2 --
 cui/source/tabpages/border.cxx         |   30 ++++++------------------------
 cui/uiconfig/ui/borderpage.ui          |    6 ++++++
 sd/source/ui/sidebar/LayoutMenu.cxx    |   27 +--------------------------
 sd/source/ui/sidebar/LayoutMenu.hxx    |    4 ----
 sd/uiconfig/simpress/ui/layoutpanel.ui |    6 ++++--
 6 files changed, 17 insertions(+), 58 deletions(-)

New commits:
commit 54f16775205b09fed8fff1f7ccf2b3fdc481d047
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Dec 16 14:31:51 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue Dec 16 23:17:16 2025 +0100

    tdf#130857 sd: Set iconview tooltips in LayoutMenu directly
    
    Use the new API introduced in previous commit
    
        Change-Id: I56e8dde0b591073dea7f58190746ca0ba1fd8a4f
        Author: Michael Weghorn <[email protected]>
        Date:   Tue Dec 16 12:10:48 2025 +0100
    
            tdf#130857 tdf#168594 weld: Introduce 
weld::IconView::set_item_tooltip_text
    
    to directly set the tooltip text for each of the
    IconView items.
    
    This means it's no longer necessary to remember a mapping
    between the ID and the layout name, so drop the corresponding
    logic.
    
    For gtk3/gtk4, add a corresponding column in the
    GtkIconView model and set GtkIconView::tooltip-column
    accordingly, as described in the above-mentioned commit.
    
    This is used in the Impress sidebar, "Properties" panel.
    
    Change-Id: I3840d4b7122a423000f3edb6f5ee64ac8118b39b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195714
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx 
b/sd/source/ui/sidebar/LayoutMenu.cxx
index 01e9ff33569f..5005d72e8fb3 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -153,7 +153,6 @@ void LayoutMenu::implConstruct( DrawDocShell& 
rDocumentShell )
 
     mxLayoutIconView->connect_item_activated(LINK(this, LayoutMenu, 
LayoutSelected));
     mxLayoutIconView->connect_mouse_press(LINK(this, LayoutMenu, 
MousePressHdl));
-    mxLayoutIconView->connect_query_tooltip(LINK(this, LayoutMenu, 
QueryTooltipHdl));
     InvalidateContent();
 
     Link<::sdtools::EventMultiplexerEvent&,void> aEventListenerLink 
(LINK(this,LayoutMenu,EventMultiplexerListener));
@@ -247,29 +246,6 @@ IMPL_LINK(LayoutMenu, MousePressHdl, const MouseEvent&, 
rMEvet, bool)
     return false;
 }
 
-IMPL_LINK(LayoutMenu, QueryTooltipHdl, const weld::TreeIter&, iter, OUString)
-{
-    const OUString sId = mxLayoutIconView->get_id(iter);
-
-    if (!sId.isEmpty())
-    {
-        AutoLayout aLayout = static_cast<AutoLayout>(sId.toInt32());
-        auto aResId = GetStringResourceIdForLayout(aLayout);
-        return aResId ? SdResId(aResId) : OUString();
-    }
-
-    return OUString();
-}
-
-TranslateId LayoutMenu::GetStringResourceIdForLayout(AutoLayout aLayout) const
-{
-    auto it = maLayoutToStringMap.find(aLayout);
-    if (it != maLayoutToStringMap.end())
-        return it->second;
-
-    return TranslateId();
-}
-
 void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout)
 {
     ViewShell* pViewShell = mrBase.GetMainViewShell().get();
@@ -531,8 +507,8 @@ void LayoutMenu::Fill()
                 {
                     Bitmap aPreviewBitmap = GetPreviewAsBitmap(aImg);
                     mxLayoutIconView->insert(id, &sLayoutName, &sId, 
&aPreviewBitmap, nullptr);
+                    mxLayoutIconView->set_item_tooltip_text(id, sLayoutName);
                 }
-                maLayoutToStringMap[elem.maAutoLayout] = elem.mpStrResId;
 
                 if (maPreviewSize.Width() == 0)
                     maPreviewSize = aImg.GetSizePixel();
@@ -547,7 +523,6 @@ void LayoutMenu::Fill()
 void LayoutMenu::Clear()
 {
     mxLayoutIconView->clear();
-    maLayoutToStringMap.clear();
 }
 
 IMPL_LINK(LayoutMenu, OnPopupEnd, const OUString&, sCommand, void)
diff --git a/sd/source/ui/sidebar/LayoutMenu.hxx 
b/sd/source/ui/sidebar/LayoutMenu.hxx
index 269e9d9b4b03..78bf13a8b1cb 100644
--- a/sd/source/ui/sidebar/LayoutMenu.hxx
+++ b/sd/source/ui/sidebar/LayoutMenu.hxx
@@ -99,7 +99,6 @@ private:
     bool mbIsMainViewChangePending;
     css::uno::Reference<css::ui::XSidebar> mxSidebar;
     bool mbIsDisposed;
-    std::map<AutoLayout, TranslateId> maLayoutToStringMap;
 
     std::unique_ptr<weld::Builder> mxMenuBuilder;
     std::unique_ptr<weld::Menu> mxMenu;
@@ -163,7 +162,6 @@ private:
     */
     DECL_LINK(LayoutSelected, weld::IconView&, bool);
     DECL_LINK(MousePressHdl, const MouseEvent&, bool);
-    DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString);
     DECL_LINK(StateChangeHandler, const OUString&, void);
     DECL_LINK(EventMultiplexerListener, ::sdtools::EventMultiplexerEvent&, 
void);
     DECL_LINK(MenuSelectAsyncHdl, void*, void);
@@ -172,8 +170,6 @@ private:
     static VclPtr<VirtualDevice> GetVirtualDevice(Image pPreview);
     static Bitmap GetPreviewAsBitmap(const Image& rImage);
     void HandleMenuSelect(std::u16string_view rIdent);
-
-    TranslateId GetStringResourceIdForLayout(AutoLayout aLayout) const;
 };
 
 } // end of namespace ::sd::toolpanel
diff --git a/sd/uiconfig/simpress/ui/layoutpanel.ui 
b/sd/uiconfig/simpress/ui/layoutpanel.ui
index a9c8a222bee9..a34b71ec7825 100644
--- a/sd/uiconfig/simpress/ui/layoutpanel.ui
+++ b/sd/uiconfig/simpress/ui/layoutpanel.ui
@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="sd">
   <requires lib="gtk+" version="3.24"/>
-  <!-- n-columns=1 n-rows=1 -->
   <object class="GtkTreeStore" id="liststore1">
     <columns>
       <!-- column-name pixbuf -->
       <column type="GdkPixbuf"/>
       <!-- column-name id -->
       <column type="gchararray"/>
+      <!-- column-name tooltip -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkBox" id="LayoutPanel">
@@ -33,6 +34,7 @@
             <property name="vexpand">True</property>
             <property name="model">liststore1</property>
             <property name="pixbuf-column">0</property>
+            <property name="tooltip-column">2</property>
             <property name="item-width">55</property>
             <property name="margin">6</property>
             <property name="activate-on-single-click">True</property>
commit e9e42c9ebda79668f918996e0f94b77633bb5f1c
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Dec 16 14:31:31 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue Dec 16 23:17:08 2025 +0100

    tdf#130857 Set iconview tooltips in "Borders" tab directly
    
    Use the new API introduced in previous commit
    
        Change-Id: I56e8dde0b591073dea7f58190746ca0ba1fd8a4f
        Author: Michael Weghorn <[email protected]>
        Date:   Tue Dec 16 12:10:48 2025 +0100
    
            tdf#130857 tdf#168594 weld: Introduce 
weld::IconView::set_item_tooltip_text
    
    to directly set the tooltip text for each of the
    IconView items, just like the accessible name (which is using
    the same string) is also set directly already.
    
    For gtk3/gtk4, add a corresponding column in the
    GtkIconView model and set GtkIconView::tooltip-column
    accordingly, as described in the above-mentioned commit.
    
    This is e.g. used for the "Borders" tab page in Writer's
    "Format" -> "Page Style" dialog.
    
    Change-Id: Idf772d2156bff9f220e304acaed8ddef8780d7fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195713
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 53ae3b991b60..e91a48cca7b8 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -168,8 +168,6 @@ private:
     DECL_LINK(ModifyWidthMFHdl_Impl, weld::MetricSpinButton&, void);
     DECL_LINK(SyncHdl_Impl, weld::Toggleable&, void);
     DECL_LINK(RemoveAdjacentCellBorderHdl_Impl, weld::Toggleable&, void);
-    DECL_LINK(QueryTooltipPreHdl, const weld::TreeIter&, OUString);
-    DECL_LINK(QueryTooltipSdwHdl, const weld::TreeIter&, OUString);
 
     sal_uInt16          GetPresetImageId(sal_uInt16 nIconViewIdx) const;
     OUString            GetPresetName(sal_uInt16 nIconViewIdx) const;
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 013bf2b6a78f..62343dc738ce 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -534,8 +534,6 @@ SvxBorderTabPage::SvxBorderTabPage(weld::Container* pPage, 
weld::DialogControlle
     m_xWndPresets->connect_selection_changed( LINK( this, SvxBorderTabPage, 
SelPreHdl_Impl ) );
     m_xWndPresets->connect_focus_out(LINK(this, SvxBorderTabPage, 
FocusOutPresets_Impl));
     m_xWndShadows->connect_selection_changed( LINK( this, SvxBorderTabPage, 
SelSdwHdl_Impl ) );
-    m_xWndPresets->connect_query_tooltip( LINK( this, SvxBorderTabPage, 
QueryTooltipPreHdl ) );
-    m_xWndShadows->connect_query_tooltip( LINK( this, SvxBorderTabPage, 
QueryTooltipSdwHdl ) );
 
     FillIconViews();
     FillLineListBox_Impl();
@@ -1239,24 +1237,6 @@ IMPL_LINK_NOARG(SvxBorderTabPage, SelSdwHdl_Impl, 
weld::IconView&, void)
     m_xLbShadowColor->set_sensitive(bEnable);
 }
 
-IMPL_LINK(SvxBorderTabPage, QueryTooltipPreHdl, const weld::TreeIter&, iter, 
OUString)
-{
-    const OUString sId = m_xWndPresets->get_id(iter);
-    if (!sId.isEmpty())
-        return GetPresetName(sId.toInt32());
-
-    return OUString();
-}
-
-IMPL_LINK(SvxBorderTabPage, QueryTooltipSdwHdl, const weld::TreeIter&, iter, 
OUString)
-{
-    const OUString sId = m_xWndShadows->get_id(iter);
-    if (!sId.isEmpty())
-        return GetShadowTypeName(sId.toInt32());
-
-    return OUString();
-}
-
 IMPL_LINK(SvxBorderTabPage, SelColHdl_Impl, ColorListBox&, rColorBox, void)
 {
     const NamedColor& aNamedColor = rColorBox.GetSelectedEntry();
@@ -1454,8 +1434,9 @@ void SvxBorderTabPage::FillPresetIV()
         OUString sId = OUString::number(nIdx);
         Bitmap aPreviewBitmap = 
GetPreviewAsBitmap(m_aBorderImgVec[GetPresetImageId(nIdx) - 1]);
         m_xWndPresets->insert(-1, nullptr, &sId, &aPreviewBitmap, nullptr);
-        m_xWndPresets->set_item_accessible_name(m_xWndPresets->n_children() - 
1,
-                                                GetPresetName(nIdx));
+        const OUString sPresetName = GetPresetName(nIdx);
+        m_xWndPresets->set_item_accessible_name(m_xWndPresets->n_children() - 
1, sPresetName);
+        m_xWndPresets->set_item_tooltip_text(m_xWndPresets->n_children() - 1, 
sPresetName);
     }
 
     // show the control
@@ -1473,8 +1454,9 @@ void SvxBorderTabPage::FillShadowIV()
         OUString sId = OUString::number(nIdx);
         Bitmap aPreviewBitmap = GetPreviewAsBitmap(m_aShadowImgVec[nIdx-1]);
         m_xWndShadows->insert(-1, nullptr, &sId, &aPreviewBitmap, nullptr);
-        m_xWndShadows->set_item_accessible_name(m_xWndShadows->n_children() - 
1,
-                                                GetShadowTypeName(nIdx));
+        const OUString sShadowTypeName = GetShadowTypeName(nIdx);
+        m_xWndShadows->set_item_accessible_name(m_xWndShadows->n_children() - 
1, sShadowTypeName);
+        m_xWndShadows->set_item_tooltip_text(m_xWndShadows->n_children() - 1, 
sShadowTypeName);
     }
 
     // show the control
diff --git a/cui/uiconfig/ui/borderpage.ui b/cui/uiconfig/ui/borderpage.ui
index c3a1bb75353f..7899b1d11bf7 100644
--- a/cui/uiconfig/ui/borderpage.ui
+++ b/cui/uiconfig/ui/borderpage.ui
@@ -41,6 +41,8 @@
       <column type="GdkPixbuf"/>
       <!-- column-name id -->
       <column type="gchararray"/>
+      <!-- column-name tooltip -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkTreeStore" id="shadows_liststore">
@@ -49,6 +51,8 @@
       <column type="GdkPixbuf"/>
       <!-- column-name id -->
       <column type="gchararray"/>
+      <!-- column-name tooltip -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <!-- n-columns=2 n-rows=3 -->
@@ -97,6 +101,7 @@
                 <property name="model">presets_liststore</property>
                 <property name="pixbuf-column">0</property>
                 <property name="columns">5</property>
+                <property name="tooltip-column">2</property>
                 <property name="activate-on-single-click">True</property>
               </object>
               <packing>
@@ -563,6 +568,7 @@
                 <property name="model">shadows_liststore</property>
                 <property name="pixbuf-column">0</property>
                 <property name="columns">5</property>
+                <property name="tooltip-column">2</property>
                 <property name="activate-on-single-click">True</property>
               </object>
               <packing>

Reply via email to