include/vcl/toolkit/svtabbx.hxx     |    1 -
 include/vcl/toolkit/treelistbox.hxx |    2 ++
 vcl/source/treelist/svtabbx.cxx     |   14 --------------
 vcl/source/treelist/treelistbox.cxx |   14 ++++++++++++++
 vcl/unx/gtk3/gtkinst.cxx            |    2 +-
 5 files changed, 17 insertions(+), 16 deletions(-)

New commits:
commit 2e5ddc659a3a25cc2a477010bf07dc72c1e22f90
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 18 18:45:12 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 19 09:20:09 2025 +0100

    vcl: Move SvTabListBox::GetEntryPos to base class
    
    The method's implementaton only uses methods from
    the SvTreeListBox base class.
    
    Move the method itself to the base class as well,
    which will allow using it in an upcoming commit
    introducing JSIconView::do_select taking a GtkTreeIter
    param instead of an int/position.
    (See also how JSTreeView already has such a method and
    makes use of SvTabListBox::GetEntryPos.)
    
    Change-Id: Ica96173c0cc8e95a9893eb1c803e15cf3f04ef7a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195863
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/toolkit/svtabbx.hxx b/include/vcl/toolkit/svtabbx.hxx
index 390774ef1cae..97cad1431e80 100644
--- a/include/vcl/toolkit/svtabbx.hxx
+++ b/include/vcl/toolkit/svtabbx.hxx
@@ -70,7 +70,6 @@ public:
     OUString         GetEntryText( sal_uInt32 nPos, sal_uInt16 nCol = 0xffff ) 
const;
     using SvTreeListBox::SetEntryText;
     OUString         GetCellText( sal_uInt32 nPos, sal_uInt16 nCol ) const;
-    sal_uInt32       GetEntryPos( const SvTreeListEntry* pEntry ) const;
 
     void             SetTabAlignCenter(sal_uInt16 nTab);
     void             SetTabEditable( sal_uInt16 nTab, bool bEditable );
diff --git a/include/vcl/toolkit/treelistbox.hxx 
b/include/vcl/toolkit/treelistbox.hxx
index 6ccdf9797d08..42bfaef4dd81 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -365,6 +365,8 @@ public:
 
     SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
 
+    sal_uInt32 GetEntryPos(const SvTreeListEntry* pEntry) const;
+
     bool            CopySelection( SvTreeListBox* pSource, SvTreeListEntry* 
pTarget );
     bool            MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, 
SvTreeListEntry* pTarget, bool bAllowCopyFallback );
     void            RemoveSelection();
diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index 5a3c42d947a8..b453a0e1eafe 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -389,20 +389,6 @@ OUString SvTabListBox::GetCellText( sal_uInt32 nPos, 
sal_uInt16 nCol ) const
     return aResult;
 }
 
-sal_uInt32 SvTabListBox::GetEntryPos( const SvTreeListEntry* pEntry ) const
-{
-    sal_uInt32 nPos = 0;
-    SvTreeListEntry* pTmpEntry = First();
-    while( pTmpEntry )
-    {
-        if ( pTmpEntry == pEntry )
-            return nPos;
-        pTmpEntry = Next( pTmpEntry );
-        ++nPos;
-    }
-    return 0xffffffff;
-}
-
 // static
 std::u16string_view SvTabListBox::GetToken( std::u16string_view sStr, 
sal_Int32& nIndex )
 {
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index fa274dfa4300..1590105397b5 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -562,6 +562,20 @@ SvTreeListEntry* SvTreeListBox::FirstChild( 
SvTreeListEntry* pParent ) const
     return pModel->FirstChild(pParent);
 }
 
+sal_uInt32 SvTreeListBox::GetEntryPos(const SvTreeListEntry* pEntry) const
+{
+    sal_uInt32 nPos = 0;
+    SvTreeListEntry* pTmpEntry = First();
+    while (pTmpEntry)
+    {
+        if (pTmpEntry == pEntry)
+            return nPos;
+        pTmpEntry = Next(pTmpEntry);
+        ++nPos;
+    }
+    return 0xffffffff;
+}
+
 // return: all entries copied
 bool SvTreeListBox::CopySelection( SvTreeListBox* pSource, SvTreeListEntry* 
pTarget )
 {
commit 360c28c6a6c01af989f93be3dea977107421774d
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 18 17:55:10 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 19 09:20:01 2025 +0100

    gtk weld: *Un*select in GtkInstanceIconView::do_unselect
    
    So far, gtk_icon_view_select_path [1] was called, just
    as in GtkInstanceIconView::do_select, but that *selects*
    an entry instead of unselecting it.
    
    Switch to gtk_icon_view_unselect_path [2] instead.
    
    In a similar way, the GtkInstanceTreeView implementation also
    uses gtk_tree_selection_unselect_path [3] in
    GtkInstanceTreeView::do_unselect and
    gtk_tree_selection_select_path [4] in
    GtkInstanceTreeView::do_select.
    
    (Noticed this while reading code for an upcoming
    refactoring.)
    
    [1] https://docs.gtk.org/gtk3/method.IconView.select_path.html
    [2] https://docs.gtk.org/gtk3/method.IconView.unselect_path.html
    [3] https://docs.gtk.org/gtk3/method.TreeSelection.unselect_path.html
    [4] https://docs.gtk.org/gtk3/method.TreeSelection.select_path.html
    
    Change-Id: I454d6968f4f13ed575dc73009e65ee4b3a50a257
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195862
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index ef0e83cfc7ef..17083b20a3f3 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -17203,7 +17203,7 @@ public:
         else
         {
             GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1);
-            gtk_icon_view_select_path(m_pIconView, path);
+            gtk_icon_view_unselect_path(m_pIconView, path);
             gtk_tree_path_free(path);
         }
         enable_notify_events();

Reply via email to