forked from AuroraMiddleware/gtk
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:
parent
5a0759bc1b
commit
9e926f9a28
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user