Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views1 page

Helloworldgtk

This document contains a simple GTK application written in C that creates a window with a button labeled 'Hello World'. When the button is clicked, it prints 'Hello World' to the console. The application initializes a GTK application, sets up the main window, and handles button clicks using signal connections.

Uploaded by

nikhil.goo20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Helloworldgtk

This document contains a simple GTK application written in C that creates a window with a button labeled 'Hello World'. When the button is clicked, it prints 'Hello World' to the console. The application initializes a GTK application, sets up the main window, and handles button clicks using signal connections.

Uploaded by

nikhil.goo20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <gtk/gtk.

h>

static void
print_hello (GtkWidget *widget,
gpointer data)
{
g_print ("Hello World\n");
}

static void
activate (GtkApplication *app,
gpointer user_data)
{
GtkWidget *window;
GtkWidget *button;

window = gtk_application_window_new (app);


gtk_window_set_title (GTK_WINDOW (window), "Hello");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

button = gtk_button_new_with_label ("Hello World");


g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
gtk_window_set_child (GTK_WINDOW (window), button);

gtk_window_present (GTK_WINDOW (window));


}

int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;

app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);


g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);

return status;
}

You might also like