Tree and List Widget Overview — Overview of GtkTreeModel, GtkTreeView, and friends of a list store. Creating a tree store operates almost exactly the same. A ew and its associated widgets are an extremely powerful way of displaying data. They are used in conjunction with a ore or Gtk. TreeStore. In this part of the GTK+ tutorial, we cover the GtkTreeView widget. Three examples demonstrate the functionality of the widget.
|Published (Last):||17 June 2009|
|PDF File Size:||10.48 Mb|
|ePub File Size:||4.15 Mb|
|Price:||Free* [*Free Regsitration Required]|
Tree and List Widget Overview: GTK+ 3 Reference Manual
GtkTreeView widget is a complex widget which can be used to display lists and trees. The widget can have one or multiple columns. This means that the data is separated from the view. There are several other objects that are used with the GtkTreeView widget. They handle data that are displayed in the GtkTreeView widget.
GtkTreeSelection is an object that handles selections. In our code example, we show five items in the GtkTreeView.
We have only one column and the header of the column is hidden. We place a GtkVBox into the window. This box has two widgets: The TreeView increases the reference of the store object.
GtkTreeView Tutorial (basic)
The model is then destroyed automatically with the view. Tutoral append a new row and set a value to the row, which is referenced by an GtkTreeIter object.
Inside the handler function, we get the value of the cell in the row referenced by the iter object. The second example adds additional functionality to the previous one. We will be able to add and remove items from the list view.
In the example, we have three buttons and one text entry. The buttons add a new item, remove the selected item, and remove all items.
This code checks if there is some item left in the list.
Obviously, we can remove items only if there is at least one left in the list. The following example uses the GtkTreeView widget to display hierarchical data. In the previous two examples, we used the list view; now we are going to use tree view.
In the example, we divide programming languages into two groups: The language categories serve as toplevel nodes for their list of items. The currently selected item is shown in the statusbar. The steps to create a tree view are very similar to creating a list view.