[Libreoffice-commits] core.git: 2 commits - cui/source cui/uiconfig extensions/source extensions/uiconfig include/vcl vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Feb 4 19:46:11 UTC 2019


 cui/source/options/personalization.cxx                    |  139 ++++------
 cui/source/options/personalization.hxx                    |   37 +-
 cui/uiconfig/ui/select_persona_dialog.ui                  |    8 
 extensions/source/propctrlr/formcomponenthandler.cxx      |    7 
 extensions/source/propctrlr/selectlabeldialog.cxx         |  185 ++++++--------
 extensions/source/propctrlr/selectlabeldialog.hxx         |   46 +--
 extensions/uiconfig/spropctrlr/ui/labelselectiondialog.ui |   64 ++++
 include/vcl/weld.hxx                                      |   14 -
 vcl/unx/gtk3/gtk3gtkinst.cxx                              |    2 
 9 files changed, 259 insertions(+), 243 deletions(-)

New commits:
commit f69b5dd07a910dd48e087664e31642af50b5fb9a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 4 15:23:27 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Feb 4 20:46:00 2019 +0100

    weld OSelectLabelDialog
    
    Change-Id: Icbf9f05e69667cb8161942dde84ded6b3fc61138
    Reviewed-on: https://gerrit.libreoffice.org/67367
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index 99ef87995ebc..7dfa51afabcf 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2855,11 +2855,12 @@ namespace pcr
 
     bool FormComponentPropertyHandler::impl_dialogChooseLabelControl_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
     {
-        ScopedVclPtrInstance< OSelectLabelDialog > dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent );
+        vcl::Window* pParent = impl_getDefaultDialogParent_nothrow();
+        OSelectLabelDialog dlgSelectLabel(pParent ? pParent->GetFrameWeld() : nullptr, m_xComponent);
         _rClearBeforeDialog.clear();
-        bool bSuccess = ( RET_OK == dlgSelectLabel->Execute() );
+        bool bSuccess = (RET_OK == dlgSelectLabel.run());
         if ( bSuccess )
-            _out_rNewValue <<= dlgSelectLabel->GetSelected();
+            _out_rNewValue <<= dlgSelectLabel.GetSelected();
         return bSuccess;
     }
 
diff --git a/extensions/source/propctrlr/selectlabeldialog.cxx b/extensions/source/propctrlr/selectlabeldialog.cxx
index 5ec3a91d15e7..c1a356abf187 100644
--- a/extensions/source/propctrlr/selectlabeldialog.cxx
+++ b/extensions/source/propctrlr/selectlabeldialog.cxx
@@ -48,32 +48,20 @@ namespace pcr
 
 
     // OSelectLabelDialog
-
-
-    OSelectLabelDialog::OSelectLabelDialog( vcl::Window* pParent, Reference< XPropertySet > const & _xControlModel )
-        :ModalDialog(pParent, "LabelSelectionDialog", "modules/spropctrlr/ui/labelselectiondialog.ui")
-        ,m_xControlModel(_xControlModel)
-        ,m_pInitialSelection(nullptr)
-        ,m_pLastSelected(nullptr)
-        ,m_bHaveAssignableControl(false)
+    OSelectLabelDialog::OSelectLabelDialog(weld::Window* pParent, Reference< XPropertySet > const & _xControlModel)
+        : GenericDialogController(pParent, "modules/spropctrlr/ui/labelselectiondialog.ui", "LabelSelectionDialog")
+        , m_xControlModel(_xControlModel)
+        , m_bLastSelected(false)
+        , m_bHaveAssignableControl(false)
+        , m_xMainDesc(m_xBuilder->weld_label("label"))
+        , m_xControlTree(m_xBuilder->weld_tree_view("control"))
+        , m_xNoAssignment(m_xBuilder->weld_check_button("noassignment"))
     {
-        get(m_pMainDesc, "label");
-        get(m_pControlTree, "control");
-        get(m_pNoAssignment, "noassignment");
-
-        // initialize the TreeListBox
-        m_pControlTree->SetSelectionMode( SelectionMode::Single );
-        m_pControlTree->SetDragDropMode( DragDropMode::NONE );
-        m_pControlTree->EnableInplaceEditing( false );
-        m_pControlTree->SetStyle(m_pControlTree->GetStyle() | WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
-
-        m_pControlTree->SetNodeBitmaps(Image(StockImage::Yes, RID_EXTBMP_COLLAPSEDNODE),
-                                       Image(StockImage::Yes, RID_EXTBMP_EXPANDEDNODE));
-        m_pControlTree->SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
-        m_pControlTree->SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+        m_xControlTree->connect_changed(LINK(this, OSelectLabelDialog, OnEntrySelected));
+        m_xControlTree->set_size_request(-1, m_xControlTree->get_height_rows(8));
 
         // fill the description
-        OUString sDescription = m_pMainDesc->GetText();
+        OUString sDescription = m_xMainDesc->get_label();
         sal_Int16 nClassID = FormComponentType::CONTROL;
         if (::comphelper::hasProperty(PROPERTY_CLASSID, m_xControlModel))
             nClassID = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID));
@@ -82,7 +70,7 @@ namespace pcr
             GetUIHeadlineName(nClassID, makeAny(m_xControlModel)));
         OUString sName = ::comphelper::getString(m_xControlModel->getPropertyValue(PROPERTY_NAME));
         sDescription = sDescription.replaceAll("$controlname$", sName);
-        m_pMainDesc->SetText(sDescription);
+        m_xMainDesc->set_label(sDescription);
 
         // search for the root of the form hierarchy
         Reference< XChild >  xCont(m_xControlModel, UNO_QUERY);
@@ -102,9 +90,9 @@ namespace pcr
             sal_Int16 nClassId = 0;
             try { nClassId = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID)); } catch(...) { }
             m_sRequiredService = (FormComponentType::RADIOBUTTON == nClassId) ? OUString(SERVICE_COMPONENT_GROUPBOX) : OUString(SERVICE_COMPONENT_FIXEDTEXT);
-            m_aRequiredControlImage = Image(StockImage::Yes, FormComponentType::RADIOBUTTON == nClassId ? OUStringLiteral(RID_EXTBMP_GROUPBOX) : OUStringLiteral(RID_EXTBMP_FIXEDTEXT));
+            m_aRequiredControlImage = (FormComponentType::RADIOBUTTON == nClassId) ? OUString(RID_EXTBMP_GROUPBOX) : OUString(RID_EXTBMP_FIXEDTEXT);
 
-            // calc the currently set label control (so InsertEntries can calc m_pInitialSelection)
+            // calc the currently set label control (so InsertEntries can calc m_xInitialSelection)
             Any aCurrentLabelControl( m_xControlModel->getPropertyValue(PROPERTY_CONTROLLABEL) );
             DBG_ASSERT((aCurrentLabelControl.getValueTypeClass() == TypeClass_INTERFACE) || !aCurrentLabelControl.hasValue(),
 
@@ -113,62 +101,49 @@ namespace pcr
                 aCurrentLabelControl >>= m_xInitialLabelControl;
 
             // insert the root
-            Image aRootImage(StockImage::Yes, RID_EXTBMP_FORMS);
-            SvTreeListEntry* pRoot = m_pControlTree->InsertEntry(PcrRes(RID_STR_FORMS), aRootImage, aRootImage);
+            OUString sRootName(PcrRes(RID_STR_FORMS));
+            OUString aFormImage(RID_EXTBMP_FORMS);
+            m_xControlTree->insert(nullptr, -1, &sRootName, nullptr,
+                                   nullptr, nullptr, &aFormImage, false);
 
             // build the tree
-            m_pInitialSelection = nullptr;
+            m_xInitialSelection.reset();
             m_bHaveAssignableControl = false;
-            InsertEntries(xSearch, pRoot);
-            m_pControlTree->Expand(pRoot);
+            std::unique_ptr<weld::TreeIter> xRoot = m_xControlTree->make_iterator();
+            m_xControlTree->get_iter_first(*xRoot);
+            InsertEntries(xSearch, *xRoot);
+            m_xControlTree->expand_row(*xRoot);
         }
 
-        if (m_pInitialSelection)
+        if (m_xInitialSelection)
         {
-            m_pControlTree->MakeVisible(m_pInitialSelection, true);
-            m_pControlTree->Select(m_pInitialSelection);
+            m_xControlTree->scroll_to_row(*m_xInitialSelection);
+            m_xControlTree->select(*m_xInitialSelection);
         }
         else
         {
-            m_pControlTree->MakeVisible(m_pControlTree->First(), true);
-            if (m_pControlTree->FirstSelected())
-                m_pControlTree->Select(m_pControlTree->FirstSelected(), false);
-            m_pNoAssignment->Check();
+            m_xControlTree->scroll_to_row(0);
+            m_xControlTree->unselect_all();
+            m_xNoAssignment->set_active(true);
         }
 
         if (!m_bHaveAssignableControl)
         {   // no controls which can be assigned
-            m_pNoAssignment->Check();
-            m_pNoAssignment->Enable(false);
+            m_xNoAssignment->set_active(true);
+            m_xNoAssignment->set_sensitive(false);
         }
 
-        m_pNoAssignment->SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
-        m_pNoAssignment->GetClickHdl().Call(m_pNoAssignment);
-    }
+        m_xLastSelected = m_xControlTree->make_iterator(nullptr);
 
