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.
This commit is contained in:
Benjamin Otte 2018-03-27 02:40:26 +02:00
parent 5a0759bc1b
commit 9e926f9a28

View File

@ -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");