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

Caolán McNamara caolanm at redhat.com
Mon Mar 5 10:49:37 UTC 2018


 cui/source/dialogs/scriptdlg.cxx |   62 ++++++++-------------
 cui/source/inc/scriptdlg.hxx     |   19 +++---
 cui/uiconfig/ui/newlibdialog.ui  |  113 ++++++++++++++++++---------------------
 3 files changed, 88 insertions(+), 106 deletions(-)

New commits:
commit ffd64fcc62937e8cfda1eb2146af4893cbf29ec5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 5 09:32:29 2018 +0000

    weld CuiInputDialog
    
    Change-Id: I121ac0ffa1f6c28bb305c90e89ba28f276da52f1
    Reviewed-on: https://gerrit.libreoffice.org/50765
    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/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index c219b6f56ef6..f52317edec7c 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -403,46 +403,34 @@ void SFTreeListBox::ExpandedHdl()
 {
 }
 
-
 // CuiInputDialog ------------------------------------------------------------
-
-CuiInputDialog::CuiInputDialog(vcl::Window * pParent, InputDialogMode nMode )
-    : ModalDialog(pParent, "NewLibDialog",
-        "cui/ui/newlibdialog.ui")
+CuiInputDialog::CuiInputDialog(weld::Window * pParent, InputDialogMode nMode)
+    : m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/newlibdialog.ui"))
+    , m_xDialog(m_xBuilder->weld_dialog("NewLibDialog"))
+    , m_xEdit(m_xBuilder->weld_entry("entry"))
 {
-    get(m_pEdit, "entry");
-    m_pEdit->GrabFocus();
+    m_xEdit->grab_focus();
 
-    FixedText *pNewLibFT = get<FixedText>("newlibft");
+    std::unique_ptr<weld::Label> xNewLibFT(m_xBuilder->weld_label("newlibft"));
 
     if ( nMode == InputDialogMode::NEWMACRO )
     {
-        pNewLibFT->Hide();
-        FixedText *pNewMacroFT = get<FixedText>("newmacroft");
-        pNewMacroFT->Show();
-        SetText(get<FixedText>("altmacrotitle")->GetText());
+        xNewLibFT->hide();
+        std::unique_ptr<weld::Label> xNewMacroFT(m_xBuilder->weld_label("newmacroft"));
+        xNewMacroFT->show();
+        std::unique_ptr<weld::Label> xAltTitle(m_xBuilder->weld_label("altmacrotitle"));
+        m_xDialog->set_title(xAltTitle->get_label());
     }
     else if ( nMode == InputDialogMode::RENAME )
     {
-        pNewLibFT->Hide();
-        FixedText *pRenameFT = get<FixedText>("renameft");
-        pRenameFT->Show();
-        SetText(get<FixedText>("altrenametitle")->GetText());
+        xNewLibFT->hide();
+        std::unique_ptr<weld::Label> xRenameFT(m_xBuilder->weld_label("renameft"));
+        xRenameFT->show();
+        std::unique_ptr<weld::Label> xAltTitle(m_xBuilder->weld_label("altrenametitle"));
+        m_xDialog->set_title(xAltTitle->get_label());
     }
 }
 
-CuiInputDialog::~CuiInputDialog()
-{
-    disposeOnce();
-}
-
-void CuiInputDialog::dispose()
-{
-    m_pEdit.clear();
-    ModalDialog::dispose();
-}
-
-
 // ScriptOrgDialog ------------------------------------------------------------
 
 SvxScriptOrgDialog::SvxScriptOrgDialog( vcl::Window* pParent, const OUString& language )
@@ -881,14 +869,14 @@ void SvxScriptOrgDialog::createEntry( SvTreeListEntry* pEntry )
             }
         }
 
-        ScopedVclPtrInstance< CuiInputDialog > xNewDlg( static_cast<vcl::Window*>(this), nMode );
-        xNewDlg->SetObjectName( aNewName );
+        CuiInputDialog aNewDlg(GetFrameWeld(), nMode);
+        aNewDlg.SetObjectName(aNewName);
 
         do
         {
-            if ( xNewDlg->Execute() && !xNewDlg->GetObjectName().isEmpty() )
+            if (aNewDlg.run() && !aNewDlg.GetObjectName().isEmpty())
             {
-                OUString aUserSuppliedName = xNewDlg->GetObjectName();
+                OUString aUserSuppliedName = aNewDlg.GetObjectName();
                 bValid = true;
                 for( sal_Int32 index = 0; index < childNodes.getLength(); index++ )
                 {
@@ -901,7 +889,7 @@ void SvxScriptOrgDialog::createEntry( SvTreeListEntry* pEntry )
                                                                        VclMessageType::Warning, VclButtonsType::Ok, aError));
                         xErrorBox->set_title(m_createErrTitleStr);
                         xErrorBox->run();
-                        xNewDlg->SetObjectName( aNewName );
+                        aNewDlg.SetObjectName(aNewName);
                         break;
                     }
                 }
