File: MimeTypes.xsp

package info (click to toggle)
libwx-perl 0.9702-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,240 kB
  • ctags: 1,812
  • sloc: cpp: 8,988; perl: 6,366; makefile: 38; ansic: 1
file content (214 lines) | stat: -rw-r--r-- 5,292 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#############################################################################
## Name:        XS/MimeTypes.xsp
## Purpose:     XS++ for wxMimeTypesManager and related classes
## Author:      Mattia Barbon
## Modified by:
## Created:     28/03/2005
## RCS-ID:      $Id: MimeTypes.xsp 2911 2010-04-26 19:51:34Z mbarbon $
## Copyright:   (c) 2005-2010 Mattia Barbon
## Licence:     This program is free software; you can redistribute it and/or
##              modify it under the same terms as Perl itself
#############################################################################

%module{Wx};

%{
#if wxUSE_MIMETYPE
#include <wx/mimetype.h>
%}
        
%typemap{wxMimeTypesManager*}{simple};
%typemap{wxFileType*}{simple};
%typemap{wxIconLocation*}{simple};
%typemap{wxFileTypeInfo*}{simple};
%typemap{const wxFileTypeInfo*}{parsed}{
    %cpp_type{%wxFileTypeInfo*%};
};

#if WXPERL_W_VERSION_GE( 2, 5, 2 )

%name{Wx::IconLocation} class wxIconLocation
{
    bool IsOk() const;
};

#endif

%name{Wx::FileTypeInfo} class wxFileTypeInfo
{
    bool IsValid() const;
    void SetIcon( const wxString& iconFile, int iconIndex = 0 );
    void SetShortDesc( const wxString& shortDesc );

    const wxString& GetMimeType() const;
    const wxString& GetOpenCommand() const;
    const wxString& GetPrintCommand() const;
    const wxString& GetShortDesc() const;
    const wxString& GetDescription() const;
    int GetExtensionsCount() const;
    const wxString& GetIconFile();
    int GetIconIndex() const;
};

%{
wxFileTypeInfo*
wxFileTypeInfo::new( strings )
    wxArrayString strings

void
wxFileTypeInfo::GetExtensions()
  PPCODE:
    const wxArrayString& extensions = THIS->GetExtensions();
    PUTBACK;
    wxPli_stringarray_push( aTHX_ extensions );
    SPAGAIN;

%}

%name{Wx::FileType} class wxFileType
{
};

%{
void
wxFileType::GetMimeTypes()
  PREINIT:
    wxArrayString mimeTypes;
  PPCODE:
    bool ok = THIS->GetMimeTypes( mimeTypes );
    if( ok )
    {
        PUTBACK;
        wxPli_stringarray_push( aTHX_ mimeTypes );
        SPAGAIN;
    }
    else
        XSRETURN_EMPTY;

void
wxFileType::GetMimeType()
  PREINIT:
    wxString mimeType;
  PPCODE:
    bool ok = THIS->GetMimeType( &mimeType );
    if( ok )
    {
        XPUSHs( wxPli_wxString_2_sv( aTHX_ mimeType, sv_newmortal() ) );
    }
    else
        XSRETURN_EMPTY;

void
wxFileType::GetExtensions()
  PREINIT:
    wxArrayString extensions;
  PPCODE:
    bool ok = THIS->GetExtensions( extensions );
    if( ok )
    {
        PUTBACK;
        wxPli_stringarray_push( aTHX_ extensions );
        SPAGAIN;
    }
    else
        XSRETURN_EMPTY;

void
wxFileType::GetIcon()
  PREINIT:
#if WXPERL_W_VERSION_GE( 2, 5, 2 )
    wxIconLocation iconLoc;
#else
    wxIcon iconLoc;
#endif
  PPCODE:
    bool ok = THIS->GetIcon( &iconLoc );
    if( ok )
    {
#if WXPERL_W_VERSION_GE( 2, 5, 2 )
        XPUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                       new wxIconLocation( iconLoc ),
                                       "Wx::IconLocation" ) );
#else
        XPUSHs( wxPli_non_object_2_sv( aTHX_ sv_newmortal(),
                                       new wxIcon( iconLoc ),
                                       "Wx::Icon" ) );
#endif
    }
    else
        XSRETURN_EMPTY;

void
wxFileType::GetDescription()
  PREINIT:
    wxString desc;
  PPCODE:
    bool ok = THIS->GetDescription( &desc );
    if( ok )
    {
        XPUSHs( wxPli_wxString_2_sv( aTHX_ desc, sv_newmortal() ) );
    }
    else
        XSRETURN_EMPTY;

void
wxFileType::GetOpenCommand( file, mimeType = wxEmptyString )
    wxString file
    wxString mimeType
  PREINIT:
    wxString command;
  PPCODE:
    bool ok = THIS->GetOpenCommand( &command,
                                    wxFileType::MessageParameters
                                        ( file, mimeType ) );
    if( ok )
        XPUSHs( wxPli_wxString_2_sv( aTHX_ command, sv_newmortal() ) );
    else
        XSRETURN_EMPTY;

void
wxFileType::GetPrintCommand( file, mimeType = wxEmptyString )
    wxString file
    wxString mimeType
  PREINIT:
    wxString command;
  PPCODE:
    bool ok = THIS->GetPrintCommand( &command,
                                     wxFileType::MessageParameters
                                         ( file, mimeType ) );
    if( ok )
        XPUSHs( wxPli_wxString_2_sv( aTHX_ command, sv_newmortal() ) );
    else
        XSRETURN_EMPTY;

%}

%name{Wx::MimeTypesManager} class wxMimeTypesManager
{
    wxMimeTypesManager();

%{
static void
wxMimeTypesManager::CLONE()
  CODE:
    wxPli_thread_sv_clone( aTHX_ CLASS, (wxPliCloneSV)wxPli_detach_object );
%}
    ## // thread OK
    ~wxMimeTypesManager()
        %code{% wxPli_thread_sv_unregister( aTHX_ "Wx::MimeTypesManager", THIS, ST(0) );
                delete THIS;
                %};

    void AddFallbacks( const wxFileTypeInfo *fallbacks );
    wxFileType* GetFileTypeFromExtension( const wxString& extension );
    wxFileType* GetFileTypeFromMimeType( const wxString& mimeType );
    bool IsOfType( const wxString& mimeType, const wxString& wildcard );
#if WXPERL_W_VERSION_LT( 2, 9, 0 )
    bool ReadMailcap( const wxString& filename, bool fallback = false );
    bool ReadMimeTypes( const wxString& filename );
#endif
};

%{
#endif // wxUSE_MIMETYPE
%}