File: gnome.override

package info (click to toggle)
gnome-python 2.28.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,288 kB
  • sloc: sh: 10,219; ansic: 7,997; xml: 2,464; python: 1,886; makefile: 392
file content (738 lines) | stat: -rw-r--r-- 23,469 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
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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#include <Python.h>

#include <signal.h>
#include <locale.h>

#define NO_IMPORT_PYGOBJECT
#include "pygobject.h"
#include <libgnome/libgnome.h>
#include <libgnome/libgnometypebuiltins.h>
#include <popt.h>
#include <config.h>
#ifdef HAVE_PRCTL
#include <sys/prctl.h>
#endif
#ifdef HAVE_SETPROCTITLE
#include <sys/types.h>
#include <unistd.h>
#endif
#include "config.h"

static struct poptOption * popt_build_table   (PyObject          *table);
static void                popt_destroy_table (struct poptOption *table);


%%
modulename gnome
%%
import gobject.GObject as PyGObject_Type
%%
ignore-glob 
  *_get_type
%%
override gnome_program_init kwargs

static void __py_object_free(gpointer data)
{
    Py_DECREF((PyObject *) data);
}

static void
popt_cb(poptContext con, 
        enum poptCallbackReason reason, 
        const struct poptOption *opt, 
        const char *arg, void *data)
{
    PyObject *dict = data;
    PyObject *item = NULL, *existing;
    PyObject *key;
    char aux[] = " ";

    switch (opt->argInfo & POPT_ARG_MASK) {
    case POPT_ARG_INT:
        item = PyInt_FromLong(*(int *)(opt->arg));
        break;
    case POPT_ARG_DOUBLE:
        item = PyFloat_FromDouble(*(double *)(opt->arg));
        break;
    case POPT_ARG_STRING:
        item = PyString_FromString(arg);
        break;
    case POPT_ARG_LONG:
        item = PyLong_FromLong(*(long *)(opt->arg));
        break;
    case POPT_ARG_NONE:
        item = PyInt_FromLong(1L);
        break;
    default:
        break;
    }
    if (!item)
        return;

    if (opt->longName) {
        key = PyString_FromString(opt->longName);
    } else {
        aux[0] = opt->shortName;
        key = PyString_FromString(aux);
    }

    existing = PyDict_GetItem(dict, key);
    if (existing && PyList_Check(existing))
        PyList_Append(existing, item);
    else
        PyDict_SetItem(dict, key, item);
    Py_DECREF(item);
}

static void
popt_destroy_table(struct poptOption *table)
{
    int i = 1;

    if (table[0].descrip) {
        Py_DECREF((PyObject *) table[0].descrip);
    }
    while ((table[i].longName != NULL) || (table[i].shortName != '\0') || 
           (table[i].argInfo != 0)) {
        if (table[i].longName)
            g_free((gpointer) table[i].longName);
        if (table[i].descrip)
            g_free((gpointer) table[i].descrip);
        if (table[i].argDescrip)
            g_free((gpointer) table[i].argDescrip);
        if ((table[i].argInfo != POPT_ARG_CALLBACK) && 
            (table[i].arg != NULL))
            g_free((gpointer) table[i].arg);
        i++;
    }
    g_free(table);
}