@@ -1002,13 +990,13 @@ void SvxScriptOrgDialog::renameEntry( SvTreeListEntry* pEntry )
             extn = aNewName.copy(extnPos);
             aNewName = aNewName.copy(0,extnPos);
         }
-        ScopedVclPtrInstance< CuiInputDialog > xNewDlg( static_cast<vcl::Window*>(this), InputDialogMode::RENAME );
-        xNewDlg->SetObjectName( aNewName );
+        CuiInputDialog aNewDlg(GetFrameWeld(), InputDialogMode::RENAME);
+        aNewDlg.SetObjectName(aNewName);
 
-        if ( !xNewDlg->Execute() || xNewDlg->GetObjectName().isEmpty() )
+        if (!aNewDlg.run() || aNewDlg.GetObjectName().isEmpty())
             return; // user hit cancel or hit OK with nothing in the editbox
 
-        aNewName = xNewDlg->GetObjectName();
+        aNewName = aNewDlg.GetObjectName();
 
         Sequence< Any > args( 1 );
         args[ 0 ] <<= aNewName;
diff --git a/cui/source/inc/scriptdlg.hxx b/cui/source/inc/scriptdlg.hxx
index 0b80c7b06330..2b86a9ea515a 100644
--- a/cui/source/inc/scriptdlg.hxx
+++ b/cui/source/inc/scriptdlg.hxx
@@ -26,6 +26,7 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/abstdlg.hxx>
+#include <vcl/weld.hxx>
 #include <sfx2/basedlgs.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
@@ -91,20 +92,20 @@ enum class InputDialogMode {
     RENAME        = 3,
 };
 
-class CuiInputDialog : public ModalDialog
+class CuiInputDialog
 {
 private:
-    VclPtr<Edit> m_pEdit;
+    std::unique_ptr<weld::Builder> m_xBuilder;
+    std::unique_ptr<weld::Dialog> m_xDialog;
+    std::unique_ptr<weld::Entry> m_xEdit;
 public:
-    CuiInputDialog(vcl::Window * pParent, InputDialogMode nMode);
-    virtual ~CuiInputDialog() override;
-    virtual void dispose() override;
-
-    OUString GetObjectName() const { return m_pEdit->GetText(); }
+    CuiInputDialog(weld::Window * pParent, InputDialogMode nMode);
+    short run() { return m_xDialog->run(); }
+    OUString GetObjectName() const { return m_xEdit->get_text(); }
     void SetObjectName(const OUString& rName)
     {
-        m_pEdit->SetText( rName );
-        m_pEdit->SetSelection( Selection( 0, rName.getLength() ) );
+        m_xEdit->set_text(rName);
+        m_xEdit->select_region(0, -1);
     }
 };
 
diff --git a/cui/uiconfig/ui/newlibdialog.ui b/cui/uiconfig/ui/newlibdialog.ui
index ec55af512af9..563598662980 100644
--- a/cui/uiconfig/ui/newlibdialog.ui
+++ b/cui/uiconfig/ui/newlibdialog.ui
@@ -1,17 +1,62 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.0 on Sat Jan  4 16:52:18 2014 -->
+<!-- Generated with glade 3.20.2 -->
 <interface domain="cui">
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
   <object class="GtkDialog" id="NewLibDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="newlibdialog|NewLibDialog">Create Library</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">
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="ok">
+                <property name="label">gtk-ok</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
         <child>
           <object class="GtkGrid" id="grid3">
             <property name="visible">True</property>
@@ -19,21 +64,18 @@
             <property name="hexpand">True</property>
             <property name="row_spacing">6</property>
             <property name="column_spacing">12</property>
-            <property name="row_homogeneous">True</property>
             <child>
               <object class="GtkLabel" id="newlibft">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="newlibdialog|newlibft">Enter the name for the new library.</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">entry</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>
@@ -45,40 +87,34 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkLabel" id="newmacroft">
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="newlibdialog|newmacroft">Enter the name for the new macro.</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">entry</property>
+                <property name="xalign">0</property>
               </object>
               <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>
               <object class="GtkLabel" id="renameft">
                 <property name="can_focus">False</property>
                 <property name="no_show_all">True</property>
-                <property name="xalign">0</property>
                 <property name="label" translatable="yes" context="newlibdialog|renameft">Enter the new name for the selected object.</property>
                 <property name="use_underline">True</property>
                 <property name="mnemonic_widget">entry</property>
+                <property name="xalign">0</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -91,8 +127,6 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">4</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -105,8 +139,6 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">5</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
           </object>
@@ -116,53 +148,14 @@
             <property name="position">0</property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="ok">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancel">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
       </object>
     </child>
     <action-widgets>
       <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