/* -*- Mode: C; c-basic-offset: 4 -*- * */ %% headers #include "pygobject.h" #include #include %% include %% modulename desktopentry %% import gobject.GObject as PyGObject_Type %% ignore %% ignore-glob print_desktop_entry_info %% ignore-win32 %% ignore-glob _* *_get_type %% override xfce_desktop_entry_get_string kwargs static PyObject * _wrap_xfce_desktop_entry_get_string(PyGObject *self, PyObject *args, PyObject *kwargs) { gchar *value; PyObject *ret; gchar *key; int translated; static char *kwlist[] = { "key", "translated", NULL }; translated = TRUE; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|i:xfce_desktop_entry_get_string", kwlist, &key, &translated)) return NULL; if (xfce_desktop_entry_get_string (XFCE_DESKTOP_ENTRY(self->obj), key, translated, &value)) { ret = PyString_FromString (value); g_free (value); return ret; } Py_INCREF(Py_None); return Py_None; } %% override xfce_desktop_entry_get_int kwargs static PyObject * _wrap_xfce_desktop_entry_get_int(PyGObject *self, PyObject *args, PyObject *kwargs) { int value; gchar *key; static char *kwlist[] = { "key", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:xfce_desktop_entry_get_int", kwlist, &key)) return NULL; if (xfce_desktop_entry_get_int (XFCE_DESKTOP_ENTRY(self->obj), key, &value)) { return PyInt_FromLong((long) value); } Py_INCREF(Py_None); return Py_None; } %% override xfce_desktop_entry_new kwargs static PyObject * _wrap_xfce_desktop_entry_new(PyGObject *self, PyObject *args, PyObject *kwargs) { const gchar** categories; const gchar* file_path; XfceDesktopEntry* desktop_entry; PyObject* py_desktop_entry; PyObject* py_categories; PyObject* py_item; int i, count; static char *kwlist[] = { "file_path", "categories", NULL }; categories = NULL; file_path = NULL; py_categories = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|O!:xfce_desktop_entry_new", kwlist, &file_path, &PyList_Type, &py_categories)) { return NULL; } count = 0; if (py_categories != NULL) { count = PyList_Size (py_categories); categories = (const gchar**) g_new0 (gchar*, count + 1); for (i = 0; i < count; i++) { py_item = PyList_GetItem (py_categories, i); categories[i] = PyString_AsString (py_item); if (categories[i] == NULL) { g_free(categories); PyErr_SetString(PyExc_TypeError, "Type Mismatch: categories should be a list of strings"); return NULL; } } } if (categories == NULL) { count = 29; categories = (const gchar**) g_new0(gchar*, count + 1); categories[0] = "Name"; categories[1] = "GenericName", categories[2] = "Type"; categories[3] = "Version"; categories[4] = "Encoding"; categories[5] = "NoDisplay"; categories[6] = "Comment"; categories[7] = "Icon"; categories[8] = "Hidden"; categories[9] = "FilePattern"; categories[10] = "TryExec"; categories[11] = "Exec"; categories[12] = "Path"; categories[13] = "Terminal"; categories[14] = "SwallowTitle"; categories[15] = "SwallowExec"; categories[16] = "Actions"; categories[17] = "MimeType"; categories[18] = "SortOrder"; categories[18] = "Dev"; categories[19] = "FSType"; categories[20] = "MountPoint"; categories[21] = "ReadOnly"; categories[22] = "UnmountIcon"; categories[23] = "URL"; categories[24] = "Categories"; categories[25] = "OnlyShowIn"; categories[26] = "NotShowIn"; categories[27] = "StartupNotify"; categories[28] = "StartupWMClass"; } desktop_entry = xfce_desktop_entry_new(file_path, categories, count); g_free(categories); if (desktop_entry == NULL) { PyErr_SetString(PyExc_OSError, "OSError"); return NULL; } py_desktop_entry = pygobject_new((GObject *) desktop_entry); g_object_unref(desktop_entry); return py_desktop_entry; }