static struct poptOption *
popt_build_table(PyObject *table)
{
    int optslen;
    int i;
    struct poptOption *popt_table = NULL;
    PyObject *tmpobj;
    char *lname, *sname, *desc = NULL, *adesc = NULL;
    PyTypeObject *tinfo;
    PyObject *dict_key = Py_None, *dict, *defval, *defval1;
    int flags;

    optslen = PyList_Size(table);
    /* save one row for the callback definition, and another for
     * end of table */
    popt_table = g_new0(struct poptOption, optslen + 2);

    if (popt_table != NULL) {

        dict = PyDict_New();
        if (dict == NULL) {
            g_free(popt_table);
            return NULL;
        }

        /* Hey popt, we want to be called back */
        popt_table[0].longName = NULL;
        popt_table[0].shortName = 0;
        popt_table[0].argInfo = POPT_ARG_CALLBACK;
        popt_table[0].arg = popt_cb;
        popt_table[0].val = 0;
        popt_table[0].descrip = (char *) dict;
        popt_table[0].argDescrip = NULL;

        for (i = 0; i < optslen; i++) {

            desc = NULL;
            adesc = NULL;

            tmpobj = PyList_GetItem(table, i);

            if (!PyTuple_Check(tmpobj)) {
                PyErr_SetString(PyExc_TypeError,
                                "table must be a list of tuples");
                popt_destroy_table(popt_table);
                return NULL;
            }

            if (!PyArg_ParseTuple(tmpobj, "zzOOi|ss", 
                                  &lname, &sname, &tinfo,
                                  &defval, &flags, &desc, &adesc)) {
                popt_destroy_table(popt_table);
                return NULL;
            }

            if (strlen(lname) == 0)
                lname = NULL;

            if (strlen(sname) == 0)
                sname = NULL;

            if (sname && strlen(sname) > 1) {
                PyErr_Format(PyExc_ValueError,
                             "popt table row %d short option"
                             " must be one character only", i);
                popt_destroy_table(popt_table);
                return NULL;
            } else {
                if (lname) {
                    dict_key = PyString_FromString(lname);
                } else if (sname) {
                    dict_key = PyString_FromString(sname);
                }
            }

            if (!sname & !lname) {
                PyErr_Format(PyExc_ValueError,
                             "popt table row %d at least short"
                             " or long name must be set", i);
                popt_destroy_table(popt_table);
                return NULL;
            }

            if (dict_key != Py_None) {
                if ((defval != Py_None && !PyList_Check(defval)) && 
                    (!PyObject_TypeCheck(defval, (PyTypeObject *) tinfo))) {
                    PyErr_Format(PyExc_ValueError,
                                 "popt table row %d type info and default "
                                 "value must have same type", i);
                    popt_destroy_table(popt_table);
                    return NULL;
                }

                /* If one doesnt want to have keys created only when
                   a parameter is found in the command line this has to
                   be done only when defval is not Py_None */
                if (PyList_Check(defval))
                    defval1 = PyList_New(0);
                else {
                    Py_INCREF(defval);
                    defval1 = defval;
                }
                if (PyDict_SetItem(dict, dict_key, defval1)) {
                    Py_DECREF(defval1);
                    popt_destroy_table(popt_table);
                    return NULL;
                }
                Py_DECREF(defval1);
            }

            /* ARG_FLOAT is not set here - we use DOUBLE */
            if (tinfo == &PyInt_Type) {
                popt_table[i + 1].argInfo = POPT_ARG_INT;
                popt_table[i + 1].arg = g_new(int, 1);
                if (PyInt_Check(defval))
                    *((int *)popt_table[i + 1].arg) = PyInt_AS_LONG(defval);
            } else if (tinfo == &PyFloat_Type) {
                popt_table[i + 1].argInfo = POPT_ARG_DOUBLE;
                popt_table[i + 1].arg = g_new(double, 1);
                if (PyFloat_Check(defval))
                    *((double *)popt_table[i + 1].arg) = PyFloat_AS_DOUBLE(defval);
            } else if (tinfo == &PyString_Type) {
                popt_table[i + 1].argInfo = POPT_ARG_STRING;
                popt_table[i + 1].arg = NULL;
            } else if (tinfo == &PyLong_Type) {
                popt_table[i + 1].argInfo = POPT_ARG_LONG;
                popt_table[i + 1].arg = g_new(long, 1);
                if (PyLong_Check(defval))
                    *((long *)popt_table[i + 1].arg) = PyInt_AS_LONG(defval);
            } else if (tinfo == (PyTypeObject *) Py_None) {
                popt_table[i + 1].argInfo = POPT_ARG_NONE;
                popt_table[i + 1].arg = NULL;
            } else {
                PyErr_Format(PyExc_ValueError,
                             "popt table row %d type info must be"
                             " None, int, str, float or long", i);
                popt_destroy_table(popt_table);
                return NULL;
            }

            popt_table[i + 1].longName = lname ? g_strdup(lname) : NULL;
            popt_table[i + 1].shortName = sname ? sname[0] : '\0';
            popt_table[i + 1].argInfo |= flags;
            popt_table[i + 1].val = 0;
            popt_table[i + 1].descrip = desc ? g_strdup(desc) : NULL;
            popt_table[i + 1].argDescrip = adesc ? g_strdup(adesc) : NULL;

        }
        /* finally the end mark */
        popt_table[optslen + 1].longName = NULL;
        popt_table[optslen + 1].shortName = 0;
        popt_table[optslen + 1].argInfo = 0;
        popt_table[optslen + 1].arg = NULL;
        popt_table[optslen + 1].val = 0;
        popt_table[optslen + 1].descrip = NULL;
        popt_table[optslen + 1].argDescrip = NULL;

        return popt_table;

    } else {
        PyErr_NoMemory();
    }

    return NULL;
}

static PyTypeObject *
get_option_context_type()
{
    PyObject *module;
    PyTypeObject *type;
    if ((module = PyImport_ImportModule("glib")) != NULL) {
        type = (PyTypeObject *)PyObject_GetAttrString(module, "OptionContext");
        Py_DECREF(module);
        if (type == NULL) {
            PyErr_SetString(PyExc_ImportError,
                            "cannot import OptionContext from glib");
            return NULL;
        } else
            return type;
    } else {
        PyErr_SetString(PyExc_ImportError, "could not import glib");
        return NULL;
    }
}

static int
build_gnome_init_params(PyObject *py_properties,
                        struct poptOption *popt_table, int flags,
                        PyObject *option_context,
                        PyObject **py_properties_items, Py_ssize_t *nparams,
                        GParameter **params_ptr)
{
    Py_ssize_t py_properties_len = -1;
    PyObject *items = NULL;
    if (py_properties) {
        *py_properties_items = items = PyMapping_Items(py_properties);
        if (!items)
            return 0;
        *nparams = py_properties_len = PyList_GET_SIZE(items);
    } else
        *nparams = 0;
    if (popt_table)
        *nparams += 2;
    if (option_context)
        *nparams += 1;

    GParameter *params = NULL;
    if (*nparams) {
        params = g_new0(GParameter, *nparams);
        if (!params) {
            PyErr_NoMemory();
            return 0;
        }
    }
    Py_ssize_t i = 0;
    if (py_properties) {
        PyObject *item, *key, *val;
        GType type;
        for (; i < py_properties_len; ++i) {
            item = PyList_GET_ITEM(items, i);
            key = PyTuple_GET_ITEM(item, 0);
            val = PyTuple_GET_ITEM(item, 1);
            type = pyg_type_from_object((PyObject *) val->ob_type);
            if (type == 0)
                goto error;
            params[i].name = PyString_AsString(key);
            g_value_init(&params[i].value, type);
            if (pyg_value_from_pyobject(&params[i].value, val))
                goto error;
            continue;
            error:
            {
                int j;
                for (j = 0; j < i; ++j)
                    g_value_unset(&params[j].value);
                g_free(params);
                Py_DECREF(items);
                return 0;
            }
        }
    }
    if (popt_table) {
        params[i].name = GNOME_PARAM_POPT_TABLE;
        g_value_init(&params[i].value, G_TYPE_POINTER);
        g_value_set_pointer(&params[i].value, popt_table);
        i++;
        params[i].name = GNOME_PARAM_POPT_FLAGS;
        g_value_init(&params[i].value, G_TYPE_INT);
        g_value_set_int(&params[i].value, flags);
    }
    if (option_context) {
        params[i].name = GNOME_PARAM_GOPTION_CONTEXT;
        g_value_init(&params[i].value, G_TYPE_POINTER);
        PyObject* context = PyObject_CallMethod(option_context, "_get_context", NULL);
        g_value_set_pointer(&params[0].value, PyCObject_AsVoidPtr(context));
        Py_DECREF(context);
    }

    *params_ptr = params;
    return 1;
}