-    OSelectLabelDialog::~OSelectLabelDialog()
-    {
-        disposeOnce();
+        m_xNoAssignment->connect_toggled(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+        OnNoAssignmentClicked(*m_xNoAssignment);
     }
 
-    void OSelectLabelDialog::dispose()
+    OSelectLabelDialog::~OSelectLabelDialog()
     {
-        // delete the entry datas of the listbox entries
-        SvTreeListEntry* pLoop = m_pControlTree->First();
-        while (pLoop)
-        {
-            void* pData = pLoop->GetUserData();
-            if (pData)
-                delete static_cast<Reference< XPropertySet > *>(pData);
-            pLoop = m_pControlTree->Next(pLoop);
-        }
-        m_pMainDesc.clear();
-        m_pControlTree.clear();
-        m_pNoAssignment.clear();
-        ModalDialog::dispose();
     }
 
-    sal_Int32 OSelectLabelDialog::InsertEntries(const Reference< XInterface > & _xContainer, SvTreeListEntry* pContainerEntry)
+    sal_Int32 OSelectLabelDialog::InsertEntries(const Reference< XInterface > & _xContainer, weld::TreeIter& rContainerEntry)
     {
         Reference< XIndexAccess >  xContainer(_xContainer, UNO_QUERY);
         if (!xContainer.is())
@@ -201,19 +176,21 @@ namespace pcr
                 Reference< XIndexAccess >  xCont(xAsSet, UNO_QUERY);
                 if (xCont.is() && xCont->getCount())
                 {   // yes -> step down
-                    Image aFormImage(StockImage::Yes, RID_EXTBMP_FORM);
-                    SvTreeListEntry* pCont = m_pControlTree->InsertEntry(sName, aFormImage, aFormImage, pContainerEntry);
-                    sal_Int32 nContChildren = InsertEntries(xCont, pCont);
+                    OUString aFormImage(RID_EXTBMP_FORM);
+
+                    m_xControlTree->insert(&rContainerEntry, -1, &sName, nullptr,
+                                           nullptr, nullptr, &aFormImage, false);
+                    auto xIter = m_xControlTree->make_iterator(&rContainerEntry);
+                    m_xControlTree->iter_nth_child(*xIter, nChildren);
+                    sal_Int32 nContChildren = InsertEntries(xCont, *xIter);
                     if (nContChildren)
                     {
-                        m_pControlTree->Expand(pCont);
+                        m_xControlTree->expand_row(*xIter);
                         ++nChildren;
                     }
                     else
                     {   // oops, no valid children -> remove the entry
-                        m_pControlTree->ModelIsRemoving(pCont);
-                        m_pControlTree->GetModel()->Remove(pCont);
-                        m_pControlTree->ModelHasRemoved(pCont);
+                        m_xControlTree->remove(*xIter);
                     }
                 }
                 continue;
@@ -229,71 +206,71 @@ namespace pcr
                 makeStringAndClear();
 
             // all requirements met -> insert
-            SvTreeListEntry* pCurrent = m_pControlTree->InsertEntry(sDisplayName, m_aRequiredControlImage, m_aRequiredControlImage, pContainerEntry);
-            pCurrent->SetUserData(new Reference< XPropertySet > (xAsSet));
-            ++nChildren;
+            m_xUserData.emplace_back(new Reference<XPropertySet>(xAsSet));
+            OUString sId(OUString::number(reinterpret_cast<sal_Int64>(m_xUserData.back().get())));
+            m_xControlTree->insert(&rContainerEntry, -1, &sDisplayName, &sId, nullptr, nullptr, &m_aRequiredControlImage, false);
 
             if (m_xInitialLabelControl == xAsSet)
-                m_pInitialSelection = pCurrent;
+            {
+                m_xInitialSelection = m_xControlTree->make_iterator(&rContainerEntry);
+                m_xControlTree->iter_nth_child(*m_xInitialSelection, nChildren);
+            }
 
+            ++nChildren;
             m_bHaveAssignableControl = true;
         }
 
         return nChildren;
     }
 
-
-    IMPL_LINK(OSelectLabelDialog, OnEntrySelected, SvTreeListBox*, pLB, void)
+    IMPL_LINK(OSelectLabelDialog, OnEntrySelected, weld::TreeView&, rLB, void)
     {
-        DBG_ASSERT(pLB == m_pControlTree, "OSelectLabelDialog::OnEntrySelected : where did this come from ?");
-        SvTreeListEntry* pSelected = m_pControlTree->FirstSelected();
-        void* pData = pSelected ? pSelected->GetUserData() : nullptr;
-
-        if (pData)
-            m_xSelectedControl.set(*static_cast<Reference< XPropertySet > *>(pData));
-
-        m_pNoAssignment->SetClickHdl(Link<Button*,void>());
-        m_pNoAssignment->Check(pData == nullptr);
-        m_pNoAssignment->SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+        DBG_ASSERT(&rLB == m_xControlTree.get(), "OSelectLabelDialog::OnEntrySelected : where did this come from ?");
+        std::unique_ptr<weld::TreeIter> xIter = m_xControlTree->make_iterator();
+        bool bSelected = m_xControlTree->get_selected(xIter.get());
+        OUString sData = bSelected ? m_xControlTree->get_id(*xIter) : OUString();
+        if (!sData.isEmpty())
+            m_xSelectedControl.set(*reinterpret_cast<Reference<XPropertySet>*>(sData.toInt64()));
+        m_xNoAssignment->set_active(sData.isEmpty());
     }
 
