include/vcl/salvtables.hxx                  |    1 
 include/vcl/weld.hxx                        |    3 
 svx/source/inc/StylesPreviewWindow.hxx      |   40 ++---
 svx/source/tbxctrls/StylesPreviewWindow.cxx |  205 +++++++++-------------------
 svx/uiconfig/ui/stylespreview.ui            |  137 +++---------------
 vcl/source/app/salvtables.cxx               |    6 
 vcl/unx/gtk3/gtk3gtkinst.cxx                |   13 +
 7 files changed, 134 insertions(+), 271 deletions(-)

New commits:
commit 168b3ccdbd085af43cd52a2f3ea0213aebed9ae5
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Feb 2 16:12:55 2021 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Mar 4 11:03:53 2021 +0100

    tdf#139429 Convert Style previews widget to IconView
    
    - this adds labels to easily identify the styles
    - easier to work with many styles
    - nice native widget in gtk3
    - double click opens the style settings
    - added Command callback fro iconview
    
    Change-Id: I08743515cbd2a4e4bd592d1509e48bbe2a43b129
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110408
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111660
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx
index 498cd1c6d94e..be939b4176f6 100644
--- a/include/vcl/salvtables.hxx
+++ b/include/vcl/salvtables.hxx
@@ -1463,6 +1463,7 @@ private:
     DECL_LINK(SelectHdl, SvTreeListBox*, void);
     DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
     DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
+    DECL_LINK(CommandHdl, const CommandEvent&, bool);
 
 public:
     SalInstanceIconView(::IconView* pIconView, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership);
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 30231aecaf30..ef208a1bc662 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1055,6 +1055,7 @@ private:
 protected:
     Link<IconView&, void> m_aSelectionChangeHdl;
     Link<IconView&, bool> m_aItemActivatedHdl;
+    Link<const CommandEvent&, bool> m_aCommandHdl;
 
     void signal_selection_changed() { m_aSelectionChangeHdl.Call(*this); }
     bool signal_item_activated() { return m_aItemActivatedHdl.Call(*this); }
@@ -1091,6 +1092,8 @@ public:
     */
     void connect_item_activated(const Link<IconView&, bool>& rLink) { 
m_aItemActivatedHdl = rLink; }
 
+    void connect_command(const Link<const CommandEvent&, bool>& rLink) { 
m_aCommandHdl = rLink; }
+
     virtual OUString get_selected_id() const = 0;
 
     virtual void clear() = 0;
diff --git a/svx/source/inc/StylesPreviewWindow.hxx 
b/svx/source/inc/StylesPreviewWindow.hxx
index ff9a4137b9dc..99e59037b617 100644
--- a/svx/source/inc/StylesPreviewWindow.hxx
+++ b/svx/source/inc/StylesPreviewWindow.hxx
@@ -33,29 +33,24 @@ class StyleStatusListener : public SfxStatusListener
     StylesPreviewWindow_Base* m_pPreviewControl;
 
 public:
-    StyleStatusListener(StylesPreviewWindow_Base* pPreviewControl,
-                        css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider);
+    StyleStatusListener(
+        StylesPreviewWindow_Base* pPreviewControl,
+        const css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider);
 
     void StateChanged(SfxItemState eState, const SfxPoolItem* pState) override;
 };
 
-class StyleItemController : public weld::CustomWidgetController
+class StyleItemController
 {
     static constexpr unsigned LEFT_MARGIN = 8;
 
     SfxStyleFamily m_eStyleFamily;
     std::pair<OUString, OUString> m_aStyleName;
-    bool m_bSelected;
-    css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
 
 public:
-    StyleItemController(const std::pair<OUString, OUString>& aStyleName,
-                        css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider);
-
-    void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& 
rRect) override;
+    StyleItemController(const std::pair<OUString, OUString>& aStyleName);
 
-    bool MouseButtonDown(const MouseEvent& rMEvt) override;
-    bool Command(const CommandEvent& rEvent) override;
+    void Paint(vcl::RenderContext& rRenderContext);
 
     void SetStyle(const std::pair<OUString, OUString>& sStyleName);
 
