File: ui.override

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 (456 lines) | stat: -rw-r--r-- 14,467 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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>

#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include <libgnomeui/libgnomeui.h>
#include <libgnomeui/gnome-ice.h>
/* #include <libgnomeui/gnome-appbar.h> */
#include <bonobo/bonobo-ui-type-builtins.h>
#define GNOME_TYPE_APP_BAR GNOME_TYPE_APPBAR
#define GNOME_APP_BAR GNOME_APPBAR
#define NO_IMPORT_PYGNOMEVFS
#include "pygnomevfs.h"
#include "config.h"

%%
modulename gnome.ui
%%
import gobject.GObject as PyGObject_Type
import gtk.Object as PyGtkObject_Type
import gtk.Widget as PyGtkWidget_Type
import gtk.Bin as PyGtkBin_Type
import gtk.Container as PyGtkContainer_Type
import gtk.HBox as PyGtkHBox_Type
import gtk.VBox as PyGtkVBox_Type
import gtk.Window as PyGtkWindow_Type
import gtk.Dialog as PyGtkDialog_Type
import gtk.Button as PyGtkButton_Type
import gtk.Image as PyGtkImage_Type
import gtk.Menu as PyGtkMenu_Type
import gtk.MenuBar as PyGtkMenuBar_Type
import gtk.Toolbar as PyGtkToolbar_Type
import gtk.Combo as PyGtkCombo_Type
import gtk.Adjustment as PyGtkAdjustment_Type
import gtk.Editable as PyGtkEditable_Type
import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
import gnomecanvas.Canvas as PyGnomeCanvas_Type
import gnomecanvas.CanvasItem as PyGnomeCanvasItem_Type
import bonobo.ui.DockItem as PyBonoboDockItem_Type
import gtk.gdk.Screen as PyGdkScreen_Type
import gtk.IconTheme as PyGtkIconTheme_Type
import gtk.HBox as PyGtkHBox_Type
%%
ignore-glob
  *_get_type
  *_construct

%%
ignore
  gnome_window_icon_init
  gnome_window_icon_set_from_file
  gnome_window_icon_set_from_file_list
  gnome_window_icon_set_default_from_file
  gnome_window_icon_set_default_from_file_list
  gnome_ok_dialog
  gnome_message_box_new
  gnome_icon_lookup_sync

