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

Caolán McNamara caolanm at redhat.com
Sat Apr 14 13:16:50 UTC 2018


 include/vcl/weld.hxx                           |    1 
 sw/source/uibase/utlui/gloslst.cxx             |   72 ++++++++++---------------
 sw/uiconfig/swriter/ui/selectautotextdialog.ui |   47 ++++++++++++++--
 3 files changed, 74 insertions(+), 46 deletions(-)

New commits:
commit 7d99b161852b4da3b5a2f97efe629d4f7c3a52e9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Apr 13 17:46:42 2018 +0100

    weld SwGlossDecideDlg
    
    Change-Id: I34a90e842d0b7d5635879e52e9ffb56239aebac2
    Reviewed-on: https://gerrit.libreoffice.org/52848
    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/vcl/weld.hxx b/include/vcl/weld.hxx
index 160512969950..97bea2941fac 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -732,6 +732,7 @@ public:
     static bool runAsync(const std::shared_ptr<DialogController>& rController,
                          const std::function<void(sal_Int32)>&);
     void set_title(const OUString& rTitle) { getDialog()->set_title(rTitle); }
+    OUString get_title() const { return getConstDialog()->get_title(); }
     void set_help_id(const OString& rHelpId) { getDialog()->set_help_id(rHelpId); }
     OString get_help_id() const { return getConstDialog()->get_help_id(); }
     virtual ~DialogController();
diff --git a/sw/source/uibase/utlui/gloslst.cxx b/sw/source/uibase/utlui/gloslst.cxx
index 0d1662e039de..5501394c9440 100644
--- a/sw/source/uibase/utlui/gloslst.cxx
+++ b/sw/source/uibase/utlui/gloslst.cxx
@@ -22,6 +22,7 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/lstbox.hxx>
+#include <vcl/weld.hxx>
 #include <svl/fstathelper.hxx>
 #include <unotools/pathoptions.hxx>
 #include <unotools/transliterationwrapper.hxx>
@@ -32,6 +33,7 @@
 #include <glosdoc.hxx>
 #include <gloslst.hxx>
 #include <swunohelper.hxx>
+#include <view.hxx>
 
 #include <vector>
 
@@ -48,53 +50,39 @@ struct TripleString
     OUString sShort;
 };
 
-class SwGlossDecideDlg : public ModalDialog
+class SwGlossDecideDlg : public weld::GenericDialogController
 {
-    VclPtr<OKButton> m_pOk;
-    VclPtr<ListBox>  m_pListLB;
+    std::unique_ptr<weld::Button> m_xOk;
+    std::unique_ptr<weld::TreeView> m_xListLB;
 
-    DECL_LINK(DoubleClickHdl, ListBox&, void);
-    DECL_LINK(SelectHdl, ListBox&, void);
+    DECL_LINK(DoubleClickHdl, weld::TreeView&, void);
+    DECL_LINK(SelectHdl, weld::TreeView&, void);
 
 public:
-    explicit SwGlossDecideDlg(vcl::Window* pParent);
-    virtual ~SwGlossDecideDlg() override;
-    virtual void dispose() override;
+    explicit SwGlossDecideDlg(weld::Window* pParent);
 
-    ListBox&    GetListBox() {return *m_pListLB;}
+    weld::TreeView& GetTreeView() {return *m_xListLB;}
 };
 
-SwGlossDecideDlg::SwGlossDecideDlg(vcl::Window* pParent)
-    : ModalDialog(pParent, "SelectAutoTextDialog",
-        "modules/swriter/ui/selectautotextdialog.ui")
+SwGlossDecideDlg::SwGlossDecideDlg(weld::Window* pParent)
+    : GenericDialogController(pParent, "modules/swriter/ui/selectautotextdialog.ui", "SelectAutoTextDialog")
+    , m_xOk(m_xBuilder->weld_button("ok"))
+    , m_xListLB(m_xBuilder->weld_tree_view("treeview"))
 {
-    get(m_pOk, "ok");
-    get(m_pListLB, "treeview");
-    m_pListLB->set_height_request(m_pListLB->GetTextHeight() * 10);
-    m_pListLB->SetDoubleClickHdl(LINK(this, SwGlossDecideDlg, DoubleClickHdl));
-    m_pListLB->SetSelectHdl(LINK(this, SwGlossDecideDlg, SelectHdl));
+    m_xListLB->set_size_request(m_xListLB->get_approximate_digit_width() * 32,
+                                m_xListLB->get_height_rows(8));
+    m_xListLB->connect_row_activated(LINK(this, SwGlossDecideDlg, DoubleClickHdl));
+    m_xListLB->connect_changed(LINK(this, SwGlossDecideDlg, SelectHdl));
 }
 
