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 ::rtl::OUString& aTitle )
52 : throw( ::com::sun::star::uno::RuntimeException );
53 :
54 : virtual void SAL_CALL implsetDisplayDirectory( const rtl::OUString& rDirectory )
55 : throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException );
56 :
57 : virtual rtl::OUString SAL_CALL implgetDisplayDirectory( )
58 : throw( com::sun::star::uno::RuntimeException );
59 : rtl::OUString uritounicode(const gchar *pIn);
60 : rtl::OString unicodetouri(const rtl::OUString &rURL);
61 :
62 : // to instantiate own services
63 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
64 : ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface > createInstance( const rtl::OUString &rName );
65 :
66 : rtl::OUString getResString( sal_Int32 aId );
67 : private:
68 : void setGtkLanguage();
69 : };
70 :
71 : class GdkThreadLock
72 : {
73 : public:
74 0 : GdkThreadLock() { gdk_threads_enter(); }
75 0 : ~GdkThreadLock() { gdk_threads_leave(); }
76 : };
77 :
78 : //Run the Gtk Dialog. Watch for any "new windows" created while we're
79 : //executing and consider that a CANCEL event to avoid e.g. "file cannot be opened"
80 : //modal dialogs and this one getting locked if some other API call causes this
81 : //to happen while we're opened waiting for user input, e.g.
82 : //https://bugzilla.redhat.com/show_bug.cgi?id=441108
83 : class RunDialog :
84 : public cppu::WeakComponentImplHelper2<
85 : ::com::sun::star::awt::XTopWindowListener,
86 : ::com::sun::star::frame::XTerminateListener >
87 : {
88 : private:
89 : osl::Mutex maLock;
90 : GtkWidget *mpDialog;
91 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit> mxToolkit;
92 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > mxDesktop;
93 : public:
94 :
95 : // XTopWindowListener
96 : using cppu::WeakComponentImplHelperBase::disposing;
97 0 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& )
98 0 : throw(::com::sun::star::uno::RuntimeException) {}
99 : virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e )
100 : throw (::com::sun::star::uno::RuntimeException);
101 0 : virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& )
102 0 : throw (::com::sun::star::uno::RuntimeException) {}
103 0 : virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& )
104 0 : throw (::com::sun::star::uno::RuntimeException) {}
105 0 : virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& )
106 0 : throw (::com::sun::star::uno::RuntimeException) {}
107 0 : virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& )
108 0 : throw (::com::sun::star::uno::RuntimeException) {}
109 0 : virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& )
110 0 : throw (::com::sun::star::uno::RuntimeException) {}
111 0 : virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& )
112 0 : throw (::com::sun::star::uno::RuntimeException) {}
113 :
114 : // XTerminateListener
115 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
116 : throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
117 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
118 : throw(::com::sun::star::uno::RuntimeException);
119 : public:
120 : RunDialog(GtkWidget *pDialog,
121 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XExtendedToolkit > &rToolkit,
122 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > &rDesktop
123 : );
124 : virtual ~RunDialog();
125 : gint run();
126 : void cancel();
127 : };
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|