[gtk/matthiasc/for-main: 1/5] Add gtk_builder_cscope_add_callback




commit faa9ef2dc02ee8eecd36024ea81e831e0692ba54
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 30 16:13:17 2022 -0400

    Add gtk_builder_cscope_add_callback
    
    This is a convenience method for the common case
    that symbols are used under their own name.

 gtk/gtkbuilderscope.c | 13 +++++++++++++
 gtk/gtkbuilderscope.h |  8 ++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbuilderscope.c b/gtk/gtkbuilderscope.c
index f5503c8b11..6d472dc6a8 100644
--- a/gtk/gtkbuilderscope.c
+++ b/gtk/gtkbuilderscope.c
@@ -428,6 +428,19 @@ gtk_builder_cscope_new (void)
   return g_object_new (GTK_TYPE_BUILDER_CSCOPE, NULL);
 }
 
+/**
+ * gtk_builder_cscope_add_callback:
+ * @self: a `GtkBuilderCScope`
+ * @callback_symbols: (scope async): The callback pointer
+ *
+ * Adds the @callback_symbol to the scope of @builder under its
+ * own name.
+ *
+ * This is a convenience wrapper of [method@Gtk.BuilderCScope.add_callback_symbol].
+ *
+ * Since: 4.8
+ */
+
 /**
  * gtk_builder_cscope_add_callback_symbol:
  * @self: a `GtkBuilderCScope`
diff --git a/gtk/gtkbuilderscope.h b/gtk/gtkbuilderscope.h
index 7fc2ccbc0b..5ab602fc06 100644
--- a/gtk/gtkbuilderscope.h
+++ b/gtk/gtkbuilderscope.h
@@ -114,10 +114,14 @@ GDK_AVAILABLE_IN_ALL
 void                    gtk_builder_cscope_add_callback_symbols (GtkBuilderCScope       *self,
                                                                  const char             *first_callback_name,
                                                                  GCallback               
first_callback_symbol,
-                                                                ...) G_GNUC_NULL_TERMINATED;
+                                                                 ...) G_GNUC_NULL_TERMINATED;
+
+#define gtk_builder_cscope_add_callback(scope, callback) \
+  gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope), #callback, G_CALLBACK (callback))
+
 GDK_AVAILABLE_IN_ALL
 GCallback               gtk_builder_cscope_lookup_callback_symbol(GtkBuilderCScope      *self,
-                                                                 const char            *callback_name);
+                                                                  const char            *callback_name);
 
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]