⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtktreemodel.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
}</pre></div></div><p><br class="example-break"></p><p>This second example shows a quick way of iterating through a list andgetting a string and an integer from each row.  The<code class="function">populate_model</code> function used below is not shown, asit is specific to the <a class="link" href="GtkListStore.html" title="GtkListStore"><span class="type">GtkListStore</span></a>.  For information on how to writesuch a function, see the <a class="link" href="GtkListStore.html" title="GtkListStore"><span class="type">GtkListStore</span></a> documentation.</p><div class="example"><a name="id3674236"></a><p class="title"><b>Example&#160;16.&#160;Reading data from a <span class="structname">GtkTreeModel</span></b></p><div class="example-contents"><pre class="programlisting">enum{  STRING_COLUMN,  INT_COLUMN,  N_COLUMNS};{  GtkTreeModel *list_store;  GtkTreeIter iter;  gboolean valid;  gint row_count = 0;  /* make a new list_store */  list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_INT);  /* Fill the list store with data */  populate_model (list_store);  /* Get the first iter in the list */  valid = gtk_tree_model_get_iter_first (list_store, &amp;iter);  while (valid)    {      /* Walk through the list, reading each row */      gchar *str_data;      gint   int_data;      /* Make sure you terminate calls to gtk_tree_model_get()       * with a '-1' value       */      gtk_tree_model_get (list_store, &amp;iter,                           STRING_COLUMN, &amp;str_data,                          INT_COLUMN, &amp;int_data,                          -1);      /* Do something with the data */      g_print ("Row %d: (%s,%d)\n", row_count, str_data, int_data);      g_free (str_data);      row_count ++;      valid = gtk_tree_model_iter_next (list_store, &amp;iter);    }}</pre></div></div><p><br class="example-break"></p></div><div class="refsect1" lang="en"><a name="id3674269"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3674294"></a><h3><a name="GtkTreeModel-struct"></a>GtkTreeModel</h3><a class="indexterm" name="id3674307"></a><pre class="programlisting">typedef struct _GtkTreeModel GtkTreeModel;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3674323"></a><h3><a name="GtkTreeIter"></a>GtkTreeIter</h3><a class="indexterm" name="id3674335"></a><pre class="programlisting">typedef struct {  gint stamp;  gpointer user_data;  gpointer user_data2;  gpointer user_data3;} GtkTreeIter;</pre><p>The <span class="structname">GtkTreeIter</span> is the primary structure foraccessing a structure.  Models are expected to put a unique integer inthe <em class="structfield"><code>stamp</code></em> member, and put model-specificdata in the three <em class="structfield"><code>user_data</code></em> members.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a>&#160;<em class="structfield"><code>stamp</code></em>;</span></p></td><td>A unique stamp to catch invalid iterators</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a>&#160;<em class="structfield"><code>user_data</code></em>;</span></p></td><td>Model specific data</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a>&#160;<em class="structfield"><code>user_data2</code></em>;</span></p></td><td>Model specific data</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a>&#160;<em class="structfield"><code>user_data3</code></em>;</span></p></td><td>Model specific data</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3674452"></a><h3><a name="GtkTreePath"></a>GtkTreePath</h3><a class="indexterm" name="id3674464"></a><pre class="programlisting">typedef struct _GtkTreePath GtkTreePath;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3674480"></a><h3><a name="GtkTreeRowReference"></a>GtkTreeRowReference</h3><a class="indexterm" name="id3674492"></a><pre class="programlisting">typedef struct _GtkTreeRowReference GtkTreeRowReference;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3674508"></a><h3><a name="GtkTreeModelIface"></a>GtkTreeModelIface</h3><a class="indexterm" name="id3674521"></a><pre class="programlisting">typedef struct {  GTypeInterface g_iface;  /* Signals */  void         (* row_changed)           (GtkTreeModel *tree_model,					  GtkTreePath  *path,					  GtkTreeIter  *iter);  void         (* row_inserted)          (GtkTreeModel *tree_model,					  GtkTreePath  *path,					  GtkTreeIter  *iter);  void         (* row_has_child_toggled) (GtkTreeModel *tree_model,					  GtkTreePath  *path,					  GtkTreeIter  *iter);  void         (* row_deleted)           (GtkTreeModel *tree_model,					  GtkTreePath  *path);  void         (* rows_reordered)        (GtkTreeModel *tree_model,					  GtkTreePath  *path,					  GtkTreeIter  *iter,					  gint         *new_order);  /* Virtual Table */  GtkTreeModelFlags (* get_flags)  (GtkTreeModel *tree_model);     gint         (* get_n_columns)   (GtkTreeModel *tree_model);  GType        (* get_column_type) (GtkTreeModel *tree_model,				    gint          index_);  gboolean     (* get_iter)        (GtkTreeModel *tree_model,				    GtkTreeIter  *iter,				    GtkTreePath  *path);  GtkTreePath *(* get_path)        (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);  void         (* get_value)       (GtkTreeModel *tree_model,				    GtkTreeIter  *iter,				    gint          column,				    GValue       *value);  gboolean     (* iter_next)       (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);  gboolean     (* iter_children)   (GtkTreeModel *tree_model,				    GtkTreeIter  *iter,				    GtkTreeIter  *parent);  gboolean     (* iter_has_child)  (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);  gint         (* iter_n_children) (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);  gboolean     (* iter_nth_child)  (GtkTreeModel *tree_model,				    GtkTreeIter  *iter,				    GtkTreeIter  *parent,				    gint          n);  gboolean     (* iter_parent)     (GtkTreeModel *tree_model,				    GtkTreeIter  *iter,				    GtkTreeIter  *child);  void         (* ref_node)        (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);  void         (* unref_node)      (GtkTreeModel *tree_model,				    GtkTreeIter  *iter);} GtkTreeModelIface;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3674607"></a><h3><a name="GtkTreeModelForeachFunc"></a>GtkTreeModelForeachFunc ()</h3><a class="indexterm" name="id3674620"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            (*GtkTreeModelForeachFunc)          (<a class="link" href="GtkTreeModel.html" title="GtkTreeModel">GtkTreeModel</a> *model,                                                         <a class="link" href="GtkTreeModel.html#GtkTreePath">GtkTreePath</a> *path,                                                         <a class="link" href="GtkTreeModel.html#GtkTreeIter">GtkTreeIter</a> *iter,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>model</code></em>&#160;:</span></p></td><td>The <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a> currently being iterated

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -