summaryrefslogtreecommitdiff
path: root/examples/builder.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-03-27 02:40:26 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-11 03:11:22 +0200
commit9e926f9a28e5a99abe27a06f8c33eb428ab555e2 (patch)
tree753e1ab3fcb4e30bcf2d85cfd34e8c9e45431549 /examples/builder.c
parent5a0759bc1bef956688942b48648f323cdc7d3eec (diff)
downloadgtk+-9e926f9a28e5a99abe27a06f8c33eb428ab555e2.tar.gz
examples: Check for error when loading file
People playing with those examples tend to mess up things, so it's really really unhelpful if we don't do error checking.
Diffstat (limited to 'examples/builder.c')
-rw-r--r--examples/builder.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/builder.c b/examples/builder.c
index a05646fdbe..3525a03a16 100644
--- a/examples/builder.c
+++ b/examples/builder.c
@@ -14,12 +14,18 @@ main (int argc,
GtkBuilder *builder;
GObject *window;
GObject *button;
+ GError *error = NULL;
gtk_init (&argc, &argv);
/* Construct a GtkBuilder instance and load our UI description */
builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, "builder.ui", NULL);
+ if (gtk_builder_add_from_file (builder, "builder.ui", &error) == 0)
+ {
+ g_printerr ("Error loading file: %s\n", error->message);
+ g_clear_error (&error);
+ return 1;
+ }
/* Connect signal handlers to the constructed widgets. */
window = gtk_builder_get_object (builder, "window");