diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-10-01 08:57:52 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-10-01 08:57:52 +0000 |
commit | ddcd4779159e43a0f6ef7867c2b19e101dc8146a (patch) | |
tree | 0065e3cd64d91e31c4e393049fe64adb753836c7 | |
parent | 2759e9c40629a3ec1c4d841f0cf17cf0d09b0a76 (diff) |
CWS-TOOLING: integrate CWS fpicker8
-rw-r--r-- | fpicker/source/unx/gnome/SalGtkFilePicker.cxx | 15 | ||||
-rw-r--r-- | fpicker/source/unx/gnome/SalGtkFolderPicker.cxx | 10 | ||||
-rw-r--r-- | fpicker/source/unx/gnome/SalGtkPicker.cxx | 89 | ||||
-rw-r--r-- | fpicker/source/unx/gnome/SalGtkPicker.hxx | 47 |
4 files changed, 140 insertions, 21 deletions
diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx index 298d7d5a97df..8e6ee1c376d3 100644 --- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SalGtkFilePicker.cxx,v $ - * $Revision: 1.28 $ + * $Revision: 1.28.42.1 $ * * This file is part of OpenOffice.org. * @@ -996,12 +996,16 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException ) int btn = GTK_RESPONSE_NO; + uno::Reference< awt::XExtendedToolkit > xToolkit( + m_xServiceMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY); + + RunDialog* pRunInMain = new RunDialog(m_pDialog, xToolkit); + uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunInMain); while( GTK_RESPONSE_NO == btn ) { btn = GTK_RESPONSE_YES; // we dont want to repeat unless user clicks NO for file save. - RunDialog aRunInMain(m_pDialog); - gint nStatus = aRunInMain.runandwaitforresult(); + gint nStatus = pRunInMain->runandwaitforresult(); switch( nStatus ) { case GTK_RESPONSE_ACCEPT: @@ -1028,8 +1032,9 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException ) OUStringToOString(aResProvider.getResString(FILE_PICKER_TITLE_SAVE ), RTL_TEXTENCODING_UTF8 ).getStr() ); - RunDialog aAnotherRunInMain(dlg); - btn = aAnotherRunInMain.runandwaitforresult(); + RunDialog* pAnotherRunInMain = new RunDialog(dlg, xToolkit); + uno::Reference < awt::XTopWindowListener > xAnotherLifeCycle(pAnotherRunInMain); + btn = pAnotherRunInMain->runandwaitforresult(); gtk_widget_destroy( dlg ); } diff --git a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx index 78b70483f0ef..c5f2f7ee7911 100644 --- a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SalGtkFolderPicker.cxx,v $ - * $Revision: 1.11 $ + * $Revision: 1.11.42.1 $ * * This file is part of OpenOffice.org. * @@ -173,8 +173,12 @@ sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException ) sal_Int16 retVal = 0; - RunDialog aRunInMain(m_pDialog); - gint nStatus = aRunInMain.runandwaitforresult(); + uno::Reference< awt::XExtendedToolkit > xToolkit( + m_xServiceMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY); + + RunDialog* pRunInMain = new RunDialog(m_pDialog, xToolkit); + uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunInMain); + gint nStatus = pRunInMain->runandwaitforresult(); switch( nStatus ) { case GTK_RESPONSE_ACCEPT: diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx index 69adb8c64c67..526183908925 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.cxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SalGtkPicker.cxx,v $ - * $Revision: 1.17 $ + * $Revision: 1.17.32.1 $ * * This file is part of OpenOffice.org. * @@ -37,16 +37,19 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp> +#include <com/sun/star/lang/SystemDependent.hpp> +#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp> +#include <com/sun/star/awt/SystemDependentXWindow.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <comphelper/processfactory.hxx> #include <cppuhelper/interfacecontainer.h> +#include <rtl/process.h> #include <osl/diagnose.h> #include <com/sun/star/uno/Any.hxx> #include <FPServiceInfo.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> -#ifndef _SALGTKPICKER_HXX_ #include "SalGtkPicker.hxx" -#endif #include <tools/urlobj.hxx> #include <stdio.h> @@ -107,11 +110,87 @@ gboolean rundialog(RunDialog *pDialog) return false; } +gboolean canceldialog(RunDialog *pDialog) +{ + pDialog->cancel(); + return false; +} + +extern "C" +{ + struct Display; + extern GdkDisplay* gdk_x11_lookup_xdisplay (void*xdisplay); +} + +RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit >& rToolkit ) : + cppu::WeakComponentImplHelper1< awt::XTopWindowListener >( maLock ), + mbFinished(false), mpDialog(pDialog), mpCreatedParent(NULL), mxToolkit(rToolkit) +{ + awt::SystemDependentXWindow aWindowHandle; + + if (mxToolkit.is()) + { + uno::Reference< awt::XTopWindow > xWindow(mxToolkit->getActiveTopWindow()); + if (xWindow.is()) + { + uno::Reference< awt::XSystemDependentWindowPeer > xSystemDepParent(xWindow, uno::UNO_QUERY); + if (xSystemDepParent.is()) + { + + sal_Int8 processID[16]; + + rtl_getGlobalProcessId( (sal_uInt8*)processID ); + uno::Sequence<sal_Int8> processIdSeq(processID, 16); + uno::Any anyHandle = xSystemDepParent->getWindowHandle(processIdSeq, SystemDependent::SYSTEM_XWINDOW); + + anyHandle >>= aWindowHandle; + } + } + } + + GdkDisplay *pDisplay = aWindowHandle.DisplayPointer ? gdk_x11_lookup_xdisplay((void*)aWindowHandle.DisplayPointer) : NULL; + GdkWindow* pParent = pDisplay ? gdk_window_lookup_for_display(pDisplay, aWindowHandle.WindowHandle) : NULL; + if (!pParent && pDisplay) + pParent = mpCreatedParent = gdk_window_foreign_new_for_display( pDisplay, aWindowHandle.WindowHandle); + if (pParent) + { + gtk_widget_realize(mpDialog); + gdk_window_set_transient_for(mpDialog->window, pParent); + } +} + + +RunDialog::~RunDialog() +{ + if (mpCreatedParent) + gdk_window_destroy (mpCreatedParent); +} + +void SAL_CALL RunDialog::windowOpened( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) +{ + g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); +} + +void RunDialog::cancel() +{ + gtk_dialog_response( GTK_DIALOG( mpDialog ), GTK_RESPONSE_CANCEL ); + gtk_widget_hide( mpDialog ); +} + void RunDialog::run() { - mnStatus = gtk_dialog_run( GTK_DIALOG( m_pDialog ) ); + if (mxToolkit.is()) + mxToolkit->addTopWindowListener(this); + + mnStatus = gtk_dialog_run( GTK_DIALOG( mpDialog ) ); + + if (mxToolkit.is()) + mxToolkit->removeTopWindowListener(this); + + if (mnStatus != 1) //PLAY - gtk_widget_hide( m_pDialog ); + gtk_widget_hide( mpDialog ); maLock.acquire(); mbFinished = true; diff --git a/fpicker/source/unx/gnome/SalGtkPicker.hxx b/fpicker/source/unx/gnome/SalGtkPicker.hxx index 293f6d1199ee..c8aff6eb9aff 100644 --- a/fpicker/source/unx/gnome/SalGtkPicker.hxx +++ b/fpicker/source/unx/gnome/SalGtkPicker.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SalGtkPicker.hxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.10.42.1 $ * * This file is part of OpenOffice.org. * @@ -36,15 +36,16 @@ //_____________________________________________________________________________ #include <osl/mutex.hxx> +#include <cppuhelper/compbase1.hxx> #include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilePicker2.hpp> - -#ifndef _COM_SUN_STAR_UI_XFOLDERPICKER_HPP_ #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> -#endif #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/XExtendedToolkit.hpp> + #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> @@ -73,17 +74,47 @@ class SalGtkPicker static rtl::OString unicodetouri(const rtl::OUString &rURL); }; -class RunDialog +//Run the Gtk Dialog in the "Main Thread" for us to avoid threading conflict and +//report back to this thread. Watch for any "new windows" created while we're +//executing and consider that a CANCEL event to avoid e.g. "file cannot be opened" +//modal dialogs and this one getting locked if some other API call causes this +//to happen while we're opened waiting for user input, e.g. +//https://bugzilla.redhat.com/show_bug.cgi?id=441108 +class RunDialog : + public cppu::WeakComponentImplHelper1< ::com::sun::star::awt::XTopWindowListener > { private: bool mbFinished; osl::Mutex maLock; gint mnStatus; - GtkWidget *m_pDialog; + GtkWidget *mpDialog; + GdkWindow *mpCreatedParent; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit> mxToolkit; public: - void run(); - RunDialog(GtkWidget *pDialog) : mbFinished(false), m_pDialog(pDialog) { } + + // XTopWindowListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& ) + throw(::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& ) + throw (::com::sun::star::uno::RuntimeException) {} +public: + RunDialog(GtkWidget *pDialog, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > &rToolkit); gint runandwaitforresult(); + void run(); + void cancel(); + ~RunDialog(); }; #endif |