[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sfx2/uiconfig

Caolán McNamara caolanm at redhat.com
Fri Apr 13 12:23:37 UTC 2018


 include/sfx2/templatedlg.hxx            |   24 +++----
 sfx2/source/dialog/dinfdlg.cxx          |  104 +++++++++++-------------------
 sfx2/source/doc/templatedlg.cxx         |  109 +++++++++++++-------------------
 sfx2/uiconfig/ui/editdurationdialog.ui  |   71 ++++++++++++++++++--
 sfx2/uiconfig/ui/templatecategorydlg.ui |   60 +++++++++++++----
 5 files changed, 208 insertions(+), 160 deletions(-)

New commits:
commit a27f1957e574f03734fd4b4419f0b0f0229549f1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 11:54:50 2018 +0100

    weld DurationDialog
    
    Change-Id: If69c4259c3fd40c822a2dd505e51059a805813f4
    Reviewed-on: https://gerrit.libreoffice.org/52821
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index d0f87eda0829..cda6becfc1ab 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1255,78 +1255,54 @@ void CustomPropertiesYesNoButton::dispose()
     Control::dispose();
 }
 
-class DurationDialog_Impl : public ModalDialog
+class DurationDialog_Impl : public weld::GenericDialogController
 {
-    VclPtr<CheckBox>       m_pNegativeCB;
-    VclPtr<NumericField>   m_pYearNF;
-    VclPtr<NumericField>   m_pMonthNF;
-    VclPtr<NumericField>   m_pDayNF;
-    VclPtr<NumericField>   m_pHourNF;
-    VclPtr<NumericField>   m_pMinuteNF;
-    VclPtr<NumericField>   m_pSecondNF;
-    VclPtr<NumericField>   m_pMSecondNF;
+    std::unique_ptr<weld::CheckButton> m_xNegativeCB;
+    std::unique_ptr<weld::SpinButton> m_xYearNF;
+    std::unique_ptr<weld::SpinButton> m_xMonthNF;
+    std::unique_ptr<weld::SpinButton> m_xDayNF;
+    std::unique_ptr<weld::SpinButton> m_xHourNF;
+    std::unique_ptr<weld::SpinButton> m_xMinuteNF;
+    std::unique_ptr<weld::SpinButton> m_xSecondNF;
+    std::unique_ptr<weld::SpinButton> m_xMSecondNF;
 
 public:
-
-    DurationDialog_Impl( vcl::Window* pParent, const util::Duration& rDuration );
-    virtual ~DurationDialog_Impl() override;
-    virtual void dispose() override;
+    DurationDialog_Impl(weld::Window* pParent, const util::Duration& rDuration);
     util::Duration  GetDuration() const;
 };
 
-DurationDialog_Impl::DurationDialog_Impl(vcl::Window* pParent,
-    const util::Duration& rDuration)
-    : ModalDialog(pParent, "EditDurationDialog",
-        "sfx/ui/editdurationdialog.ui")
-{
-    get(m_pNegativeCB, "negative");
-    get(m_pYearNF, "years");
-    get(m_pMonthNF, "months");
-    get(m_pDayNF, "days");
-    get(m_pHourNF, "hours");
-    get(m_pMinuteNF, "minutes");
-    get(m_pSecondNF, "seconds");
-    get(m_pMSecondNF, "milliseconds");
-
-    m_pNegativeCB->Check(rDuration.Negative);
-    m_pYearNF->SetValue(rDuration.Years);
-    m_pMonthNF->SetValue(rDuration.Months);
-    m_pDayNF->SetValue(rDuration.Days);
-    m_pHourNF->SetValue(rDuration.Hours);
-    m_pMinuteNF->SetValue(rDuration.Minutes);
-    m_pSecondNF->SetValue(rDuration.Seconds);
-    m_pMSecondNF->SetValue(rDuration.NanoSeconds);
-}
-
-DurationDialog_Impl::~DurationDialog_Impl()
-{
-    disposeOnce();
-}
-
-void DurationDialog_Impl::dispose()
-{
-    m_pNegativeCB.clear();
-    m_pYearNF.clear();
-    m_pMonthNF.clear();
-    m_pDayNF.clear();
-    m_pHourNF.clear();
-    m_pMinuteNF.clear();
-    m_pSecondNF.clear();
-    m_pMSecondNF.clear();
-    ModalDialog::dispose();
+DurationDialog_Impl::DurationDialog_Impl(weld::Window* pParent, const util::Duration& rDuration)
+    : GenericDialogController(pParent, "sfx/ui/editdurationdialog.ui", "EditDurationDialog")
+    , m_xNegativeCB(m_xBuilder->weld_check_button("negative"))
+    , m_xYearNF(m_xBuilder->weld_spin_button("years"))
+    , m_xMonthNF(m_xBuilder->weld_spin_button("months"))
+    , m_xDayNF(m_xBuilder->weld_spin_button("days"))
+    , m_xHourNF(m_xBuilder->weld_spin_button("hours"))
+    , m_xMinuteNF(m_xBuilder->weld_spin_button("minutes"))
+    , m_xSecondNF(m_xBuilder->weld_spin_button("seconds"))
+    , m_xMSecondNF(m_xBuilder->weld_spin_button("milliseconds"))
+{
+    m_xNegativeCB->set_active(rDuration.Negative);
+    m_xYearNF->set_value(rDuration.Years);
+    m_xMonthNF->set_value(rDuration.Months);
+    m_xDayNF->set_value(rDuration.Days);
+    m_xHourNF->set_value(rDuration.Hours);
+    m_xMinuteNF->set_value(rDuration.Minutes);
+    m_xSecondNF->set_value(rDuration.Seconds);
+    m_xMSecondNF->set_value(rDuration.NanoSeconds);
 }
 
 util::Duration  DurationDialog_Impl::GetDuration() const
 {
     util::Duration  aRet;
-    aRet.Negative = m_pNegativeCB->IsChecked();
-    aRet.Years = m_pYearNF->GetValue();
-    aRet.Months = m_pMonthNF->GetValue( );
-    aRet.Days = m_pDayNF->GetValue(   );
-    aRet.Hours  = m_pHourNF->GetValue( );
-    aRet.Minutes = m_pMinuteNF->GetValue();
-    aRet.Seconds = m_pSecondNF->GetValue();
-    aRet.NanoSeconds = m_pMSecondNF->GetValue();
+    aRet.Negative = m_xNegativeCB->get_active();
+    aRet.Years = m_xYearNF->get_value();
+    aRet.Months = m_xMonthNF->get_value();
+    aRet.Days = m_xDayNF->get_value();
+    aRet.Hours  = m_xHourNF->get_value();
+    aRet.Minutes = m_xMinuteNF->get_value();
+    aRet.Seconds = m_xSecondNF->get_value();
+    aRet.NanoSeconds = m_xMSecondNF->get_value();
     return aRet;
 }
 
@@ -1377,9 +1353,9 @@ CustomPropertiesEditButton::CustomPropertiesEditButton(vcl::Window* pParent, Win
 
 IMPL_LINK_NOARG(CustomPropertiesEditButton, ClickHdl, Button*, void)
 {
-    VclPtrInstance< DurationDialog_Impl > pDurationDlg( this, m_pLine->m_aDurationField->GetDuration() );
-    if ( RET_OK == pDurationDlg->Execute() )
-        m_pLine->m_aDurationField->SetDuration( pDurationDlg->GetDuration() );
+    DurationDialog_Impl aDurationDlg(GetFrameWeld(), m_pLine->m_aDurationField->GetDuration());
+    if (aDurationDlg.run() == RET_OK)
+        m_pLine->m_aDurationField->SetDuration(aDurationDlg.GetDuration());
 }
 
 void CustomPropertiesYesNoButton::Resize()
diff --git a/sfx2/uiconfig/ui/editdurationdialog.ui b/sfx2/uiconfig/ui/editdurationdialog.ui
index e5bbad63acc2..a820a1d05e4f 100644
--- a/sfx2/uiconfig/ui/editdurationdialog.ui
+++ b/sfx2/uiconfig/ui/editdurationdialog.ui
@@ -1,12 +1,50 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment2">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment3">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment4">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment5">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment6">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkAdjustment" id="adjustment7">
+    <property name="upper">2147483647</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkDialog" id="EditDurationDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="editdurationdialog|EditDurationDialog">Edit Duration</property>
     <property name="resizable">False</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 internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -112,10 +150,10 @@
                       <object class="GtkLabel" id="label1">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label1">_Years:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">years</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -126,10 +164,10 @@
                       <object class="GtkLabel" id="label">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label">_Months:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">months</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -140,10 +178,10 @@
                       <object class="GtkLabel" id="label3">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label3">_Days:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">days</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -154,10 +192,10 @@
                       <object class="GtkLabel" id="label4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label4">H_ours:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">hours</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -168,10 +206,10 @@
                       <object class="GtkLabel" id="label5">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label5">Min_utes:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">minutes</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -182,10 +220,10 @@
                       <object class="GtkLabel" id="label6">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label6">_Seconds:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">seconds</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -196,10 +234,10 @@
                       <object class="GtkLabel" id="label7">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="xalign">1</property>
                         <property name="label" translatable="yes" context="editdurationdialog|label7">Millise_conds:</property>
                         <property name="use_underline">True</property>
                         <property name="mnemonic_widget">milliseconds</property>
+                        <property name="xalign">1</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
@@ -210,6 +248,8 @@
                       <object class="GtkSpinButton" id="years">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment1</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -220,6 +260,8 @@
                       <object class="GtkSpinButton" id="months">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment2</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -230,6 +272,8 @@
                       <object class="GtkSpinButton" id="days">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment3</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -240,6 +284,8 @@
                       <object class="GtkSpinButton" id="hours">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment4</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -250,6 +296,8 @@
                       <object class="GtkSpinButton" id="minutes">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment5</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -260,6 +308,8 @@
                       <object class="GtkSpinButton" id="seconds">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment6</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -270,6 +320,8 @@
                       <object class="GtkSpinButton" id="milliseconds">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment7</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
@@ -304,5 +356,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
commit a8b096cba3a49732bfec608b4b7e7b90badb31c3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 11:31:02 2018 +0100

    weld SfxTemplateCategoryDialog
    
    Change-Id: I7462102797e3b0f552aec97f6cbae919e89e7099
    Reviewed-on: https://gerrit.libreoffice.org/52820
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index 40d735d8231b..7f730c50161d 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -18,6 +18,7 @@
 #include <vcl/dialog.hxx>
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 #include <com/sun/star/frame/XDesktop2.hpp>
 
 #include <sfx2/templatelocalview.hxx>
@@ -146,21 +147,21 @@ protected:
 
 //  class SfxTemplateCategoryDialog -------------------------------------------------------------------
 
-class SFX2_DLLPUBLIC SfxTemplateCategoryDialog : public ModalDialog
+class SFX2_DLLPUBLIC SfxTemplateCategoryDialog : public weld::GenericDialogController
 {
 private:
-    VclPtr<ListBox>         mpLBCategory;
-    VclPtr<FixedText>       mpSelectLabel;
-    VclPtr<Edit>            mpNewCategoryEdit;
-    VclPtr<FixedText>       mpCreateLabel;
-    VclPtr<PushButton>      mpOKButton;
-
     OUString   msSelectedCategory;
     bool       mbIsNewCategory;
 
+    std::unique_ptr<weld::TreeView> mxLBCategory;
+    std::unique_ptr<weld::Label> mxSelectLabel;
+    std::unique_ptr<weld::Entry> mxNewCategoryEdit;
+    std::unique_ptr<weld::Label> mxCreateLabel;
+    std::unique_ptr<weld::Button> mxOKButton;
+
 public:
-    DECL_LINK(NewCategoryEditHdl, Edit&, void);
-    DECL_LINK(SelectCategoryHdl, ListBox&, void);
+    DECL_LINK(NewCategoryEditHdl, weld::Entry&, void);
+    DECL_LINK(SelectCategoryHdl, weld::TreeView&, void);
 
     void SetCategoryLBEntries(std::vector<OUString> names);
 
@@ -171,7 +172,7 @@ public:
     };
 
     void SetSelectLabelText(OUString const & sText) const {
-        mpSelectLabel->SetText(sText);
+        mxSelectLabel->set_label(sText);
     };
 
     bool IsNewCategoryCreated() const {
@@ -180,10 +181,9 @@ public:
 
 public:
 
-    explicit SfxTemplateCategoryDialog();
+    explicit SfxTemplateCategoryDialog(weld::Window* pParent);
 
     virtual ~SfxTemplateCategoryDialog() override;
-    virtual void dispose() override;
 };
 
 
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 03459cd9cfff..8317b8c139f3 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -570,16 +570,15 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, OkClickHdl, Button*, void)
 IMPL_LINK_NOARG(SfxTemplateManagerDlg, MoveClickHdl, Button*, void)
 {
     // modal dialog to select templates category
-    ScopedVclPtrInstance<SfxTemplateCategoryDialog> aDlg;
-    aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
+    SfxTemplateCategoryDialog aDlg(GetFrameWeld());
+    aDlg.SetCategoryLBEntries(mpLocalView->getFolderNames());
 
     size_t nItemId = 0;
 
-    if (aDlg->Execute() == RET_OK)
+    if (aDlg.run() == RET_OK)
     {
-        OUString sCategory = aDlg->GetSelectedCategory();
-        bool bIsNewCategory = aDlg->IsNewCategoryCreated();
-        aDlg.disposeAndClear();
+        OUString sCategory = aDlg.GetSelectedCategory();
+        bool bIsNewCategory = aDlg.IsNewCategoryCreated();
         if(bIsNewCategory)
         {
             if (!sCategory.isEmpty())
@@ -612,14 +611,13 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, ExportClickHdl, Button*, void)
 IMPL_LINK_NOARG(SfxTemplateManagerDlg, ImportClickHdl, Button*, void)
 {
     //Modal Dialog to select Category
-    ScopedVclPtrInstance<SfxTemplateCategoryDialog> aDlg;
-    aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
+    SfxTemplateCategoryDialog aDlg(GetFrameWeld());
+    aDlg.SetCategoryLBEntries(mpLocalView->getFolderNames());
 
-    if (aDlg->Execute() == RET_OK)
+    if (aDlg.run() == RET_OK)
     {
-        OUString sCategory = aDlg->GetSelectedCategory();
-        bool bIsNewCategory = aDlg->IsNewCategoryCreated();
-        aDlg.disposeAndClear();
+        OUString sCategory = aDlg.GetSelectedCategory();
+        bool bIsNewCategory = aDlg.IsNewCategoryCreated();
         if(bIsNewCategory)
         {
             if(mpLocalView->createRegion(sCategory))
@@ -1168,16 +1166,15 @@ void SfxTemplateManagerDlg::OnCategoryRename()
 
 void SfxTemplateManagerDlg::OnCategoryDelete()
 {
-    ScopedVclPtrInstance< SfxTemplateCategoryDialog > aDlg;
-    aDlg->SetCategoryLBEntries(mpLocalView->getFolderNames());
-    aDlg->HideNewCategoryOption();
-    aDlg->SetText(SfxResId(STR_CATEGORY_DELETE));
-    aDlg->SetSelectLabelText(SfxResId(STR_CATEGORY_SELECT));
+    SfxTemplateCategoryDialog aDlg(GetFrameWeld());
+    aDlg.SetCategoryLBEntries(mpLocalView->getFolderNames());
+    aDlg.HideNewCategoryOption();
+    aDlg.set_title(SfxResId(STR_CATEGORY_DELETE));
+    aDlg.SetSelectLabelText(SfxResId(STR_CATEGORY_SELECT));
 
-    if (aDlg->Execute() == RET_OK)
+    if (aDlg.run() == RET_OK)
     {
-        OUString sCategory = aDlg->GetSelectedCategory();
-        aDlg.disposeAndClear();
+        OUString sCategory = aDlg.GetSelectedCategory();
         std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Question, VclButtonsType::YesNo,
                                                       SfxResId(STR_QMSG_SEL_FOLDER_DELETE)));
         if (popupDlg->run() != RET_YES)
@@ -1319,69 +1316,57 @@ static std::vector<OUString> lcl_getAllFactoryURLs ()
 
 //   Class SfxTemplateCategoryDialog --------------------------------------------------
 
-SfxTemplateCategoryDialog::SfxTemplateCategoryDialog():
-        ModalDialog(nullptr, "TemplatesCategoryDialog", "sfx/ui/templatecategorydlg.ui"),
-        msSelectedCategory(OUString()),
-        mbIsNewCategory(false)
+SfxTemplateCategoryDialog::SfxTemplateCategoryDialog(weld::Window* pParent)
+    : weld::GenericDialogController(pParent, "sfx/ui/templatecategorydlg.ui", "TemplatesCategoryDialog")
+    , msSelectedCategory(OUString())
+    , mbIsNewCategory(false)
+    , mxLBCategory(m_xBuilder->weld_tree_view("categorylb"))
+    , mxSelectLabel(m_xBuilder->weld_label("select_label"))
+    , mxNewCategoryEdit(m_xBuilder->weld_entry("category_entry"))
+    , mxCreateLabel(m_xBuilder->weld_label("create_label"))
+    , mxOKButton(m_xBuilder->weld_button("ok"))
 {
-    get(mpLBCategory, "categorylb");
-    get(mpNewCategoryEdit, "category_entry");
-    get(mpOKButton, "ok");
-    get(mpSelectLabel, "select_label");
-    get(mpCreateLabel, "create_label");
-
-    mpNewCategoryEdit->SetModifyHdl(LINK(this, SfxTemplateCategoryDialog, NewCategoryEditHdl));
-    mpLBCategory->SetSelectHdl(LINK(this, SfxTemplateCategoryDialog, SelectCategoryHdl));
-
-    mpOKButton->Disable();
+    mxNewCategoryEdit->connect_changed(LINK(this, SfxTemplateCategoryDialog, NewCategoryEditHdl));
+    mxLBCategory->set_size_request(mxLBCategory->get_approximate_digit_width() * 32,
+                                   mxLBCategory->get_height_rows(8));
+    mxLBCategory->connect_changed(LINK(this, SfxTemplateCategoryDialog, SelectCategoryHdl));
+    mxOKButton->set_sensitive(false);
 }
 
 SfxTemplateCategoryDialog::~SfxTemplateCategoryDialog()
 {
-    disposeOnce();
-}
-
-void SfxTemplateCategoryDialog::dispose()
-{
-    mpLBCategory.clear();
-    mpNewCategoryEdit.clear();
-    mpOKButton.clear();
-    mpSelectLabel.clear();
-    mpCreateLabel.clear();
-
-    ModalDialog::dispose();
 }
 
-IMPL_LINK_NOARG(SfxTemplateCategoryDialog, NewCategoryEditHdl, Edit&, void)
+IMPL_LINK_NOARG(SfxTemplateCategoryDialog, NewCategoryEditHdl, weld::Entry&, void)
 {
-    OUString sParam = comphelper::string::strip(mpNewCategoryEdit->GetText(), ' ');
-    mpLBCategory->Enable(sParam.isEmpty());
+    OUString sParam = comphelper::string::strip(mxNewCategoryEdit->get_text(), ' ');
+    mxLBCategory->set_sensitive(sParam.isEmpty());
     if(!sParam.isEmpty())
     {
         msSelectedCategory = sParam;
         mbIsNewCategory = true;
-        mpOKButton->Enable();
+        mxOKButton->set_sensitive(true);
     }
     else
     {
-        SelectCategoryHdl(*mpLBCategory);
+        SelectCategoryHdl(*mxLBCategory);
         mbIsNewCategory = false;
     }
 }
 
-IMPL_LINK_NOARG(SfxTemplateCategoryDialog, SelectCategoryHdl, ListBox&, void)
+IMPL_LINK_NOARG(SfxTemplateCategoryDialog, SelectCategoryHdl, weld::TreeView&, void)
 {
-    if(mpLBCategory->GetSelectedEntryPos() == 0)
+    if (mxLBCategory->get_selected_index() == 0)
     {
         msSelectedCategory = OUString();
-        mpOKButton->Disable();
-        mpNewCategoryEdit->Enable();
+        mxOKButton->set_sensitive(false);
+        mxNewCategoryEdit->set_sensitive(true);
     }
     else
     {
-        msSelectedCategory = mpLBCategory->GetSelectedEntry();
-        mpNewCategoryEdit->Disable();
-        mpOKButton->Enable();
+        msSelectedCategory = mxLBCategory->get_selected();
+        mxNewCategoryEdit->set_sensitive(false);
+        mxOKButton->set_sensitive(true);
     }
 
     mbIsNewCategory = false;
@@ -1392,15 +1377,15 @@ void SfxTemplateCategoryDialog::SetCategoryLBEntries(std::vector<OUString> aFold
     if (!aFolderNames.empty())
     {
         for (size_t i = 0, n = aFolderNames.size(); i < n; ++i)
-            mpLBCategory->InsertEntry(aFolderNames[i], i+1);
+            mxLBCategory->append_text(aFolderNames[i]);
     }
-    mpLBCategory->SelectEntryPos(0);
+    mxLBCategory->select(0);
 }
 
 void SfxTemplateCategoryDialog::HideNewCategoryOption()
 {
-    mpCreateLabel->Hide();
-    mpNewCategoryEdit->Hide();
+    mxCreateLabel->hide();
+    mxNewCategoryEdit->hide();
 }
 
 // SfxTemplateSelectionDialog -----------------------------------------------------------------
diff --git a/sfx2/uiconfig/ui/templatecategorydlg.ui b/sfx2/uiconfig/ui/templatecategorydlg.ui
index 13012b48cb2f..908120a62908 100644
--- a/sfx2/uiconfig/ui/templatecategorydlg.ui
+++ b/sfx2/uiconfig/ui/templatecategorydlg.ui
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkListStore" id="categorylist">
     <columns>
-      <!-- column-name gchararray1 -->
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
       <column type="gchararray"/>
     </columns>
     <data>
@@ -19,6 +20,8 @@
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="templatecategorydlg|TemplatesCategoryDialog">Select Category</property>
     <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">normal</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
@@ -87,20 +90,24 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="margin_bottom">6</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
             <property name="row_spacing">12</property>
             <property name="column_spacing">12</property>
             <child>
               <object class="GtkBox" id="box1">
                 <property name="visible">True</property>
                 <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>
                   <object class="GtkLabel" id="select_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="templatecategorydlg|select_label">Select from Existing Category</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="normal"/>
                     </attributes>
@@ -112,15 +119,36 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkTreeView" id="categorylb:border">
-                    <property name="height_request">150</property>
-                    <property name="width_request">300</property>
+                  <object class="GtkScrolledWindow">
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="border_width">2</property>
-                    <property name="model">categorylist</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="categorylb">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="vexpand">True</property>
+                        <property name="model">categorylist</property>
+                        <property name="headers_visible">False</property>
+                        <property name="headers_clickable">False</property>
+                        <property name="search_column">0</property>
+                        <property name="show_expanders">False</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection1"/>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
                     </child>
                   </object>
                   <packing>
@@ -139,14 +167,15 @@
               <object class="GtkBox" id="box2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkLabel" id="create_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="templatecategorydlg|create_label">or Create a New Category</property>
+                    <property name="xalign">0</property>
                     <attributes>
                       <attribute name="weight" value="normal"/>
                     </attributes>
@@ -160,8 +189,8 @@
                 <child>
                   <object class="GtkEntry" id="category_entry">
                     <property name="visible">True</property>
-                    <property name="width_request">300</property>
                     <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -189,5 +218,8 @@
       <action-widget response="-5">ok</action-widget>
       <action-widget response="-6">cancel</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list