sw/source/ui/misc/outline.cxx                 |   93 ++++++++++----------------
 sw/uiconfig/swriter/ui/numberingnamedialog.ui |   56 ++++++++++++---
 2 files changed, 83 insertions(+), 66 deletions(-)

New commits:
commit 3a29d1a53d7ed362a8b420650c0046f30e4759ed
Author: Caolán McNamara <caol...@redhat.com>
Date:   Sat Apr 28 21:19:05 2018 +0100

    weld SwNumNamesDlg
    
    Change-Id: Ife0b7b7c996a5764040a33991cf83ba7e28a6e40
    Reviewed-on: https://gerrit.libreoffice.org/53611
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index ab00ae40cd09..7fb4fd8a9d95 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -55,44 +55,28 @@
 
 using namespace ::com::sun::star;
 
-class SwNumNamesDlg : public ModalDialog
+class SwNumNamesDlg : public weld::GenericDialogController
 {
-    VclPtr<Edit>     m_pFormEdit;
-    VclPtr<ListBox>  m_pFormBox;
-    VclPtr<OKButton> m_pOKBtn;
+    std::unique_ptr<weld::Entry> m_xFormEdit;
+    std::unique_ptr<weld::TreeView> m_xFormBox;
+    std::unique_ptr<weld::Button> m_xOKBtn;
 
-    DECL_LINK( ModifyHdl, Edit&, void );
-    DECL_LINK( SelectHdl, ListBox&, void );
-    DECL_LINK( DoubleClickHdl, ListBox&, void );
+    DECL_LINK( ModifyHdl, weld::Entry&, void );
+    DECL_LINK( SelectHdl, weld::TreeView&, void );
+    DECL_LINK( DoubleClickHdl, weld::TreeView&, void );
 
 public:
-    explicit SwNumNamesDlg(vcl::Window *pParent);
-    virtual ~SwNumNamesDlg() override;
-    virtual void dispose() override;
+    explicit SwNumNamesDlg(weld::Window *pParent);
     void SetUserNames(const OUString *pList[]);
-    OUString GetName() const { return m_pFormEdit->GetText(); }
-    sal_Int32 GetCurEntryPos() const { return 
m_pFormBox->GetSelectedEntryPos(); }
+    OUString GetName() const { return m_xFormEdit->get_text(); }
+    int GetCurEntryPos() const { return m_xFormBox->get_selected_index(); }
 };
 
-SwNumNamesDlg::~SwNumNamesDlg()
-{
-    disposeOnce();
-}
-
-void SwNumNamesDlg::dispose()
-{
-    m_pFormEdit.clear();
-    m_pFormBox.clear();
-    m_pOKBtn.clear();
-    ModalDialog::dispose();
-}
-
-
 // remember selected entry
