summaryrefslogtreecommitdiffstats
path: root/gio/gfileinfo.override
blob: 730e91bd401f594841ed21c57c1f2a5c196157b0 (plain)
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
/* -*- Mode: C; c-basic-offset: 4 -*-
 * pygobject - Python bindings for GObject
 * Copyright (C) 2008  Johan Dahlin
 *               2009  Gian Mario Tagliaretti
 *
 *   gfileinfo.override: module overrides for GFileInfo
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

%%
headers

#ifndef G_TYPE_FILE_ATTRIBUTE_MATCHER
#define G_TYPE_FILE_ATTRIBUTE_MATCHER (_g_file_attribute_matcher_get_type ())

static GType _g_file_attribute_matcher_get_type (void)
{
  static GType our_type = 0;
  
  if (our_type == 0)
    our_type = g_boxed_type_register_static ("GFileAttributeMatcher",
                                (GBoxedCopyFunc)g_file_attribute_matcher_ref,
                                (GBoxedFreeFunc)g_file_attribute_matcher_unref);

  return our_type;
}
#endif

%%
override g_file_info_list_attributes kwargs
static PyObject *
_wrap_g_file_info_list_attributes(PyGObject *self, 
                                  PyObject  *args, 
				  PyObject  *kwargs)
{
    char *kwlist[] = { "name_space", NULL};
    gchar *name_space = NULL;
    gchar **names;
    gchar **n;
    PyObject *ret;
    
    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
				     "|z:gio.FileInfo.list_attributes",
				     kwlist, &name_space))
	return NULL;

    names = g_file_info_list_attributes(G_FILE_INFO(self->obj),
					name_space);

    ret = PyList_New(0);
    n = names;
    while (n && *n) {
        PyObject *item = PyString_FromString(n[0]);
        PyList_Append(ret, item);
        Py_DECREF(item);

        n++;
    }
    
    g_strfreev(names);
    return ret;
}
%%
override g_file_info_get_modification_time noargs
static PyObject *
_wrap_g_file_info_get_modification_time(PyGObject *self, PyObject *unused)
{
    GTimeVal timeval;

    g_file_info_get_modification_time(G_FILE_INFO(self->obj), &timeval);
    return pyglib_float_from_timeval(timeval);
}
%%
override g_file_info_set_modification_time kwargs
static PyObject *
_wrap_g_file_info_set_modification_time(PyGObject *self, 
                                        PyObject  *args, 
                                        PyObject  *kwargs)
{
    char *kwlist[] = { "mtime", NULL};
    double py_mtime = 0.0;
    GTimeVal ttime, *mtime;
    
    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "d:gio.FileInfo.set_modification_time",
                                     kwlist, &py_mtime))
        return NULL;

    if (py_mtime > 0.0) {
	ttime.tv_sec = (glong) py_mtime;
	ttime.tv_usec = (glong)((py_mtime - ttime.tv_sec) * G_USEC_PER_SEC);
        mtime = &ttime;
    } else if (py_mtime == 0.0) {
	mtime = NULL;
    } else {
        PyErr_SetString(PyExc_ValueError, "mtime must be >= 0.0");
        return NULL;
    }
    
    g_file_info_set_modification_time(G_FILE_INFO(self->obj), mtime);
    
    Py_INCREF(Py_None);
    return Py_None;
}

/* GFileInfo.get_attribute_data: No ArgType for GFileAttributeType* */
/* GFileInfo.set_attribute: No ArgType for gpointer */