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

Caolán McNamara caolanm at redhat.com
Fri May 18 07:56:20 UTC 2018


 uui/source/fltdlg.cxx           |   48 ++++++++++++++---------------------
 uui/source/fltdlg.hxx           |   18 +++----------
 uui/source/iahndl-filter.cxx    |   15 +++++------
 uui/uiconfig/ui/filterselect.ui |   54 +++++++++++++++++++++++++++++++++-------
 4 files changed, 77 insertions(+), 58 deletions(-)

New commits:
commit 8a8c384eeb8bc8dace6c77bad59e6d2654e8840b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu May 17 10:53:29 2018 +0100

    weld FilterDialog
    
    I think this is theoretical and in practice this dialog never appears
    anymore
    
    Change-Id: I1c29432ecf0df215c686c228326183d9a3a422d3
    Reviewed-on: https://gerrit.libreoffice.org/54489
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/uui/source/fltdlg.cxx b/uui/source/fltdlg.cxx
index e904fcdadb68..2911acb03b22 100644
--- a/uui/source/fltdlg.cxx
+++ b/uui/source/fltdlg.cxx
@@ -44,28 +44,18 @@ namespace uui
     @param      "pParentWindow"  , parent window for dialog
     @threadsafe no
 *//*-*************************************************************************************************************/
