#include <gtk/gtk.h>
static void activate_clbk ( GtkApplication *application )
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *button_1;
GtkWidget *button_2;
GtkWidget *button_3;
GtkWidget *button_4;
/// ***
window = gtk_application_window_new ( application );
gtk_window_set_default_size ( GTK_WINDOW ( window ), 300, 300 );
/// ***
grid = gtk_grid_new ();
/// ***
button_1 = gtk_button_new_with_label ( "One button" );
gtk_widget_set_name ( button_1, "One button" );
button_2 = gtk_button_new_with_label ( "Another button" );
gtk_widget_set_name ( button_2, "Another button" );
button_3 = gtk_button_new_with_label ( "Open button" );
gtk_widget_set_name ( button_3, "Open button" );
button_4 = gtk_button_new_with_label ( "Quit app" );
gtk_widget_set_name ( button_4, "Quit app" );
/// ***
gtk_grid_attach ( GTK_GRID ( grid ), button_1, 0, 0, 1, 1 );
gtk_grid_attach ( GTK_GRID ( grid ), button_2, 1, 0, 1, 1 );
///gtk_grid_attach ( GTK_GRID ( grid ), button_3, 0, 1, 1, 1 );
///gtk_grid_attach ( GTK_GRID ( grid ), button_4, 1, 1, 1, 1 );
/// ***
gtk_grid_attach_next_to ( GTK_GRID ( grid ), button_3, button_1, GTK_POS_BOTTOM, 1, 1 );
gtk_grid_attach_next_to ( GTK_GRID ( grid ), button_4, button_3, GTK_POS_RIGHT, 1, 1 );
/// ***
gtk_grid_set_row_homogeneous ( GTK_GRID ( grid ), TRUE );
gtk_grid_set_column_homogeneous ( GTK_GRID ( grid ), TRUE );
gtk_grid_set_row_spacing ( GTK_GRID ( grid ), 10 );
gtk_grid_set_column_spacing ( GTK_GRID ( grid ), 10 );
/// ***
GtkWidget *child;
child = gtk_grid_get_child_at ( GTK_GRID ( grid ), 0, 1 ); /// button_3
g_print ( "Child is: %s\n", gtk_widget_get_name ( child ) );
/// ***
int col, row, width, height;
gtk_grid_query_child ( GTK_GRID ( grid ), child, &col, &row, &width, &height );
g_print ( "Col: %d\n", col );
g_print ( "Row: %d\n", row );
g_print ( "Width: %d\n", width );
g_print ( "Height: %d\n", height );
/// ***
gtk_grid_query_child ( GTK_GRID ( grid ), button_3, &col, &row, &width, &height );
g_print ( "\nCol: %d\n", col );
g_print ( "Row: %d\n", row );
g_print ( "Width: %d\n", width );
g_print ( "Height: %d\n", height );
/// ***
gtk_window_set_child ( GTK_WINDOW ( window ), grid );
/// ***
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;
}