2011-01-20 06:30:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_hello (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_print ("Hello World\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
|
|
|
GObject *window;
|
|
|
|
GObject *button;
|
2018-03-27 00:40:26 +00:00
|
|
|
GError *error = NULL;
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
|
|
|
/* Construct a GtkBuilder instance and load our UI description */
|
|
|
|
builder = gtk_builder_new ();
|
2018-03-27 00:40:26 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
/* Connect signal handlers to the constructed widgets. */
|
|
|
|
window = gtk_builder_get_object (builder, "window");
|
|
|
|
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
|
|
|
|
|
|
|
button = gtk_builder_get_object (builder, "button1");
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
|
|
|
|
|
|
|
button = gtk_builder_get_object (builder, "button2");
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
|
|
|
|
|
|
|
|
button = gtk_builder_get_object (builder, "quit");
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|