-IMPL_LINK( SwNumNamesDlg, SelectHdl, ListBox&, rBox, void )
+IMPL_LINK( SwNumNamesDlg, SelectHdl, weld::TreeView&, rBox, void )
 {
-    m_pFormEdit->SetText(rBox.GetSelectedEntry());
-    m_pFormEdit->SetSelection(Selection(0, SELECTION_MAX));
+    m_xFormEdit->set_text(rBox.get_selected());
+    m_xFormEdit->select_region(0, -1);
 }
 
 /** set user defined names
@@ -106,40 +90,41 @@ void SwNumNamesDlg::SetUserNames(const OUString *pList[])
     {
         if(pList[i])
         {
-            m_pFormBox->RemoveEntry(i);
-            m_pFormBox->InsertEntry(*pList[i], i);
+            m_xFormBox->remove(i);
+            m_xFormBox->insert_text(*pList[i], i);
             if (i == nSelect && nSelect < SwChapterNumRules::nMaxRules)
                 nSelect++;
         }
     }
-    m_pFormBox->SelectEntryPos(nSelect);
-    SelectHdl(*m_pFormBox);
+    m_xFormBox->select(nSelect);
+    SelectHdl(*m_xFormBox);
 }
 
 // unlock OK-Button when text is in Edit
-IMPL_LINK( SwNumNamesDlg, ModifyHdl, Edit&, rBox, void )
+IMPL_LINK( SwNumNamesDlg, ModifyHdl, weld::Entry&, rBox, void )
 {
-    m_pOKBtn->Enable(!rBox.GetText().isEmpty());
+    m_xOKBtn->set_sensitive(!rBox.get_text().isEmpty());
 }
 
 // DoubleClickHdl
-IMPL_LINK_NOARG(SwNumNamesDlg, DoubleClickHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwNumNamesDlg, DoubleClickHdl, weld::TreeView&, void)
 {
-    EndDialog(RET_OK);
+    m_xDialog->response(RET_OK);
 }
 
-SwNumNamesDlg::SwNumNamesDlg(vcl::Window *pParent)
-    : ModalDialog(pParent, "NumberingNameDialog",
-        "modules/swriter/ui/numberingnamedialog.ui")
+SwNumNamesDlg::SwNumNamesDlg(weld::Window *pParent)
+    : weld::GenericDialogController(pParent,
+            "modules/swriter/ui/numberingnamedialog.ui",
+            "NumberingNameDialog")
+    , m_xFormEdit(m_xBuilder->weld_entry("entry"))
+    , m_xFormBox(m_xBuilder->weld_tree_view("form"))
+    , m_xOKBtn(m_xBuilder->weld_button("ok"))
 {
-    get(m_pFormEdit, "entry");
-    get(m_pFormBox, "form");
-    m_pFormBox->SetDropDownLineCount(5);
-    get(m_pOKBtn, "ok");
-    m_pFormEdit->SetModifyHdl(LINK(this, SwNumNamesDlg, ModifyHdl));
-    m_pFormBox->SetSelectHdl(LINK(this, SwNumNamesDlg, SelectHdl));
-    m_pFormBox->SetDoubleClickHdl(LINK(this, SwNumNamesDlg, DoubleClickHdl));
-    SelectHdl(*m_pFormBox);
+    m_xFormEdit->connect_changed(LINK(this, SwNumNamesDlg, ModifyHdl));
+    m_xFormBox->connect_changed(LINK(this, SwNumNamesDlg, SelectHdl));
+    m_xFormBox->connect_row_activated(LINK(this, SwNumNamesDlg, 
DoubleClickHdl));
+    m_xFormBox->set_size_request(-1, m_xFormBox->get_height_rows(9));
+    SelectHdl(*m_xFormBox);
 }
 
 static sal_uInt16 lcl_BitToLevel(sal_uInt16 nActLevel)
@@ -276,7 +261,7 @@ IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, 
pMenu, bool )
         nLevelNo = 9;
     else if (sIdent == "saveas")
     {
-        VclPtrInstance< SwNumNamesDlg > pDlg(this);
+        SwNumNamesDlg aDlg(GetFrameWeld());
         const OUString *aStrArr[SwChapterNumRules::nMaxRules];
         for(sal_uInt16 i = 0; i < SwChapterNumRules::nMaxRules; ++i)
         {
@@ -286,13 +271,13 @@ IMPL_LINK( SwOutlineTabDialog, MenuSelectHdl, Menu *, 
pMenu, bool )
             else
                 aStrArr[i] = nullptr;
         }
-        pDlg->SetUserNames(aStrArr);
-        if(RET_OK == pDlg->Execute())
+        aDlg.SetUserNames(aStrArr);
+        if (aDlg.run() == RET_OK)
         {
-            const OUString aName(pDlg->GetName());
+            const OUString aName(aDlg.GetName());
             pChapterNumRules->ApplyNumRules( SwNumRulesWithName(
-                    *xNumRule, aName ), pDlg->GetCurEntryPos() );
-            pMenu->SetItemText(pMenu->GetItemId(pDlg->GetCurEntryPos()), 
aName);
+                    *xNumRule, aName ), aDlg.GetCurEntryPos() );
+            pMenu->SetItemText(pMenu->GetItemId(aDlg.GetCurEntryPos()), aName);
         }
         return false;
     }
diff --git a/sw/uiconfig/swriter/ui/numberingnamedialog.ui 
b/sw/uiconfig/swriter/ui/numberingnamedialog.ui
index 32c785c50948..003f0bf082f2 100644
--- a/sw/uiconfig/swriter/ui/numberingnamedialog.ui
+++ b/sw/uiconfig/swriter/ui/numberingnamedialog.ui
@@ -4,7 +4,9 @@
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkListStore" id="liststore1">
     <columns>
-      <!-- column-name gchararray1 -->
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
       <column type="gchararray"/>
     </columns>
     <data>
@@ -134,14 +136,37 @@
                     <property name="row_spacing">6</property>
                     <property name="column_spacing">12</property>
                     <child>
-                      <object class="GtkTreeView" id="form:border">
+                      <object class="GtkScrolledWindow">
                         <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>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" 
id="treeview-selection1"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="form">
+                            <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="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>
@@ -153,6 +178,7 @@
                       <object class="GtkEntry" id="entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
+                        <property name="activates_default">True</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
commit 8952840ce752893f6195262a5dfa57a4dcc6d983
Author: Caolán McNamara <caol...@redhat.com>
Date:   Sat Apr 28 15:53:53 2018 +0100

    flip numberingnamedialog action area orientation to standard
    
    Change-Id: I682ff6b50244bda9ba148ffe48dd26e2ff69cb0e
    Reviewed-on: https://gerrit.libreoffice.org/53610
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/uiconfig/swriter/ui/numberingnamedialog.ui 
b/sw/uiconfig/swriter/ui/numberingnamedialog.ui
index da12ce7bfe14..32c785c50948 100644
--- a/sw/uiconfig/swriter/ui/numberingnamedialog.ui
+++ b/sw/uiconfig/swriter/ui/numberingnamedialog.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.18"/>
   <object class="GtkListStore" id="liststore1">
     <columns>
       <!-- column-name gchararray1 -->
@@ -40,16 +41,19 @@
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" 
context="numberingnamedialog|NumberingNameDialog">Save As</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="orientation">vertical</property>
-            <property name="layout_style">start</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="ok">
                 <property name="label">gtk-ok</property>
@@ -63,6 +67,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
+                <property name="pack_type">end</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -77,6 +82,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
+                <property name="pack_type">end</property>
                 <property name="position">1</property>
               </packing>
             </child>
@@ -92,6 +98,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -140,8 +147,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>
@@ -152,8 +157,6 @@
                       <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>
@@ -184,5 +187,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to