A minimal GNOME application: a window with a title.

#include <adwaita.h>

G_DECLARE_FINAL_TYPE (MyApplication, my_application, MY, APPLICATION, AdwApplication)

struct _MyApplication {
  AdwApplication parent_instance;

G_DEFINE_TYPE (MyApplication, my_application, ADW_TYPE_APPLICATION)

static void
my_application_activate (GApplication *application)
  // create a Gtk Window belonging to the application itself
  GtkWidget *window =
    gtk_application_window_new (GTK_APPLICATION (application));

  gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");

  gtk_window_present (GTK_WINDOW (window));

static void
my_application_class_init (MyApplicationClass *klass)
  G_APPLICATION_CLASS (klass)->activate = my_application_activate;

static void
my_application_init (MyApplication *self)

main (int argc,
      char *argv[])
  GApplication *app =
    g_object_new (my_application_get_type (),
                  "application-id", "com.example.Application",

  return g_application_run (app, argc, argv);

Useful methods for a Window widget

  • set_content() sets the content of the application window

  • set_default_size(200, 100) sets the default size of the window to a width of 200 and a height of 100; if instead of a positive number we pass -1 we have the default size.

API References

In this sample we used the following: