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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 20 21:10:44 UTC 2019


 svx/source/dialog/docrecovery.cxx        |   33 ++++-----------
 svx/source/inc/docrecovery.hxx           |   48 +++++++++++-----------
 svx/source/unodraw/recoveryui.cxx        |    5 --
 svx/uiconfig/ui/docrecoverysavedialog.ui |   65 +++++++++++++++++++++++++++----
 4 files changed, 94 insertions(+), 57 deletions(-)

New commits:
commit 45980b72480c4331f0884d8a0c7ef59e757e7aa6
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Sep 30 11:44:05 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Feb 20 22:10:11 2019 +0100

    weld SaveDialog
    
    Change-Id: Iaef35328c0657a4538d4b4a44734146baee0346b
    Reviewed-on: https://gerrit.libreoffice.org/61153
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index baaaa04db053..accb44c5172d 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -646,52 +646,39 @@ void SAL_CALL WeldPluginProgress::reset()
         m_pProgressBar->set_percentage(0);
 }
 
-SaveDialog::SaveDialog(vcl::Window* pParent, RecoveryCore* pCore)
-    : Dialog(pParent, "DocRecoverySaveDialog",
-        "svx/ui/docrecoverysavedialog.ui")
+SaveDialog::SaveDialog(weld::Window* pParent, RecoveryCore* pCore)
+    : GenericDialogController(pParent, "svx/ui/docrecoverysavedialog.ui", "DocRecoverySaveDialog")
     , m_pCore(pCore)
+    , m_xFileListLB(m_xBuilder->weld_tree_view("filelist"))
+    , m_xOkBtn(m_xBuilder->weld_button("ok"))
 {
-    get(m_pFileListLB, "filelist");
-    m_pFileListLB->set_height_request(m_pFileListLB->GetTextHeight() * 10);
-    get(m_pOkBtn, "ok");
+    m_xFileListLB->set_size_request(-1, m_xFileListLB->get_height_rows(10));
 
     // Prepare the office for the following crash save step.
     // E.g. hide all open windows so the user can't influence our
     // operation .-)
     m_pCore->doEmergencySavePrepare();
 
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-
-    m_pOkBtn->SetClickHdl( LINK( this, SaveDialog, OKButtonHdl ) );
-    m_pFileListLB->SetControlBackground( rStyleSettings.GetDialogColor() );
+    m_xOkBtn->connect_clicked(LINK(this, SaveDialog, OKButtonHdl));
 
     // fill listbox with current open documents
-    m_pFileListLB->Clear();
 
     TURLList&                rURLs = m_pCore->getURLListAccess();
 
     for (const TURLInfo& rInfo : rURLs)
     {
-        m_pFileListLB->InsertEntry( rInfo.DisplayName, rInfo.StandardImage );
+        m_xFileListLB->append("", rInfo.DisplayName, rInfo.StandardImageId);
     }
 }
 
 SaveDialog::~SaveDialog()
 {
-    disposeOnce();
-}
-
-void SaveDialog::dispose()
-{
-    m_pFileListLB.clear();
-    m_pOkBtn.clear();
-    Dialog::dispose();
 }
 
-IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void)
+IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, weld::Button&, void)
 {
     // start crash-save with progress
-    std::unique_ptr<SaveProgressDialog> xProgress(new SaveProgressDialog(GetFrameWeld(), m_pCore));
+    std::unique_ptr<SaveProgressDialog> xProgress(new SaveProgressDialog(m_xDialog.get(), m_pCore));
     short nResult = xProgress->run();
     xProgress.reset();
 
@@ -700,7 +687,7 @@ IMPL_LINK_NOARG(SaveDialog, OKButtonHdl, Button*, void)
     if (nResult == DLG_RET_OK)
         nResult = DLG_RET_OK_AUTOLUNCH;
 
-    EndDialog(nResult);
+    m_xDialog->response(nResult);
 }
 
 SaveProgressDialog::SaveProgressDialog(weld::Window* pParent, RecoveryCore* pCore)
diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx
index 3a4c1f769c9b..698882acbdc2 100644
--- a/svx/source/inc/docrecovery.hxx
+++ b/svx/source/inc/docrecovery.hxx
@@ -26,6 +26,7 @@
 #include <vcl/lstbox.hxx>
 #include <vcl/tabdlg.hxx>
 #include <vcl/tabpage.hxx>
+#include <vcl/weld.hxx>
 #include <svtools/simptabl.hxx>
 #include <vcl/svlbitm.hxx>
 #include <svtools/svmedit2.hxx>
@@ -381,36 +382,35 @@ public:
     virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener) override;
 };
 
