1 |
From 8636f3f41f8f6950a0e3c05f50eb4423c4035b2f Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Thu, 27 Jan 2011 16:41:00 +0000 |
4 |
Subject: [PATCH 1/2] Related: rhbz#672872 cancel gtk file-dialog on desktop::terminate |
5 |
|
6 |
--- |
7 |
fpicker/source/unx/gnome/SalGtkFilePicker.cxx | 7 +++++-- |
8 |
fpicker/source/unx/gnome/SalGtkFolderPicker.cxx | 5 ++++- |
9 |
fpicker/source/unx/gnome/SalGtkPicker.cxx | 19 ++++++++++++++++--- |
10 |
fpicker/source/unx/gnome/SalGtkPicker.hxx | 20 +++++++++++++++++--- |
11 |
4 files changed, 42 insertions(+), 9 deletions(-) |
12 |
|
13 |
diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx |
14 |
index d08125e..068ead5 100644 |
15 |
--- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx |
16 |
+++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx |
17 |
@@ -1030,7 +1030,10 @@ |
18 |
uno::Reference< awt::XExtendedToolkit > xToolkit( |
19 |
m_xServiceMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY); |
20 |
|
21 |
- RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit); |
22 |
+ uno::Reference< frame::XDesktop > xDesktop( |
23 |
+ m_xServiceMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ), uno::UNO_QUERY); |
24 |
+ |
25 |
+ RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop); |
26 |
uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunDialog); |
27 |
while( GTK_RESPONSE_NO == btn ) |
28 |
{ |
29 |
@@ -1063,7 +1066,7 @@ |
30 |
OUStringToOString(aResProvider.getResString(FILE_PICKER_TITLE_SAVE ), |
31 |
RTL_TEXTENCODING_UTF8 ).getStr() ); |
32 |
|
33 |
- RunDialog* pAnotherDialog = new RunDialog(dlg, xToolkit); |
34 |
+ RunDialog* pAnotherDialog = new RunDialog(dlg, xToolkit, xDesktop); |
35 |
uno::Reference < awt::XTopWindowListener > xAnotherLifeCycle(pAnotherDialog); |
36 |
btn = pAnotherDialog->run(); |
37 |
|
38 |
diff --git a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx |
39 |
index c42021c..08bbf04 100644 |
40 |
--- a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx |
41 |
+++ b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx |
42 |
@@ -184,7 +184,10 @@ |
43 |
uno::Reference< awt::XExtendedToolkit > xToolkit( |
44 |
m_xServiceMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.awt.Toolkit") ), uno::UNO_QUERY); |
45 |
|
46 |
- RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit); |
47 |
+ uno::Reference< frame::XDesktop > xDesktop( |
48 |
+ m_xServiceMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ), uno::UNO_QUERY); |
49 |
+ |
50 |
+ RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop); |
51 |
uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunDialog); |
52 |
gint nStatus = pRunDialog->run(); |
53 |
switch( nStatus ) |
54 |
diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx |
55 |
index 6dbaa03..9bdad50 100644 |
56 |
--- a/fpicker/source/unx/gnome/SalGtkPicker.cxx |
57 |
+++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx |
58 |
@@ -130,9 +130,10 @@ extern "C" |
59 |
extern GdkDisplay* gdk_x11_lookup_xdisplay (void*xdisplay); |
60 |
} |
61 |
|
62 |
-RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit >& rToolkit ) : |
63 |
- cppu::WeakComponentImplHelper1< awt::XTopWindowListener >( maLock ), |
64 |
- mpDialog(pDialog), mpCreatedParent(NULL), mxToolkit(rToolkit) |
65 |
+RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit >& rToolkit, |
66 |
+ uno::Reference< frame::XDesktop >& rDesktop ) : |
67 |
+ cppu::WeakComponentImplHelper2< awt::XTopWindowListener, frame::XTerminateListener >( maLock ), |
68 |
+ mpDialog(pDialog), mpCreatedParent(NULL), mxToolkit(rToolkit), mxDesktop(rDesktop) |
69 |
{ |
70 |
awt::SystemDependentXWindow aWindowHandle; |
71 |
|
72 |
@@ -186,6 +187,18 @@ void SAL_CALL RunDialog::windowOpened( const ::com::sun::star::lang::EventObject |
73 |
g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); |
74 |
} |
75 |
|
76 |
+void SAL_CALL RunDialog::queryTermination( const ::com::sun::star::lang::EventObject& ) |
77 |
+ throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException) |
78 |
+{ |
79 |
+} |
80 |
+ |
81 |
+void SAL_CALL RunDialog::notifyTermination( const ::com::sun::star::lang::EventObject& ) |
82 |
+ throw(::com::sun::star::uno::RuntimeException) |
83 |
+{ |
84 |
+ GdkThreadLock aLock; |
85 |
+ g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL); |
86 |
+} |
87 |
+ |
88 |
void RunDialog::cancel() |
89 |
{ |
90 |
GdkThreadLock aLock; |
91 |
diff --git a/fpicker/source/unx/gnome/SalGtkPicker.hxx b/fpicker/source/unx/gnome/SalGtkPicker.hxx |
92 |
index 889790d..52fe5a0 100644 |
93 |
--- a/fpicker/source/unx/gnome/SalGtkPicker.hxx |
94 |
+++ b/fpicker/source/unx/gnome/SalGtkPicker.hxx |
95 |
@@ -34,7 +34,7 @@ |
96 |
//_____________________________________________________________________________ |
97 |
|
98 |
#include <osl/mutex.hxx> |
99 |
-#include <cppuhelper/compbase1.hxx> |
100 |
+#include <cppuhelper/compbase2.hxx> |
101 |
#include <com/sun/star/ui/dialogs/XFilePicker.hpp> |
102 |
#include <com/sun/star/ui/dialogs/XFilePicker2.hpp> |
103 |
#include <com/sun/star/ui/dialogs/XFolderPicker.hpp> |
104 |
@@ -43,6 +43,8 @@ |
105 |
|
106 |
#include <com/sun/star/awt/XTopWindowListener.hpp> |
107 |
#include <com/sun/star/awt/XExtendedToolkit.hpp> |
108 |
+#include <com/sun/star/frame/XDesktop.hpp> |
109 |
+#include <com/sun/star/frame/XTerminateListener.hpp> |
110 |
|
111 |
#include <gtk/gtk.h> |
112 |
#include <gdk/gdkkeysyms.h> |
113 |
@@ -85,13 +87,16 @@ public: |
114 |
//to happen while we're opened waiting for user input, e.g. |
115 |
//https://bugzilla.redhat.com/show_bug.cgi?id=441108 |
116 |
class RunDialog : |
117 |
- public cppu::WeakComponentImplHelper1< ::com::sun::star::awt::XTopWindowListener > |
118 |
+ public cppu::WeakComponentImplHelper2< |
119 |
+ ::com::sun::star::awt::XTopWindowListener, |
120 |
+ ::com::sun::star::frame::XTerminateListener > |
121 |
{ |
122 |
private: |
123 |
osl::Mutex maLock; |
124 |
GtkWidget *mpDialog; |
125 |
GdkWindow *mpCreatedParent; |
126 |
::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit> mxToolkit; |
127 |
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > mxDesktop; |
128 |
public: |
129 |
|
130 |
// XTopWindowListener |
131 |
@@ -112,8 +117,17 @@ public: |
132 |
throw (::com::sun::star::uno::RuntimeException) {} |
133 |
virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& ) |
134 |
throw (::com::sun::star::uno::RuntimeException) {} |
135 |
+ |
136 |
+ // XTerminateListener |
137 |
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) |
138 |
+ throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); |
139 |
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) |
140 |
+ throw(::com::sun::star::uno::RuntimeException); |
141 |
public: |
142 |
- RunDialog(GtkWidget *pDialog, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > &rToolkit); |
143 |
+ RunDialog(GtkWidget *pDialog, |
144 |
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > &rToolkit, |
145 |
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > &rDesktop |
146 |
+ ); |
147 |
gint run(); |
148 |
void cancel(); |
149 |
~RunDialog(); |
150 |
-- |
151 |
1.7.3.5 |
152 |
|