GtkBox – Part II

#include <gtk/gtk.h>

static void activate ( GtkApplication *application, G_GNUC_UNUSED gpointer data )
{
    GtkWidget *window;
    GtkWidget *box;
    GtkWidget *button_1;
    GtkWidget *button_2;
    GtkWidget *button_3;

    /// ***
    window = gtk_application_window_new   ( application );

    /// ***
    gtk_window_set_default_size ( GTK_WINDOW ( window ), 400, 250 );

    /// ***
    box = gtk_box_new ( GTK_ORIENTATION_VERTICAL, 0 );

    /// ***
    button_1 = gtk_button_new_with_label ( "Open" );
    button_2 = gtk_button_new_with_label ( "Close" );
    button_3 = gtk_button_new_with_label ( "New" );

    /// ***
    gtk_box_append ( GTK_BOX ( box ), button_1 );
    gtk_box_append ( GTK_BOX ( box ), button_2 );
    gtk_box_prepend ( GTK_BOX ( box ), button_3 );

    /// ***
    gtk_box_set_spacing ( GTK_BOX ( box ), 25 );

    /// ***
    gtk_box_set_homogeneous ( GTK_BOX ( box ), TRUE );

    /// ***
    gtk_window_set_child ( GTK_WINDOW ( window ), box );

    /// ***
    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 ), 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. Required fields are marked *