Wed Mar  6 14:12:34 2002  Jonathan Blandford  <jrb@redhat.com>

	* gtk/tmpl/gtktreeselection.sgml: docs

	* gtk/tree_widget.sgml: clean up docs
This commit is contained in:
Jonathan Blandford 2002-03-06 19:22:36 +00:00 committed by Jonathan Blandford
parent cc83c500e4
commit ba60ad9a94
3 changed files with 67 additions and 19 deletions

View File

@ -1,3 +1,9 @@
Wed Mar 6 14:12:34 2002 Jonathan Blandford <jrb@redhat.com>
* gtk/tmpl/gtktreeselection.sgml: docs
* gtk/tree_widget.sgml: clean up docs
2002-03-05 Matthias Clasen <maclas@gmx.de> 2002-03-05 Matthias Clasen <maclas@gmx.de>
* gtk/gtk-sections.txt: Remove gtk_win32_get_installation_directory. * gtk/gtk-sections.txt: Remove gtk_win32_get_installation_directory.

View File

@ -2,16 +2,42 @@
GtkTreeSelection GtkTreeSelection
<!-- ##### SECTION Short_Description ##### --> <!-- ##### SECTION Short_Description ##### -->
The selection object for #GtkTreeView
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
The #GtkTreeSelection object is a helper object to manage the selection
for a #GtkTreeView widget. The #GtkTreeSelection object is
automatically created when a new #GtkTreeView widget is created, and
cannot exist independentally of this widget. The primary reason the
#GtkTreeSelection objects exists is for cleanliness of code and API.
That is, there is no conceptual reason all these functions could not be
methods on the #GtkTreeView widget instead of a separate function.
</para>
<para>
The #GtkTreeSelection object is gotten from a #GtkTreeView by calling
gtk_tree_view_get_selection(). It can be manipulated to check the
selection status of the tree, as well as select and deselect individual
rows. Selection is done completely view side. As a result, multiple
views of the same model can have completely different selections.
Additionally, you cannot change the selection of a row on the model that
is not currently displayed by the view without expanding its parents
first.
</para>
<para>
One of the important things to remember when monitoring the selection of
a view is that the "changed" signal is mostly a hint. That is, it may
only emit one signal when a range of rows is selected. Additionally, it
may on occasion emit a "changed" signal when nothing has happened
(mostly as a result of programmers calling select_row on an already
selected row).
</para> </para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
#GtkTreeView, #GtkTreeViewColumn, #GtkTreeDnd, #GtkTreeMode, #GtkTreeSortable, #GtkTreeModelSort, #GtkListStore, #GtkTreeStore, #GtkCellRenderer, #GtkCellEditable, #GtkCellRendererPixbuf, #GtkCellRendererText, #GtkCellRendererToggle
</para> </para>
<!-- ##### STRUCT GtkTreeSelection ##### --> <!-- ##### STRUCT GtkTreeSelection ##### -->
@ -22,26 +48,30 @@ GtkTreeSelection
<!-- ##### USER_FUNCTION GtkTreeSelectionFunc ##### --> <!-- ##### USER_FUNCTION GtkTreeSelectionFunc ##### -->
<para> <para>
A function used by gtk_tree_selection_set_select_function() to filter
whether or not a row may be selected. It is called whenever a row's
state might change. A return value of %TRUE indicates to @selection
that it is okay to change the selection.
</para> </para>
@selection: @selection: A #GtkTreeSelection
@model: @model: A #GtkTreeModel being viewed
@path: @path: The #GtkTreePath of the row in question
@path_currently_selected: @path_currently_selected: %TRUE, if the path is currently selected
@data: @data: user data
@Returns: @Returns: %TRUE, if the selection state of the row can be toggled
<!-- ##### USER_FUNCTION GtkTreeSelectionForeachFunc ##### --> <!-- ##### USER_FUNCTION GtkTreeSelectionForeachFunc ##### -->
<para> <para>
A function used by gtk_tree_selection_selected_foreach() to map all
selected rows. It will be called on every selected row in the view.
</para> </para>
@model: @model: The #GtkTreeModel being viewed
@path: @path: The #GtkTreePath of a selected row
@iter: @iter: A #GtkTreeIter pointing to a selected row
@data: @data: user data
<!-- ##### FUNCTION gtk_tree_selection_set_mode ##### --> <!-- ##### FUNCTION gtk_tree_selection_set_mode ##### -->
@ -196,7 +226,8 @@ GtkTreeSelection
<!-- ##### SIGNAL GtkTreeSelection::changed ##### --> <!-- ##### SIGNAL GtkTreeSelection::changed ##### -->
<para> <para>
Emitted whenever the selection has (possibly) changed. Please note that
this signal is
</para> </para>
@treeselection: the object which received the signal. @treeselection: the object which received the signal.

View File

@ -50,6 +50,12 @@
information can be found on this in the <link information can be found on this in the <link
linkend="GtkTreeStore">GtkTreeModel</link> section. linkend="GtkTreeStore">GtkTreeModel</link> section.
<informalexample><programlisting><![CDATA[ <informalexample><programlisting><![CDATA[
enum
{
COLUMN_ONE,
N_COLUMNS
};
{ {
GtkTreeStore *model; GtkTreeStore *model;
GtkWidget *view; GtkWidget *view;
@ -58,7 +64,9 @@
/* Create a model. We are using the store model for now, though we /* Create a model. We are using the store model for now, though we
* could use any other GtkTreeModel */ * could use any other GtkTreeModel */
model = gtk_tree_store_new_with_values (1, G_TYPE_STRING); model = gtk_tree_store_new_with_values (N_COLUMNS, G_TYPE_STRING);
/* custom function to fill the model with data */
populate_tree_model (model); populate_tree_model (model);
/* Create a view */ /* Create a view */
@ -68,8 +76,8 @@
* reference */ * reference */
g_object_unref (G_OBJECT (model)); g_object_unref (G_OBJECT (model));
/* Create a cell render and arbitrarily make it red for demonstartion /* Create a cell render and arbitrarily make it red for demonstration
*purposes */ * purposes */
cell_renderer = gtk_cell_renderer_text_new (); cell_renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (cell_renderer), "foreground", "red", NULL); g_object_set (G_OBJECT (cell_renderer), "foreground", "red", NULL);
@ -77,11 +85,14 @@
* cell_renderer to the first column of the model */ * cell_renderer to the first column of the model */
column = gtk_tree_view_column_new_with_attributes ("title", column = gtk_tree_view_column_new_with_attributes ("title",
cell_renderer, cell_renderer,
"text", 0, "text", COLUMN_ONE,
NULL); NULL);
/* Add the column to the view. */ /* Add the column to the view. */
gtk_tree_view_append_column (GTK_TREE_VIEW (view), column); gtk_tree_view_append_column (GTK_TREE_VIEW (view), column);
/* Now we can manipulate the view just like any other GTK widget */
...
} }
]]> ]]>
</programlisting></informalexample> </programlisting></informalexample>