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

📄 gtktreemodelsort.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 3 页
字号:
</div><p><br class="example-break"></p><p>To demonstrate how to access the underlying child model from the sortmodel, the next example will be a callback for the <a class="link" href="GtkTreeSelection.html" title="GtkTreeSelection"><span class="type">GtkTreeSelection</span></a>"changed" signal.  In this callback, we get a string from COLUMN_1 ofthe model.  We then modify the string, find the same selected row on thechild model, and change the row there.</p><p></p><div class="example"><a name="id3805854"></a><p class="title"><b>Example&#160;19.&#160;Accessing the child model of in a selection changed callback</b></p><div class="example-contents"><pre class="programlisting">voidselection_changed (GtkTreeSelection *selection, gpointer data){  GtkTreeModel *sort_model = NULL;  GtkTreeModel *child_model;  GtkTreeIter sort_iter;  GtkTreeIter child_iter;  char *some_data = NULL;  char *modified_data;  /* Get the current selected row and the model. */  if (! gtk_tree_selection_get_selected (selection,                                         &amp;sort_model,                                         &amp;sort_iter))    return;  /* Look up the current value on the selected row and get a new value   * to change it to.   */  gtk_tree_model_get (GTK_TREE_MODEL (sort_model), &amp;sort_iter,                      COLUMN_1, &amp;some_data,                      -1);  modified_data = change_the_data (some_data);  g_free (some_data);  /* Get an iterator on the child model, instead of the sort model. */  gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (sort_model),                                                  &amp;child_iter,                                                  &amp;sort_iter);  /* Get the child model and change the value of the row.  In this   * example, the child model is a GtkListStore.  It could be any other   * type of model, though.   */  child_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model));  gtk_list_store_set (GTK_LIST_STORE (child_model), &amp;child_iter,                      COLUMN_1, &amp;modified_data,                      -1);  g_free (modified_data);}</pre></div></div><p><br class="example-break"></p></div><div class="refsect1" lang="en"><a name="id3805870"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3805220"></a><h3><a name="GtkTreeModelSort-struct"></a>GtkTreeModelSort</h3><a class="indexterm" name="id3805233"></a><pre class="programlisting">typedef struct _GtkTreeModelSort GtkTreeModelSort;</pre><p>This should not be accessed directly.  Use the accessor functions below.</p></div><hr><div class="refsect2" lang="en"><a name="id3805250"></a><h3><a name="gtk-tree-model-sort-new-with-model"></a>gtk_tree_model_sort_new_with_model ()</h3><a class="indexterm" name="id3805264"></a><pre class="programlisting"><a class="link" href="GtkTreeModel.html" title="GtkTreeModel">GtkTreeModel</a>*       gtk_tree_model_sort_new_with_model  (<a class="link" href="GtkTreeModel.html" title="GtkTreeModel">GtkTreeModel</a> *child_model);</pre><p>Creates a new <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a>, with <em class="parameter"><code>child_model</code></em> as the child model.</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>child_model</code></em>&#160;:</span></p></td><td> A <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> A new <a class="link" href="GtkTreeModel.html" title="GtkTreeModel"><span class="type">GtkTreeModel</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3806188"></a><h3><a name="gtk-tree-model-sort-get-model"></a>gtk_tree_model_sort_get_model ()</h3><a class="indexterm" name="id3806202"></a><pre class="programlisting"><a class="link" href="GtkTreeModel.html" title="GtkTreeModel">GtkTreeModel</a>*       gtk_tree_model_sort_get_model       (<a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort">GtkTreeModelSort</a> *tree_model);</pre><p>Returns the model the <a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort"><span class="type">GtkTreeModelSort</span></a> is sorting.</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_model</code></em>&#160;:</span></p></td><td> a <a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort"><span class="type">GtkTreeModelSort</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the "child model" being sorted</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3806280"></a><h3><a name="gtk-tree-model-sort-convert-child-path-to-path"></a>gtk_tree_model_sort_convert_child_path_to_path ()</h3><a class="indexterm" name="id3806294"></a><pre class="programlisting"><a class="link" href="GtkTreeModel.html#GtkTreePath">GtkTreePath</a>*        gtk_tree_model_sort_convert_child_path_to_path                                                        (<a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort">GtkTreeModelSort</a> *tree_model_sort,                                                         <a class="link" href="GtkTreeModel.html#GtkTreePath">GtkTreePath</a> *child_path);</pre><p>Converts <em class="parameter"><code>child_path</code></em> to a path relative to <em class="parameter"><code>tree_model_sort</code></em>.  That is,<em class="parameter"><code>child_path</code></em> points to a path in the child model.  The returned path willpoint to the same row in the sorted model.  If <em class="parameter"><code>child_path</code></em> isn't a valid path on the child model, then <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</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_model_sort</code></em>&#160;:</span></p></td><td> A <a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort"><span class="type">GtkTreeModelSort</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>child_path</code></em>&#160;:</span></p></td><td> A <a class="link" href="GtkTreeModel.html#GtkTreePath"><span class="type">GtkTreePath</span></a> to convert</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> A newly allocated <a class="link" href="GtkTreeModel.html#GtkTreePath"><span class="type">GtkTreePath</span></a>, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3806450"></a><h3><a name="gtk-tree-model-sort-convert-child-iter-to-iter"></a>gtk_tree_model_sort_convert_child_iter_to_iter ()</h3><a class="indexterm" name="id3806464"></a><pre class="programlisting">void                gtk_tree_model_sort_convert_child_iter_to_iter                                                        (<a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort">GtkTreeModelSort</a> *tree_model_sort,                                                         <a class="link" href="GtkTreeModel.html#GtkTreeIter">GtkTreeIter</a> *sort_iter,                                                         <a class="link" href="GtkTreeModel.html#GtkTreeIter">GtkTreeIter</a> *child_iter);</pre><p>Sets <em class="parameter"><code>sort_iter</code></em> to point to the row in <em class="parameter"><code>tree_model_sort</code></em> that corresponds tothe row pointed at by <em class="parameter"><code>child_iter</code></em>.</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_model_sort</code></em>&#160;:</span></p></td><td> A <a class="link" href="GtkTreeModelSort.html" title="GtkTreeModelSort"><span class="type">GtkTreeModelSort</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>sort_iter</code></em>&#160;:</span></p></td><td> An uninitialized <a class="link" href="GtkTreeModel.html#GtkTreeIter"><span class="type">GtkTreeIter</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>child_iter</code></em>&#160;:</span></p></td><td> A valid <a class="link" href="GtkTreeModel.html#GtkTreeIter"><span class="type">GtkTreeIter</span></a> pointing to a row on the child model</td></tr></tbody></table></div></div>

⌨️ 快捷键说明

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