-FilterDialog::FilterDialog( vcl::Window* pParentWindow )
-    :   ModalDialog  (pParentWindow, "FilterSelectDialog", "uui/ui/filterselect.ui" )
-    ,   m_pFilterNames(nullptr)
+FilterDialog::FilterDialog(weld::Window* pParentWindow)
+    : GenericDialogController(pParentWindow, "uui/ui/filterselect.ui", "FilterSelectDialog")
+    , m_pFilterNames(nullptr)
+    , m_xFtURL(m_xBuilder->weld_label("url"))
+    , m_xLbFilters(m_xBuilder->weld_tree_view("filters"))
 {
-    get(m_pFtURL, "url");
-    get(m_pLbFilters, "filters");
-    Size aSize(pParentWindow->LogicToPixel(Size(182, 175), MapMode(MapUnit::MapAppFont)));
-    m_pLbFilters->set_height_request(aSize.Height());
-    m_pLbFilters->set_width_request(aSize.Width());
-    m_pFtURL->SetSizePixel(Size(aSize.Width(), m_pFtURL->GetOptimalSize().Height()));
+    m_xLbFilters->set_size_request(m_xLbFilters->get_approximate_digit_width() * 42,
+                                   m_xLbFilters->get_height_rows(15));
 }
 
 FilterDialog::~FilterDialog()
 {
-    disposeOnce();
-}
-
-void FilterDialog::dispose()
-{
-    m_pFtURL.clear();
-    m_pLbFilters.clear();
-    ModalDialog::dispose();
 }
 
 /*-************************************************************************************************************
@@ -77,7 +67,7 @@ void FilterDialog::dispose()
 void FilterDialog::SetURL( const OUString& sURL )
 {
     // convert it and use given pure string as fallback if conversion failed
-    m_pFtURL->SetText( impl_buildUIFileName(sURL) );
+    m_xFtURL->set_label(impl_buildUIFileName(sURL));
 }
 
 /*-************************************************************************************************************
@@ -100,14 +90,14 @@ void FilterDialog::SetURL( const OUString& sURL )
 void FilterDialog::ChangeFilters( const FilterNameList* pFilterNames )
 {
     m_pFilterNames = pFilterNames;
-    m_pLbFilters->Clear();
+    m_xLbFilters->clear();
     if( m_pFilterNames != nullptr )
     {
         for( FilterNameListPtr pItem  = m_pFilterNames->begin();
                                pItem != m_pFilterNames->end()  ;
                                ++pItem                         )
         {
-            m_pLbFilters->InsertEntry( pItem->sUI );
+            m_xLbFilters->append_text(pItem->sUI);
         }
     }
 }
@@ -136,12 +126,12 @@ bool FilterDialog::AskForFilter( FilterNameListPtr& pSelectedItem )
 
     if( m_pFilterNames != nullptr )
     {
-        if( ModalDialog::Execute() == RET_OK )
+        if (m_xDialog->run() == RET_OK)
         {
-            OUString sEntry = m_pLbFilters->GetSelectedEntry();
+            OUString sEntry = m_xLbFilters->get_selected_text();
             if( !sEntry.isEmpty() )
             {
-                int nPos = m_pLbFilters->GetSelectedEntryPos();
+                int nPos = m_xLbFilters->get_selected_index();
                 if( nPos < static_cast<int>(m_pFilterNames->size()) )
                 {
                     pSelectedItem  = m_pFilterNames->begin();
@@ -167,18 +157,18 @@ bool FilterDialog::AskForFilter( FilterNameListPtr& pSelectedItem )
 class StringCalculator : public ::cppu::WeakImplHelper< css::util::XStringWidth >
 {
     public:
-        explicit StringCalculator( const OutputDevice* pDevice )
-            : m_pDevice( const_cast< OutputDevice * >( pDevice ) )
+        explicit StringCalculator(weld::Widget* pDevice)
+            : m_pDevice(pDevice)
         {
         }
 
         sal_Int32 SAL_CALL queryStringWidth( const OUString& sString ) override
         {
-            return static_cast<sal_Int32>(m_pDevice->GetTextWidth(sString));
+            return static_cast<sal_Int32>(m_pDevice->get_pixel_size(sString).Width());
         }
 
     private:
-        VclPtr<OutputDevice> m_pDevice;
+        weld::Widget* m_pDevice;
 };
 
 /*-************************************************************************************************************
@@ -206,11 +196,11 @@ OUString FilterDialog::impl_buildUIFileName( const OUString& sName )
     else
     {
         // otherwise its really a url ... build short name by using INetURLObject
-        css::uno::Reference< css::util::XStringWidth > xStringCalculator( new StringCalculator(m_pFtURL) );
+        css::uno::Reference< css::util::XStringWidth > xStringCalculator(new StringCalculator(m_xFtURL.get()));
         if( xStringCalculator.is() )
         {
             INetURLObject aBuilder   ( sName );
-            Size          aSize      = m_pFtURL->GetOutputSizePixel();
+            Size          aSize      = m_xLbFilters->get_preferred_size();
                           sShortName = aBuilder.getAbbreviated( xStringCalculator, aSize.Width(), INetURLObject::DecodeMechanism::Unambiguous );
         }
     }
diff --git a/uui/source/fltdlg.hxx b/uui/source/fltdlg.hxx
index 76d1d257d6a0..5f788073c41c 100644
--- a/uui/source/fltdlg.hxx
+++ b/uui/source/fltdlg.hxx
@@ -20,12 +20,7 @@
 #ifndef INCLUDED_UUI_SOURCE_FLTDLG_HXX
 #define INCLUDED_UUI_SOURCE_FLTDLG_HXX
 
-#include <vcl/dialog.hxx>
-
-#include <vcl/lstbox.hxx>
-
-#include <vcl/button.hxx>
-#include <vcl/fixed.hxx>
+#include <vcl/weld.hxx>
 
 #include <vector>
 
@@ -41,27 +36,24 @@ struct FilterNamePair
 typedef ::std::vector< FilterNamePair > FilterNameList   ;
 typedef FilterNameList::const_iterator  FilterNameListPtr;
 
-class FilterDialog : public ModalDialog
+class FilterDialog : public weld::GenericDialogController
 {
     // public interface
     public:
-        explicit FilterDialog(vcl::Window* pParentWindow);
+        explicit FilterDialog(weld::Window* pParentWindow);
         virtual ~FilterDialog() override;
-        virtual void dispose() override;
         void SetURL       ( const OUString&          sURL           );
         void ChangeFilters( const FilterNameList*    pFilterNames   );
         bool AskForFilter (       FilterNameListPtr& pSelectedItem  );
 
-    // helper (or hided functions!)
     private:
-        short Execute() override { return RET_CANCEL; };
         OUString impl_buildUIFileName( const OUString& sURL );
 
     // member
     private:
-              VclPtr<FixedText>       m_pFtURL       ;
-              VclPtr<ListBox>         m_pLbFilters   ;
         const FilterNameList* m_pFilterNames;
+        std::unique_ptr<weld::Label> m_xFtURL;
+        std::unique_ptr<weld::TreeView> m_xLbFilters;
 
 };  // class FilterDialog
 
diff --git a/uui/source/iahndl-filter.cxx b/uui/source/iahndl-filter.cxx
index 38c98375f3e5..9a8ef64c247c 100644
--- a/uui/source/iahndl-filter.cxx
+++ b/uui/source/iahndl-filter.cxx
@@ -45,20 +45,20 @@ namespace {
 
 void
 executeFilterDialog(
-    vcl::Window          * pParent ,
+    weld::Window* pParent ,
     OUString       const & rURL    ,
     uui::FilterNameList const & rFilters,
     OUString             & rFilter )
 {
     SolarMutexGuard aGuard;
 
-    ScopedVclPtrInstance< uui::FilterDialog > xDialog(pParent);
+    uui::FilterDialog aDialog(pParent);
 
-    xDialog->SetURL(rURL);
-    xDialog->ChangeFilters(&rFilters);
+    aDialog.SetURL(rURL);
+    aDialog.ChangeFilters(&rFilters);
 
     uui::FilterNameListPtr pSelected = rFilters.end();
-    if( xDialog->AskForFilter( pSelected ) )
+    if (aDialog.AskForFilter(pSelected))
     {
         rFilter = pSelected->sInternal;
     }
@@ -66,7 +66,7 @@ executeFilterDialog(
 
 void
 handleNoSuchFilterRequest_(
-    vcl::Window * pParent,
+    weld::Window* pParent,
     uno::Reference< uno::XComponentContext > const & xContext,
     document::NoSuchFilterRequest const & rRequest,
     uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
@@ -292,7 +292,8 @@ UUIInteractionHelper::handleNoSuchFilterRequest(
     document::NoSuchFilterRequest aNoSuchFilterRequest;
     if (aAnyRequest >>= aNoSuchFilterRequest)
     {
-        handleNoSuchFilterRequest_(getParentProperty(),
+        uno::Reference<awt::XWindow> xParent = getParentXWindow();
+        handleNoSuchFilterRequest_(Application::GetFrameWeld(xParent),
                                    m_xContext,
                                    aNoSuchFilterRequest,
                                    rRequest->getContinuations());
diff --git a/uui/uiconfig/ui/filterselect.ui b/uui/uiconfig/ui/filterselect.ui
index 5d8fda80109f..a4258df7751c 100644
--- a/uui/uiconfig/ui/filterselect.ui
+++ b/uui/uiconfig/ui/filterselect.ui
@@ -1,22 +1,37 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
 <interface domain="uui">
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="FilterSelectDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
     <property name="title" translatable="yes" context="filterselect|FilterSelectDialog">Filter Selection</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>
         <property name="hexpand">True</property>
         <property name="vexpand">True</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>
@@ -24,7 +39,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -40,7 +54,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -56,13 +69,13 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -96,13 +109,36 @@
               </packing>
             </child>
             <child>
-              <object class="GtkTreeView" id="filters: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="filters">
+                    <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>
               <packing>


More information about the Libreoffice-commits mailing list