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