diff options
-rw-r--r-- | girepository/giobjectinfo.c | 31 | ||||
-rw-r--r-- | girepository/giobjectinfo.h | 4 | ||||
-rw-r--r-- | tests/repository/gitestrepo.c | 7 |
3 files changed, 42 insertions, 0 deletions
diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 03ed2a22..e1f0bc1d 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -472,6 +472,37 @@ g_object_info_get_signal (GIObjectInfo *info, } /** + * g_object_info_find_signal: + * @info: a #GIObjectInfo + * @name: Name of signal + * + * Returns: Info for the signal with name @name in @info, or %NULL on failure. + */ +GISignalInfo * +g_object_info_find_signal (GIObjectInfo *info, + const gchar *name) +{ + gint n_signals; + gint i; + + n_signals = g_object_info_get_n_signals (info); + for (i = 0; i < n_signals; i++) + { + GISignalInfo *siginfo = g_object_info_get_signal (info, i); + + if (g_strcmp0 (g_base_info_get_name (siginfo), name) != 0) + { + g_base_info_unref ((GIBaseInfo*)siginfo); + continue; + } + + return siginfo; + } + return NULL; +} + + +/** * g_object_info_get_n_vfuncs: * @info: a #GIObjectInfo * diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index 11c1c5ac..09e4bec9 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -94,6 +94,10 @@ GIFunctionInfo * g_object_info_find_method (GIObjectInfo *info, gint g_object_info_get_n_signals (GIObjectInfo *info); GISignalInfo * g_object_info_get_signal (GIObjectInfo *info, gint n); + +GISignalInfo * g_object_info_find_signal (GIObjectInfo *info, + const gchar *name); + gint g_object_info_get_n_vfuncs (GIObjectInfo *info); GIVFuncInfo * g_object_info_get_vfunc (GIObjectInfo *info, gint n); diff --git a/tests/repository/gitestrepo.c b/tests/repository/gitestrepo.c index 67af4ff1..25b590f3 100644 --- a/tests/repository/gitestrepo.c +++ b/tests/repository/gitestrepo.c @@ -41,6 +41,7 @@ main(int argc, char **argv) GITypelib *ret; GError *error = NULL; GIBaseInfo *info; + GIBaseInfo *siginfo; GType gtype; char *girdir; @@ -73,6 +74,12 @@ main(int argc, char **argv) info = g_irepository_find_by_name (repo, "Gio", "ThisDoesNotExist"); g_assert (info == NULL); + info = g_irepository_find_by_name (repo, "Gio", "FileMonitor"); + g_assert (info != NULL); + siginfo = g_object_info_find_signal ((GIObjectInfo*) info, "changed"); + g_assert (siginfo != NULL); + g_base_info_unref (siginfo); + /* vfunc tests */ { GIVFuncInfo *vfunc; |