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