-SwGlossDecideDlg::~SwGlossDecideDlg()
+IMPL_LINK_NOARG(SwGlossDecideDlg, DoubleClickHdl, weld::TreeView&, void)
 {
-    disposeOnce();
+    m_xDialog->response(RET_OK);
 }
 
-void SwGlossDecideDlg::dispose()
+IMPL_LINK_NOARG(SwGlossDecideDlg, SelectHdl, weld::TreeView&, void)
 {
-    m_pOk.clear();
-    m_pListLB.clear();
-    ModalDialog::dispose();
-}
-
-IMPL_LINK_NOARG(SwGlossDecideDlg, DoubleClickHdl, ListBox&, void)
-{
-    EndDialog(RET_OK);
-}
-
-IMPL_LINK_NOARG(SwGlossDecideDlg, SelectHdl, ListBox&, void)
-{
-    m_pOk->Enable(LISTBOX_ENTRY_NOTFOUND != m_pListLB->GetSelectedEntryPos());
+    m_xOk->set_sensitive(m_xListLB->get_selected_index() != -1);
 }
 
 SwGlossaryList::SwGlossaryList() :
@@ -155,19 +143,19 @@ bool SwGlossaryList::GetShortName(const OUString& rLongName,
     }
     else if(1 < nCount)
     {
-        ScopedVclPtrInstance< SwGlossDecideDlg > aDlg(nullptr);
-        OUString sTitle = aDlg->GetText() + " " + aTripleStrings.front().sBlock;
-        aDlg->SetText(sTitle);
+        SwView *pView  = ::GetActiveView();
+        SwGlossDecideDlg aDlg(pView ? pView->GetFrameWeld() : nullptr);
+        OUString sTitle = aDlg.get_title() + " " + aTripleStrings.front().sBlock;
+        aDlg.set_title(sTitle);
 
-        ListBox& rLB = aDlg->GetListBox();
+        weld::TreeView& rLB = aDlg.GetTreeView();
         for(std::vector<TripleString>::const_iterator i = aTripleStrings.begin(); i != aTripleStrings.end(); ++i)
-            rLB.InsertEntry(i->sGroup.getToken(0, GLOS_DELIM));
+            rLB.append_text(i->sGroup.getToken(0, GLOS_DELIM));
 
-        rLB.SelectEntryPos(0);
-        if(RET_OK == aDlg->Execute() &&
-            LISTBOX_ENTRY_NOTFOUND != rLB.GetSelectedEntryPos())
+        rLB.select(0);
+        if (aDlg.run() == RET_OK && rLB.get_selected_index() != -1)
         {
-            const TripleString& rTriple(aTripleStrings[rLB.GetSelectedEntryPos()]);
+            const TripleString& rTriple(aTripleStrings[rLB.get_selected_index()]);
             rShortName = rTriple.sShort;
             rGroupName = rTriple.sGroup;
             bRet = true;
diff --git a/sw/uiconfig/swriter/ui/selectautotextdialog.ui b/sw/uiconfig/swriter/ui/selectautotextdialog.ui
index 85c1a977b632..9f465a86ecd4 100644
--- a/sw/uiconfig/swriter/ui/selectautotextdialog.ui
+++ b/sw/uiconfig/swriter/ui/selectautotextdialog.ui
@@ -1,10 +1,22 @@
 <?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="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="SelectAutoTextDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="selectautotextdialog|SelectAutoTextDialog">Select AutoText:</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">
@@ -57,6 +69,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -82,13 +95,36 @@
                 <property name="top_padding">6</property>
                 <property name="left_padding">12</property>
                 <child>
-                  <object class="GtkTreeView" id="treeview: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>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">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>
                 </child>
@@ -118,5 +154,8 @@
       <action-widget response="-6">cancel</action-widget>
       <action-widget response="-11">help</action-widget>
     </action-widgets>
+    <child>
+      <placeholder/>
+    </child>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list