%%
override gnome_about_new kwargs
static int
_wrap_gnome_about_new (PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char  *kwlist[] = { "name", "version", "copyright", "comments",
			       "authors", "documenters", "translator_credits",
			       "logo_pixbuf", NULL };
    
    char       *name, *version, *copyright, *comments;
    PyObject   *pyauthors;
    PyObject   *pydocumenters = Py_None;
    char       *translator_credits = NULL;
    PyGObject  *pypixbuf = NULL;
    int         n_authors;
    char      **authors;
    int         i;
    int         n_documenters;
    char      **documenters;
    GdkPixbuf  *pixbuf;
    
    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "ssssO|OzO!:GnomeAbout.__init__", kwlist,
                                     &name, &version, &copyright, &comments,
				     &pyauthors, &pydocumenters,
				     &translator_credits, &PyGdkPixbuf_Type, &pypixbuf)) {
	return -1;
    }

    if (!PyList_Check(pyauthors) && !PyTuple_Check(pyauthors)) {
	PyErr_SetString(PyExc_TypeError, "5th argument not a tuple or list");
	return -1;
    }

    if (pydocumenters != Py_None && !PyList_Check(pydocumenters) && !PyTuple_Check(pydocumenters)) {
	PyErr_SetString(PyExc_TypeError, "6th argument not a tuple or list");
	return -1;
    }
    
    n_authors = PySequence_Length(pyauthors);
    authors = g_new(gchar *, n_authors + 1);
    for (i = 0; i < n_authors; i++) {
        PyObject *item = PySequence_GetItem(pyauthors, i);
        Py_DECREF(item); 
        authors[i] = PyString_AsString(item);
    }
    authors[n_authors] = NULL;
    
    if (pydocumenters != Py_None) {
	    n_documenters = PySequence_Length(pydocumenters);
	    documenters = g_new(gchar *, n_documenters + 1);
	    for (i = 0; i < n_documenters; i++) {
		    PyObject *item = PySequence_GetItem(pydocumenters, i);
		    Py_DECREF(item); 
		    documenters[i] = PyString_AsString(item);
	    }
	    documenters[n_documenters] = NULL;
    } else {
	    documenters = NULL;
    }

    /* if translator_credits is "translator_credits", set it to NULL */
    if (translator_credits &&
	!strcmp(translator_credits, "translator_credits"))
	translator_credits = NULL;

    if (pypixbuf != NULL) {
	pixbuf = GDK_PIXBUF(pypixbuf->obj);
    } else {
	pixbuf = NULL;
    }
    
    self->obj = (GObject*)gnome_about_new (name,
					   version,
					   copyright,
					   comments,
					   (const gchar**)authors,
					   (const gchar**)documenters,
					   translator_credits,
					   pixbuf);
    if (!self->obj) {
        PyErr_SetString(PyExc_RuntimeError,"could not create GnomeAbout object");
        return -1;
    }

    g_object_ref(self->obj); /* we don't own the first reference of windows */
    pygobject_register_wrapper((PyObject *)self);
    return 0;
}
%%
override gnome_icon_list_get_icon_data kwargs
static PyObject *
_wrap_gnome_icon_list_get_icon_data(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "idx", NULL };
    int idx;
    PyGObject *data;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
				     "i:GnomeIconList.get_icon_data",
				     kwlist, &idx))
        return NULL;
    
    data = gnome_icon_list_get_icon_data(GNOME_ICON_LIST(self->obj), idx);
    if (!data) {
	Py_INCREF(Py_None);
	return Py_None;
    }
    
    Py_INCREF(data);
    return (PyObject*)data;
}
%%
override gnome_icon_list_set_icon_data kwargs
static PyObject *
_wrap_gnome_icon_list_set_icon_data(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "idx", "data", NULL };
    int idx;
    PyGObject *data;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
				     "iO:GnomeIconList.set_icon_data",
				     kwlist, &idx, &data))
        return NULL;
    
    gnome_icon_list_set_icon_data(GNOME_ICON_LIST(self->obj),
				  idx, data);
    
    Py_INCREF(Py_None);
    return Py_None;
}
%%
override gnome_icon_list_get_selection
static PyObject *
_wrap_gnome_icon_list_get_selection(PyGObject *self)
{
    GList    *list, *l;
    PyObject *rv;
    int       len, i;

    list = gnome_icon_list_get_selection(GNOME_ICON_LIST(self->obj));
    len = g_list_length(list);
    rv = PyList_New(len);
    if (!rv) {
	return NULL;
    }
    for (i = 0, l = list; i < len; ++i, l = l->next)
	PyList_SET_ITEM(rv, i, PyInt_FromLong(GPOINTER_TO_INT(l->data)));
    g_list_free(list);
    return rv;
}
%%
override gnome_client_set_restart_command kwargs

typedef void (*clientfunc) (GnomeClient *, int, gchar*[]);

