diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:49:46 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:49:49 +0900 |
commit | 834a4dcd043de07e4b8670c47ff647f58da5f5e4 (patch) | |
tree | 83124c8c6fb305f76988f61aee231044ca5b801a /gi/pygi-signal-closure.c | |
parent | cf76ccccc8e2364c85afba6ea59645fc188c3d19 (diff) | |
download | pygobject2-834a4dcd043de07e4b8670c47ff647f58da5f5e4.tar.gz pygobject2-834a4dcd043de07e4b8670c47ff647f58da5f5e4.tar.bz2 pygobject2-834a4dcd043de07e4b8670c47ff647f58da5f5e4.zip |
Imported Upstream version 3.9.1
Change-Id: Iea08d370f802808b02274c20102ee1635ee58f78
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/pygi-signal-closure.c')
-rw-r--r-- | gi/pygi-signal-closure.c | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c index 6e026de..20c6b56 100644 --- a/gi/pygi-signal-closure.c +++ b/gi/pygi-signal-closure.c @@ -20,47 +20,28 @@ #include "pygi-private.h" -/* Copied from glib */ -static void -canonicalize_key (gchar *key) -{ - gchar *p; - - for (p = key; *p != 0; p++) - { - gchar c = *p; - - if (c != '-' && - (c < '0' || c > '9') && - (c < 'A' || c > 'Z') && - (c < 'a' || c > 'z')) - *p = '-'; - } -} - static GISignalInfo * _pygi_lookup_signal_from_g_type (GType g_type, const gchar *signal_name) { GIRepository *repository; GIBaseInfo *info; - GType parent; + GISignalInfo *signal_info = NULL; repository = g_irepository_get_default(); info = g_irepository_find_by_gtype (repository, g_type); - if (info != NULL) { - GISignalInfo *signal_info; - signal_info = g_object_info_find_signal ((GIObjectInfo *) info, signal_name); - g_base_info_unref (info); - if (signal_info != NULL) - return signal_info; - } - - parent = g_type_parent (g_type); - if (parent > 0) - return _pygi_lookup_signal_from_g_type (parent, signal_name); - - return NULL; + if (info == NULL) + return NULL; + + if (GI_IS_OBJECT_INFO (info)) + signal_info = g_object_info_find_signal ((GIObjectInfo *) info, + signal_name); + else if (GI_IS_INTERFACE_INFO (info)) + signal_info = g_interface_info_find_signal ((GIInterfaceInfo *) info, + signal_name); + + g_base_info_unref (info); + return signal_info; } static void @@ -192,26 +173,21 @@ pygi_signal_closure_marshal(GClosure *closure, GClosure * pygi_signal_closure_new_real (PyGObject *instance, - const gchar *sig_name, + GType g_type, + const gchar *signal_name, PyObject *callback, PyObject *extra_args, PyObject *swap_data) { GClosure *closure = NULL; PyGISignalClosure *pygi_closure = NULL; - GType g_type; GISignalInfo *signal_info = NULL; - char *signal_name = g_strdup (sig_name); g_return_val_if_fail(callback != NULL, NULL); - canonicalize_key(signal_name); - - g_type = pyg_type_from_object ((PyObject *)instance); signal_info = _pygi_lookup_signal_from_g_type (g_type, signal_name); - if (signal_info == NULL) - goto out; + return NULL; closure = g_closure_new_simple(sizeof(PyGISignalClosure), NULL); g_closure_add_invalidate_notifier(closure, NULL, pygi_signal_closure_invalidate); @@ -238,8 +214,5 @@ pygi_signal_closure_new_real (PyGObject *instance, closure->derivative_flag = TRUE; } -out: - g_free (signal_name); - return closure; } |