static void
free_gnome_init_params(PyObject *py_properties_items, Py_ssize_t nparams,
                       GParameter *params)
{
    Py_XDECREF(py_properties_items);
    if (nparams)
    {
        Py_ssize_t i;
        for (i = 0; i < nparams; ++i)
            g_value_unset(&params[i].value);
        g_free(params);
    }
}

static PyObject *
_wrap_gnome_program_init(PyObject *self, 
                         PyObject *args, 
                         PyObject *kwargs)
{
    static char *kwlist[] = { "app_id", "app_version", "module_info", 
                              "argv", "popt_table", "popt_flags",
                              "option_context", "properties", NULL };
    gchar *app_id;
    gchar *app_version;
    PyObject *av = NULL;
    int argc;
    char **argv, **leftover_args;
    int i;
    GnomeModuleInfo *moduleinfo;
    GnomeProgram *program;
    struct sigaction sa;
    struct poptOption *popt_table = NULL;
    int flags = 0;
    PyObject *table = NULL;
    PyObject *m = NULL;
    PyObject *argdict, *py_leftover_args;
    PyObject *tmpobj;
    PyObject *option_context = NULL;
    PyObject *py_properties = NULL;
    PyObject *py_properties_items = NULL;
    GParameter *params;
    Py_ssize_t nparams;
    poptContext ctx = NULL;

    PyTypeObject *py_goption_context_type = get_option_context_type();
    if (!py_goption_context_type) {
        return NULL;
    }

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "ss|OO!O!iO!O!:gnome.program_init",
                                     kwlist,
                                     &app_id, &app_version, &m,
                                     &PyList_Type, &av,
                                     &PyList_Type, &table,
                                     &flags,
                                     py_goption_context_type, &option_context,
                                     &PyDict_Type, &py_properties)) {
        return NULL;
    }

    Py_DECREF(py_goption_context_type);

    if (m == NULL) {
        moduleinfo = (GnomeModuleInfo *) libgnome_module_info_get();
    } else {
        if (pyg_boxed_check(m, GNOME_TYPE_MODULE_INFO))
            moduleinfo = pyg_boxed_get(m, GnomeModuleInfo);
        else {
            PyErr_SetString(PyExc_TypeError,
                            "module_info should be a GnomeModuleInfo");
            return NULL;
        }
    }

    if (av == NULL) {
          /* ... use argc and argv from sys */
        av = PySys_GetObject("argv");
    }
    argc = PyList_Size(av);
    argv = g_new(char *, argc);
    if (!argv)
        return PyErr_NoMemory();
    for (i = 0; i < argc; i++)
        argv[i] = PyString_AsString(PyList_GetItem(av, i));

    if (table != NULL) {
        popt_table = popt_build_table(table);
        if (!popt_table)
            return NULL;
    }

    if (!build_gnome_init_params(py_properties, popt_table, flags,
                                 option_context,
                                 &py_properties_items, &nparams, &params)) {
        if (popt_table)
            popt_destroy_table(popt_table);
        return NULL;
    }

    memset(&sa, 0, sizeof(sa));
    sigaction(SIGCHLD, NULL, &sa);

    program = gnome_program_init_paramv(GNOME_TYPE_PROGRAM,
                                        app_id, app_version,
                                        moduleinfo,  argc, argv,
                                        (guint) nparams, params);

    free_gnome_init_params(py_properties_items, nparams, params);

    if (!program) {
        PyErr_SetString(PyExc_RuntimeError,
                        "could not create GnomeProgram object");
        if (popt_table)
            popt_destroy_table(popt_table);
        g_free(argv);
        return NULL;
    }
      /* --- */

    sigaction(SIGCHLD, &sa, NULL);
