1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SalGtkFilePicker.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SALGTKFILEPICKER_HXX_
32 #define _SALGTKFILEPICKER_HXX_
34 //_______________________________________________________________________________________________________________________
35 // includes of other projects
36 //_______________________________________________________________________________________________________________________
38 #include <cppuhelper/compbase10.hxx>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
41 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
42 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
43 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
45 #include <com/sun/star/beans/StringPair.hpp>
47 #ifndef _SALGTKPICKER_HXX_
48 #include "SalGtkPicker.hxx"
53 #ifndef _RTL_USTRING_H_
54 #include <rtl/ustring.hxx>
59 //----------------------------------------------------------
60 // Implementation class for the XFilePicker Interface
61 //----------------------------------------------------------
63 //----------------------------------------------------------
64 // forward declarations
65 //----------------------------------------------------------
70 struct ElementEntry_Impl
;
72 typedef ::std::list
< FilterEntry
> FilterList
;
73 typedef ::std::list
< ElementEntry_Impl
> ElementList
;
74 typedef ::com::sun::star::beans::StringPair UnoFilterEntry
;
75 typedef ::com::sun::star::uno::Sequence
< UnoFilterEntry
> UnoFilterList
; // can be transported more effectively
78 //----------------------------------------------------------
80 //----------------------------------------------------------
82 class SalGtkFilePicker
:
84 public cppu::WeakComponentImplHelper10
<
85 ::com::sun::star::ui::dialogs::XFilterManager
,
86 ::com::sun::star::ui::dialogs::XFilterGroupManager
,
87 ::com::sun::star::ui::dialogs::XFilePickerControlAccess
,
88 ::com::sun::star::ui::dialogs::XFilePickerNotifier
,
89 ::com::sun::star::ui::dialogs::XFilePreview
,
90 ::com::sun::star::ui::dialogs::XFilePicker2
,
91 ::com::sun::star::lang::XInitialization
,
92 ::com::sun::star::util::XCancellable
,
93 ::com::sun::star::lang::XEventListener
,
94 ::com::sun::star::lang::XServiceInfo
>
99 SalGtkFilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
101 //------------------------------------------------------------------------------------
102 // XFilePickerNotifier
103 //------------------------------------------------------------------------------------
105 virtual void SAL_CALL
addFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
106 throw( ::com::sun::star::uno::RuntimeException
);
107 virtual void SAL_CALL
removeFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
)
108 throw( ::com::sun::star::uno::RuntimeException
);
110 //------------------------------------------------------------------------------------
111 // XExecutableDialog functions
112 //------------------------------------------------------------------------------------
114 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& aTitle
)
115 throw( ::com::sun::star::uno::RuntimeException
);
117 virtual sal_Int16 SAL_CALL
execute( )
118 throw( ::com::sun::star::uno::RuntimeException
);
120 //------------------------------------------------------------------------------------
121 // XFilePicker functions
122 //------------------------------------------------------------------------------------
124 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
)
125 throw( ::com::sun::star::uno::RuntimeException
);
127 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
& aName
)
128 throw( ::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
& aDirectory
)
131 throw( com::sun::star::lang::IllegalArgumentException
,
132 ::com::sun::star::uno::RuntimeException
);
134 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory( )
135 throw( ::com::sun::star::uno::RuntimeException
);
137 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles( )
138 throw( ::com::sun::star::uno::RuntimeException
);
140 //------------------------------------------------------------------------------------
141 // XFilePicker2 functions
142 //------------------------------------------------------------------------------------
144 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSelectedFiles()
145 throw (::com::sun::star::uno::RuntimeException
);
147 //------------------------------------------------------------------------------------
148 // XFilterManager functions
149 //------------------------------------------------------------------------------------
151 virtual void SAL_CALL
appendFilter( const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aFilter
)
152 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
154 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
& aTitle
)
155 throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
157 virtual ::rtl::OUString SAL_CALL
getCurrentFilter( )
158 throw( ::com::sun::star::uno::RuntimeException
);
160 //------------------------------------------------------------------------------------
161 // XFilterGroupManager functions
162 //------------------------------------------------------------------------------------
164 virtual void SAL_CALL
appendFilterGroup( const ::rtl::OUString
& sGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& aFilters
)
165 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
167 //------------------------------------------------------------------------------------
168 // XFilePickerControlAccess functions
169 //------------------------------------------------------------------------------------
171 virtual void SAL_CALL
setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const ::com::sun::star::uno::Any
& aValue
)
172 throw (::com::sun::star::uno::RuntimeException
);
174 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 aControlId
, sal_Int16 aControlAction
)
175 throw (::com::sun::star::uno::RuntimeException
);
177 virtual void SAL_CALL
enableControl( sal_Int16 nControlId
, sal_Bool bEnable
)
178 throw(::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
setLabel( sal_Int16 nControlId
, const ::rtl::OUString
& aLabel
)
181 throw (::com::sun::star::uno::RuntimeException
);
183 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 nControlId
)
184 throw (::com::sun::star::uno::RuntimeException
);
186 //------------------------------------------------
188 //------------------------------------------------
190 virtual ::com::sun::star::uno::Sequence
< sal_Int16
> SAL_CALL
getSupportedImageFormats( )
191 throw (::com::sun::star::uno::RuntimeException
);
193 virtual sal_Int32 SAL_CALL
getTargetColorDepth( )
194 throw (::com::sun::star::uno::RuntimeException
);
196 virtual sal_Int32 SAL_CALL
getAvailableWidth( )
197 throw (::com::sun::star::uno::RuntimeException
);
199 virtual sal_Int32 SAL_CALL
getAvailableHeight( )
200 throw (::com::sun::star::uno::RuntimeException
);
202 virtual void SAL_CALL
setImage( sal_Int16 aImageFormat
, const ::com::sun::star::uno::Any
& aImage
)
203 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
205 virtual sal_Bool SAL_CALL
setShowState( sal_Bool bShowState
)
206 throw (::com::sun::star::uno::RuntimeException
);
208 virtual sal_Bool SAL_CALL
getShowState( )
209 throw (::com::sun::star::uno::RuntimeException
);
211 //------------------------------------------------
213 //------------------------------------------------
215 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
216 throw(::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
218 //------------------------------------------------
220 //------------------------------------------------
222 virtual void SAL_CALL
cancel( )
223 throw( ::com::sun::star::uno::RuntimeException
);
225 //------------------------------------------------
227 //------------------------------------------------
229 using cppu::WeakComponentImplHelperBase::disposing
;
230 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
)
231 throw(::com::sun::star::uno::RuntimeException
);
233 //------------------------------------------------
235 //------------------------------------------------
237 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
238 throw(::com::sun::star::uno::RuntimeException
);
240 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
241 throw(::com::sun::star::uno::RuntimeException
);
243 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
244 throw(::com::sun::star::uno::RuntimeException
);
246 //------------------------------------------------------------------------------------
247 // FilePicker Event functions
248 //------------------------------------------------------------------------------------
250 void SAL_CALL
fileSelectionChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
251 void SAL_CALL
directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
252 rtl::OUString SAL_CALL
helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
) const;
253 void SAL_CALL
controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent
);
256 // prevent copy and assignment
257 SalGtkFilePicker( const SalGtkFilePicker
& );
258 SalGtkFilePicker
& operator=( const SalGtkFilePicker
& );
260 sal_Bool
FilterNameExists( const ::rtl::OUString
& rTitle
);
261 sal_Bool
FilterNameExists( const UnoFilterList
& _rGroupedFilters
);
263 void ensureFilterList( const ::rtl::OUString
& _rInitialCurrentFilter
);
265 // to instanciate own services
266 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceMgr
;
269 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>
271 ::rtl::OUString msPlayLabel
;
272 FilterList
*m_pFilterList
;
275 GtkWidget
*m_pFilterExpander
;
276 GtkWidget
*m_pFilterView
;
277 GtkListStore
*m_pFilterStore
;
290 GtkWidget
*m_pToggles
[ TOGGLE_LAST
];
292 bool mbToggleVisibility
[TOGGLE_LAST
];
293 bool mbToggleChecked
[TOGGLE_LAST
];
295 static const rtl::OString m_ToggleLabels
[TOGGLE_LAST
];
301 GtkWidget
*m_pButtons
[ BUTTON_LAST
];
310 GtkWidget
*m_pHBoxs
[ LIST_LAST
];
311 GtkWidget
*m_pAligns
[ LIST_LAST
];
312 GtkWidget
*m_pLists
[ LIST_LAST
];
313 GtkWidget
*m_pListLabels
[ LIST_LAST
];
314 bool mbListVisibility
[ LIST_LAST
];
315 bool mbButtonVisibility
[ BUTTON_LAST
];
316 gulong mnHID_FolderChange
;
317 gulong mnHID_SelectionChange
;
319 ::rtl::OUString m_aCurrentFilter
;
321 bool bVersionWidthUnset
;
322 sal_Bool mbPreviewState
;
324 GtkWidget
* m_pPreview
;
325 sal_Int32 m_PreviewImageWidth
;
326 sal_Int32 m_PreviewImageHeight
;
328 GtkWidget
*getWidget( sal_Int16 nControlId
, GType
*pType
= NULL
);
330 void SetCurFilter( const OUString
& rFilter
);
332 void UpdateFilterfromUI();
334 void implChangeType( GtkTreeSelection
*selection
);
335 int implAddFilter( const OUString
& rFilter
, const OUString
& rType
);
336 int implAddFilterGroup( const OUString
& rFilter
,
337 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
>& _rFilters
);
338 void updateCurrentFilterFromName(const gchar
* filtername
);
339 void unselect_type();
340 void InitialMapping();
342 void HandleSetListValue(GtkComboBox
*pWidget
, sal_Int16 nControlAction
,
343 const ::com::sun::star::uno::Any
& rValue
);
344 ::com::sun::star::uno::Any
HandleGetListValue(GtkComboBox
*pWidget
, sal_Int16 nControlAction
) const;
346 static void expander_changed_cb( GtkExpander
*expander
, SalGtkFilePicker
*pobjFP
);
347 static void preview_toggled_cb (GtkObject
*cb
, SalGtkFilePicker
*pobjFP
);
348 static void filter_changed_cb (GtkFileChooser
*file_chooser
, GParamSpec
*pspec
, SalGtkFilePicker
*pobjFP
);
349 static void type_changed_cb( GtkTreeSelection
*selection
, SalGtkFilePicker
*pobjFP
);
350 static void folder_changed_cb (GtkFileChooser
*file_chooser
, SalGtkFilePicker
*pobjFP
);
351 static void selection_changed_cb (GtkFileChooser
*file_chooser
, SalGtkFilePicker
*pobjFP
);
352 static void update_preview_cb (GtkFileChooser
*file_chooser
, SalGtkFilePicker
*pobjFP
);
353 static void dialog_mapped_cb(GtkWidget
*widget
, SalGtkFilePicker
*pobjFP
);
355 virtual ~SalGtkFilePicker();
358 /* vi:set tabstop=4 shiftwidth=4 expandtab: */
359 #endif // _SALGTKFILEPICKER_HXX_