Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SALGTKFPICKER_HXX_
21 : #define _SALGTKFPICKER_HXX_
22 :
23 : #include <osl/mutex.hxx>
24 : #include <cppuhelper/compbase2.hxx>
25 :
26 : #include <com/sun/star/awt/XTopWindowListener.hpp>
27 : #include <com/sun/star/awt/XExtendedToolkit.hpp>
28 : #include <com/sun/star/frame/XDesktop.hpp>
29 : #include <com/sun/star/frame/XTerminateListener.hpp>
30 :
31 : #include <gtk/gtk.h>
32 : #include <gdk/gdkkeysyms.h>
33 :
34 : #define FOLDERPICKER_TITLE 500
35 : #define FOLDER_PICKER_DEF_DESCRIPTION 501
36 : #define FILE_PICKER_TITLE_OPEN 502
37 : #define FILE_PICKER_TITLE_SAVE 503
38 : #define FILE_PICKER_FILE_TYPE 504
39 : #define FILE_PICKER_OVERWRITE 505
40 : #define FILE_PICKER_ALLFORMATS 506
41 :
42 : class SalGtkPicker
43 : {
44 : public:
45 : SalGtkPicker( const ::com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext );
46 : virtual ~SalGtkPicker();
47 : protected:
48 : osl::Mutex m_rbHelperMtx;
49 : GtkWidget *m_pDialog;
50 : protected:
51 : virtual void SAL_CALL implsetTitle( const OUString& aTitle )
52 : throw( ::com::sun::star::uno::RuntimeException );
53 :
54 : virtual void SAL_CALL implsetDisplayDirectory( const OUString& rDirectory )
55 : throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException );
56 :
57 : virtual OUString SAL_CALL implgetDisplayDirectory( )
58 : throw( com::sun::star::uno::RuntimeException );
59 : OUString uritounicode(const gchar *pIn);
60 : OString unicodetouri(const OUString &rURL);
61 :
62 : // to instantiate own services
63 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
64 :
65 : OUString getResString( sal_Int32 aId );
66 : private:
67 : void setGtkLanguage();
68 : };
69 :
70 : class GdkThreadLock
71 : {
72 : public:
73 0 : GdkThreadLock() { gdk_threads_enter(); }
74 0 : ~GdkThreadLock() { gdk_threads_leave(); }
75 : };
76 :
77 : //Run the Gtk Dialog. Watch for any "new windows" created while we're
78 : //executing and consider that a CANCEL event to avoid e.g. "file cannot be opened"
79 : //modal dialogs and this one getting locked if some other API call causes this
80 : //to happen while we're opened waiting for user input, e.g.
81 : //https://bugzilla.redhat.com/show_bug.cgi?id=441108
82 : class RunDialog :
83 : public cppu::WeakComponentImplHelper2<
84 : ::com::sun::star::awt::XTopWindowListener,
85 : ::com::sun::star::frame::XTerminateListener >
86 : {
87 : private:
88 : osl::Mutex maLock;
89 : GtkWidget *mpDialog;
90 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit> mxToolkit;
91 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > mxDesktop;
92 : public:
93 :
94 : // XTopWindowListener
95 : using cppu::WeakComponentImplHelperBase::disposing;
96 0 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& )
97 0 : throw(::com::sun::star::uno::RuntimeException) {}
98 : virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e )
99 : throw (::com::sun::star::uno::RuntimeException);
100 0 : virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& )
101 0 : throw (::com::sun::star::uno::RuntimeException) {}
102 0 : virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& )
103 0 : throw (::com::sun::star::uno::RuntimeException) {}
104 0 : virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& )
105 0 : throw (::com::sun::star::uno::RuntimeException) {}
106 0 : virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& )
107 0 : throw (::com::sun::star::uno::RuntimeException) {}
108 0 : virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& )
109 0 : throw (::com::sun::star::uno::RuntimeException) {}
110 0 : virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& )
111 0 : throw (::com::sun::star::uno::RuntimeException) {}
112 :
113 : // XTerminateListener
114 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
115 : throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
116 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
117 : throw(::com::sun::star::uno::RuntimeException);
118 : public:
119 : RunDialog(GtkWidget *pDialog,
120 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > &rToolkit,
121 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > &rDesktop
122 : );
123 : virtual ~RunDialog();
124 : gint run();
125 : void cancel();
126 : };
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|