[Libreoffice-commits] core.git: sw/source sw/uiconfig

Caolán McNamara caolanm at redhat.com
Wed Apr 25 19:27:28 UTC 2018


 sw/source/ui/envelp/labprt.cxx             |  100 ++++++++++++-----------------
 sw/source/ui/envelp/labprt.hxx             |   23 +++---
 sw/uiconfig/swriter/ui/labeloptionspage.ui |   40 +++--------
 3 files changed, 65 insertions(+), 98 deletions(-)

New commits:
commit c31668c50fff0c7050cc176a7a5a83a08c670c12
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 23 09:10:08 2018 +0100

    weld SwLabPrtPage
    
    Change-Id: I64ae3826298ad210ec095256e4364b607684abca
    Reviewed-on: https://gerrit.libreoffice.org/53327
    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/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index faecd0ee8018..872f31d7f070 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -27,35 +27,31 @@
 
 #include <cmdid.h>
 
-SwLabPrtPage::SwLabPrtPage(vcl::Window* pParent, const SfxItemSet& rSet)
-    : SfxTabPage(pParent, "LabelOptionsPage",
-        "modules/swriter/ui/labeloptionspage.ui", &rSet)
+SwLabPrtPage::SwLabPrtPage(TabPageParent pParent, const SfxItemSet& rSet)
+    : SfxTabPage(pParent, "modules/swriter/ui/labeloptionspage.ui", "LabelOptionsPage", &rSet)
     , pPrinter(nullptr)
+    , m_xPageButton(m_xBuilder->weld_radio_button("entirepage"))
+    , m_xSingleButton(m_xBuilder->weld_radio_button("singlelabel"))
+    , m_xSingleGrid(m_xBuilder->weld_widget("singlegrid"))
+    , m_xPrinterFrame(m_xBuilder->weld_widget("printerframe"))
+    , m_xColField(m_xBuilder->weld_spin_button("cols"))
+    , m_xRowField(m_xBuilder->weld_spin_button("rows"))
+    , m_xSynchronCB(m_xBuilder->weld_check_button("synchronize"))
+    , m_xPrinterInfo(m_xBuilder->weld_label("printername"))
+    , m_xPrtSetup(m_xBuilder->weld_button("setup"))
 {
-    get(m_pPageButton, "entirepage");
-    get(m_pSingleButton, "singlelabel");
-    get(m_pSingleGrid, "singlegrid");
-    get(m_pColField, "cols");
-    get(m_pRowField, "rows");
-    get(m_pSynchronCB, "synchronize");
-    get(m_pPrinterFrame, "printerframe");
-    get(m_pPrinterInfo, "printername");
-    get(m_pPrtSetup, "setup");
     SetExchangeSupport();
 
     // Install handlers
-    Link<Button*,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
-    m_pPageButton->SetClickHdl( aLk );
-    m_pSingleButton->SetClickHdl( aLk );
-
-    m_pPrtSetup->SetClickHdl( aLk );
+    Link<weld::Button&,void> aLk = LINK(this, SwLabPrtPage, CountHdl);
+    m_xPageButton->connect_clicked( aLk );
+    m_xSingleButton->connect_clicked( aLk );
+    m_xPrtSetup->connect_clicked( aLk );
 
     SvtCommandOptions aCmdOpts;
-    if ( aCmdOpts.Lookup(
-             SvtCommandOptions::CMDOPTION_DISABLED,
-             "Print" ) )
+    if (aCmdOpts.Lookup(SvtCommandOptions::CMDOPTION_DISABLED, "Print"))
     {
-        m_pPrinterFrame->Hide();
+        m_xPrinterFrame->hide();
     }
 }
 
@@ -67,21 +63,12 @@ SwLabPrtPage::~SwLabPrtPage()
 void SwLabPrtPage::dispose()
 {
     pPrinter.disposeAndClear();
-    m_pPageButton.clear();
-    m_pSingleButton.clear();
-    m_pSingleGrid.clear();
-    m_pPrinterFrame.clear();
-    m_pColField.clear();
-    m_pRowField.clear();
-    m_pSynchronCB.clear();
-    m_pPrinterInfo.clear();
-    m_pPrtSetup.clear();
     SfxTabPage::dispose();
 }
 
-IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton, void )
+IMPL_LINK( SwLabPrtPage, CountHdl, weld::Button&, rButton, void )
 {
-    if (pButton == m_pPrtSetup)
+    if (&rButton == m_xPrtSetup.get())
     {
         // Call printer setup
         if (!pPrinter)
@@ -90,24 +77,24 @@ IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton, void )
         PrinterSetupDialog aDlg(GetFrameWeld());
         aDlg.SetPrinter(pPrinter);
         aDlg.execute();
-        GrabFocus();
-        m_pPrinterInfo->SetText(pPrinter->GetName());
+        rButton.grab_focus();
+        m_xPrinterInfo->set_label(pPrinter->GetName());
         return;
     }
-    const bool bEnable = pButton == m_pSingleButton;
-    m_pSingleGrid->Enable(bEnable);
-    m_pSynchronCB->Enable(!bEnable);
+    const bool bEnable = &rButton == m_xSingleButton.get();
+    m_xSingleGrid->set_sensitive(bEnable);
+    m_xSynchronCB->set_sensitive(!bEnable);
 
-    OSL_ENSURE(!bEnable || pButton == m_pPageButton, "NewButton?" );
+    OSL_ENSURE(!bEnable || &rButton == m_xPageButton.get(), "NewButton?" );
     if ( bEnable )
     {
-        m_pColField->GrabFocus();
+        m_xColField->grab_focus();
     }
 }
 
 VclPtr<SfxTabPage> SwLabPrtPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
 {
-    return VclPtr<SwLabPrtPage>::Create( pParent.pParent, *rSet );
+    return VclPtr<SwLabPrtPage>::Create(pParent, *rSet );
 }
 
 void SwLabPrtPage::ActivatePage( const SfxItemSet& rSet )
@@ -125,10 +112,10 @@ DeactivateRC SwLabPrtPage::DeactivatePage(SfxItemSet* _pSet)
 
 void SwLabPrtPage::FillItem(SwLabItem& rItem)
 {
-    rItem.m_bPage = m_pPageButton->IsChecked();
-    rItem.m_nCol = static_cast<sal_Int32>(m_pColField->GetValue());
-    rItem.m_nRow = static_cast<sal_Int32>(m_pRowField->GetValue());
-    rItem.m_bSynchron = m_pSynchronCB->IsChecked() && m_pSynchronCB->IsEnabled();
+    rItem.m_bPage = m_xPageButton->get_active();
+    rItem.m_nCol = m_xColField->get_value();
+    rItem.m_nRow = m_xRowField->get_value();
+    rItem.m_bSynchron = m_xSynchronCB->get_active() && m_xSynchronCB->get_sensitive();
 }
 
 bool SwLabPrtPage::FillItemSet(SfxItemSet* rSet)
@@ -146,35 +133,32 @@ void SwLabPrtPage::Reset(const SfxItemSet* )
     SwLabItem aItem;
     GetParentSwLabDlg()->GetLabItem(aItem);
 
-    m_pColField->SetValue   (aItem.m_nCol);
-    m_pRowField->SetValue   (aItem.m_nRow);
+    m_xColField->set_value(aItem.m_nCol);
+    m_xRowField->set_value(aItem.m_nRow);
 
     if (aItem.m_bPage)
     {
-        m_pPageButton->Check();
-        m_pPageButton->GetClickHdl().Call(m_pPageButton);
+        m_xPageButton->set_active(true);
+        CountHdl(*m_xPageButton);
     }
     else
     {
-        m_pSingleButton->GetClickHdl().Call(m_pSingleButton);
-        m_pSingleButton->Check();
+        CountHdl(*m_xSingleButton);
+        m_xSingleButton->set_active(true);
     }
 
     if (pPrinter)
     {
         // show printer
-        m_pPrinterInfo->SetText(pPrinter->GetName());
+        m_xPrinterInfo->set_label(pPrinter->GetName());
     }
     else
-        m_pPrinterInfo->SetText(Printer::GetDefaultPrinterName());
-
-    m_pColField->SetMax(aItem.m_nCols);
-    m_pRowField->SetMax(aItem.m_nRows);
+        m_xPrinterInfo->set_label(Printer::GetDefaultPrinterName());
 
-    m_pColField->SetLast(m_pColField->GetMax());
-    m_pRowField->SetLast(m_pRowField->GetMax());
+    m_xColField->set_max(aItem.m_nCols);
+    m_xRowField->set_max(aItem.m_nRows);
 