@@ -75,28 +70,26 @@ class StylesPreviewWindow_Base
 protected:
     static constexpr unsigned STYLES_COUNT = 4;
 
-    std::unique_ptr<StyleItemController> m_xStyleControllers[STYLES_COUNT];
-    std::unique_ptr<weld::CustomWeld> m_xStyleControllersWeld[STYLES_COUNT];
+    css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
+
+    std::unique_ptr<weld::IconView> m_xStylesView;
 
     StyleStatusListener* m_pStatusListener;
     css::uno::Reference<css::lang::XComponent> m_xStatusListener;
 
-    std::unique_ptr<weld::Toolbar> m_xUp;
-    std::unique_ptr<weld::Toolbar> m_xDown;
-
     std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
     std::vector<std::pair<OUString, OUString>> m_aAllStyles;
 
-    unsigned m_nStyleIterator;
     OUString m_sSelectedStyle;
 
-    DECL_LINK(GoUp, const OString&, void);
-    DECL_LINK(GoDown, const OString&, void);
+    DECL_LINK(Selected, weld::IconView&, void);
+    DECL_LINK(DoubleClick, weld::IconView&, bool);
+    DECL_LINK(DoCommand, const CommandEvent&, bool);
 
 public:
-    StylesPreviewWindow_Base(weld::Builder& xBuilder,
-                             std::vector<std::pair<OUString, OUString>>& 
aDefaultStyles,
-                             
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
+    StylesPreviewWindow_Base(
+        weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>& 
aDefaultStyles,
+        const css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider);
     ~StylesPreviewWindow_Base();
 
     void Select(const OUString& rStyleName);
@@ -104,8 +97,7 @@ public:
 private:
     void Update();
     void UpdateStylesList();
-    void MakeCurrentStyleVisible();
-    std::pair<OUString, OUString> GetVisibleStyle(unsigned nPosition);
+    bool Command(const CommandEvent& rEvent);
 };
 
 class StylesPreviewWindow_Impl : public InterimItemWindow, public 
StylesPreviewWindow_Base
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx 
b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index ec733dbdd8b1..5413056e2177 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -27,6 +27,7 @@
 #include <sfx2/sfxsids.hrc>
 #include <sfx2/tplpitem.hxx>
 #include <sfx2/viewsh.hxx>
+#include <vcl/virdev.hxx>
 
 #include <editeng/editids.hrc>
 #include <editeng/fontitem.hxx>
