1.5 KiB
1.5 KiB
GTK Box https://devdocs.io/gtk~3.20/
Multiple widgets can be added in GTK Box unlike containers.
//#include "gtk/gtksignal.h"
#include <gtk/gtk.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
gtk_init(&argc,&argv);
GtkWidget *window;
GtkWidget *box;
GtkWidget *button1;
GtkWidget *button2;
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_default_size(GTK_WINDOW(window), 500, 500);
button1= gtk_button_new_with_label("button1");
// to initialize size(width and height) of gtk widget
// Also this is the minimum size too
gtk_widget_set_size_request(GTK_WIDGET(button1), 300, 300);
button2= gtk_button_new_with_label("button2");
gtk_container_add(GTK_CONTAINER(window), box);
// 1st para : box,2nd: child, 3rd: isexpand, 4th : isFill, 5th: padding
gtk_box_pack_end(GTK_BOX(box), button1, TRUE,TRUE, 50);
gtk_box_pack_start(GTK_BOX(box), button2, TRUE,TRUE, 50);
// homogeneous box means all child widgets inside it are of same size
int isHomo=gtk_box_get_homogeneous(GTK_BOX(box));
printf("is Homogenous? %d\n",isHomo);
gtk_box_set_homogeneous(GTK_BOX(box),TRUE);
isHomo=gtk_box_get_homogeneous(GTK_BOX(box));
printf("is Homogenous after setter call? %d\n",isHomo);
// gtk_container_remove(GTK_CONTAINER(window), button1);
// gtk_container_add(GTK_CONTAINER(window), button2);
g_signal_connect(GTK_WINDOW(window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}