-class SaveDialog : public Dialog
+class SaveDialog : public weld::GenericDialogController
 {
-    // member
-    private:
-        VclPtr<ListBox>        m_pFileListLB;
-        VclPtr<OKButton>       m_pOkBtn;
-        RecoveryCore*   m_pCore;
+// member
+private:
+    RecoveryCore*   m_pCore;
+    std::unique_ptr<weld::TreeView> m_xFileListLB;
+    std::unique_ptr<weld::Button> m_xOkBtn;
 
-    // interface
-    public:
-        /** @short  create all child controls of this dialog.
+// interface
+public:
+    /** @short  create all child controls of this dialog.
 
-            @descr  The dialog isn't shown nor it starts any
-                    action by itself!
+        @descr  The dialog isn't shown nor it starts any
+                action by itself!
 
-            @param  pParent
-                    can point to a parent window.
-                    If its set to 0, the defmodal-dialog-parent
-                    is used automatically.
+        @param  pParent
+                can point to a parent window.
+                If its set to 0, the defmodal-dialog-parent
+                is used automatically.
 
-            @param  pCore
-                    provides access to the recovery core service
-                    and the current list of open documents,
-                    which should be shown inside this dialog.
-         */
-        SaveDialog(vcl::Window* pParent, RecoveryCore* pCore);
-        virtual ~SaveDialog() override;
-        virtual void dispose() override;
+        @param  pCore
+                provides access to the recovery core service
+                and the current list of open documents,
+                which should be shown inside this dialog.
+     */
+    SaveDialog(weld::Window* pParent, RecoveryCore* pCore);
+    virtual ~SaveDialog() override;
 
-        DECL_LINK(OKButtonHdl, Button*, void);
+    DECL_LINK(OKButtonHdl, weld::Button&, void);
 };
 
 class SaveProgressDialog : public weld::GenericDialogController
diff --git a/svx/source/unodraw/recoveryui.cxx b/svx/source/unodraw/recoveryui.cxx
index 2f1d6a49cae0..05d9c223f669 100644
--- a/svx/source/unodraw/recoveryui.cxx
+++ b/svx/source/unodraw/recoveryui.cxx
@@ -247,11 +247,10 @@ bool RecoveryUI::impl_doEmergencySave()
     rtl::Reference<svxdr::RecoveryCore> pCore = new svxdr::RecoveryCore(m_xContext, true);
 
     // create dialog for this operation and bind it to the used core service
-    ScopedVclPtrInstance<svxdr::SaveDialog> xDialog(m_pParentWindow, pCore.get());
-    DialogReleaseGuard dialogReleaseGuard(m_pDialog, xDialog);
+    svxdr::SaveDialog aDialog(m_pParentWindow ? m_pParentWindow->GetFrameWeld() : nullptr, pCore.get());
 
     // start the dialog
-    short nRet = xDialog->Execute();
+    short nRet = aDialog.run();
     return (nRet==DLG_RET_OK_AUTOLUNCH);
 }
 
diff --git a/svx/uiconfig/ui/docrecoverysavedialog.ui b/svx/uiconfig/ui/docrecoverysavedialog.ui
index e61d93869eb4..df6fb307a5c9 100644
--- a/svx/uiconfig/ui/docrecoverysavedialog.ui
+++ b/svx/uiconfig/ui/docrecoverysavedialog.ui
@@ -1,12 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name image -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="DocRecoverySaveDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="docrecoverysavedialog|DocRecoverySaveDialog">%PRODUCTNAME %PRODUCTVERSION Document Recovery</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>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -44,6 +60,7 @@
           <object class="GtkGrid" id="bgrid1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="vexpand">True</property>
             <property name="row_spacing">12</property>
             <child>
               <object class="GtkGrid" id="grid1">
@@ -58,7 +75,8 @@
                     <property name="can_focus">False</property>
                     <property name="label" translatable="yes" context="docrecoverysavedialog|label1">Due to an unexpected error, %PRODUCTNAME crashed. All the files you were working on will now be saved. The next time %PRODUCTNAME is launched, your files will be recovered automatically.</property>
                     <property name="wrap">True</property>
-                    <property name="max_width_chars">87</property>
+                    <property name="width_chars">80</property>
+                    <property name="max_width_chars">80</property>
                     <property name="xalign">0</property>
                   </object>
                   <packing>
@@ -79,7 +97,7 @@
                         <property name="can_focus">False</property>
                         <property name="label" translatable="yes" context="docrecoverysavedialog|label2">The following files will be recovered:</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">filelist:border</property>
+                        <property name="mnemonic_widget">filelist</property>
                         <property name="xalign">0</property>
                       </object>
                       <packing>
@@ -88,14 +106,47 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkTreeView" id="filelist: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="show_expanders">False</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="filelist">
+                            <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-selection2"/>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                <child>
+                                  <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
+                                  <attributes>
+                                    <attribute name="pixbuf">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                  <attributes>
+                                    <attribute name="text">1</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
                         </child>
                       </object>
                       <packing>


More information about the Libreoffice-commits mailing list