@@ -57,7 +58,7 @@
 
 StyleStatusListener::StyleStatusListener(
     StylesPreviewWindow_Base* pPreviewControl,
-    css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
+    const css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider)
     : SfxStatusListener(xDispatchProvider, SID_STYLE_FAMILY2, ".uno:ParaStyle")
     , m_pPreviewControl(pPreviewControl)
 {
@@ -71,18 +72,13 @@ void StyleStatusListener::StateChanged(SfxItemState 
/*eState*/, const SfxPoolIte
         m_pPreviewControl->Select(pStateItem->GetStyleName());
 }
 
-StyleItemController::StyleItemController(
-    const std::pair<OUString, OUString>& aStyleName,
-    css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
+StyleItemController::StyleItemController(const std::pair<OUString, OUString>& 
aStyleName)
     : m_eStyleFamily(SfxStyleFamily::Para)
     , m_aStyleName(aStyleName)
-    , m_bSelected(false)
-    , m_xDispatchProvider(xDispatchProvider)
 {
 }
 
-void StyleItemController::Paint(vcl::RenderContext& rRenderContext,
-                                const tools::Rectangle& /*rRect*/)
+void StyleItemController::Paint(vcl::RenderContext& rRenderContext)
 {
     rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::FONT | 
PushFlags::TEXTCOLOR);
 
@@ -91,51 +87,19 @@ void StyleItemController::Paint(vcl::RenderContext& 
rRenderContext,
     rRenderContext.Pop();
 }
 
-void StyleItemController::SetStyle(const std::pair<OUString, OUString>& 
sStyleName)
-{
-    m_aStyleName = sStyleName;
-    Invalidate();
-}
-
-void StyleItemController::Select(bool bSelect)
-{
-    m_bSelected = bSelect;
-    Invalidate();
-}
-
-bool StyleItemController::MouseButtonDown(const MouseEvent& rMEvt)
-{
-    if (rMEvt.IsLeft())
-    {
-        css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
-        aArgs[0].Value <<= m_aStyleName.second;
-        aArgs[1].Name = "Family";
-        aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
-
-        aArgs[0].Name = "Template";
-        SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:StyleApply", 
aArgs);
-    }
-
-    return false;
-}
-
-bool StyleItemController::Command(const CommandEvent& rEvent)
+bool StylesPreviewWindow_Base::Command(const CommandEvent& rEvent)
 {
     if (rEvent.GetCommand() != CommandEventId::ContextMenu)
-        return CustomWidgetController::Command(rEvent);
+        return false;
 
     std::unique_ptr<weld::Builder> xBuilder(
-        Application::CreateBuilder(GetDrawingArea(), "svx/ui/stylemenu.ui"));
+        Application::CreateBuilder(m_xStylesView.get(), 
"svx/ui/stylemenu.ui"));
     std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
     std::string_view rIdent = xMenu->popup_at_rect(
-        GetDrawingArea(), tools::Rectangle(rEvent.GetMousePosPixel(), Size(1, 
1)));
+        m_xStylesView.get(), tools::Rectangle(rEvent.GetMousePosPixel(), 
Size(1, 1)));
     if (rIdent == "update" || rIdent == "edit")
     {
-        css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
-        aArgs[0].Name = "Param";
-        aArgs[0].Value <<= m_aStyleName.second;
-        aArgs[1].Name = "Family";
-        aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
+        css::uno::Sequence<css::beans::PropertyValue> aArgs(0);
 
         SfxToolBoxControl::Dispatch(m_xDispatchProvider,
                                     rIdent == "update" ? 
OUString(".uno:StyleUpdateByExample")
@@ -259,24 +223,13 @@ void StyleItemController::DrawEntry(vcl::RenderContext& 
rRenderContext)
 
         Size aSize(rRenderContext.GetOutputSizePixel());
         tools::Rectangle aFullRect(Point(0, 0), aSize);
-        aSize = Size(aSize.getWidth() - 6, aSize.getHeight() - 6);
         tools::Rectangle aContentRect(aFullRect);
 
         Color aOriginalColor = rRenderContext.GetFillColor();
         Color aOriginalLineColor = rRenderContext.GetLineColor();
-        vcl::Region aOriginalClipRegion(aFullRect);
-
-        if (m_bSelected)
-        {
-            aContentRect = tools::Rectangle(Point(3, 3), aSize);
-            DrawSelection(rRenderContext);
-        }
 
         DrawContentBackground(rRenderContext, aContentRect, aOriginalColor);
 
-        vcl::Region aClipRegion(aContentRect);
-        rRenderContext.SetClipRegion(aClipRegion);
-
         std::unique_ptr<const SfxItemSet> const 
pItemSet(pStyle->GetItemSetForPreview());
         if (!pItemSet)
             return;
@@ -326,7 +279,6 @@ void StyleItemController::DrawEntry(vcl::RenderContext& 
rRenderContext)
 
         rRenderContext.SetFillColor(aOriginalColor);
         rRenderContext.SetLineColor(aOriginalLineColor);
-        rRenderContext.SetClipRegion(aOriginalClipRegion);
     }
 }
 
@@ -385,31 +337,52 @@ void StyleItemController::DrawText(vcl::RenderContext& 
rRenderContext)
 
 StylesPreviewWindow_Base::StylesPreviewWindow_Base(
     weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>& 
aDefaultStyles,
-    css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
-    : m_xUp(xBuilder.weld_toolbar("uptoolbar"))
-    , m_xDown(xBuilder.weld_toolbar("downtoolbar"))
+    const css::uno::Reference<css::frame::XDispatchProvider>& 
xDispatchProvider)
+    : m_xDispatchProvider(xDispatchProvider)
+    , m_xStylesView(xBuilder.weld_icon_view("stylesview"))
     , m_aDefaultStyles(aDefaultStyles)