static PyObject*
generic_gnome_client_command (PyGObject *self, PyObject*args, PyObject* kwargs,
			      const char *name, clientfunc func)
{
    char **argv;
    int argc, i;
    PyObject *py_argv;
    char fmt[128];

    if (PySequence_Length(args) == 2) {
	static char *kwlist[] = { "argc", "argv", NULL };
	snprintf(fmt, 128, "iO:gome.ui.Client.%s", name);
	if (!PyArg_ParseTupleAndKeywords(args, kwargs,
					 fmt, kwlist, &argc, &py_argv))
	    return NULL;
	if (PyErr_Warn(PyExc_DeprecationWarning, "the 'argc' parameter"
		       " is optional and deprecated") < 0)
	    return NULL;
    } else {
	static char *kwlist[] = { "argv", NULL };
	snprintf(fmt, 128, "O:gome.ui.Client.%s", name);
	if (!PyArg_ParseTupleAndKeywords(args, kwargs,
					 fmt, kwlist, &py_argv))
	    return NULL;
    }

    if (!PySequence_Check(py_argv)) {
	PyErr_SetString(PyExc_TypeError, "argv argument is not a sequence");
	return NULL;
    }

    argc = PySequence_Length(py_argv);
    argv = g_new(gchar *, argc + 1);
    for (i = 0; i < argc; i++) {
	PyObject *item = PySequence_GetItem(py_argv, i);
	if (!PyString_Check(item)) {
	    PyErr_SetString(PyExc_TypeError, "argv element is not a string");
	    Py_DECREF(item);
	    g_free(argv);
	    return NULL;
	}
	argv[i] = PyString_AsString(item);
	Py_DECREF(item);
    }
    argv[i] = NULL;
    func(GNOME_CLIENT(self->obj), argc, argv);
    g_free(argv);
    
    Py_INCREF(Py_None);
    return Py_None;
}

