File: pygnomevfs.h

package info (click to toggle)
gnome-python 2.28.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,288 kB
  • ctags: 1,032
  • sloc: sh: 10,219; ansic: 7,997; xml: 2,464; python: 1,886; makefile: 394
file content (105 lines) | stat: -rw-r--r-- 3,141 bytes parent folder | download | duplicates (5)
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
/* -*- mode: C; c-basic-offset: 4 -*- */
#ifndef __PYGNOMEVFS_H_
#define __PYGNOMEVFS_H_

#include <Python.h>

#include <libgnomevfs/gnome-vfs-init.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-directory.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-result.h>
#include <libgnomevfs/gnome-vfs-context.h>
#include <libgnomevfs/gnome-vfs-xfer.h>


G_BEGIN_DECLS

typedef struct {
    PyObject_HEAD
    GnomeVFSURI *uri;
} PyGnomeVFSURI;

typedef struct {
    PyObject_HEAD
    GnomeVFSFileInfo *finfo;
} PyGnomeVFSFileInfo;

typedef struct {
    PyObject_HEAD
    GnomeVFSContext *context;
} PyGnomeVFSContext;
    
#define pygnome_vfs_uri_get(v) (((PyGnomeVFSURI *)(v))->uri)
#define pygnome_vfs_uri_check(v) ((v)->ob_type == _PyGnomeVFS_API->uri_type)

#define pygnome_vfs_file_info_get(v) (((PyGnomeVFSFileInfo *)(v))->finfo)
#define pygnome_vfs_file_info_check(v) ((v)->ob_type == _PyGnomeVFS_API->file_info_type)

#define pygnome_vfs_context_get(v) (((PyGnomeVFSURI *)(v))->context)
#define pygnome_vfs_context_check(v) ((v)->ob_type == _PyGnomeVFS_API->context_type)

struct _PyGnomeVFS_Functions {
    GnomeVFSResult (* exception_check)(void);
    PyObject *(* uri_new)(GnomeVFSURI *uri);
    PyTypeObject *uri_type;
    PyObject *(* file_info_new)(GnomeVFSFileInfo *finfo);
    PyTypeObject *file_info_type;
    PyObject *(* context_new)(GnomeVFSContext *context);
    PyTypeObject *context_type;
};

#ifndef _INSIDE_PYGNOMEVFS_

#if defined(NO_IMPORT) || defined(NO_IMPORT_PYGNOMEVFS)
extern struct _PyGnomeVFS_Functions *_PyGnomeVFS_API;
#else
struct _PyGnomeVFS_Functions *_PyGnomeVFS_API;
#endif

#define pygnome_vfs_exception_check (_PyGnomeVFS_API->exception_check)
#define pygnome_vfs_uri_new         (_PyGnomeVFS_API->uri_new)
#define PyGnomeVFSURI_Type          (*_PyGnomeVFS_API->uri_type)
#define pygnome_vfs_file_info_new   (_PyGnomeVFS_API->file_info_new)
#define PyGnomeVFSFileInfo_Type     (*_PyGnomeVFS_API->file_info_type)
#define pygnome_vfs_context_new     (_PyGnomeVFS_API->context_new)
#define PyGnomeVFSContext_Type      (*_PyGnomeVFS_API->context_type)

static inline PyObject *
pygnomevfs_init(void)
{
    PyObject *module = PyImport_ImportModule("gnomevfs");
    if (module != NULL) {
        PyObject *mdict = PyModule_GetDict(module);
        PyObject *cobject = PyDict_GetItemString(mdict, "_PyGnomeVFS_API");
        if (PyCObject_Check(cobject))
            _PyGnomeVFS_API = (struct _PyGnomeVFS_Functions *)PyCObject_AsVoidPtr(cobject);
        else {
	    Py_FatalError("could not find _PyGnomeVFS_API object");
        }
    } else {
        Py_FatalError("could not import gnomevfs");
    }
    return module;
}

#define init_pygnomevfs() pygnomevfs_init();


#endif /* !_INSIDE_PYGNOMEVFS_ */


#define PYGVFS_CONTROL_MAGIC_IN 0xa346a943U
#define PYGVFS_CONTROL_MAGIC_OUT 0xb49535dcU

typedef struct {
    guint magic;
    PyObject *data;
} PyGVFSOperationData;

G_END_DECLS

#endif /* __PYGNOMEVFS_H_ */