-    , m_nStyleIterator(0)
 {
-    for (unsigned int i = 0; i < STYLES_COUNT; i++)
-    {
-        auto aStyle
-            = i < aDefaultStyles.size() ? aDefaultStyles[i] : 
std::pair<OUString, OUString>("", "");
-        m_xStyleControllers[i].reset(new StyleItemController(aStyle, 
xDispatchProvider));
+    m_xStylesView->connect_selection_changed(LINK(this, 
StylesPreviewWindow_Base, Selected));
+    m_xStylesView->connect_item_activated(LINK(this, StylesPreviewWindow_Base, 
DoubleClick));
+    m_xStylesView->connect_command(LINK(this, StylesPreviewWindow_Base, 
DoCommand));
 
-        OUString sIdOUString = "style" + OUString::number(i + 1);
-        OString sId = OUStringToOString(sIdOUString, 
RTL_TEXTENCODING_ASCII_US);
+    m_pStatusListener = new StyleStatusListener(this, xDispatchProvider);
+    m_xStatusListener.set(static_cast<cppu::OWeakObject*>(m_pStatusListener), 
css::uno::UNO_QUERY);
 
-        m_xStyleControllersWeld[i].reset(
-            new weld::CustomWeld(xBuilder, sId, *m_xStyleControllers[i]));
-        m_xStyleControllersWeld[i]->set_size_request(100, 60);
-    }
+    Update();
+}
 
-    m_xUp->connect_clicked(LINK(this, StylesPreviewWindow_Base, GoUp));
-    m_xDown->connect_clicked(LINK(this, StylesPreviewWindow_Base, GoDown));
+IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView&, rIconView, void)
+{
+    OUString sStyleName = rIconView.get_selected_text();
 
-    m_pStatusListener = new StyleStatusListener(this, xDispatchProvider);
-    m_xStatusListener.set(static_cast<cppu::OWeakObject*>(m_pStatusListener), 
css::uno::UNO_QUERY);
+    css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
+    aArgs[0].Value <<= sStyleName;
+    aArgs[1].Name = "Family";
+    aArgs[1].Value <<= sal_Int16(SfxStyleFamily::Para);
+
+    aArgs[0].Name = "Template";
+    SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:StyleApply", aArgs);
+}
+
+IMPL_LINK(StylesPreviewWindow_Base, DoubleClick, weld::IconView&, rIconView, 
bool)
+{
+    OUString sStyleName = rIconView.get_selected_text();
+
+    css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
+    aArgs[0].Name = "Param";
+    aArgs[0].Value <<= sStyleName;
+    aArgs[1].Name = "Family";
+    aArgs[1].Value <<= sal_Int16(SfxStyleFamily::Para);
+
+    SfxToolBoxControl::Dispatch(m_xDispatchProvider, ".uno:EditStyle", aArgs);
+
+    return true;
+}
+
+IMPL_LINK(StylesPreviewWindow_Base, DoCommand, const CommandEvent&, rPos, bool)
+{
+    return Command(rPos);
 }
 
 StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
@@ -427,64 +400,25 @@ StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
     m_pStatusListener = nullptr;
 }
 
-std::pair<OUString, OUString> 
StylesPreviewWindow_Base::GetVisibleStyle(unsigned nPosition)
-{
-    if (nPosition >= STYLES_COUNT || !m_aAllStyles.size())
-        return std::make_pair<OUString, OUString>("", "");
-
-    return m_aAllStyles[(m_nStyleIterator + nPosition) % m_aAllStyles.size()];
-}
-
 void StylesPreviewWindow_Base::Select(const OUString& rStyleName)
 {
     m_sSelectedStyle = rStyleName;
 
     UpdateStylesList();
-    MakeCurrentStyleVisible();
     Update();
 }
 
