Adding 2 different widgets on single window GTK+

1.8k views Asked by At

I want to add 2 Widgets on same window one is of type gtk_drawing_area_new (); for using Cairo and other is of fixed to add some buttons.

Is there anyway I can do this on same Window? I'm new to GTK+.

1

There are 1 answers

0
iain On BEST ANSWER

Use a GtkContainer subclass such as GtkHBox, GtkVBox or GtkGrid

GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
GtkWidget *drawingArea = gtk_drawing_area_new ();
GtkWidget *button = gtk_button_new_with_label ("Button");

gtk_container_add (GTK_CONTAINER (window), hbox);

gtk_box_pack_start (GTK_BOX (hbox), drawingArea, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

gtk_widget_show_all (window);

You can see all the standard containers that are available here: https://developer.gnome.org/gtk3/stable/GtkContainer.html#GtkContainer.object-hierarchy