gtk-sandbox/gtk3/example-0/exampleapp.c

39 lines
1.0 KiB
C

#include <gtk/gtk.h>
static void activate (GtkApplication* app, gpointer user_data)
{
GtkWidget *window;
/*create new object and store it at the pointer*/
window = gtk_application_window_new (app);
/*set window title*/
/*cast pointer using the macro GTK_WINDOW() instead of C cast*/
gtk_window_set_title (GTK_WINDOW (window), "Window Title");
/*set window size*/
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
/*make window visible*/
gtk_widget_show_all (window);
}
/*create a GtkApplication object and run it*/
int main (int argc, char **argv)
{
GtkApplication *app;
int status;
/*initialise pointer with app id (name) and without flags*/
app = gtk_application_new ("de.swingbe.gtk.example0", G_APPLICATION_FLAGS_NONE);
/*connect the active signal with the active function defined above*/
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
/*launch app and pass through arguments*/
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}