summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-11-30 01:17:10 +0100
committerBenjamin Otte <otte@redhat.com>2019-12-12 19:39:23 +0100
commitf8a7f30a0dd1643376f942619603719333a8d6bf (patch)
treec57d4d338f6b0d9f64fed0099650b4cb5a484a34 /demos
parent1f94028ff77d1bfc8550a7dd9c9623e75a5b9943 (diff)
downloadgtk+-f8a7f30a0dd1643376f942619603719333a8d6bf.tar.gz
builder: Add GtkBuilderScope
GtkBuilderScope is an interface that provides the scope that a builder instance operates in. It creates closures and resolves types. Language bindings are meant to use this interface to customize the behavior of builder files, in particular when instantiating templates. A default implementation for C is provided via GtkBuilderCScope (to keep with the awkward naming that glib uses for closures). It is derivable on purpose so that languages or extensions that extend C can use it. The reftest code in fact does derive GtkBuilderCScope for its own scope implementation that implements looking up symbols in modules. gtk-widget-factory was updated to use the new GtkBuilderCScope to add its custom callback symbols. So it does it different from gtk-demo, which uses the normal way of exporting symbols for dlsym() and thereby makes the 2 demos test the 2 ways GtkBuilder uses for looking up symbols.
Diffstat (limited to 'demos')
-rw-r--r--demos/widget-factory/widget-factory.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 565383483c..94ddcfae68 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1663,6 +1663,7 @@ static void
activate (GApplication *app)
{
GtkBuilder *builder;
+ GtkBuilderScope *scope;
GtkWindow *window;
GtkWidget *widget;
GtkWidget *widget2;
@@ -1716,18 +1717,23 @@ activate (GApplication *app)
g_object_unref (provider);
builder = gtk_builder_new ();
- gtk_builder_add_callback_symbol (builder, "on_entry_icon_release", (GCallback)on_entry_icon_release);
- gtk_builder_add_callback_symbol (builder, "on_scale_button_value_changed", (GCallback)on_scale_button_value_changed);
- gtk_builder_add_callback_symbol (builder, "on_scale_button_query_tooltip", (GCallback)on_scale_button_query_tooltip);
- gtk_builder_add_callback_symbol (builder, "on_record_button_toggled", (GCallback)on_record_button_toggled);
- gtk_builder_add_callback_symbol (builder, "on_page_combo_changed", (GCallback)on_page_combo_changed);
- gtk_builder_add_callback_symbol (builder, "on_range_from_changed", (GCallback)on_range_from_changed);
- gtk_builder_add_callback_symbol (builder, "on_range_to_changed", (GCallback)on_range_to_changed);
- gtk_builder_add_callback_symbol (builder, "tab_close_cb", (GCallback)tab_close_cb);
- gtk_builder_add_callback_symbol (builder, "increase_icon_size", (GCallback)increase_icon_size);
- gtk_builder_add_callback_symbol (builder, "decrease_icon_size", (GCallback)decrease_icon_size);
- gtk_builder_add_callback_symbol (builder, "reset_icon_size", (GCallback)reset_icon_size);
- gtk_builder_add_callback_symbol (builder, "osd_frame_pressed", (GCallback)osd_frame_pressed);
+ scope = gtk_builder_cscope_new ();
+ gtk_builder_cscope_add_callback_symbols (GTK_BUILDER_CSCOPE (scope),
+ "on_entry_icon_release", (GCallback)on_entry_icon_release,
+ "on_scale_button_value_changed", (GCallback)on_scale_button_value_changed,
+ "on_scale_button_query_tooltip", (GCallback)on_scale_button_query_tooltip,
+ "on_record_button_toggled", (GCallback)on_record_button_toggled,
+ "on_page_combo_changed", (GCallback)on_page_combo_changed,
+ "on_range_from_changed", (GCallback)on_range_from_changed,
+ "on_range_to_changed", (GCallback)on_range_to_changed,
+ "tab_close_cb", (GCallback)tab_close_cb,
+ "increase_icon_size", (GCallback)increase_icon_size,
+ "decrease_icon_size", (GCallback)decrease_icon_size,
+ "reset_icon_size", (GCallback)reset_icon_size,
+ "osd_frame_pressed", (GCallback)osd_frame_pressed,
+ NULL);
+ gtk_builder_set_scope (builder, scope);
+ g_object_unref (scope);
gtk_builder_add_from_resource (builder, "/org/gtk/WidgetFactory4/widget-factory.ui", NULL);
window = (GtkWindow *)gtk_builder_get_object (builder, "window");