#if PY_VERSION_HEX < 0x020400F0
    setlocale(LC_NUMERIC, "C");
#endif

    if (popt_table) {
          /* get argdict, store in object for later use */
        argdict = (PyObject *) popt_table[0].descrip;
        Py_INCREF(argdict);
        g_object_set_data_full(G_OBJECT(program),
                               "gnome-python-popt-argdict",
                               argdict, __py_object_free);

          /* get leftover args, store in object for later use */
        g_object_get(G_OBJECT(program), GNOME_PARAM_POPT_CONTEXT, &ctx, NULL);
        leftover_args = (char **) poptGetArgs(ctx);
        py_leftover_args = PyList_New(0);
        if (!py_leftover_args) {
            return PyErr_NoMemory();
        }
        if (leftover_args) {
            for (i = 0; leftover_args[i]; i++) {
                tmpobj = PyString_FromString(leftover_args[i]);
                if (!tmpobj) {
                    Py_DECREF(py_leftover_args);
                    return NULL;
                }
                if (PyList_Append(py_leftover_args, tmpobj)) {
                    Py_DECREF(tmpobj);
                    Py_DECREF(py_leftover_args);
                    return NULL;
                }
                Py_DECREF(tmpobj);
            }
        }
        g_object_set_data_full(G_OBJECT(program),
                               "gnome-python-popt-leftover-args",
                               py_leftover_args, __py_object_free);

        popt_destroy_table(popt_table);
    }

#if (defined(HAVE_PRCTL) && defined(PR_SET_NAME)) || defined(HAVE_SETPROCTITLE)
    if (argv && argv[0]) {
#if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
    if (prctl(PR_SET_NAME, (unsigned long) argv[0], 0, 0, 0)) {
            g_warning("prctl() failed");
        }
#elif defined(HAVE_SETPROCTITLE)
    setproctitle("-%s", argv[0]);
#endif
    }
#endif

    g_free (argv);
    return pygobject_new((GObject *) program);
}

%%
override gnome_get_popt_args noargs
static PyObject *
_wrap_gnome_get_popt_args(PyGObject *self, PyObject *args)
{
    PyObject *argdict, *leftover_args;

    argdict = g_object_get_data(G_OBJECT(self->obj),
                                "gnome-python-popt-argdict");
    leftover_args = g_object_get_data(G_OBJECT(self->obj),
                                      "gnome-python-popt-leftover-args");
    if (argdict) {
        Py_INCREF(argdict);
    } else
        argdict = PyDict_New();

    if (leftover_args) {
        Py_INCREF(leftover_args);
    } else
        leftover_args = PyList_New(0);

    return Py_BuildValue("(NN)", leftover_args, argdict);
}

