📄 gtktreestore.html
字号:
The <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a> object is a list model for use with a <a class="link" href="GtkTreeView.html" title="GtkTreeView"><span class="type">GtkTreeView</span></a>widget. It implements the <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a> interface, and consequentialy,can use all of the methods available there. It also implements the<a class="link" href="GtkTreeSortable.html" title="GtkTreeSortable"><span class="type">GtkTreeSortable</span></a> interface so it can be sorted by the view. Finally,it also implements the tree drag anddrop interfaces.</p><div class="refsect2" lang="en"><a name="GtkTreeStore-BUILDER-UI"></a><h3>GtkTreeStore as GtkBuildable</h3><p>The GtkTreeStore implementation of the GtkBuildable interface allowsto specify the model columns with a <columns> element that maycontain multiple <column> elements, each specifying one modelcolumn. The "type" attribute specifies the data type for the column.</p><div class="example"><a name="id3857951"></a><p class="title"><b>Example 23. A UI Definition fragment for a tree store</b></p><div class="example-contents"><pre class="programlisting"><object class="GtkTreeStore"> <columns> <column type="gchararray"/> <column type="gchararray"/> <column type="gint"/> </columns></object></pre></div></div><br class="example-break"></div></div><div class="refsect1" lang="en"><a name="id3857969"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3857979"></a><h3><a name="GtkTreeStore-struct"></a>GtkTreeStore</h3><a class="indexterm" name="id3857990"></a><pre class="programlisting">typedef struct _GtkTreeStore GtkTreeStore;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3858006"></a><h3><a name="gtk-tree-store-new"></a>gtk_tree_store_new ()</h3><a class="indexterm" name="id3858019"></a><pre class="programlisting"><a class="link" href="GtkTreeStore.html" title="GtkTreeStore">GtkTreeStore</a>* gtk_tree_store_new (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> n_columns, ...);</pre><p>Creates a new tree store as with <em class="parameter"><code>n_columns</code></em> columns each of the types passedin. Note that only types derived from standard GObject fundamental types are supported. </p><p>As an example, <code class="literal">gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,GDK_TYPE_PIXBUF);</code> will create a new <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a> with three columns, of type<span class="type">int</span>, <span class="type">string</span> and <ahref="/usr/share/gtk-doc/html/gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"><span class="type">GdkPixbuf</span></a> respectively.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>n_columns</code></em> :</span></p></td><td> number of columns in the tree store</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td> all <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> types for the columns, from first to last</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a new <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3858154"></a><h3><a name="gtk-tree-store-newv"></a>gtk_tree_store_newv ()</h3><a class="indexterm" name="id3858168"></a><pre class="programlisting"><a class="link" href="GtkTreeStore.html" title="GtkTreeStore">GtkTreeStore</a>* gtk_tree_store_newv (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> n_columns, <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType">GType</a> *types);</pre><p>Non vararg creation function. Used primarily by language bindings.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>n_columns</code></em> :</span></p></td><td> number of columns in the tree store</td></tr><tr><td><p><span class="term"><em class="parameter"><code>types</code></em> :</span></p></td><td> an array of <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> types for the columns, from first to last</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a new <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3858268"></a><h3><a name="gtk-tree-store-set-column-types"></a>gtk_tree_store_set_column_types ()</h3><a class="indexterm" name="id3858282"></a><pre class="programlisting">void gtk_tree_store_set_column_types (<a class="link" href="GtkTreeStore.html" title="GtkTreeStore">GtkTreeStore</a> *tree_store, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> n_columns, <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType">GType</a> *types);</pre><p>This function is meant primarily for <span class="type">GObjects</span> that inherit from <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a>, and should only be used when constructing a new <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a>. It will not function after a row has been added, or a method on the <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a> interface is called.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>tree_store</code></em> :</span></p></td><td> A <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>n_columns</code></em> :</span></p></td><td> Number of columns for the tree store</td></tr><tr><td><p><span class="term"><em class="parameter"><code>types</code></em> :</span></p></td><td> An array of <ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> types, one for each column</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3858429"></a><h3><a name="gtk-tree-store-set-value"></a>gtk_tree_store_set_value ()</h3><a class="indexterm" name="id3858442"></a><pre class="programlisting">void gtk_tree_store_set_value (<a class="link" href="GtkTreeStore.html" title="GtkTreeStore">GtkTreeStore</a> *tree_store, <a class="link" href="GtkTreeModel.html#GtkTreeIter">GtkTreeIter</a> *iter, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> column, <ahref="/usr/share/gtk-doc/html/gobject/gobject-Generic-values.html#GValue">GValue</a> *value);</pre><p>Sets the data in the cell specified by <em class="parameter"><code>iter</code></em> and <em class="parameter"><code>column</code></em>.The type of <em class="parameter"><code>value</code></em> must be convertible to the type of thecolumn.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>tree_store</code></em> :</span></p></td><td> a <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>iter</code></em> :</span></p></td><td> A valid <a class="link" href="GtkTreeModel.html#GtkTreeIter"><span class="type">GtkTreeIter</span></a> for the row being modified</td></tr><tr><td><p><span class="term"><em class="parameter"><code>column</code></em> :</span></p></td><td> column number to modify</td></tr><tr><td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td><td> new value for the cell</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3858593"></a><h3><a name="gtk-tree-store-set"></a>gtk_tree_store_set ()</h3><a class="indexterm" name="id3858607"></a><pre class="programlisting">void gtk_tree_store_set (<a class="link" href="GtkTreeStore.html" title="GtkTreeStore">GtkTreeStore</a> *tree_store, <a class="link" href="GtkTreeModel.html#GtkTreeIter">GtkTreeIter</a> *iter, ...);</pre><p>Sets the value of one or more cells in the row referenced by <em class="parameter"><code>iter</code></em>.The variable argument list should contain integer column numbers,each column number followed by the value to be set. The list is terminated by a -1. For example, to set column 0 with type<ahref="/usr/share/gtk-doc/html/gobject/gobject-Type-Information.html#G-TYPE-STRING:CAPS"><code class="literal">G_TYPE_STRING</code></a> to "Foo", you would write <code class="literal">gtk_tree_store_set (store, iter, 0, "Foo", -1)</code>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>tree_store</code></em> :</span></p></td><td> A <a class="link" href="GtkTreeStore.html" title="GtkTreeStore"><span class="type">GtkTreeStore</span></a></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -