LCOV - code coverage report
Current view: top level - vcl/unx/gtk/fpicker - SalGtkFolderPicker.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 61 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          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             : #ifdef AIX
      21             : #define _LINUX_SOURCE_COMPAT
      22             : #include <sys/timer.h>
      23             : #undef _LINUX_SOURCE_COMPAT
      24             : #endif
      25             : 
      26             : #include <config_vclplug.h>
      27             : 
      28             : #include <com/sun/star/awt/Toolkit.hpp>
      29             : #include <com/sun/star/frame/Desktop.hpp>
      30             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      31             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      32             : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
      33             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      34             : #include <osl/diagnose.h>
      35             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      36             : #include <com/sun/star/uno/Any.hxx>
      37             : #include <osl/mutex.hxx>
      38             : #include <vcl/svapp.hxx>
      39             : #include "unx/gtk/gtkinst.hxx"
      40             : #include "gtk/fpicker/SalGtkFolderPicker.hxx"
      41             : 
      42             : #include <string.h>
      43             : 
      44             : using namespace ::rtl;
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::ui::dialogs;
      47             : using namespace ::com::sun::star::lang;
      48             : using namespace ::com::sun::star::uno;
      49             : 
      50             : // constructor
      51             : 
      52           0 : SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference< uno::XComponentContext >& xContext ) :
      53           0 :     SalGtkPicker( xContext )
      54             : {
      55             :     m_pDialog = gtk_file_chooser_dialog_new(
      56             :         OUStringToOString( getResString( FOLDERPICKER_TITLE ), RTL_TEXTENCODING_UTF8 ).getStr(),
      57             :         NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      58           0 :         GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, (char *)NULL );
      59             : 
      60           0 :     gtk_dialog_set_default_response( GTK_DIALOG (m_pDialog), GTK_RESPONSE_ACCEPT );
      61             : #if ENABLE_GNOME_VFS || ENABLE_GIO
      62           0 :     gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( m_pDialog ), false );
      63             : #endif
      64           0 :     gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( m_pDialog ), false );
      65           0 : }
      66             : 
      67             : // XEventListener
      68             : 
      69           0 : void SAL_CALL SalGtkFolderPicker::disposing( const lang::EventObject& )
      70             :     throw( uno::RuntimeException )
      71             : {
      72           0 : }
      73             : 
      74           0 : void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const OUString& aDirectory )
      75             :     throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
      76             : {
      77           0 :     SolarMutexGuard g;
      78             : 
      79             :     OSL_ASSERT( m_pDialog != NULL );
      80             : 
      81           0 :     OString aTxt = unicodetouri( aDirectory );
      82           0 :     if( aTxt.isEmpty() ){
      83           0 :       aTxt = unicodetouri(OUString("file:///."));
      84             :     }
      85             : 
      86           0 :     if( aTxt.endsWith("/") )
      87           0 :         aTxt = aTxt.copy( 0, aTxt.getLength() - 1 );
      88             : 
      89             :     OSL_TRACE( "setting path to %s", aTxt.getStr() );
      90             : 
      91           0 :     gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
      92           0 :         aTxt.getStr() );
      93           0 : }
      94             : 
      95           0 : OUString SAL_CALL SalGtkFolderPicker::getDisplayDirectory() throw( uno::RuntimeException, std::exception )
      96             : {
      97           0 :     SolarMutexGuard g;
      98             : 
      99             :     OSL_ASSERT( m_pDialog != NULL );
     100             : 
     101             :     gchar* pCurrentFolder =
     102           0 :         gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
     103           0 :     OUString aCurrentFolderName = uritounicode(pCurrentFolder);
     104           0 :     g_free( pCurrentFolder );
     105             : 
     106           0 :     return aCurrentFolderName;
     107             : }
     108             : 
     109           0 : OUString SAL_CALL SalGtkFolderPicker::getDirectory() throw( uno::RuntimeException, std::exception )
     110             : {
     111           0 :     SolarMutexGuard g;
     112             : 
     113             :     OSL_ASSERT( m_pDialog != NULL );
     114             : 
     115             :     gchar* pSelectedFolder =
     116           0 :         gtk_file_chooser_get_uri( GTK_FILE_CHOOSER( m_pDialog ) );
     117           0 :     OUString aSelectedFolderName = uritounicode(pSelectedFolder);
     118           0 :     g_free( pSelectedFolder );
     119             : 
     120           0 :     return aSelectedFolderName;
     121             : }
     122             : 
     123           0 : void SAL_CALL SalGtkFolderPicker::setDescription( const OUString& /*rDescription*/ )
     124             :     throw( uno::RuntimeException, std::exception )
     125             : {
     126           0 : }
     127             : 
     128             : // XExecutableDialog functions
     129             : 
     130           0 : void SAL_CALL SalGtkFolderPicker::setTitle( const OUString& aTitle ) throw( uno::RuntimeException, std::exception )
     131             : {
     132           0 :     SolarMutexGuard g;
     133             : 
     134             :     OSL_ASSERT( m_pDialog != NULL );
     135             : 
     136           0 :     OString aWindowTitle = OUStringToOString( aTitle, RTL_TEXTENCODING_UTF8 );
     137             : 
     138           0 :     gtk_window_set_title( GTK_WINDOW( m_pDialog ), aWindowTitle.getStr() );
     139           0 : }
     140             : 
     141           0 : sal_Int16 SAL_CALL SalGtkFolderPicker::execute() throw( uno::RuntimeException, std::exception )
     142             : {
     143           0 :     SolarMutexGuard g;
     144             : 
     145             :     OSL_TRACE( "1: HERE WE ARE");
     146             :     OSL_ASSERT( m_pDialog != NULL );
     147             : 
     148           0 :     sal_Int16 retVal = 0;
     149             : 
     150             :     uno::Reference< awt::XExtendedToolkit > xToolkit(
     151             :         awt::Toolkit::create(m_xContext),
     152           0 :         uno::UNO_QUERY);
     153             : 
     154           0 :     uno::Reference< frame::XDesktop > xDesktop( frame::Desktop::create(m_xContext), uno::UNO_QUERY);
     155             : 
     156           0 :     RunDialog* pRunDialog = new RunDialog(m_pDialog, xToolkit, xDesktop);
     157           0 :     uno::Reference < awt::XTopWindowListener > xLifeCycle(pRunDialog);
     158           0 :     gint nStatus = pRunDialog->run();
     159           0 :     switch( nStatus )
     160             :     {
     161             :         case GTK_RESPONSE_ACCEPT:
     162           0 :             retVal = ExecutableDialogResults::OK;
     163           0 :             break;
     164             :         case GTK_RESPONSE_CANCEL:
     165           0 :             retVal = ExecutableDialogResults::CANCEL;
     166           0 :             break;
     167             :         default:
     168           0 :             retVal = 0;
     169           0 :             break;
     170             :     }
     171             : 
     172           0 :     return retVal;
     173             : }
     174             : 
     175             : // XCancellable
     176             : 
     177           0 : void SAL_CALL SalGtkFolderPicker::cancel() throw( uno::RuntimeException, std::exception )
     178             : {
     179           0 :     SolarMutexGuard g;
     180             : 
     181           0 :     OSL_ASSERT( m_pDialog != NULL );
     182             : 
     183             :     // TODO m_pImpl->cancel();
     184           0 : }
     185             : 
     186             : uno::Reference< ui::dialogs::XFolderPicker2 >
     187           0 : GtkInstance::createFolderPicker( const uno::Reference< uno::XComponentContext > &xMSF )
     188             : {
     189             :     return uno::Reference< ui::dialogs::XFolderPicker2 >(
     190           0 :                 new SalGtkFolderPicker( xMSF ) );
     191           0 : }
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10