%%
override gnome_popt_parse kwargs
static PyObject *
_wrap_gnome_popt_parse(PyObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "argv", "table", "flags", NULL };
    PyObject *pytable, *pyargv, *tmpobj;
    PyObject *argdict, *py_leftover_args;
    poptContext ctx = NULL;
    struct poptOption *table = NULL;
    GnomeProgram *program;
    const char *program_name;
    int i, argc, flags = 0;
    const char **argv = NULL;
    const char **leftover_args = NULL;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!|i:popt_parse",
                                     kwlist,
                                     &PyList_Type, &pyargv,
                                     &PyList_Type, &pytable,
                                     &flags))
        return NULL;

    table = popt_build_table(pytable);
    if (table == NULL)
        return NULL;

      /* so much code just to get the program name :| */
    program = gnome_program_get();
    if (program)
        program_name = gnome_program_get_app_id(program);
    else {
        PyObject *sysargv, *arg0;
        sysargv = PySys_GetObject("argv");
        arg0 = PyList_GetItem(sysargv, 0);
        if (!arg0) {
            PyErr_Clear();
            program_name = "gnome-python";
        } else {
            program_name = PyString_AsString(arg0);
            if (!program_name) {
                PyErr_Clear();
                program_name = "gnome-python";
            }
        }
    }

    argc = PyList_Size(pyargv);
    argv = g_new(const char *, argc);
    for (i = 0; i < argc; i++)
        argv[i] = PyString_AsString(PyList_GetItem(pyargv, i));

    ctx = poptGetContext(program_name, argc, argv, table, flags);
    while (poptGetNextOpt(ctx) >= 0);
    
    argdict = (PyObject *) table[0].descrip;
    Py_INCREF(argdict);

    leftover_args = poptGetArgs(ctx);
    py_leftover_args = PyList_New(0);
    if (leftover_args)
        for (i = 0; leftover_args[i]; i++) {
            tmpobj = PyString_FromString(leftover_args[i]);
            PyList_Append(py_leftover_args, tmpobj);
            Py_DECREF(tmpobj);
        }

    popt_destroy_table(table);
    poptFreeContext(ctx);
    g_free(argv);

    return Py_BuildValue("(NN)", py_leftover_args, argdict);
}
%%
override gnome_help_display kwargs
static PyObject *
_wrap_gnome_help_display(PyObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "doc_name", "link_id", NULL };
    char *doc_name, *link_id = NULL;
    int ret;
    GError *error = NULL;
    PyObject *py_ret;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z:help_display", kwlist, &doc_name, &link_id))
        return NULL;
    ret = gnome_help_display(doc_name, link_id, &error);
    if (pyg_error_check(&error))
        return NULL;
    py_ret = ret ? Py_True : Py_False;
    Py_INCREF(py_ret);
    return py_ret;
}
%%
override libgnome_module_info_get noargs
static PyObject *
_wrap_libgnome_module_info_get(PyObject *self)
{
    GnomeModuleInfo *ret;

    ret = (GnomeModuleInfo *) libgnome_module_info_get();
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}
%%
override gnome_program_locate_file kwargs
static PyObject *
_wrap_gnome_program_locate_file(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "domain", "file_name", "only_if_exists", NULL };
    PyObject *py_domain = NULL;
    GnomeFileDomain domain;
    char *file_name;
    int only_if_exists, i;
    GSList *ret_locations = NULL, *l;
    PyObject *py_ret_locations;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Osi:GnomeProgram.locate_file",
                                     kwlist, &py_domain, &file_name, &only_if_exists))
        return NULL;
    if (pyg_enum_get_value(GNOME_TYPE_FILE_DOMAIN, py_domain, (gint *)&domain))
        return NULL;
    gnome_program_locate_file(GNOME_PROGRAM(self->obj), domain, file_name,
                              only_if_exists, &ret_locations);
    py_ret_locations = PyList_New(g_slist_length(ret_locations));
    for (l = ret_locations, i = 0; l; l = l->next, ++i) {
        PyList_SET_ITEM(py_ret_locations, i, PyString_FromString(l->data));
        g_free(l->data);
    }
    g_slist_free(ret_locations);
    return py_ret_locations;
}
%%
override gnome_bonobo_module_info_get noargs
static PyObject *
_wrap_gnome_bonobo_module_info_get(PyObject *self)
{
    GnomeModuleInfo *ret;

    ret = (GnomeModuleInfo *) gnome_bonobo_module_info_get();
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}
%%
override gnome_program_module_load kwargs
static PyObject *
_wrap_gnome_program_module_load(PyObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "mod_name", NULL };
    char *mod_name;
    GnomeModuleInfo *ret;

    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:program_module_load", kwlist, &mod_name))
        return NULL;
    ret = (GnomeModuleInfo *) gnome_program_module_load(mod_name);
    /* pyg_boxed_new handles NULL checking */
    return pyg_boxed_new(GNOME_TYPE_MODULE_INFO, ret, TRUE, TRUE);
}