[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 26 12:48:42 UTC 2021


 vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx |   23 +++++++++++++++++++++--
 vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx |    2 ++
 2 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit f07d6e060df1c52e6a9a6c89c028a842d5c97be1
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Aug 26 10:03:09 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Aug 26 14:48:07 2021 +0200

    Resolves: tdf#144084 if not initialized default to FILEOPEN_SIMPLE
    
    which is a problem since...
    
    commit 43335776cfc18cdc7addf33250cffc886d384186
    Author: Caolán McNamara <caolanm at redhat.com>
    Date:   Tue May 11 17:21:47 2021 +0100
    
        gtk[3|4] don't create File Dialog with buttons that need to be removed
    
        just create it without the offending buttons in the first place
    
    where we create without buttons because its hard, especially since gtk4,
    to remove unwanted buttons.
    
    Change-Id: Ib0337c412fa7e8210d3b1bf3261174c4ffac0a0a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121081
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    Tested-by: Jenkins

diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
index 2b5081463403..a318a115f575 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
@@ -89,6 +89,7 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
     mnHID_SelectionChange( 0 ),
     bVersionWidthUnset( false ),
     mbPreviewState( false ),
+    mbInitialized(false),
     mHID_Preview( 0 ),
     m_pPreview( nullptr ),
     m_pPseudoFilter( nullptr )
@@ -899,6 +900,13 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute()
 {
     SolarMutexGuard g;
 
+    if (!mbInitialized)
+    {
+        // tdf#144084 if not initialized default to FILEOPEN_SIMPLE
+        impl_initialize(nullptr, FILEOPEN_SIMPLE);
+        assert(mbInitialized);
+    }
+
     OSL_ASSERT( m_pDialog != nullptr );
 
     sal_Int16 retVal = 0;
@@ -1610,6 +1618,8 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
     sal_Int16 templateId = -1;
     aAny >>= templateId;
 
+    GtkWidget* pParentWidget = nullptr;
+
     css::uno::Reference<css::awt::XWindow> xParentWindow;
     if (aArguments.getLength() > 1)
     {
@@ -1619,7 +1629,7 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
     if (xParentWindow.is())
     {
         if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(xParentWindow.get()))
-            m_pParentWidget = pGtkXWindow->getGtkWidget();
+            pParentWidget = pGtkXWindow->getGtkWidget();
         else
         {
             css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(xParentWindow, css::uno::UNO_QUERY);
@@ -1630,11 +1640,18 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
                 aAny = xSysDepWin->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW);
                 css::awt::SystemDependentXWindow tmp;
                 aAny >>= tmp;
-                m_pParentWidget = GetGtkSalData()->GetGtkDisplay()->findGtkWidgetForNativeHandle(tmp.WindowHandle);
+                pParentWidget = GetGtkSalData()->GetGtkDisplay()->findGtkWidgetForNativeHandle(tmp.WindowHandle);
             }
         }
     }
 
+    impl_initialize(pParentWidget, templateId);
+}
+
+void SalGtkFilePicker::impl_initialize(GtkWidget* pParentWidget, sal_Int16 templateId)
+{
+    m_pParentWidget = pParentWidget;
+
     GtkFileChooserAction eAction = GTK_FILE_CHOOSER_ACTION_OPEN;
     OString sOpen = getOpenText();
     OString sSave = getSaveText();
@@ -1781,6 +1798,8 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
             gtk_widget_show( m_pHBoxs[ nTVIndex ] );
         }
     }
+
+    mbInitialized = true;
 }
 
 void SalGtkFilePicker::preview_toggled_cb( GObject *cb, SalGtkFilePicker* pobjFP )
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx
index 5797a7a04e19..1c072c83c1a9 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.hxx
@@ -142,6 +142,7 @@ class SalGtkFilePicker : public SalGtkPicker, public SalGtkFilePicker_Base
         void impl_fileSelectionChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
         void impl_directoryChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
         void impl_controlStateChanged( const css::ui::dialogs::FilePickerEvent& aEvent );
+        void impl_initialize(GtkWidget* pParentWidget, sal_Int16 templateId);
 
     private:
         css::uno::Reference< css::ui::dialogs::XFilePickerListener >
@@ -196,6 +197,7 @@ class SalGtkFilePicker : public SalGtkPicker, public SalGtkFilePicker_Base
 
         bool bVersionWidthUnset;
         bool mbPreviewState;
+        bool mbInitialized;
         gulong mHID_Preview;
         GtkWidget* m_pPreview;
         GtkFileFilter* m_pPseudoFilter;


More information about the Libreoffice-commits mailing list