container
Container is an abstract type. You may not instantiate it.
Container, is like a fundamental type, over which many widgets are based on.
Container is an aggregator widget, extended to a Bin and a Box widgets,
which handle only one widget, and one or many widgets respectively.

Though you cannot instantiate a container type directly, you can use
the container API on widgets derived from Container.

A container holds other widget, called child widget.
Container widget has a nice API to add, remove child widgets.

You will interesting in this container API, as it will
help you while working with other widgets derived from
container, mentioned above.


 To add widgets use:
void    gtk_container_add		 (GtkContainer	   *container,
					  GtkWidget	   *widget);

 To remove them:
void    gtk_container_remove		 (GtkContainer	   *container,
					  GtkWidget	   *widget);

 Accessors for border width are:
void    gtk_container_set_border_width	 (GtkContainer	   *container,
					  guint		    border_width);

guint   gtk_container_get_border_width   (GtkContainer     *container);

 Accessors for resize mode:
 void    gtk_container_set_resize_mode    (GtkContainer     *container,
				  GtkResizeMode     resize_mode);
GtkResizeMode gtk_container_get_resize_mode (GtkContainer     *container);


 To get a list of child widgets attached to a Container use this:
   GList*   gtk_container_get_children     (GtkContainer       *container);

Iterate through this  GList structure, and typecast the list->data pointer
 to a GtkWidget pointer and use it like this, 
  

   for(orglist=list=gtk_container_get_children(window);  list!=NULL;
	list=list->next)
	{
		GtkWidget *foo=GTK_WIDGET(list->data);

		/* Do something with this widget */
		foo->bar();
	}
	
and finally free the list.
	g_list_free(glist);

Choose which widgets get to have a focussable, property.

void     gtk_container_set_focus_chain  (GtkContainer   *container,
                                         GList          *focusable_widgets);
gboolean gtk_container_get_focus_chain  (GtkContainer   *container,
					 GList         **focusable_widgets);
void     gtk_container_unset_focus_chain (GtkContainer  *container);

To redraw the child widgets, using your expose event of container, y
ou can use this utility function; you dont need this, ifyoure not
writing widgets.
void     gtk_container_propagate_expose (GtkContainer   *container,
					 GtkWidget      *child,
					 GdkEventExpose *event);

These are the application level methods.


Last Modified on Fri Jul 1 19:52:06 IST 2005
This is part of the GtkBook project Hosted Here
This code, documents and images are © Muthiah Annamalai
This document is under Creative Commons License given by LICENSE