-
-    IMPL_LINK(OSelectLabelDialog, OnNoAssignmentClicked, Button*, pButton, void)
+    IMPL_LINK(OSelectLabelDialog, OnNoAssignmentClicked, weld::ToggleButton&, rButton, void)
     {
-        DBG_ASSERT(pButton == m_pNoAssignment, "OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
+        DBG_ASSERT(&rButton == m_xNoAssignment.get(), "OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
 
-        if (m_pNoAssignment->IsChecked())
-            m_pLastSelected = m_pControlTree->FirstSelected();
+        if (m_xNoAssignment->get_active())
+        {
+            m_bLastSelected = m_xControlTree->get_selected(m_xLastSelected.get());
+        }
         else
         {
             DBG_ASSERT(m_bHaveAssignableControl, "OSelectLabelDialog::OnNoAssignmentClicked");
             // search the first assignable entry
-            SvTreeListEntry* pSearch = m_pControlTree->First();
-            while (pSearch)
+            auto xSearch = m_xControlTree->make_iterator(nullptr);
+            bool bSearch = m_xControlTree->get_iter_first(*xSearch);
+            while (bSearch)
             {
-                if (pSearch->GetUserData())
+                if (m_xControlTree->get_id(*xSearch).toInt64())
                     break;
-                pSearch = m_pControlTree->Next(pSearch);
+                bSearch = m_xControlTree->iter_next(*xSearch);
             }
             // and select it
-            if (pSearch)
+            if (bSearch)
             {
-                m_pControlTree->Select(pSearch);
-                m_pLastSelected = pSearch;
+                m_xControlTree->copy_iterator(*xSearch, *m_xLastSelected);
+                m_xControlTree->select(*m_xLastSelected);
+                m_bLastSelected = true;
             }
         }
 
-        if (m_pLastSelected)
+        if (m_bLastSelected)
         {
-            m_pControlTree->SetSelectHdl(Link<SvTreeListBox*,void>());
-            m_pControlTree->SetDeselectHdl(Link<SvTreeListBox*,void>());
-            m_pControlTree->Select(m_pLastSelected, !m_pNoAssignment->IsChecked());
-            m_pControlTree->SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
-            m_pControlTree->SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+            if (!m_xNoAssignment->get_active())
+                m_xControlTree->select(*m_xLastSelected);
+            else
+                m_xControlTree->unselect(*m_xLastSelected);
         }
     }
-
-
 }   // namespace pcr
 
 
diff --git a/extensions/source/propctrlr/selectlabeldialog.hxx b/extensions/source/propctrlr/selectlabeldialog.hxx
index bc6d70a72993..40d0d280f0d6 100644
--- a/extensions/source/propctrlr/selectlabeldialog.hxx
+++ b/extensions/source/propctrlr/selectlabeldialog.hxx
@@ -20,56 +20,46 @@
 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SELECTLABELDIALOG_HXX
 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SELECTLABELDIALOG_HXX
 
-#include <vcl/fixed.hxx>
-#include <vcl/treelistbox.hxx>
-#include <vcl/button.hxx>
-#include <vcl/image.hxx>
-#include <vcl/dialog.hxx>
+#include <vcl/weld.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include "modulepcr.hxx"
 
-
 namespace pcr
 {
-
-
     // OSelectLabelDialog
-
-    class OSelectLabelDialog final
-            :public ModalDialog
+    class OSelectLabelDialog final : public weld::GenericDialogController
     {
-        VclPtr<FixedText>       m_pMainDesc;
-        VclPtr<SvTreeListBox>   m_pControlTree;
-        VclPtr<CheckBox>        m_pNoAssignment;
-
         css::uno::Reference< css::beans::XPropertySet >   m_xControlModel;
         OUString m_sRequiredService;
-        Image                   m_aRequiredControlImage;
-        SvTreeListEntry*        m_pInitialSelection;
+        OUString m_aRequiredControlImage;
+        std::unique_ptr<weld::TreeIter> m_xInitialSelection;
+        // the entry datas of the listbox entries
+        std::vector<std::unique_ptr<css::uno::Reference<css::beans::XPropertySet>>> m_xUserData;
         css::uno::Reference< css::beans::XPropertySet >   m_xInitialLabelControl;
 
         css::uno::Reference< css::beans::XPropertySet >   m_xSelectedControl;
-        SvTreeListEntry*        m_pLastSelected;
-        bool                    m_bHaveAssignableControl;
+        std::unique_ptr<weld::TreeIter> m_xLastSelected;
+        bool m_bLastSelected;
+        bool m_bHaveAssignableControl;
+
+        std::unique_ptr<weld::Label> m_xMainDesc;
+        std::unique_ptr<weld::TreeView> m_xControlTree;
+        std::unique_ptr<weld::CheckButton> m_xNoAssignment;
 
     public:
-        OSelectLabelDialog(vcl::Window* pParent, css::uno::Reference< css::beans::XPropertySet > const & _xControlModel);
+        OSelectLabelDialog(weld::Window* pParent, css::uno::Reference< css::beans::XPropertySet > const & _xControlModel);
         virtual ~OSelectLabelDialog() override;
-        virtual void dispose() override;
 
-        css::uno::Reference< css::beans::XPropertySet >  GetSelected() const { return m_pNoAssignment->IsChecked() ? css::uno::Reference< css::beans::XPropertySet > () : m_xSelectedControl; }
+        css::uno::Reference< css::beans::XPropertySet >  GetSelected() const { return m_xNoAssignment->get_active() ? css::uno::Reference< css::beans::XPropertySet > () : m_xSelectedControl; }
 
     private:
-        sal_Int32 InsertEntries(const css::uno::Reference< css::uno::XInterface >& _xContainer, SvTreeListEntry* pContainerEntry);
+        sal_Int32 InsertEntries(const css::uno::Reference< css::uno::XInterface >& _xContainer, weld::TreeIter& rContainerEntry);
 
-        DECL_LINK(OnEntrySelected, SvTreeListBox*, void);
-        DECL_LINK(OnNoAssignmentClicked, Button*, void);
+        DECL_LINK(OnEntrySelected, weld::TreeView&, void);
+        DECL_LINK(OnNoAssignmentClicked, weld::ToggleButton&, void);
     };
-
-
 }   // namespace pcr
 
-
 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_SELECTLABELDIALOG_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/uiconfig/spropctrlr/ui/labelselectiondialog.ui b/extensions/uiconfig/spropctrlr/ui/labelselectiondialog.ui
index 6c40ce48f239..b6580cf719c9 100644
--- a/extensions/uiconfig/spropctrlr/ui/labelselectiondialog.ui
+++ b/extensions/uiconfig/spropctrlr/ui/labelselectiondialog.ui
@@ -1,16 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="pcr">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <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="GtkDialog" id="LabelSelectionDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="labelselectiondialog|LabelSelectionDialog">Label Field Selection</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
         <property name="orientation">vertical</property>
         <property name="spacing">6</property>
         <child internal-child="action_area">
@@ -86,7 +102,8 @@
                 <property name="label" translatable="yes" context="labelselectiondialog|label">These are control fields that can be used as label fields for the $controlclass$ $controlname$.</property>
                 <property name="use_underline">True</property>
                 <property name="wrap">True</property>
-                <property name="mnemonic_widget">control:border</property>
+                <property name="mnemonic_widget">control</property>
+                <property name="width_chars">60</property>
                 <property name="max_width_chars">60</property>
                 <property name="xalign">0</property>
                 <property name="yalign">0</property>
@@ -98,15 +115,44 @@
               </packing>
             </child>
             <child>
-              <object class="vcllo-SvTreeListBox" id="control:border">
-                <property name="width_request">200</property>
-                <property name="height_request">150</property>
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
-                <child internal-child="selection">
-                  <object class="GtkTreeSelection" id="treeview-selection1"/>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="control">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore1</property>
+                    <property name="headers_visible">False</property>
+                    <property name="search_column">1</property>
+                    <property name="show_expanders">True</property>
+                    <property name="enable_tree_lines">True</property>
+                    <child internal-child="selection">
+                      <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkCellRendererPixbuf" id="cellrenderertext4"/>
+                          <attributes>
+                            <attribute name="pixbuf">0</attribute>
+                          </attributes>
+                        </child>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                          <attributes>
+                            <attribute name="text">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
                 </child>
               </object>
               <packing>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index ea5576c35ce8..2649e551921a 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -463,7 +463,10 @@ protected:
 
     void signal_changed() { m_aChangeHdl.Call(*this); }
     void signal_row_activated() { m_aRowActivatedHdl.Call(*this); }
-    bool signal_expanding(TreeIter& rIter) { return m_aExpandingHdl.Call(rIter); }
+    bool signal_expanding(TreeIter& rIter)
+    {
+        return !m_aExpandingHdl.IsSet() || m_aExpandingHdl.Call(rIter);
+    }
     // arg is pair<row,col>
     void signal_toggled(const std::pair<int, int>& rRowCol) { m_aRadioToggleHdl.Call(rRowCol); }
 
@@ -566,6 +569,15 @@ public:
     // set iter to point to next node, depth first, then sibling
     virtual bool iter_next(TreeIter& rIter) const = 0;
     virtual bool iter_children(TreeIter& rIter) const = 0;
+    bool iter_nth_child(TreeIter& rIter, int nChild) const
+    {
+        if (!iter_children(rIter))
+            return false;
+        bool bRet = true;
+        for (int i = 0; i < nChild && bRet; ++i)
+            bRet = iter_next(rIter);
+        return bRet;
+    }
     virtual bool iter_parent(TreeIter& rIter) const = 0;
     virtual int get_iter_depth(const TreeIter& rIter) const = 0;
     virtual bool iter_has_child(const TreeIter& rIter) const = 0;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 63dea2b4208d..b64cb1933a73 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -5625,7 +5625,7 @@ public:
         GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore);
         GtkTreePath* path = gtk_tree_model_get_path(pModel, &rGtkIter.iter);
         if (!gtk_tree_view_row_expanded(m_pTreeView, path))
