2011-01-20 06:30:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
2017-03-12 20:13:10 +00:00
|
|
|
#include <glib/gstdio.h>
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
print_hello (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
g_print ("Hello World\n");
|
|
|
|
}
|
|
|
|
|
2020-02-10 01:06:58 +00:00
|
|
|
static void
|
|
|
|
quit_cb (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *done = data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
|
|
|
|
g_main_context_wakeup (NULL);
|
|
|
|
}
|
|
|
|
|
2011-01-20 06:30:34 +00:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
|
|
|
GObject *window;
|
|
|
|
GObject *button;
|
2020-02-10 01:06:58 +00:00
|
|
|
gboolean done = FALSE;
|
2011-01-20 06:30:34 +00:00
|
|
|
|
2017-03-12 20:13:10 +00:00
|
|
|
#ifdef GTK_SRCDIR
|
|
|
|
g_chdir (GTK_SRCDIR);
|
|
|
|
#endif
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
/* Construct a GtkBuilder instance and load our UI description */
|
|
|
|
builder = gtk_builder_new ();
|
|
|
|
gtk_builder_add_from_file (builder, "builder.ui", NULL);
|
|
|
|
|
|
|
|
/* Connect signal handlers to the constructed widgets. */
|
|
|
|
window = gtk_builder_get_object (builder, "window");
|
2020-02-10 01:06:58 +00:00
|
|
|
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
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");
|
2020-02-10 01:06:58 +00:00
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
|
|
|
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (window));
|
2011-01-20 06:30:34 +00:00
|
|
|
|
2020-02-10 01:06:58 +00:00
|
|
|
while (!done)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2011-01-20 06:30:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|