-    m_pSynchronCB->Check(aItem.m_bSynchron);
+    m_xSynchronCB->set_active(aItem.m_bSynchron);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/envelp/labprt.hxx b/sw/source/ui/envelp/labprt.hxx
index 500f2c40332c..d4dc36d0dfab 100644
--- a/sw/source/ui/envelp/labprt.hxx
+++ b/sw/source/ui/envelp/labprt.hxx
@@ -32,18 +32,17 @@ class SwLabPrtPage : public SfxTabPage
 {
     VclPtr<Printer>      pPrinter; // for the shaft setting - unfortunately
 
-    VclPtr<RadioButton>  m_pPageButton;
-    VclPtr<RadioButton>  m_pSingleButton;
-    VclPtr<VclContainer> m_pSingleGrid;
-    VclPtr<VclContainer> m_pPrinterFrame;
-    VclPtr<NumericField> m_pColField;
-    VclPtr<NumericField> m_pRowField;
-    VclPtr<CheckBox>     m_pSynchronCB;
+    std::unique_ptr<weld::RadioButton>  m_xPageButton;
+    std::unique_ptr<weld::RadioButton>  m_xSingleButton;
+    std::unique_ptr<weld::Widget> m_xSingleGrid;
+    std::unique_ptr<weld::Widget> m_xPrinterFrame;
+    std::unique_ptr<weld::SpinButton> m_xColField;
+    std::unique_ptr<weld::SpinButton> m_xRowField;
+    std::unique_ptr<weld::CheckButton>  m_xSynchronCB;
+    std::unique_ptr<weld::Label>  m_xPrinterInfo;
+    std::unique_ptr<weld::Button> m_xPrtSetup;
 
-    VclPtr<FixedText>    m_pPrinterInfo;
-    VclPtr<PushButton>   m_pPrtSetup;
-
-    DECL_LINK( CountHdl, Button *, void );
+    DECL_LINK( CountHdl, weld::Button&, void );
 
     SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetTabDialog());}
 
@@ -51,7 +50,7 @@ class SwLabPrtPage : public SfxTabPage
     using TabPage::DeactivatePage;
 
 public:
-    SwLabPrtPage(vcl::Window* pParent, const SfxItemSet& rSet);
+    SwLabPrtPage(TabPageParent pParent, const SfxItemSet& rSet);
     virtual ~SwLabPrtPage() override;
     virtual void dispose() override;
 
diff --git a/sw/uiconfig/swriter/ui/labeloptionspage.ui b/sw/uiconfig/swriter/ui/labeloptionspage.ui
index 07128b489ab0..f9cb8ec893dd 100644
--- a/sw/uiconfig/swriter/ui/labeloptionspage.ui
+++ b/sw/uiconfig/swriter/ui/labeloptionspage.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
 <interface domain="sw">
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
   <object class="GtkAdjustment" id="adjustment1">
     <property name="lower">1</property>
     <property name="upper">100</property>
@@ -8,6 +9,12 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
+  <object class="GtkAdjustment" id="adjustment2">
+    <property name="lower">1</property>
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkBox" id="LabelOptionsPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -42,13 +49,11 @@
                     <property name="xalign">0</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
-                    <property name="group">singlelabel</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
                     <property name="width">2</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -66,8 +71,6 @@
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -84,16 +87,14 @@
                           <object class="GtkLabel" id="label4">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
                             <property name="label" translatable="yes" context="labeloptionspage|label4">Colu_mn</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">cols</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
                             <property name="left_attach">0</property>
                             <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
                           </packing>
                         </child>
                         <child>
@@ -105,16 +106,12 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
                         <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
                       </packing>
                     </child>
                     <child>
@@ -126,45 +123,37 @@
                           <object class="GtkLabel" id="label5">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
                             <property name="label" translatable="yes" context="labeloptionspage|label5">Ro_w</property>
                             <property name="use_underline">True</property>
                             <property name="mnemonic_widget">rows</property>
+                            <property name="xalign">0</property>
                           </object>
                           <packing>
                             <property name="left_attach">0</property>
                             <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
                           </packing>
                         </child>
                         <child>
                           <object class="GtkSpinButton" id="rows">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="adjustment">adjustment1</property>
+                            <property name="adjustment">adjustment2</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">1</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -181,7 +170,6 @@
                     <property name="left_attach">0</property>
                     <property name="top_attach">2</property>
                     <property name="width">2</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
               </object>
@@ -236,8 +224,6 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
                 <child>
@@ -245,16 +231,14 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="hexpand">True</property>
-                    <property name="xalign">0</property>
                     <property name="label" translatable="yes" context="labeloptionspage|printername">Printer Name</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">setup</property>
+                    <property name="xalign">0</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
                     <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
                   </packing>
                 </child>
               </object>


More information about the Libreoffice-commits mailing list