%% headers #include #define NO_IMPORT_PYGOBJECT #include "pygobject.h" #include "mooutils/moowin.h" #include "mooutils/moodialogs.h" #include "mooutils/mooprefs.h" #include "mooutils/mooprefsdialog.h" #include "mooutils/moostock.h" #include "mooutils/moofileutils.h" #include "mooutils/moolog.h" #include "mooutils/mooutils-python.h" void moo_utils_register_classes (PyObject *dict); void moo_utils_add_constants (PyObject *module, const gchar *strip_prefix); static PyTypeObject *_PyGdkColor_Type; #define PyGdkColor_Type (*_PyGdkColor_Type) static void prefs_set (const char *key, PyObject *val) { if (val == Py_None) { moo_prefs_set (key, NULL); } #ifdef PyGEnum_Type else if (PyObject_TypeCheck (val, &PyGEnum_Type)) { int ival; pyg_enum_get_value (pyg_type_from_object (val), val, &ival); moo_prefs_set_enum (key, pyg_type_from_object (val), ival); } #endif #ifdef PyBool_Check else if (PyBool_Check (val)) { moo_prefs_set_bool (key, Py_True == val); } #endif else if (PyFloat_Check (val)) { moo_prefs_set_double (key, PyFloat_AS_DOUBLE (val)); } else if (PyLong_Check (val)) { moo_prefs_set_int (key, PyLong_AsLong (val)); } else if (PyInt_Check (val)) { moo_prefs_set_int (key, PyInt_AS_LONG (val)); } else if (PyString_Check (val)) { moo_prefs_set_string (key, PyString_AS_STRING (val)); } else if (PyObject_TypeCheck (val, &PyGdkColor_Type)) { GdkColor *color = ((PyGBoxed*)val)->boxed; moo_prefs_set_color (key, color); } else { PyErr_SetString (PyExc_TypeError, "could not set prefs value"); return; } } %% modulename moo %% import gtk.Window as PyGtkWindow_Type import gtk.Widget as PyGtkWidget_Type import gtk.ToggleButton as PyGtkToggleButton_Type import gtk.Button as PyGtkButton_Type import gtk.Dialog as PyGtkDialog_Type import gtk.VBox as PyGtkVBox_Type import gtk.gdk.Color as PyGdkColor_Type %% ignore-glob *_get_type %% override moo_prefs_set kwargs static PyObject * _wrap_moo_prefs_set(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "key", "val", NULL }; char *key; PyObject *val; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:prefs_set", kwlist, &key, &val)) return NULL; prefs_set (key, val); if (!PyErr_Occurred ()) { Py_INCREF (Py_None); return Py_None; } else { return NULL; } } %% override moo_prefs_get kwargs static PyObject * _wrap_moo_prefs_get(PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = {"key", NULL}; char *key; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:prefs_get", kwlist, &key)) return NULL; return moo_gvalue_to_pyobject (moo_prefs_get (key)); } %% override moo_g_object_new kwargs static PyObject * _wrap_moo_g_object_new (PyObject *self, PyObject *args, PyObject *kwargs) { PyErr_SetString (PyExc_NotImplementedError, "not implemented"); return NULL; }