]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/gnome/gvfs.cpp
added wxApp::Set/GetAppDisplayName() (patch 1780414)
[wxWidgets.git] / src / gtk / gnome / gvfs.cpp
CommitLineData
1d115baf
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/gnome/gvfs.cpp
3// Author: Robert Roebling
4// Purpose: Implement GNOME VFS support
5// Created: 03/17/06
6// RCS-ID: $Id$
7// Copyright: Robert Roebling
8// Licence: wxWindows Licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx/wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
1d115baf
RR
18#if wxUSE_MIMETYPE && wxUSE_LIBGNOMEVFS
19
09a09455
PC
20#include "wx/gtk/gnome/gvfs.h"
21
e4db172a
WS
22#ifndef WX_PRECOMP
23 #include "wx/log.h"
02761f6c 24 #include "wx/module.h"
e4db172a
WS
25#endif
26
1d115baf 27#include "wx/mimetype.h"
1d115baf 28#include "wx/dynlib.h"
1d115baf
RR
29
30#include <libgnomevfs/gnome-vfs-mime-handlers.h>
31
09a09455
PC
32#include "wx/link.h"
33wxFORCE_LINK_THIS_MODULE(gnome_vfs)
1d115baf
RR
34
35//----------------------------------------------------------------------------
36// wxGnomeVFSLibrary
37//----------------------------------------------------------------------------
38
1d115baf
RR
39class wxGnomeVFSLibrary
40{
41public:
42 wxGnomeVFSLibrary();
43 ~wxGnomeVFSLibrary();
44
45 bool IsOk();
46 void InitializeMethods();
47
48private:
49 bool m_ok;
50 wxDynamicLibrary *m_gnome_vfs_lib;
51
52public:
53 wxDL_METHOD_DEFINE( gboolean, gnome_vfs_init,
54 (), (), FALSE )
55 wxDL_METHOD_DEFINE( void, gnome_vfs_shutdown,
56 (), (), /**/ )
e4db172a 57
1d115baf
RR
58 wxDL_METHOD_DEFINE( GnomeVFSResult, gnome_vfs_mime_set_icon,
59 (const char *mime_type, const char *filename), (mime_type, filename), GNOME_VFS_OK )
60};
61
62wxGnomeVFSLibrary::wxGnomeVFSLibrary()
63{
64 m_gnome_vfs_lib = NULL;
65
66 wxLogNull log;
67
68 m_gnome_vfs_lib = new wxDynamicLibrary( wxT("libgnomevfs-2.so.0") );
69 m_ok = m_gnome_vfs_lib->IsLoaded();
70 if (!m_ok) return;
71
72 InitializeMethods();
73}
74
75wxGnomeVFSLibrary::~wxGnomeVFSLibrary()
76{
77 if (m_gnome_vfs_lib)
78 delete m_gnome_vfs_lib;
79}
80
81bool wxGnomeVFSLibrary::IsOk()
82{
83 return m_ok;
84}
85
86void wxGnomeVFSLibrary::InitializeMethods()
87{
88 m_ok = false;
89 bool success;
90
91 wxDL_METHOD_LOAD( m_gnome_vfs_lib, gnome_vfs_init, success )
92 wxDL_METHOD_LOAD( m_gnome_vfs_lib, gnome_vfs_shutdown, success )
e4db172a 93
1d115baf
RR
94 m_ok = true;
95}
96
97static wxGnomeVFSLibrary* gs_lgvfs = NULL;
98
99//----------------------------------------------------------------------------
100// wxGnomeVFSMimeTypesManagerFactory
101//----------------------------------------------------------------------------
102
103wxMimeTypesManagerImpl *wxGnomeVFSMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
104{
105 return new wxGnomeVFSMimeTypesManagerImpl;
106}
107
108
109//----------------------------------------------------------------------------
110// wxGnomeVFSMimeTypesManagerImpl
111//----------------------------------------------------------------------------
112
113bool wxGnomeVFSMimeTypesManagerImpl::DoAssociation(const wxString& strType,
114 const wxString& strIcon,
115 wxMimeTypeCommands *entry,
116 const wxArrayString& strExtensions,
117 const wxString& strDesc)
118{
119 int nIndex = AddToMimeData(strType, strIcon, entry, strExtensions, strDesc, true);
e4db172a 120
1d115baf
RR
121 if ( nIndex == wxNOT_FOUND )
122 return false;
123
124 if (m_mailcapStylesInited & wxMAILCAP_GNOME)
125 {
126 // User modificationt to the MIME database
127 // are not supported :-)
128 }
e4db172a 129
1d115baf
RR
130 return false;
131}
132
133//----------------------------------------------------------------------------
134// wxGnomeVFSModule
135//----------------------------------------------------------------------------
136
137class wxGnomeVFSModule: public wxModule
138{
139public:
140 wxGnomeVFSModule() {}
141 bool OnInit();
142 void OnExit();
143
144private:
145 DECLARE_DYNAMIC_CLASS(wxGnomeVFSModule)
146};
147
148bool wxGnomeVFSModule::OnInit()
149{
150 gs_lgvfs = new wxGnomeVFSLibrary;
151 if (gs_lgvfs->IsOk())
152 {
153 if (gs_lgvfs->gnome_vfs_init())
b1d8cb44 154 wxMimeTypesManagerFactory::Set( new wxGnomeVFSMimeTypesManagerFactory );
1d115baf
RR
155 }
156 return true;
157}
158
159void wxGnomeVFSModule::OnExit()
160{
161 if (gs_lgvfs->IsOk())
162 gs_lgvfs->gnome_vfs_shutdown();
e4db172a 163
1d115baf
RR
164 delete gs_lgvfs;
165}
166
167IMPLEMENT_DYNAMIC_CLASS(wxGnomeVFSModule, wxModule)
168
169#endif
1c0338c5 170 // wxUSE_LIBGNOMEVFS
1d115baf 171 // wxUSE_MIMETYPE