Wrapped moo_glade_xml_set_signal_func
parent
3cac721335
commit
14c5421c08
2
moo.mprj
2
moo.mprj
|
@ -34,7 +34,7 @@
|
|||
</configure>
|
||||
</optimized>
|
||||
</configurations>
|
||||
<file_selector_dir>/home/muntyan/projects/moo/moo/mooutils/</file_selector_dir>
|
||||
<file_selector_dir>/home/muntyan/projects/moo/</file_selector_dir>
|
||||
<run>
|
||||
<args>--new-app --mode=project</args>
|
||||
<exe>medit/medit</exe>
|
||||
|
|
|
@ -684,13 +684,14 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method map_signal
|
||||
(define-method set_signal_func
|
||||
(of-object "MooGladeXML")
|
||||
(c-name "moo_glade_xml_map_signal")
|
||||
(c-name "moo_glade_xml_set_signal_func")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("MooGladeSignalFunc" "func")
|
||||
'("gpointer" "data")
|
||||
'("GDestroyNotify" "notify")
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -700,7 +701,7 @@
|
|||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-char*" "file")
|
||||
'("const-char*" "root")
|
||||
'("const-char*" "root" (null-ok) (default "NULL"))
|
||||
'("GError**" "error")
|
||||
)
|
||||
)
|
||||
|
|
|
@ -767,3 +767,113 @@ _wrap_moo_glade_xml_tp_getattr (PyObject *self, char *attr)
|
|||
|
||||
return Py_FindMethod ((PyMethodDef*) _PyMooGladeXML_methods, self, attr);
|
||||
}
|
||||
%%
|
||||
override moo_glade_xml_set_signal_func varargs
|
||||
|
||||
typedef struct {
|
||||
PyObject *func;
|
||||
PyObject *args;
|
||||
} Closure;
|
||||
|
||||
#define closure_new() g_new0 (Closure, 1)
|
||||
|
||||
static void
|
||||
closure_free (Closure *closure)
|
||||
{
|
||||
if (closure)
|
||||
{
|
||||
Py_XDECREF (closure->func);
|
||||
Py_XDECREF (closure->args);
|
||||
g_free (closure);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
signal_func (MooGladeXML *xml,
|
||||
const char *widget_id,
|
||||
GtkWidget *widget,
|
||||
const char *signal,
|
||||
const char *handler,
|
||||
const char *object,
|
||||
gpointer data)
|
||||
{
|
||||
Closure *closure = data;
|
||||
PyObject *result, *args;
|
||||
gboolean ret;
|
||||
|
||||
args = PyTuple_New (6 + (closure->args ? PyTuple_GET_SIZE (closure->args) : 0));
|
||||
PyTuple_SET_ITEM (args, 0, pygobject_new (G_OBJECT (xml)));
|
||||
PyTuple_SET_ITEM (args, 1, PyString_FromString (widget_id));
|
||||
PyTuple_SET_ITEM (args, 2, pygobject_new (G_OBJECT (widget)));
|
||||
PyTuple_SET_ITEM (args, 3, PyString_FromString (signal));
|
||||
PyTuple_SET_ITEM (args, 4, PyString_FromString (handler));
|
||||
PyTuple_SET_ITEM (args, 5, object ? PyString_FromString (object) : Py_None);
|
||||
|
||||
if (!object)
|
||||
Py_INCREF (Py_None);
|
||||
|
||||
if (closure->args)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PyTuple_GET_SIZE (closure->args); ++i)
|
||||
{
|
||||
PyTuple_SET_ITEM (args, i + 6, PyTuple_GET_ITEM (closure->args, i));
|
||||
Py_INCREF (PyTuple_GET_ITEM (closure->args, i));
|
||||
}
|
||||
}
|
||||
|
||||
result = PyObject_CallObject (closure->func, args);
|
||||
|
||||
Py_DECREF (args);
|
||||
|
||||
if (result)
|
||||
{
|
||||
ret = PyObject_IsTrue (result);
|
||||
Py_DECREF (result);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = FALSE;
|
||||
PyErr_Print ();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_moo_glade_xml_set_signal_func (PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_func;
|
||||
PyObject *func_args = NULL;
|
||||
Closure *closure;
|
||||
|
||||
if (!args)
|
||||
return_TypeError ("arguments required");
|
||||
|
||||
if (PyTuple_GET_SIZE (args) < 1)
|
||||
return_TypeError ("function argument required");
|
||||
|
||||
py_func = PyTuple_GET_ITEM (args, 0);
|
||||
|
||||
if (!PyCallable_Check (py_func))
|
||||
return_TypeError ("function must be callable");
|
||||
|
||||
if (PyTuple_GET_SIZE (args) > 1)
|
||||
{
|
||||
func_args = PyTuple_GetSlice (args, 1, PyTuple_GET_SIZE (args));
|
||||
if (!func_args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
closure = closure_new ();
|
||||
closure->func = py_func;
|
||||
Py_INCREF (closure->func);
|
||||
closure->args = func_args;
|
||||
|
||||
moo_glade_xml_set_signal_func (MOO_GLADE_XML (self->obj),
|
||||
signal_func, closure,
|
||||
(GDestroyNotify) closure_free);
|
||||
|
||||
return_None;
|
||||
}
|
||||
|
|
|
@ -145,8 +145,10 @@ struct _MooGladeXMLPrivate {
|
|||
|
||||
MooGladeSignalFunc signal_func;
|
||||
gpointer signal_func_data;
|
||||
GDestroyNotify signal_func_notify;
|
||||
MooGladePropFunc prop_func;
|
||||
gpointer prop_func_data;
|
||||
GDestroyNotify prop_func_notify;
|
||||
|
||||
guint done : 1;
|
||||
};
|
||||
|
@ -2435,11 +2437,17 @@ moo_glade_xml_cleanup (MooGladeXML *xml)
|
|||
g_hash_table_destroy (xml->priv->id_to_func);
|
||||
if (xml->priv->props)
|
||||
g_hash_table_destroy (xml->priv->props);
|
||||
if (xml->priv->signal_func_data && xml->priv->signal_func_notify)
|
||||
xml->priv->signal_func_notify (xml->priv->signal_func_data);
|
||||
if (xml->priv->prop_func_data && xml->priv->prop_func_notify)
|
||||
xml->priv->prop_func_notify (xml->priv->prop_func_data);
|
||||
|
||||
xml->priv->class_to_type = NULL;
|
||||
xml->priv->id_to_type = NULL;
|
||||
xml->priv->id_to_func = NULL;
|
||||
xml->priv->props = NULL;
|
||||
xml->priv->signal_func_data = NULL;
|
||||
xml->priv->prop_func_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2537,22 +2545,34 @@ void moo_glade_xml_map_custom (MooGladeXML *xml,
|
|||
void
|
||||
moo_glade_xml_set_signal_func (MooGladeXML *xml,
|
||||
MooGladeSignalFunc func,
|
||||
gpointer data)
|
||||
gpointer data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
g_return_if_fail (xml != NULL);
|
||||
|
||||
if (xml->priv->signal_func_data && xml->priv->signal_func_notify)
|
||||
xml->priv->signal_func_notify (xml->priv->signal_func_data);
|
||||
|
||||
xml->priv->signal_func = func;
|
||||
xml->priv->signal_func_data = data;
|
||||
xml->priv->signal_func_notify = notify;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_glade_xml_set_prop_func (MooGladeXML *xml,
|
||||
MooGladePropFunc func,
|
||||
gpointer data)
|
||||
gpointer data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
g_return_if_fail (xml != NULL);
|
||||
|
||||
if (xml->priv->prop_func_data && xml->priv->prop_func_notify)
|
||||
xml->priv->prop_func_notify (xml->priv->prop_func_data);
|
||||
|
||||
xml->priv->prop_func = func;
|
||||
xml->priv->prop_func_data = data;
|
||||
xml->priv->prop_func_notify = notify;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -75,10 +75,12 @@ void moo_glade_xml_map_custom (MooGladeXML *xml,
|
|||
gpointer data);
|
||||
void moo_glade_xml_set_signal_func (MooGladeXML *xml,
|
||||
MooGladeSignalFunc func,
|
||||
gpointer data);
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
void moo_glade_xml_set_prop_func (MooGladeXML *xml,
|
||||
MooGladePropFunc func,
|
||||
gpointer data);
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
void moo_glade_xml_set_property (MooGladeXML *xml,
|
||||
const char *widget,
|
||||
|
|
|
@ -414,8 +414,8 @@ moo_prefs_dialog_page_fill_from_xml (MooPrefsDialogPage *page,
|
|||
data.prefs_root = prefs_root;
|
||||
data.page_id = page_id;
|
||||
|
||||
moo_glade_xml_set_signal_func (xml, connect_signals, &data);
|
||||
moo_glade_xml_set_prop_func (xml, set_props, &data);
|
||||
moo_glade_xml_set_signal_func (xml, connect_signals, &data, NULL);
|
||||
moo_glade_xml_set_prop_func (xml, set_props, &data, NULL);
|
||||
|
||||
if (!moo_glade_xml_fill_widget (xml, GTK_WIDGET (page), buffer, -1, page_id, &error))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue