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

Generated by: LCOV version 1.10