-            gtk_tree_view_expand_row(m_pTreeView, path, false);
+            gtk_tree_view_expand_to_path(m_pTreeView, path);
         gtk_tree_path_free(path);
     }
 
commit ad5493c3fcbec7dfa41e57ca2f98acbbce739b85
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Feb 4 16:53:38 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Feb 4 20:45:49 2019 +0100

    weld SelectPersonaDialog
    
    Change-Id: Ice5e59bb8c26f007b71ba7844872ce825a5549f8
    Reviewed-on: https://gerrit.libreoffice.org/67371
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx
index f5d6e9f232a3..e748baf8ac60 100644
--- a/cui/source/options/personalization.cxx
+++ b/cui/source/options/personalization.cxx
@@ -29,6 +29,7 @@
 #include <vcl/settings.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <vcl/mnemonic.hxx>
+#include <vcl/virdev.hxx>
 #include <dialmgr.hxx>
 #include <strings.hrc>
 
@@ -162,52 +163,41 @@ void curlDownload(const OString& rURL, const OUString& sFileURL)
 }
 
 } //End of anonymous namespace
-
-SelectPersonaDialog::SelectPersonaDialog( vcl::Window *pParent )
-    : ModalDialog( pParent, "SelectPersonaDialog", "cui/ui/select_persona_dialog.ui" )
+SelectPersonaDialog::SelectPersonaDialog(weld::Window *pParent)
+    : GenericDialogController(pParent, "cui/ui/select_persona_dialog.ui", "SelectPersonaDialog")
+    , m_xEdit(m_xBuilder->weld_entry("search_term"))
+    , m_xSearchButton(m_xBuilder->weld_button("search_personas"))
+    , m_xProgressLabel(m_xBuilder->weld_label("progress_label"))
+    , m_xCategories(m_xBuilder->weld_combo_box("categoriesCB"))
+    , m_xOkButton(m_xBuilder->weld_button("ok"))
+    , m_xCancelButton(m_xBuilder->weld_button("cancel"))
+    , m_vResultList{ m_xBuilder->weld_button("result1"),
+                     m_xBuilder->weld_button("result2"),
+                     m_xBuilder->weld_button("result3"),
+                     m_xBuilder->weld_button("result4"),
+                     m_xBuilder->weld_button("result5"),
+                     m_xBuilder->weld_button("result6"),
+                     m_xBuilder->weld_button("result7"),
+                     m_xBuilder->weld_button("result8"),
+                     m_xBuilder->weld_button("result9") }
 {
-    get( m_pSearchButton, "search_personas" );
-    m_pSearchButton->SetClickHdl( LINK( this, SelectPersonaDialog, SearchPersonas ) );
-
-    get( m_pEdit, "search_term" );
-
-    get( m_pCategories, "categoriesCB" );
-    m_pCategories->SetSelectHdl( LINK( this, SelectPersonaDialog, SelectCategory ) );
-
-    get( m_pProgressLabel, "progress_label" );
+    m_xSearchButton->connect_clicked( LINK( this, SelectPersonaDialog, SearchPersonas ) );
+    m_xCategories->connect_changed( LINK( this, SelectPersonaDialog, SelectCategory ) );
+    m_xOkButton->connect_clicked( LINK( this, SelectPersonaDialog, ActionOK ) );
+    m_xCancelButton->connect_clicked( LINK( this, SelectPersonaDialog, ActionCancel ) );
 
-    get( m_pOkButton, "ok" );
-    m_pOkButton->SetClickHdl( LINK( this, SelectPersonaDialog, ActionOK ) );
-
-    get( m_pCancelButton, "cancel" );
-    m_pCancelButton->SetClickHdl( LINK( this, SelectPersonaDialog, ActionCancel ) );
-    get( m_vResultList[0], "result1" );
-    get( m_vResultList[1], "result2" );
-    get( m_vResultList[2], "result3" );
-    get( m_vResultList[3], "result4" );
-    get( m_vResultList[4], "result5" );
-    get( m_vResultList[5], "result6" );
-    get( m_vResultList[6], "result7" );
-    get( m_vResultList[7], "result8" );
-    get( m_vResultList[8], "result9" );
-
-    for (VclPtr<PushButton> & nIndex : m_vResultList)
+    for (auto & nIndex : m_vResultList)
     {
-        nIndex->SetClickHdl( LINK( this, SelectPersonaDialog, SelectPersona ) );
-        nIndex->Disable();
+        nIndex->connect_clicked( LINK( this, SelectPersonaDialog, SelectPersona ) );
+        nIndex->set_sensitive(false);
     }
 
-    m_pCategories->SelectEntry("Featured");
-    m_pCategories->GetSelectHdl().Call(*m_pCategories);
+    m_xCategories->set_active_text("Featured");
+    SelectCategory(*m_xCategories);
 }
 
 SelectPersonaDialog::~SelectPersonaDialog()
 {
-    disposeOnce();
-}
-
-void SelectPersonaDialog::dispose()
-{
     if (m_pSearchThread.is())
     {
         // Release the solar mutex, so the thread is not affected by the race
@@ -216,16 +206,6 @@ void SelectPersonaDialog::dispose()
         SolarMutexReleaser aReleaser;
         m_pSearchThread->join();
     }
-
-    m_pCategories.clear();
-    m_pEdit.clear();
-    m_pSearchButton.clear();
-    m_pProgressLabel.clear();
-    for (VclPtr<PushButton>& vp : m_vResultList)
-        vp.clear();
-    m_pOkButton.clear();
-    m_pCancelButton.clear();
-    ModalDialog::dispose();
 }
 
 OUString SelectPersonaDialog::GetSelectedPersona() const
