nitin kumar
nitin kumar

Reputation: 652

Adding 2 different widgets on single window GTK+

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+.

Upvotes: 0

Views: 1976

Answers (1)

iain
iain

Reputation: 5683

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

Upvotes: 1

Related Questions