File: nautilus_burn.override

package info (click to toggle)
gnome-python-desktop 2.32.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,548 kB
  • sloc: sh: 10,214; xml: 8,851; ansic: 3,428; python: 1,457; makefile: 664
file content (191 lines) | stat: -rw-r--r-- 5,561 bytes parent folder | download | duplicates (4)
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
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
%%
headers
#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include <nautilus-burn.h>
/* #include "nb_typebuiltins.h" */
#include "nb_track.h"

#include "config.h"

%%
modulename nautilusburn
%%
import gtk.ComboBox as PyGtkComboBox_Type
import gobject.GObject as PyGObject_Type
%%
ignore-glob
  *_get_type
%%
ignore
  nautilus_burn_drive_ref
  nautilus_burn_drive_unref
  nautilus_burn_recorder_error_quark
%%
override nautilus_burn_recorder_write_tracks

static PyObject *
_wrap_nautilus_burn_recorder_write_tracks (PyGObject *self, PyObject *args, PyObject *kwargs)
{
    PyObject *drive;
    nb_Track *track;
    PyObject *tracks;
    GList *g_tracks = NULL;
    GError *error = NULL;

    int speed, flags, i, len, ret;

    if (!PyArg_ParseTuple(args, "O!Oii", &PyNautilusBurnDrive_Type, &drive, &tracks, &speed, &flags))
        return NULL;
    if (!PyList_Check(tracks)) {
        PyErr_SetString(PyExc_TypeError, "second parameter (tracks) must be a list");
        return NULL;
    }

    len = PyList_GET_SIZE(tracks);
    for (i = 0; i < len; i++) {
        track = (nb_Track *)PyList_GET_ITEM(tracks, i);
        if (!nb_AudioTrack_Check((PyObject*)track) && !nb_DataTrack_Check((PyObject*)track)) {
            PyErr_SetString(PyExc_TypeError, "Elements must be "
                            "nautilusburn.AudioTrack or "
                            "nautilusburn.DataTrack");
            g_list_free(g_tracks);
            return NULL;
        }
        g_tracks = g_list_append(g_tracks, &track->track);
    }
    
    pyg_begin_allow_threads;
    ret = nautilus_burn_recorder_write_tracks((NautilusBurnRecorder*)self->obj,
                                              NAUTILUS_BURN_DRIVE(pygobject_get(drive)), 
                                              g_tracks, 
                                              speed, 
                                              flags, &error);
    pyg_end_allow_threads;
    
    g_list_free(g_tracks);
    if (pyg_error_check(&error))
        return NULL;
    return PyInt_FromLong(ret);
}

%%
override nautilus_burn_drive_monitor_get_drives noargs

static PyObject *
_wrap_nautilus_burn_drive_monitor_get_drives(PyObject *self, PyObject *args, PyObject *kwargs)
{
	int index, len;
	GList *cds, *iter;
	PyObject *cds_tuple, *cd;
	
	cds = nautilus_burn_drive_monitor_get_drives(
            NAUTILUS_BURN_DRIVE_MONITOR(pygobject_get(self)));
	len = g_list_length (cds);
	cds_tuple = PyTuple_New (len);
	
	for (iter = g_list_first (cds), index = 0; iter; iter = iter->next, index++) {
		/* create the new Drive object */
		assert (iter->data);
		cd = pygobject_new((GObject *) iter->data);
		if (!cd) {
			return NULL;
		}
		if (PyTuple_SetItem (cds_tuple, index, cd)) {
			return NULL;
		}
                g_object_unref((GObject *) iter->data);
	}

	g_list_free (cds);
	return cds_tuple;
}

%%
define bytes_to_seconds
static PyObject *
_wrap_bytes_to_seconds (PyObject *self, PyObject *args)
{
	long int size;
	if (!PyArg_ParseTuple (args, "l", &size))
		return NULL;
	return Py_BuildValue("l", (long int) NAUTILUS_BURN_DRIVE_SIZE_TO_TIME(size));
}

%%
override nautilus_burn_drive_lock kwargs
static PyObject *
_wrap_nautilus_burn_drive_lock(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "reason", NULL };
    char *reason, *failure = NULL;
    int ret;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:NautilusBurnDrive.lock", kwlist, &reason))
        return NULL;
    
    ret = nautilus_burn_drive_lock(NAUTILUS_BURN_DRIVE(self->obj), reason, &failure);
    if (failure) {
        PyErr_SetString(PyExc_RuntimeError, failure);
        return NULL;
    }
    return PyBool_FromLong(ret);
}

%%
override nautilus_burn_drive_get_write_speeds noargs
static PyObject *
_wrap_nautilus_burn_drive_get_write_speeds(PyGObject *self)
{
    const int *write_speeds;
    int i;
    PyObject *py_write_speeds;

    write_speeds = nautilus_burn_drive_get_write_speeds(NAUTILUS_BURN_DRIVE(self->obj));
    py_write_speeds = PyList_New(0);
    for (i = 0; write_speeds[i]; ++i) {
        PyObject *speed = PyInt_FromLong(write_speeds[i]);
        PyList_Append(py_write_speeds, speed);
        Py_DECREF(speed);
    }
    return py_write_speeds;
}

%%
override nautilus_burn_drive_get_media_type_full noargs
static PyObject *
_wrap_nautilus_burn_drive_get_media_type_full(PyGObject *self)
{
    gint ret;
    gboolean is_rewritable, is_blank, has_data, has_audio;
    
    ret = nautilus_burn_drive_get_media_type_full(NAUTILUS_BURN_DRIVE(self->obj),
                                                  &is_rewritable, &is_blank,
                                                  &has_data, &has_audio);
    
    return Py_BuildValue("Niiii", pyg_enum_from_gtype(G_TYPE_NONE, ret),
                         is_rewritable, is_blank, has_data, has_audio);
}

%%
override nautilus_burn_drive_monitor_get_recorder_drives noargs
static PyObject *
_wrap_nautilus_burn_drive_monitor_get_recorder_drives(PyGObject *self)
{
    GList *drives, *l;
    PyObject *py_drives;

    drives = nautilus_burn_drive_monitor_get_recorder_drives(NAUTILUS_BURN_DRIVE_MONITOR(self->obj));
    py_drives = PyList_New(0);
    for (l = drives; l; l = l->next) {
        GObject *drive = G_OBJECT(l->data);
        PyObject *py_drive = pygobject_new(drive);
        PyList_Append(py_drives, py_drive);
        Py_DECREF(py_drive);
        g_object_unref(drive);
    }
    g_list_free(drives);
    return py_drives;
}