@@ -236,9 +216,9 @@ OUString SelectPersonaDialog::GetSelectedPersona() const
     return OUString();
 }
 
-IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, weld::Button&, void )
 {
-    OUString searchTerm = m_pEdit->GetText();
+    OUString searchTerm = m_xEdit->get_text();
 
     if( searchTerm.isEmpty( ) )
         return;
@@ -284,7 +264,7 @@ IMPL_LINK_NOARG( SelectPersonaDialog, SearchPersonas, Button*, void )
     m_pSearchThread->launch();
 }
 
-IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, weld::Button&, void )
 {
     OUString aSelectedPersona = GetSelectedPersona();
 
@@ -299,23 +279,23 @@ IMPL_LINK_NOARG( SelectPersonaDialog, ActionOK, Button*, void )
         if ( m_pSearchThread.is() )
             m_pSearchThread->StopExecution();
 
-        EndDialog( RET_OK );
+        m_xDialog->response(RET_OK);
     }
 }
 
-IMPL_LINK_NOARG( SelectPersonaDialog, ActionCancel, Button*, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, ActionCancel, weld::Button&, void )
 {
     if( m_pSearchThread.is() )
         m_pSearchThread->StopExecution();
     if( m_pGetPersonaThread.is() )
         m_pGetPersonaThread->StopExecution();
 
-    EndDialog();
+    m_xDialog->response(RET_CANCEL);
 }
 
-IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, ListBox&, void )
+IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, weld::ComboBox&, void )
 {
-    OUString searchTerm = *static_cast<OUString*>(m_pCategories->GetSelectedEntryData());
+    OUString searchTerm = m_xCategories->get_active_id();
     OUString rSearchURL;
 
     if (searchTerm.isEmpty())
@@ -335,7 +315,7 @@ IMPL_LINK_NOARG( SelectPersonaDialog, SelectCategory, ListBox&, void )
     m_pSearchThread->launch();
 }
 
-IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void )
+IMPL_LINK( SelectPersonaDialog, SelectPersona, weld::Button&, rButton, void )
 {
     if( m_pSearchThread.is() )
         m_pSearchThread->StopExecution();
@@ -344,7 +324,7 @@ IMPL_LINK( SelectPersonaDialog, SelectPersona, Button*, pButton, void )
 
     for( sal_Int32 index = 0; index < MAX_RESULTS; index++ )
     {
-        if( pButton == m_vResultList[index] )
+        if( &rButton == m_vResultList[index].get() )
         {
             if( !m_vPersonaSettings[index].isEmpty() )
             {
@@ -374,21 +354,21 @@ const OUString& SelectPersonaDialog::GetAppliedPersonaSetting() const
 void SelectPersonaDialog::SetProgress( const OUString& rProgress )
 {
     if(rProgress.isEmpty())
-        m_pProgressLabel->Hide();
+        m_xProgressLabel->hide();
     else
     {
         SolarMutexGuard aGuard;
-        m_pProgressLabel->Show();
-        m_pProgressLabel->SetText( rProgress );
-        setOptimalLayoutSize();
+        m_xProgressLabel->show();
+        m_xProgressLabel->set_label( rProgress );
+        m_xDialog->resize_to_request(); //TODO
     }
 }
 
-void SelectPersonaDialog::SetImages( const Image& aImage, const OUString& sName, const sal_Int32& nIndex )
+void SelectPersonaDialog::SetImages( VirtualDevice& rImage, const OUString& sName, const sal_Int32& nIndex )
 {
-    m_vResultList[nIndex]->Enable();
-    m_vResultList[nIndex]->SetModeImage( aImage );
-    m_vResultList[nIndex]->SetQuickHelpText( sName );
+    m_vResultList[nIndex]->set_sensitive(true);
+    m_vResultList[nIndex]->set_image(&rImage);
+    m_vResultList[nIndex]->set_tooltip_text( sName );
 }
 
 void SelectPersonaDialog::AddPersonaSetting( OUString const & rPersonaSetting )
@@ -402,10 +382,10 @@ void SelectPersonaDialog::ClearSearchResults()
     SolarMutexGuard aGuard;
     m_vPersonaSettings.clear();
     m_aSelectedPersona.clear();
-    for(VclPtr<PushButton> & nIndex : m_vResultList)
+    for(auto & nIndex : m_vResultList)
     {
-        nIndex->Disable();
-        nIndex->SetModeImage(Image());
+        nIndex->set_sensitive(false);
+        nIndex->set_image(nullptr);
     }
 }
 
@@ -655,11 +635,11 @@ void SvxPersonalizationTabPage::LoadExtensionThemes()
 IMPL_LINK_NOARG( SvxPersonalizationTabPage, SelectPersona, Button*, void )
 {
     m_pOwnPersona->Check();
-    ScopedVclPtrInstance< SelectPersonaDialog > aDialog(nullptr);
+    SelectPersonaDialog aDialog(GetDialogFrameWeld());
 
-    if ( aDialog->Execute() == RET_OK )
+    if (aDialog.run() == RET_OK)
     {
-        OUString aPersonaSetting( aDialog->GetAppliedPersonaSetting() );
+        OUString aPersonaSetting(aDialog.GetAppliedPersonaSetting());
         if ( !aPersonaSetting.isEmpty() )
         {
             SetPersonaSettings( aPersonaSetting );
@@ -908,8 +888,11 @@ void SearchAndParseThread::execute()
                 aFilter.ImportGraphic( aGraphic, aURLObj );
                 BitmapEx aBmp = aGraphic.GetBitmapEx();
 
-                m_pPersonaDialog->SetImages( Image( aBmp ), personaInfo.sName, nIndex );
-                m_pPersonaDialog->setOptimalLayoutSize();
+                ScopedVclPtr<VirtualDevice> xVirDev(VclPtr<VirtualDevice>::Create());
+                xVirDev->SetOutputSizePixel(aBmp.GetSizePixel());
+                xVirDev->DrawBitmapEx(Point(0, 0), aBmp);
+
+                m_pPersonaDialog->SetImages(*xVirDev, personaInfo.sName, nIndex );
 
                 if (++nIndex >= MAX_RESULTS)
                     break;
@@ -971,8 +954,11 @@ void SearchAndParseThread::execute()
             aFilter.ImportGraphic( aGraphic, aURLObj );
             BitmapEx aBmp = aGraphic.GetBitmapEx();
 
-            m_pPersonaDialog->SetImages( Image( aBmp ), aPersonaInfo.sName, 0 );
-            m_pPersonaDialog->setOptimalLayoutSize();
+            ScopedVclPtr<VirtualDevice> xVirDev(VclPtr<VirtualDevice>::Create());
+            xVirDev->SetOutputSizePixel(aBmp.GetSizePixel());
+            xVirDev->DrawBitmapEx(Point(0, 0), aBmp);
+
+            m_pPersonaDialog->SetImages( *xVirDev, aPersonaInfo.sName, 0 );
         }
 
     }
@@ -983,7 +969,6 @@ void SearchAndParseThread::execute()
     SolarMutexGuard aGuard;
     sProgress.clear();
     m_pPersonaDialog->SetProgress( sProgress );
-    m_pPersonaDialog->setOptimalLayoutSize();
 }
 
 GetPersonaThread::GetPersonaThread( SelectPersonaDialog* pDialog,
@@ -1062,7 +1047,7 @@ void GetPersonaThread::execute()
             + ";" + aTextColor;
 
     m_pPersonaDialog->SetAppliedPersonaSetting( aPersonaSetting );
-    m_pPersonaDialog->EndDialog( RET_OK );
+    m_pPersonaDialog->response( RET_OK );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/options/personalization.hxx b/cui/source/options/personalization.hxx
index 8cd7fd89bcb1..1e0638024cff 100644
--- a/cui/source/options/personalization.hxx
+++ b/cui/source/options/personalization.hxx
@@ -94,25 +94,24 @@ private:
 };
 
 /** Dialog that will allow the user to choose a Persona to use. */
-class SelectPersonaDialog : public ModalDialog
+class SelectPersonaDialog : public weld::GenericDialogController
 {
 private:
-    VclPtr<Edit> m_pEdit;                                   ///< The input line for the search term
-    VclPtr<PushButton> m_pSearchButton;                     ///< The search button
-    VclPtr<FixedText> m_pProgressLabel;                     ///< The label for showing progress of search
-    VclPtr<PushButton> m_vResultList[MAX_RESULTS];                    ///< List of buttons to show search results
-    VclPtr<ListBox> m_pCategories;                         ///< The list of categories
-    VclPtr<PushButton> m_pOkButton;                         ///< The OK button
-    VclPtr<PushButton> m_pCancelButton;                     ///< The Cancel button
-
     std::vector<OUString> m_vPersonaSettings;
     OUString m_aSelectedPersona;
     OUString m_aAppliedPersona;
 
+    std::unique_ptr<weld::Entry> m_xEdit;                              ///< The input line for the search term
+    std::unique_ptr<weld::Button> m_xSearchButton;                     ///< The search button
+    std::unique_ptr<weld::Label> m_xProgressLabel;                     ///< The label for showing progress of search
+    std::unique_ptr<weld::ComboBox> m_xCategories;                     ///< The list of categories
+    std::unique_ptr<weld::Button> m_xOkButton;                         ///< The OK button
+    std::unique_ptr<weld::Button> m_xCancelButton;                     ///< The Cancel button
+    std::unique_ptr<weld::Button> m_vResultList[MAX_RESULTS];          ///< List of buttons to show search results
+
 public:
-    explicit SelectPersonaDialog( vcl::Window *pParent );
+    explicit SelectPersonaDialog(weld::Window *pParent);
     virtual ~SelectPersonaDialog() override;
-    virtual void dispose() override;
     ::rtl::Reference< SearchAndParseThread >    m_pSearchThread;
     ::rtl::Reference< GetPersonaThread >        m_pGetPersonaThread;
 
@@ -124,7 +123,7 @@ public:
      * @param sName Name of the persona
      * @param nIndex Index number of the result button
      */
-    void SetImages(const Image& aPreviewImage, const OUString& sName, const sal_Int32& nIndex );
+    void SetImages( VirtualDevice& rPreviewImage, const OUString& sName, const sal_Int32& nIndex );
     void AddPersonaSetting( OUString const & );
     void ClearSearchResults();
     void SetAppliedPersonaSetting( OUString const & );
@@ -132,19 +131,19 @@ public:
 
 private:
     /// Handle the Search button
-    DECL_LINK( SearchPersonas, Button*, void );
+    DECL_LINK( SearchPersonas, weld::Button&, void );
     /// Handle persona categories list box
-    DECL_LINK( SelectCategory, ListBox&, void );
-    DECL_LINK( SelectPersona, Button*, void );
-    DECL_LINK( ActionOK, Button*, void );
-    DECL_LINK( ActionCancel, Button*, void );
+    DECL_LINK( SelectCategory, weld::ComboBox&, void );
+    DECL_LINK( SelectPersona, weld::Button&, void );
+    DECL_LINK( ActionOK, weld::Button&, void );
+    DECL_LINK( ActionCancel, weld::Button&, void );
 };
 
 class SearchAndParseThread: public salhelper::Thread
 {
 private:
 
-    VclPtr<SelectPersonaDialog> m_pPersonaDialog;
+    SelectPersonaDialog* m_pPersonaDialog;
     OUString m_aURL;
     std::atomic<bool> m_bExecute;
     bool m_bDirectURL;
@@ -164,7 +163,7 @@ class GetPersonaThread: public salhelper::Thread
 {
 private:
 
-    VclPtr<SelectPersonaDialog> m_pPersonaDialog;
+    SelectPersonaDialog* m_pPersonaDialog;
     OUString m_aSelectedPersona;
     std::atomic<bool> m_bExecute;
 
diff --git a/cui/uiconfig/ui/select_persona_dialog.ui b/cui/uiconfig/ui/select_persona_dialog.ui
index 36d80658a5d2..9c17e485fa24 100644
--- a/cui/uiconfig/ui/select_persona_dialog.ui
+++ b/cui/uiconfig/ui/select_persona_dialog.ui
@@ -6,6 +6,9 @@
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="select_persona_dialog|SelectPersonaDialog">Select Firefox Theme</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
     <child>
       <placeholder/>
@@ -68,7 +71,9 @@
               <object class="GtkLabel" id="progress_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
                 <property name="ellipsize">end</property>
+                <property name="width_chars">45</property>
                 <property name="max_width_chars">45</property>
                 <property name="xalign">0</property>
               </object>
@@ -98,6 +103,7 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="hexpand">True</property>
+                <property name="activates_default">True</property>
                 <property name="primary_icon_activatable">False</property>
                 <property name="secondary_icon_activatable">False</property>
                 <property name="placeholder_text" translatable="yes" context="select_persona_dialog|search_term">Search term or address</property>
@@ -142,7 +148,7 @@
               <object class="GtkLabel" id="categories_label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" context="select_persona_dialog|categories_label" translatable="yes">Ca_tegory:</property>
+                <property name="label" translatable="yes" context="select_persona_dialog|categories_label">Ca_tegory:</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">categoriesCB</property>
               </object>


More information about the Libreoffice-commits mailing list