1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _VCL_GTKINST_HXX 29 #define _VCL_GTKINST_HXX 30 31 #include <unx/salinst.h> 32 #include <unx/salsys.h> 33 34 class GtkYieldMutex : public SalYieldMutex 35 { 36 public: 37 GtkYieldMutex(); 38 virtual void acquire(); 39 virtual void release(); 40 virtual sal_Bool tryToAcquire(); 41 42 virtual int Grab(); 43 virtual void Ungrab( int ); 44 45 class GtkYieldGuard 46 { 47 GtkYieldMutex* m_pMutex; 48 int m_nGrab; 49 public: 50 GtkYieldGuard( GtkYieldMutex* pMutex ) 51 : m_pMutex( pMutex ) 52 { 53 m_nGrab = m_pMutex->Grab(); 54 } 55 ~GtkYieldGuard() 56 { 57 m_pMutex->Ungrab( m_nGrab ); 58 } 59 }; 60 }; 61 62 class GtkHookedYieldMutex : public GtkYieldMutex 63 { 64 virtual int Grab() { return 0; }; 65 virtual void Ungrab(int ) {}; 66 std::list<sal_uLong> aYieldStack; 67 public: 68 GtkHookedYieldMutex(); 69 virtual void acquire(); 70 virtual void release(); 71 virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); } 72 void ThreadsEnter(); 73 void ThreadsLeave(); 74 }; 75 76 77 #define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) ) 78 79 class GtkInstance : public X11SalInstance 80 { 81 public: 82 GtkInstance( SalYieldMutex* pMutex ) 83 : X11SalInstance( pMutex ) 84 {} 85 virtual ~GtkInstance(); 86 87 virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle ); 88 virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ); 89 virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow = sal_True ); 90 virtual SalSystem* CreateSalSystem(); 91 virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); 92 }; 93 94 class GtkSalSystem : public X11SalSystem 95 { 96 public: 97 GtkSalSystem() : X11SalSystem() {} 98 virtual ~GtkSalSystem(); 99 virtual int ShowNativeDialog( const String& rTitle, 100 const String& rMessage, 101 const std::list< String >& rButtons, 102 int nDefButton ); 103 }; 104 105 #endif // _VCL_GTKINST_HXX 106