GtkApplication – Part II

#include <gtk/gtk.h>

static void activate_clbk ( GtkApplication *application )
{
    GtkWidget *window;
    guint cookie;

    /// ***
    window = gtk_application_window_new   ( application );
    gtk_window_set_default_size ( GTK_WINDOW ( window ), 200, 200 );

    /// ***
    GtkApplicationInhibitFlags flags;

    /// ***
    flags = GTK_APPLICATION_INHIBIT_SWITCH | GTK_APPLICATION_INHIBIT_LOGOUT | GTK_APPLICATION_INHIBIT_SUSPEND;

    /// ***
    cookie = gtk_application_inhibit ( application, GTK_WINDOW ( window ), flags, "You should save your work first" );

    /// ***
    gtk_application_uninhibit ( application, cookie );

    /// ***
    gtk_window_present ( GTK_WINDOW ( window ) );
}

int main ( void )
{
    GtkApplication *application;
    gint status;

    /// ***
    application = gtk_application_new ( "this.is.my-nice.app", G_APPLICATION_FLAGS_NONE );

    /// ***
    g_signal_connect ( application, "activate", G_CALLBACK ( activate_clbk ), NULL );

    /// ***
    status = g_application_run ( G_APPLICATION ( application ), FALSE, NULL );

    /// ***
    g_object_unref ( application );
    return status;
}
Author: MichaelB

Leave a Reply

Your email address will not be published.