GTK tress are a bit like file system directory structures, a root having
a bunch of entries corresponding to files and directories, the
directories having their own entries, and so on. Similarly, a GTK tree
has a "root" that has a bunch of rows under it, each row can have a
bunch of columns, each entry in a column can have sub-nodes, and so on.
A simple tree would just have rows, each row having columns, but no
column entry, a node, having any sub-nodes. Every node in a simple tree
can be located with a row number and a column number within the row, the
numbers being indices[0] and indices[1] respectively. If a node has
sub-nodes, the sub-node location would be indices[2]; sub-sub-nodes
indices[3], and so on.
The column parameter is a pointerto the column structure, not to the
entry in the column. It's mostly there so you can see and manipulate
the characteristics of the whole column. (See
https://developer.gnome.org/gtk3/stable/GtkTreeViewColumn.html)
On 08/10/2018 14:44, Igor Korot wrote:
Hi, Chris,
On Mon, Oct 8, 2018 at 12:11 PM Chris Moller <mol...@mollerware.com> wrote:
Hi, Igor,
The row-activated handler calls:
void
user_function (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data)
{
}
so what you need is :
gint *indices = gtk_tree_path_get_indices (path);
According to the documentation:
path the GtkTreePath for the activated row
and I'm looking for a column number, which IIUC, should be the third
parameter. Or what is the purpose of:
column the GtkTreeViewColumn in which the activation occurred
?
I just want to know the number of column and not some object pointer,
which is of no use.
Or I'm wrong?
which will return an integer vector ow the row, column, sub-column,
subsub-column... depending on the topgraphy of your tree. (You can get the
depth of the tree--thus the number of entries in the vector--with:
gint len = gtk_tree_path_get_depth (path);
)
If it's a simple two-dimensional tree, the column number will be indices[1],
but you might want to make sure that the tree depth is at least two before
doing that or you might be pointing past the end of the indices array.
By the way, don't try to free the indices array--it points to a GTK internal
structure.
HTH,
Chris
On 08/10/2018 12:52, Igor Korot wrote:
Hi, Chris,
On Sun, Oct 7, 2018 at 3:34 PM Chris Moller <mol...@mollerware.com> wrote:
Take a look at
gint * gtk_tree_path_get_indices (GtkTreePath *path);
with the "GtkTreePath *path" parameter you get from the row-activated
callback.
https://developer.gnome.org/gtk3/stable/GtkTreeModel.html#gtk-tree-path-get-indices
I tried to do:
int column = gtk_tree_path_get_indices( column );
but got an error:
Can't convert GtkTreeViewColumjn to GtkTreePath
The "row-activated" callback is defined as:
void user_function(GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer user_data);
And so the types are unrelated.
What am I doling wrong?
Thank you.
On 07/10/2018 20:04, Igor Korot via gtk-list wrote:
Hi, ALL,
For the GtkTreeView there is a "row-activated" signal:
https://developer.gnome.org/gtk3/stable/GtkTreeView.html#GtkTreeView-row-activated.
That function receives as a parameter
column the GtkTreeViewColumn in which the activation occurred.
The problem is (at least as I see it) is that it is not a simple integer
for the column number.
Is there a simple way to get a column number on which I activated
the row from this signal?
Thank you.
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list