[gobject-introspection] Add g_object_info_find_signal
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Add g_object_info_find_signal
- Date: Fri, 12 Nov 2010 20:35:59 +0000 (UTC)
commit 8bb515bb3abbc2576fed04f6bf0155dab9f016f4
Author: Colin Walters <walters verbum org>
Date: Tue Oct 26 11:47:00 2010 -0400
Add g_object_info_find_signal
This matches g_object_info_find_method, and allows us to add indexing
later.
https://bugzilla.gnome.org/show_bug.cgi?id=633204
girepository/giobjectinfo.c | 31 +++++++++++++++++++++++++++++++
girepository/giobjectinfo.h | 4 ++++
tests/repository/gitestrepo.c | 7 +++++++
3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c
index 03ed2a2..e1f0bc1 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 11c1c5a..09e4bec 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 67af4ff..25b590f 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]