static PyObject*
_wrap_gnome_client_set_restart_command (PyGObject *self, PyObject *args,
					PyObject *kwargs)
{
    return generic_gnome_client_command(self, args, kwargs,
					"set_restart_command",
					gnome_client_set_restart_command);
}
%%
override gnome_client_set_clone_command kwargs
static PyObject*
_wrap_gnome_client_set_clone_command (PyGObject *self, PyObject *args,
				      PyObject *kwargs)
{
    return generic_gnome_client_command(self, args, kwargs,
					"set_clone_command",
					gnome_client_set_clone_command);
}
%%
override gnome_client_set_discard_command kwargs
static PyObject*
_wrap_gnome_client_set_discard_command (PyGObject *self, PyObject *args,
					PyObject *kwargs)
{
    return generic_gnome_client_command(self, args, kwargs,
					"set_discard_command",
					gnome_client_set_discard_command);
}
%%
override gnome_client_set_resign_command kwargs
static PyObject*
_wrap_gnome_client_set_resign_command (PyGObject *self, PyObject *args,
				       PyObject *kwargs)
{
    return generic_gnome_client_command(self, args, kwargs,
					"set_resign_command",
					gnome_client_set_resign_command);
}
%%
override gnome_client_set_shutdown_command kwargs
static PyObject*
_wrap_gnome_client_set_shutdown_command (PyGObject *self, PyObject *args,
					 PyObject *kwargs)
{
    return generic_gnome_client_command(self, args, kwargs,
					"set_shutdown_command",
					gnome_client_set_shutdown_command);
}
%%
override gnome_client_module_info_get noargs
static PyObject *
_wrap_gnome_client_module_info_get(PyObject *self)
{
    GnomeModuleInfo *ret;

    ret = (GnomeModuleInfo *) gnome_client_module_info_get();
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}
%%
override libgnomeui_module_info_get noargs
static PyObject *
_wrap_libgnomeui_module_info_get(PyObject *self)
{
    GnomeModuleInfo *ret;

    ret = (GnomeModuleInfo *) libgnomeui_module_info_get();
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}
%%
override gnome_gtk_module_info_get noargs
static PyObject *
_wrap_gnome_gtk_module_info_get(PyObject *self)
{
    GnomeModuleInfo *ret;

    ret = (GnomeModuleInfo *) gnome_gtk_module_info_get();
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}
%%
override gnome_icon_lookup kwargs
static PyObject *
_wrap_gnome_icon_lookup(PyObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "icon_theme", "thumbnail_factory", "file_uri",
                              "custom_icon", "flags", "mime_type", "file_info", NULL };
    PyGObject *icon_theme;
    char *file_uri, *custom_icon = NULL, *mime_type = NULL;
    gchar *ret;
    PyObject *file_info = NULL;
    PyObject *py_flags = NULL;
    PyObject *py_thumb_fact;
    GnomeThumbnailFactory *thumbnail_factory = NULL;
    GnomeIconLookupFlags flags;
    GnomeIconLookupResultFlags result_flags = 0;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Os|sOsO!:icon_lookup", kwlist,
                                     &PyGtkIconTheme_Type, &icon_theme,
                                     &py_thumb_fact,
                                     &file_uri, &custom_icon,
                                     &py_flags, &mime_type,
                                     &PyGnomeVFSFileInfo_Type, &file_info))
        return NULL;

    if ((file_info && !mime_type) || (!file_info && mime_type)) {
        PyErr_SetString(PyExc_TypeError, "file_info and mime_type mutually exclusive");
        return NULL;
    }

    if (py_flags) {
        if (pyg_flags_get_value(GNOME_TYPE_ICON_LOOKUP_FLAGS, py_flags, (gint *)&flags))
            return NULL;
    } else
        flags = GNOME_ICON_LOOKUP_FLAGS_NONE;
    
    if (pygobject_check(((PyGObject *) py_thumb_fact), &PyGnomeThumbnailFactory_Type))
        thumbnail_factory = GNOME_THUMBNAIL_FACTORY(((PyGObject *) py_thumb_fact)->obj);
    else if (py_thumb_fact == Py_None)
        thumbnail_factory = NULL;
    else {
        PyErr_SetString(PyExc_TypeError,
                        "thumbnail_factory has to be a GnomeThumbnailFactory or None");
        return NULL;
    }

    if (file_info)
        ret = gnome_icon_lookup(GTK_ICON_THEME(icon_theme->obj),
                                thumbnail_factory,
                                file_uri, custom_icon,
                                pygnome_vfs_file_info_get(file_info),
                                mime_type, flags, &result_flags);
    else
        ret = gnome_icon_lookup_sync(GTK_ICON_THEME(icon_theme->obj),
                                     thumbnail_factory,
                                     file_uri, custom_icon,
                                     flags, &result_flags);
    if (ret) {
        PyObject *py_ret = Py_BuildValue("si", ret, result_flags);
        g_free(ret);
        return py_ret;
    }
      /* The function should never return NULL; if it does, it's an internal bug */
    PyErr_SetString(PyExc_RuntimeError, "internal error");
    return NULL;
}
%%
override gnome_appbar_new kwargs
static int
_wrap_gnome_appbar_new(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    GType obj_type = pyg_type_from_object((PyObject *) self);
    GParameter params[3];
    PyObject *parsed_args[3] = {NULL, };
    char *arg_names[] = {"has_progress", "has_status", "interactivity", NULL };
    char *prop_names[] = {"has_progress", "has_status", "interactivity", NULL };
    guint nparams, i;

      /* http://bugzilla.gnome.org/show_bug.cgi?id=334836 */
    if ((args? PySequence_Size(args) : 0) + (kwargs? PyDict_Size(kwargs) : 0) < 3) {
        if (PyErr_Warn(PyExc_DeprecationWarning, "gnome.ui.AppBar constructor takes exactly 3 arguments,"
                       " but calling old gtk.HBox constructor for compatibility reasons.") < 0)
            return -1;
        return PyGtkHBox_Type.tp_init((PyObject *) self, args, kwargs);
    }

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:gnome.ui.AppBar.__init__" , arg_names ,
                                     &parsed_args[0] , &parsed_args[1] , &parsed_args[2]))
        return -1;

    memset(params, 0, sizeof(GParameter)*3);
    if (!pyg_parse_constructor_args(obj_type, arg_names,
                                    prop_names, params, 
                                    &nparams, parsed_args))
        return -1;
    pygobject_constructv(self, nparams, params);
    for (i = 0; i < nparams; ++i)
        g_value_unset(&params[i].value);
    if (!self->obj) {
        PyErr_SetString(
            PyExc_RuntimeError, 
            "could not create gnome.ui.AppBar object");
        return -1;
    }
    return 0;
}