summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/aqua/FilterHelper.cxx11
-rw-r--r--fpicker/source/aqua/NSURL_OOoAdditions.hxx13
-rw-r--r--fpicker/source/aqua/NSURL_OOoAdditions.mm30
-rw-r--r--fpicker/source/unx/gnome/SalGtkFilePicker.cxx135
-rw-r--r--fpicker/source/unx/gnome/SalGtkFolderPicker.cxx19
-rw-r--r--fpicker/source/unx/gnome/SalGtkPicker.cxx62
-rw-r--r--fpicker/source/unx/gnome/SalGtkPicker.hxx9
-rw-r--r--fpicker/source/unx/gnome/resourceprovider.cxx2
-rw-r--r--fpicker/source/unx/kde4/KDE4FilePicker.cxx12
9 files changed, 202 insertions, 91 deletions
diff --git a/fpicker/source/aqua/FilterHelper.cxx b/fpicker/source/aqua/FilterHelper.cxx
index 10e429f201c5..9c644326005e 100644
--- a/fpicker/source/aqua/FilterHelper.cxx
+++ b/fpicker/source/aqua/FilterHelper.cxx
@@ -35,6 +35,7 @@
// #endif
#include "CFStringUtilities.hxx"
#include "NSString_OOoAdditions.hxx"
+#include "NSURL_OOoAdditions.hxx"
#include "FilterHelper.hxx"
@@ -428,6 +429,16 @@ sal_Bool FilterHelper::filenameMatchesFilter(NSString* sFilename)
}
}
+ // might be an alias
+ NSString* pResolved = resolveAlias( sFilename );
+ if( pResolved )
+ {
+ sal_Bool bResult = filenameMatchesFilter( pResolved );
+ [pResolved autorelease];
+ if( bResult )
+ return sal_True;
+ }
+
DBG_PRINT_EXIT(CLASS_NAME, __func__);
return sal_False;
diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.hxx b/fpicker/source/aqua/NSURL_OOoAdditions.hxx
index 8be2c0362096..31b55385e155 100644
--- a/fpicker/source/aqua/NSURL_OOoAdditions.hxx
+++ b/fpicker/source/aqua/NSURL_OOoAdditions.hxx
@@ -29,15 +29,20 @@
#define _NSURL_OOOADDITIONS_HXX_
#include <premac.h>
-#include <Foundation/Foundation.h>
+#include <CoreFoundation/CoreFoundation.h>
#include <postmac.h>
#include "CFStringUtilities.hxx"
#include <rtl/ustring.hxx>
-// #include <sal/types.h>
-
@interface NSURL (OOoAdditions)
- (rtl::OUString) OUStringForInfo:(InfoType)info;
@end
-#endif \ No newline at end of file
+/*
+ returns the resolved string if there was an alias
+ if there was no alias, nil is returned
+*/
+
+NSString* resolveAlias( NSString* i_pSystemPath );
+
+#endif
diff --git a/fpicker/source/aqua/NSURL_OOoAdditions.mm b/fpicker/source/aqua/NSURL_OOoAdditions.mm
index 56fc198650c8..ecc38b7e232b 100644
--- a/fpicker/source/aqua/NSURL_OOoAdditions.mm
+++ b/fpicker/source/aqua/NSURL_OOoAdditions.mm
@@ -80,3 +80,33 @@
return sResult;
}
@end
+
+NSString* resolveAlias( NSString* i_pSystemPath )
+{
+ NSString* pResolvedPath = nil;
+ CFURLRef rUrl = CFURLCreateWithFileSystemPath( kCFAllocatorDefault,
+ (CFStringRef)i_pSystemPath,
+ kCFURLPOSIXPathStyle, false);
+ if( rUrl != NULL )
+ {
+ FSRef rFS;
+ if( CFURLGetFSRef( rUrl, &rFS ) )
+ {
+ MacOSBoolean bIsFolder = false;
+ MacOSBoolean bAlias = false;
+ OSErr err = FSResolveAliasFile( &rFS, true, &bIsFolder, &bAlias);
+ if( (err == noErr) && bAlias )
+ {
+ CFURLRef rResolvedUrl = CFURLCreateFromFSRef( kCFAllocatorDefault, &rFS );
+ if( rResolvedUrl != NULL )
+ {
+ pResolvedPath = (NSString*)CFURLCopyFileSystemPath( rResolvedUrl, kCFURLPOSIXPathStyle );
+ CFRelease( rResolvedUrl );
+ }
+ }
+ }
+ CFRelease( rUrl );
+ }
+
+ return pResolvedPath;
+}
diff --git a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
index 4fe6f6f11b20..fdf4866daf24 100644
--- a/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
+++ b/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
@@ -33,13 +33,13 @@
//------------------------------------------------------------------------
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <osl/diagnose.h>
+#include <osl/process.h>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
#include <com/sun/star/uno/Any.hxx>
@@ -96,6 +96,8 @@ namespace
static void expandexpanders(GtkContainer *pWidget)
{
+ GdkThreadLock aLock;
+
GList *pChildren = gtk_container_get_children(pWidget);
for( GList *p = pChildren; p; p = p->next )
{
@@ -114,6 +116,8 @@ void SalGtkFilePicker::dialog_mapped_cb(GtkWidget *, SalGtkFilePicker *pobjFP)
void SalGtkFilePicker::InitialMapping()
{
+ GdkThreadLock aLock;
+
if (!mbPreviewState )
{
gtk_widget_hide( m_pPreview );
@@ -122,41 +126,8 @@ void SalGtkFilePicker::InitialMapping()
gtk_widget_set_size_request (m_pPreview, -1, -1);
}
-static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr)
-{
- static bool bSet = false;
- if (bSet)
- return;
-
- OUString sUILocale;
- try
- {
- uno::Reference<lang::XMultiServiceFactory> xConfigMgr =
- uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance(
- OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
- UNO_QUERY_THROW );
-
- Sequence< Any > theArgs(1);
- theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
-
- uno::Reference< container::XNameAccess > xNameAccess =
- uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments(
- OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ),
- UNO_QUERY_THROW );
-
- if (xNameAccess.is())
- xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale;
- } catch (...) {}
-
- if (sUILocale.getLength())
- {
- sUILocale = rtl::OUString::createFromAscii("LANGUAGE=") + sUILocale.replace('-', '_');
- putenv(strdup(rtl::OUStringToOString(sUILocale, osl_getThreadTextEncoding()).getStr()));
- }
- bSet = true;
-}
-
SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) :
+ SalGtkPicker(xServiceMgr),
cppu::WeakComponentImplHelper10<
XFilterManager,
XFilterGroupManager,
@@ -180,8 +151,6 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFact
m_PreviewImageWidth( 256 ),
m_PreviewImageHeight( 256 )
{
- lcl_setGTKLanguage(xServiceMgr);
-
int i;
for( i = 0; i < TOGGLE_LAST; i++ )
@@ -208,6 +177,8 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFact
CResourceProvider aResProvider;
OUString aFilePickerTitle = aResProvider.getResString( FILE_PICKER_TITLE_OPEN );
+ GdkThreadLock aLock;
+
m_pDialog = gtk_file_chooser_dialog_new(
OUStringToOString( aFilePickerTitle, RTL_TEXTENCODING_UTF8 ).getStr(),
NULL,
@@ -385,14 +356,12 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFact
void SAL_CALL SalGtkFilePicker::addFilePickerListener( const uno::Reference<XFilePickerListener>& xListener )
throw( uno::RuntimeException )
{
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
m_xListener = xListener;
}
void SAL_CALL SalGtkFilePicker::removeFilePickerListener( const uno::Reference<XFilePickerListener>& )
throw( uno::RuntimeException )
{
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
m_xListener.clear();
}
@@ -591,6 +560,8 @@ shrinkFilterName( const rtl::OUString &rFilterName, bool bAllowNoStar = false )
static void
dialog_remove_buttons( GtkDialog *pDialog )
{
+ GdkThreadLock aLock;
+
g_return_if_fail( GTK_IS_DIALOG( pDialog ) );
GList *pChildren =
@@ -700,7 +671,6 @@ void SAL_CALL SalGtkFilePicker::appendFilter( const rtl::OUString& aTitle, const
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
if( FilterNameExists( aTitle ) )
throw IllegalArgumentException();
@@ -721,7 +691,6 @@ void SAL_CALL SalGtkFilePicker::setCurrentFilter( const rtl::OUString& aTitle )
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
OSL_TRACE( "Setting current filter to %s\n",
OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 ).getStr() );
@@ -763,6 +732,9 @@ void SalGtkFilePicker::UpdateFilterfromUI()
// from the filter of the files glob on which he is currently searching
if (!mnHID_FolderChange || !mnHID_SelectionChange)
return;
+
+ GdkThreadLock aLock;
+
GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pFilterView));
GtkTreeIter iter;
GtkTreeModel *model;
@@ -782,7 +754,6 @@ void SalGtkFilePicker::UpdateFilterfromUI()
rtl::OUString SAL_CALL SalGtkFilePicker::getCurrentFilter() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
OSL_TRACE( "GetCURRENTfilter\n" );
@@ -802,7 +773,6 @@ void SAL_CALL SalGtkFilePicker::appendFilterGroup( const rtl::OUString& /*sGroup
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO m_pImpl->appendFilterGroup( sGroupTitle, aFilters );
// check the names
@@ -832,7 +802,8 @@ void SAL_CALL SalGtkFilePicker::appendFilterGroup( const rtl::OUString& /*sGroup
void SAL_CALL SalGtkFilePicker::setMultiSelectionMode( sal_Bool bMode ) throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER(m_pDialog), bMode );
}
@@ -841,7 +812,8 @@ void SAL_CALL SalGtkFilePicker::setDefaultName( const rtl::OUString& aName )
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
OString aStr = OUStringToOString( aName, RTL_TEXTENCODING_UTF8 );
GtkFileChooserAction eAction = gtk_file_chooser_get_action( GTK_FILE_CHOOSER( m_pDialog ) );
@@ -877,7 +849,8 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getFiles() throw( uno::R
uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
GSList* pPathList = gtk_file_chooser_get_uris( GTK_FILE_CHOOSER(m_pDialog) );
@@ -927,6 +900,9 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw
{
static const OUString aStarDot = OUString::createFromAscii( "*." );
+ ::rtl::OUString aNewFilter;
+ ::rtl::OUString aOldFilter = getCurrentFilter();
+ sal_Bool bChangeFilter = sal_True;
for ( FilterList::iterator aListIter = m_pFilterList->begin();
aListIter != m_pFilterList->end();
++aListIter
@@ -934,11 +910,17 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles() throw
{
if( aListIter->getFilter().indexOf( aStarDot+sExtension ) >= 0 )
{
- setCurrentFilter( aListIter->getTitle() );
+ if( !aNewFilter.getLength() )
+ aNewFilter = aListIter->getTitle();
+
+ if( aOldFilter == aListIter->getTitle() )
+ bChangeFilter = sal_False;
+
bExtensionTypedIn = true;
- break;
}
}
+ if( bChangeFilter )
+ setCurrentFilter( aNewFilter );
}
}
@@ -1014,7 +996,8 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute() throw( uno::RuntimeException )
{
OSL_TRACE( "1: HERE WE ARE\n");
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
sal_Int16 retVal = 0;
@@ -1171,6 +1154,8 @@ namespace
{
void HackWidthToFirst(GtkComboBox *pWidget)
{
+ GdkThreadLock aLock;
+
GtkRequisition requisition;
gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
@@ -1179,6 +1164,8 @@ namespace
void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction, const uno::Any& rValue)
{
+ GdkThreadLock aLock;
+
switch (nControlAction)
{
case ControlActions::ADD_ITEM:
@@ -1253,6 +1240,8 @@ void SalGtkFilePicker::HandleSetListValue(GtkComboBox *pWidget, sal_Int16 nContr
uno::Any SalGtkFilePicker::HandleGetListValue(GtkComboBox *pWidget, sal_Int16 nControlAction) const
{
+ GdkThreadLock aLock;
+
uno::Any aAny;
switch (nControlAction)
{
@@ -1312,15 +1301,15 @@ void SAL_CALL SalGtkFilePicker::setValue( sal_Int16 nControlId, sal_Int16 nContr
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
OSL_TRACE( "SETTING VALUE %d\n", nControlAction );
GType tType;
GtkWidget *pWidget;
+ GdkThreadLock aLock;
+
if( !( pWidget = getWidget( nControlId, &tType ) ) )
OSL_TRACE("enable unknown control %d\n", nControlId);
-
else if( tType == GTK_TYPE_TOGGLE_BUTTON )
{
sal_Bool bChecked = false;
@@ -1340,15 +1329,16 @@ uno::Any SAL_CALL SalGtkFilePicker::getValue( sal_Int16 nControlId, sal_Int16 nC
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
uno::Any aRetval;
GType tType;
GtkWidget *pWidget;
+ GdkThreadLock aLock;
+
if( !( pWidget = getWidget( nControlId, &tType ) ) )
OSL_TRACE("enable unknown control %d\n", nControlId);
-
else if( tType == GTK_TYPE_TOGGLE_BUTTON )
aRetval <<= (sal_Bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( pWidget ) );
else if( tType == GTK_TYPE_COMBO_BOX )
@@ -1364,13 +1354,13 @@ void SAL_CALL SalGtkFilePicker::enableControl( sal_Int16 nControlId, sal_Bool bE
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
GtkWidget *pWidget;
+ GdkThreadLock aLock;
+
if ( nControlId == ExtendedFilePickerElementIds::LISTBOX_FILTER_SELECTOR )
gtk_expander_set_expanded( GTK_EXPANDER( m_pFilterExpander ), bEnable );
-
else if( ( pWidget = getWidget( nControlId ) ) )
{
if( bEnable )
@@ -1392,11 +1382,12 @@ void SAL_CALL SalGtkFilePicker::setLabel( sal_Int16 nControlId, const ::rtl::OUS
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
GType tType;
GtkWidget *pWidget;
+ GdkThreadLock aLock;
+
if( !( pWidget = getWidget( nControlId, &tType ) ) )
{
OSL_TRACE("Set label on unknown control %d\n", nControlId);
@@ -1428,18 +1419,17 @@ rtl::OUString SAL_CALL SalGtkFilePicker::getLabel( sal_Int16 nControlId )
throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
GType tType;
OString aTxt;
GtkWidget *pWidget;
+ GdkThreadLock aLock;
+
if( !( pWidget = getWidget( nControlId, &tType ) ) )
OSL_TRACE("Get label on unknown control %d\n", nControlId);
-
else if( tType == GTK_TYPE_TOGGLE_BUTTON || tType == GTK_TYPE_BUTTON || tType == GTK_TYPE_LABEL )
aTxt = gtk_button_get_label( GTK_BUTTON( pWidget ) );
-
else
OSL_TRACE("Can't get label on list\n");
@@ -1453,7 +1443,6 @@ rtl::OUString SAL_CALL SalGtkFilePicker::getLabel( sal_Int16 nControlId )
uno::Sequence<sal_Int16> SAL_CALL SalGtkFilePicker::getSupportedImageFormats() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO return m_pImpl->getSupportedImageFormats();
return 0;
@@ -1462,7 +1451,6 @@ uno::Sequence<sal_Int16> SAL_CALL SalGtkFilePicker::getSupportedImageFormats() t
sal_Int32 SAL_CALL SalGtkFilePicker::getTargetColorDepth() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO return m_pImpl->getTargetColorDepth();
return 0;
@@ -1471,18 +1459,14 @@ sal_Int32 SAL_CALL SalGtkFilePicker::getTargetColorDepth() throw( uno::RuntimeEx
sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableWidth() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
- // TODO return m_pImpl->getAvailableWidth();
return m_PreviewImageWidth;
}
sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableHeight() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
- // TODO return m_pImpl->getAvailableHeight();
return m_PreviewImageHeight;
}
@@ -1490,7 +1474,6 @@ void SAL_CALL SalGtkFilePicker::setImage( sal_Int16 /*aImageFormat*/, const uno:
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO m_pImpl->setImage( aImageFormat, aImage );
}
@@ -1499,6 +1482,9 @@ void SalGtkFilePicker::implChangeType( GtkTreeSelection *selection )
{
CResourceProvider aResProvider;
OUString aLabel = aResProvider.getResString( FILE_PICKER_FILE_TYPE );
+
+ GdkThreadLock aLock;
+
GtkTreeIter iter;
GtkTreeModel *model;
if (gtk_tree_selection_get_selected (selection, &model, &iter))
@@ -1523,6 +1509,8 @@ void SalGtkFilePicker::type_changed_cb( GtkTreeSelection *selection, SalGtkFileP
void SalGtkFilePicker::unselect_type()
{
+ GdkThreadLock aLock;
+
gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(GTK_TREE_VIEW(m_pFilterView)));
}
@@ -1589,11 +1577,12 @@ void SalGtkFilePicker::update_preview_cb( GtkFileChooser *file_chooser, SalGtkFi
sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO return m_pImpl->setShowState( bShowState );
if( bShowState != mbPreviewState )
{
+ GdkThreadLock aLock;
+
if( bShowState )
{
// Show
@@ -1622,9 +1611,7 @@ sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState ) throw( u
sal_Bool SAL_CALL SalGtkFilePicker::getShowState() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
- // TODO return m_pImpl->getShowState();
return mbPreviewState;
}
@@ -1740,6 +1727,8 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
1 );
}
+ GdkThreadLock aLock;
+
if( GTK_FILE_CHOOSER_ACTION_SAVE == eAction )
{
CResourceProvider aResProvider;
@@ -1801,7 +1790,6 @@ void SalGtkFilePicker::preview_toggled_cb( GtkObject *cb, SalGtkFilePicker* pobj
void SAL_CALL SalGtkFilePicker::cancel() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO m_pImpl->cancel();
}
@@ -1848,6 +1836,8 @@ uno::Sequence<rtl::OUString> SAL_CALL SalGtkFilePicker::getSupportedServiceNames
//-------------------------------------------------
void SalGtkFilePicker::SetCurFilter( const OUString& rFilter )
{
+ GdkThreadLock aLock;
+
// Get all the filters already added
GSList *filters = gtk_file_chooser_list_filters ( GTK_FILE_CHOOSER( m_pDialog ) );
bool bFound = false;
@@ -1903,6 +1893,8 @@ case_insensitive_filter (const GtkFileFilterInfo *filter_info, gpointer data)
int SalGtkFilePicker::implAddFilter( const OUString& rFilter, const OUString& rType )
{
+ GdkThreadLock aLock;
+
GtkFileFilter *filter = gtk_file_filter_new();
OUString aShrunkName = shrinkFilterName( rFilter );
@@ -1981,6 +1973,9 @@ int SalGtkFilePicker::implAddFilterGroup( const OUString& /*_rFilter*/, const Se
void SalGtkFilePicker::SetFilters()
{
OSL_TRACE( "start setting filters\n");
+
+ GdkThreadLock aLock;
+
int nAdded = 0;
if( m_pFilterList && !m_pFilterList->empty() )
{
diff --git a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx
index 6b843d8b79f4..dd5d30d203a6 100644
--- a/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx
+++ b/fpicker/source/unx/gnome/SalGtkFolderPicker.cxx
@@ -84,9 +84,13 @@ namespace
// constructor
//-----------------------------------------------------------------------------------------
SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) :
- m_xServiceMgr( xServiceMgr )
+ SalGtkPicker(xServiceMgr),
+ m_xServiceMgr(xServiceMgr)
{
CResourceProvider aResProvider;
+
+ GdkThreadLock aLock;
+
m_pDialog = gtk_file_chooser_dialog_new(
OUStringToOString( aResProvider.getResString( FOLDERPICKER_TITLE ), RTL_TEXTENCODING_UTF8 ).getStr(),
NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -110,7 +114,6 @@ void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const rtl::OUString& aDir
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
OString aTxt = unicodetouri( aDirectory );
@@ -119,14 +122,17 @@ void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const rtl::OUString& aDir
OSL_TRACE( "setting path to %s\n", aTxt.getStr() );
+ GdkThreadLock aLock;
+
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
- aTxt.getStr() );
+ aTxt.getStr() );
}
rtl::OUString SAL_CALL SalGtkFolderPicker::getDisplayDirectory() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
gchar* pCurrentFolder =
gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
@@ -156,9 +162,10 @@ void SAL_CALL SalGtkFolderPicker::setDescription( const rtl::OUString& rDescript
void SAL_CALL SalGtkFolderPicker::setTitle( const rtl::OUString& aTitle ) throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
::rtl::OString aWindowTitle = OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 );
+
+ GdkThreadLock aLock;
gtk_window_set_title( GTK_WINDOW( m_pDialog ), aWindowTitle.getStr() );
}
@@ -166,7 +173,6 @@ sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException )
{
OSL_TRACE( "1: HERE WE ARE\n");
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
sal_Int16 retVal = 0;
@@ -199,7 +205,6 @@ sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException )
void SAL_CALL SalGtkFolderPicker::cancel() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
// TODO m_pImpl->cancel();
}
diff --git a/fpicker/source/unx/gnome/SalGtkPicker.cxx b/fpicker/source/unx/gnome/SalGtkPicker.cxx
index 2d2e086ba2ca..6fd19b2f7f79 100644
--- a/fpicker/source/unx/gnome/SalGtkPicker.cxx
+++ b/fpicker/source/unx/gnome/SalGtkPicker.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
#include <com/sun/star/awt/SystemDependentXWindow.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <rtl/process.h>
@@ -148,6 +149,8 @@ RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit
}
}
+ GdkThreadLock aLock;
+
GdkDisplay *pDisplay = aWindowHandle.DisplayPointer ? gdk_x11_lookup_xdisplay(reinterpret_cast<void*>(static_cast<sal_IntPtr>(aWindowHandle.DisplayPointer))) : NULL;
GdkWindow* pParent = pDisplay ? gdk_window_lookup_for_display(pDisplay, aWindowHandle.WindowHandle) : NULL;
if (!pParent && pDisplay)
@@ -163,17 +166,22 @@ RunDialog::RunDialog( GtkWidget *pDialog, uno::Reference< awt::XExtendedToolkit
RunDialog::~RunDialog()
{
if (mpCreatedParent)
+ {
+ GdkThreadLock aLock;
gdk_window_destroy (mpCreatedParent);
+ }
}
void SAL_CALL RunDialog::windowOpened( const ::com::sun::star::lang::EventObject& )
throw (::com::sun::star::uno::RuntimeException)
{
+ GdkThreadLock aLock;
g_timeout_add_full(G_PRIORITY_HIGH_IDLE, 0, (GSourceFunc)canceldialog, this, NULL);
}
void RunDialog::cancel()
{
+ GdkThreadLock aLock;
gtk_dialog_response( GTK_DIALOG( mpDialog ), GTK_RESPONSE_CANCEL );
gtk_widget_hide( mpDialog );
}
@@ -183,6 +191,7 @@ gint RunDialog::run()
if (mxToolkit.is())
mxToolkit->addTopWindowListener(this);
+ GdkThreadLock aLock;
gint nStatus = gtk_dialog_run( GTK_DIALOG( mpDialog ) );
if (mxToolkit.is())
@@ -194,17 +203,59 @@ gint RunDialog::run()
return nStatus;
}
+static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr)
+{
+ static bool bSet = false;
+ if (bSet)
+ return;
+
+ OUString sUILocale;
+ try
+ {
+ uno::Reference<lang::XMultiServiceFactory> xConfigMgr =
+ uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ UNO_QUERY_THROW );
+
+ Sequence< Any > theArgs(1);
+ theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
+
+ uno::Reference< container::XNameAccess > xNameAccess =
+ uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ),
+ UNO_QUERY_THROW );
+
+ if (xNameAccess.is())
+ xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale;
+ } catch (...) {}
+
+ if (sUILocale.getLength())
+ {
+ sUILocale = sUILocale.replace('-', '_');
+ rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("LANGUAGE"));
+ osl_setEnvironment(envVar.pData, sUILocale.pData);
+ }
+ bSet = true;
+}
+
+SalGtkPicker::SalGtkPicker(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) : m_pDialog(0)
+{
+ lcl_setGTKLanguage(xServiceMgr);
+}
+
SalGtkPicker::~SalGtkPicker()
{
if (m_pDialog)
+ {
+ GdkThreadLock aLock;
gtk_widget_destroy(m_pDialog);
+ }
}
void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const rtl::OUString& aDirectory )
throw( lang::IllegalArgumentException, uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
OString aTxt = unicodetouri(aDirectory);
@@ -213,14 +264,16 @@ void SAL_CALL SalGtkPicker::implsetDisplayDirectory( const rtl::OUString& aDirec
OSL_TRACE( "setting path to %s\n", aTxt.getStr() );
+ GdkThreadLock aLock;
gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
- aTxt.getStr() );
+ aTxt.getStr() );
}
rtl::OUString SAL_CALL SalGtkPicker::implgetDisplayDirectory() throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ GdkThreadLock aLock;
gchar* pCurrentFolder =
gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
@@ -233,8 +286,9 @@ rtl::OUString SAL_CALL SalGtkPicker::implgetDisplayDirectory() throw( uno::Runti
void SAL_CALL SalGtkPicker::implsetTitle( const rtl::OUString& aTitle ) throw( uno::RuntimeException )
{
OSL_ASSERT( m_pDialog != NULL );
- ::vos::OGuard aGuard( Application::GetSolarMutex() );
::rtl::OString aWindowTitle = OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 );
+
+ GdkThreadLock aLock;
gtk_window_set_title( GTK_WINDOW( m_pDialog ), aWindowTitle.getStr() );
}
diff --git a/fpicker/source/unx/gnome/SalGtkPicker.hxx b/fpicker/source/unx/gnome/SalGtkPicker.hxx
index 5baa5bdb56e8..94e7a11de99a 100644
--- a/fpicker/source/unx/gnome/SalGtkPicker.hxx
+++ b/fpicker/source/unx/gnome/SalGtkPicker.hxx
@@ -53,7 +53,7 @@
class SalGtkPicker
{
public:
- SalGtkPicker() : m_pDialog(0) {}
+ SalGtkPicker(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xServiceMgr);
virtual ~SalGtkPicker();
protected:
osl::Mutex m_rbHelperMtx;
@@ -71,6 +71,13 @@ class SalGtkPicker
static rtl::OString unicodetouri(const rtl::OUString &rURL);
};
+class GdkThreadLock
+{
+public:
+ GdkThreadLock() { gdk_threads_enter(); }
+ ~GdkThreadLock() { gdk_threads_leave(); }
+};
+
//Run the Gtk Dialog. Watch for any "new windows" created while we're
//executing and consider that a CANCEL event to avoid e.g. "file cannot be opened"
//modal dialogs and this one getting locked if some other API call causes this
diff --git a/fpicker/source/unx/gnome/resourceprovider.cxx b/fpicker/source/unx/gnome/resourceprovider.cxx
index 393ea7585d5a..8df810060ee5 100644
--- a/fpicker/source/unx/gnome/resourceprovider.cxx
+++ b/fpicker/source/unx/gnome/resourceprovider.cxx
@@ -168,8 +168,6 @@ public:
String aResString;
OUString aResOUString;
- const ::vos::OGuard aGuard( Application::GetSolarMutex() );
-
try
{
OSL_ASSERT( m_ResMgr && m_OtherResMgr );
diff --git a/fpicker/source/unx/kde4/KDE4FilePicker.cxx b/fpicker/source/unx/kde4/KDE4FilePicker.cxx
index a7fa01a5ece6..eadc255f0ec0 100644
--- a/fpicker/source/unx/kde4/KDE4FilePicker.cxx
+++ b/fpicker/source/unx/kde4/KDE4FilePicker.cxx
@@ -46,6 +46,8 @@
#include <vcl/sysdata.hxx>
#include <vcl/syswin.hxx>
+#include "osl/file.h"
+
#include "KDE4FilePicker.hxx"
#include "FPServiceInfo.hxx"
@@ -246,7 +248,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
// kde file picker returns the file and directories for selectedFiles()
// when a file is double clicked
// make a true list of files
- const QString dir = "file://" + KUrl(rawFiles[0]).directory();
+ const QString dir = KUrl(rawFiles[0]).directory();
bool singleFile = true;
if (rawFiles.size() > 1)
@@ -262,7 +264,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
{
// if the raw file is not the base directory (see above kde bug)
// we add the file to list of avail files
- if ((dir + "/") != ("file://" + rawFiles[i]))
+ if ((dir + "/") != ( rawFiles[i]))
{
QString filename = KUrl(rawFiles[i]).fileName();
@@ -280,7 +282,11 @@ uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
// add all files and leading directory to outgoing OO sequence
uno::Sequence< ::rtl::OUString > seq(files.size());
for (int i = 0; i < files.size(); ++i)
- seq[i] = toOUString(files[i]);
+ {
+ rtl::OUString aFile(toOUString(files[i])), aURL;
+ osl_getFileURLFromSystemPath(aFile.pData, &aURL.pData );
+ seq[i] = aURL;
+ }
return seq;
}