-void StylesPreviewWindow_Base::MakeCurrentStyleVisible()
-{
-    if (m_aAllStyles.size())
-    {
-        unsigned nNewIterator = m_nStyleIterator;
-        auto aIt = m_aAllStyles.begin();
-        auto aFound = m_aAllStyles.end();
-        while (aIt != m_aAllStyles.end())
-        {
-            if (aIt->first == m_sSelectedStyle || aIt->second == 
m_sSelectedStyle)
-            {
-                aFound = aIt;
-                break;
-            }
-            aIt++;
-        }
-        if (aFound != m_aAllStyles.end())
-            nNewIterator = aFound - m_aAllStyles.begin();
-
-        bool bIsAlreadyVisible
-            = nNewIterator >= m_nStyleIterator % m_aAllStyles.size()
-              && nNewIterator < m_nStyleIterator % m_aAllStyles.size() + 
STYLES_COUNT;
-        if (!bIsAlreadyVisible)
-            m_nStyleIterator = nNewIterator;
-    }
-}
-
 void StylesPreviewWindow_Base::Update()
 {
     UpdateStylesList();
 
-    for (unsigned int i = 0; i < STYLES_COUNT; i++)
+    for (unsigned long i = 0; i < m_aAllStyles.size(); ++i)
     {
-        std::pair<OUString, OUString> sStyleName = GetVisibleStyle(i);
-        m_xStyleControllers[i]->SetStyle(sStyleName);
-        m_xStyleControllersWeld[i]->set_tooltip_text(sStyleName.second);
-
-        if (sStyleName.first == m_sSelectedStyle || sStyleName.second == 
m_sSelectedStyle)
-            m_xStyleControllers[i]->Select(true);
-        else
-            m_xStyleControllers[i]->Select(false);
+        if (m_aAllStyles[i].first == m_sSelectedStyle || 
m_aAllStyles[i].second == m_sSelectedStyle)
+        {
+            m_xStylesView->select(i);
+            break;
+        }
     }
 }
 
@@ -511,22 +445,19 @@ void StylesPreviewWindow_Base::UpdateStylesList()
             pStyle = xIter->Next();
         }
     }
-}
 
-IMPL_LINK(StylesPreviewWindow_Base, GoUp, const OString&, /*rItem*/, void)
-{
-    if (m_nStyleIterator == 0)
-        m_nStyleIterator = m_aAllStyles.size();
-    else
-        m_nStyleIterator--;
+    m_xStylesView->clear();
+    for (auto& rStyle : m_aAllStyles)
+    {
+        ScopedVclPtr<VirtualDevice> pImg = VclPtr<VirtualDevice>::Create();
+        const Size aSize(100, 30);
+        pImg->SetOutputSizePixel(aSize);
 
-    Update();
-}
+        StyleItemController aStyleController(rStyle);
+        aStyleController.Paint(*pImg);
 
-IMPL_LINK(StylesPreviewWindow_Base, GoDown, const OString&, /*rItem*/, void)
-{
-    m_nStyleIterator++;
-    Update();
+        m_xStylesView->append(rStyle.first, rStyle.second, pImg);
+    }
 }
 
 StylesPreviewWindow_Impl::StylesPreviewWindow_Impl(
@@ -543,11 +474,7 @@ StylesPreviewWindow_Impl::~StylesPreviewWindow_Impl() { 
disposeOnce(); }
 
 void StylesPreviewWindow_Impl::dispose()
 {
-    m_xUp.reset();
-    m_xDown.reset();
-
-    for (unsigned int i = 0; i < STYLES_COUNT; i++)
-        m_xStyleControllersWeld[i].reset();
+    m_xStylesView.reset();
 
     InterimItemWindow::dispose();
 }
diff --git a/svx/uiconfig/ui/stylespreview.ui b/svx/uiconfig/ui/stylespreview.ui
index e714c31a3f37..cfe5f42bcf0c 100644
--- a/svx/uiconfig/ui/stylespreview.ui
+++ b/svx/uiconfig/ui/stylespreview.ui
@@ -2,6 +2,16 @@
 <!-- Generated with glade 3.20.4 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name expander -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkBox" id="ApplyStyleBox">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -13,122 +23,33 @@
         <property name="can_focus">False</property>
         <property name="spacing">3</property>
         <child>
-          <object class="GtkBox" id="stylescontainer">
+          <object class="GtkScrolledWindow">
+            <property name="width_request">360</property>
+            <property name="height_request">65</property>
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="spacing">6</property>
-            <property name="homogeneous">True</property>
-            <child>
-              <object class="GtkDrawingArea" id="style1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
+            <property name="can_focus">True</property>
+            <property name="valign">center</property>
+            <property name="hscrollbar_policy">never</property>
+            <property name="vscrollbar_policy">always</property>
+            <property name="shadow_type">in</property>
+            <property name="min_content_width">70</property>
             <child>
-              <object class="GtkDrawingArea" id="style2">
+              <object class="GtkIconView" id="stylesview">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
+                <property name="margin">0</property>
+                <property name="model">liststore1</property>
+                <property name="columns">3</property>
+                <property name="item_width">70</property>
+                <property name="pixbuf-column">0</property>
+                <property name="text-column">1</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkDrawingArea" id="style3">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkDrawingArea" id="style4">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <child>
-              <object class="GtkToolbar" id="uptoolbar">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="toolbar_style">icons</property>
-                <child>
-                  <object class="GtkToolButton" id="up">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes" 
context="stylespreview|up">Previous</property>
-                    <property name="use_underline">True</property>
-                    <property name="icon_name">cmd/lc_prevrecord.png</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="homogeneous">True</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkToolbar" id="downtoolbar">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="toolbar_style">icons</property>
-                <child>
-                  <object class="GtkToolButton" id="down">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="label" translatable="yes" 
context="stylespreview|down">Next</property>
-                    <property name="use_underline">True</property>
-                    <property name="icon_name">cmd/lc_nextrecord.png</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="homogeneous">True</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
           </packing>
         </child>
       </object>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 4450ca3d1ee2..32deb0c9a310 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4745,6 +4745,7 @@ SalInstanceIconView::SalInstanceIconView(::IconView* 
pIconView, SalInstanceBuild
     m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
     m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
     m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, 
DoubleClickHdl));
+    m_xIconView->SetPopupMenuHdl(LINK(this, SalInstanceIconView, CommandHdl));
 }
 
 void SalInstanceIconView::freeze()
