Bind xdgmime in SugarExt
And use it in the sugar3.mime modules. This allows to get rid of the pygtk generated sugarbase module, along with the wrapping code. Also add more cases to test_time to make sure everything is still working.master
parent
e6397cf2db
commit
6202d4d5cc
@ -1,33 +0,0 @@
|
||||
; functions
|
||||
|
||||
(define-function get_mime_type_from_file_name
|
||||
(c-name "sugar_mime_get_mime_type_from_file_name")
|
||||
(return-type "const-char*")
|
||||
(parameters
|
||||
'("const-char*" "filename")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function get_mime_type_for_file
|
||||
(c-name "sugar_mime_get_mime_type_for_file")
|
||||
(return-type "const-char*")
|
||||
(parameters
|
||||
'("const-char*" "filename")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function list_mime_parents
|
||||
(c-name "sugar_mime_list_mime_parents")
|
||||
(return-type "char**")
|
||||
(parameters
|
||||
'("const-char*" "mime")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function uri_list_extract_uris
|
||||
(c-name "g_uri_list_extract_uris")
|
||||
(return-type "gchar**")
|
||||
(parameters
|
||||
'("const-char*" "uri_list")
|
||||
)
|
||||
)
|
@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
#include <glib.h>
|
||||
#include "xdgmime.h"
|
||||
%%
|
||||
modulename _sugarext
|
||||
%%
|
||||
ignore-glob
|
||||
*_get_type
|
||||
_*
|
||||
%%
|
||||
override sugar_mime_get_mime_type_for_file kwargs
|
||||
static PyObject *
|
||||
_wrap_sugar_mime_get_mime_type_for_file(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "filename", NULL };
|
||||
char *filename;
|
||||
const char *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:get_mime_type_for_file", kwlist, &filename))
|
||||
return NULL;
|
||||
|
||||
ret = sugar_mime_get_mime_type_for_file(filename, NULL);
|
||||
|
||||
if (ret)
|
||||
return PyString_FromString(ret);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override sugar_mime_list_mime_parents kwargs
|
||||
static PyObject *
|
||||
_wrap_sugar_mime_list_mime_parents(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "mime_type", NULL };
|
||||
char *mime_type;
|
||||
char **parents, **tmp;
|
||||
int i = 0, j;
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:list_mime_parents", kwlist, &mime_type))
|
||||
return NULL;
|
||||
|
||||
parents = (char **)sugar_mime_list_mime_parents(mime_type);
|
||||
if (!parents)
|
||||
return PyTuple_New(0);
|
||||
|
||||
tmp = parents;
|
||||
while (*tmp)
|
||||
tmp++, i++;
|
||||
|
||||
ret = PyTuple_New(i);
|
||||
for (j = 0; j < i; j++)
|
||||
PyTuple_SetItem(ret, j, PyString_FromString(parents[j]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override g_uri_list_extract_uris kwargs
|
||||
static PyObject *
|
||||
_wrap_g_uri_list_extract_uris(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "uri_list", NULL };
|
||||
char *uri_list;
|
||||
char **uris, **tmp;
|
||||
int i = 0, j;
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:uri_list_extract_uris", kwlist, &uri_list))
|
||||
return NULL;
|
||||
|
||||
uris = (char **)g_uri_list_extract_uris(uri_list);
|
||||
if (!uris)
|
||||
return PyTuple_New(0);
|
||||
|
||||
tmp = uris;
|
||||
while (*tmp)
|
||||
tmp++, i++;
|
||||
|
||||
ret = PyTuple_New(i);
|
||||
for (j = 0; j < i; j++)
|
||||
PyTuple_SetItem(ret, j, PyString_FromString(uris[j]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2007, Red Hat, Inc.
|
||||
*
|
||||
* 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 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., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <Python.h>
|
||||
|
||||
extern PyMethodDef py_sugarbaseext_functions[];
|
||||
|
||||
DL_EXPORT(void)
|
||||
init_sugarbaseext(void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
m = Py_InitModule ("_sugarbaseext", py_sugarbaseext_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
Py_FatalError ("can't initialise module _sugarext");
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="2.0">
|
||||
</svg>
|
After Width: | Height: | Size: 117 B |
Loading…
Reference in New Issue