@@ -5001,6 +5002,11 @@ IMPL_LINK_NOARG(SalInstanceIconView, DoubleClickHdl, 
SvTreeListBox*, bool)
     return !signal_item_activated();
 }
 
+IMPL_LINK(SalInstanceIconView, CommandHdl, const CommandEvent&, rEvent, bool)
+{
+    return m_aCommandHdl.Call(rEvent);
+}
+
 double SalInstanceSpinButton::toField(int nValue) const
 {
     return static_cast<double>(nValue) / Power10(get_digits());
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 25c54899d9eb..84163b05ac64 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -10539,10 +10539,21 @@ private:
     gint m_nIdCol;
     gulong m_nSelectionChangedSignalId;
     gulong m_nItemActivatedSignalId;
+    gulong m_nPopupMenu;
     ImplSVEvent* m_pSelectionChangeEvent;
 
     DECL_LINK(async_signal_selection_changed, void*, void);
 
+    bool signal_command(const CommandEvent& rCEvt)
+    {
+        return m_aCommandHdl.Call(rCEvt);
+    }
+
+    virtual bool signal_popup_menu(const CommandEvent& rCEvt) override
+    {
+        return signal_command(rCEvt);
+    }
+
     void launch_signal_selection_changed()
     {
         //tdf#117991 selection change is sent before the focus change, and 
focus change
@@ -10647,6 +10658,7 @@ public:
         , m_nSelectionChangedSignalId(g_signal_connect(pIconView, 
"selection-changed",
                                       G_CALLBACK(signalSelectionChanged), 
this))
         , m_nItemActivatedSignalId(g_signal_connect(pIconView, 
"item-activated", G_CALLBACK(signalItemActivated), this))
+        , m_nPopupMenu(g_signal_connect(pIconView, "popup-menu", 
G_CALLBACK(signalPopupMenu), this))
         , m_pSelectionChangeEvent(nullptr)
     {
         m_nIdCol = m_nTextCol + 1;
@@ -10913,6 +10925,7 @@ public:
 
         g_signal_handler_disconnect(m_pIconView, m_nItemActivatedSignalId);
         g_signal_handler_disconnect(m_pIconView, m_nSelectionChangedSignalId);
+        g_signal_handler_disconnect(m_pIconView, m_nPopupMenu);
     }
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to