Re: GtkTreeView: getting selection
- From: Kristian Rietveld <kris gtk org>
- To: Romain Lievin <rlievin free fr>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GtkTreeView: getting selection
- Date: 26 Nov 2002 22:02:26 +0100
On Tue, 2002-11-26 at 18:44, Romain Lievin wrote:
Hi,
I am developping the GTK+ version of the new 2.5 kernel configurator...
I am using GtkTreeModel & GtkTreeView for displaying a tree.
I would like to retrieve the row and column which have been clicked by the
user.
The code below works unless you horizontally scroll the view.
Why ?
Is there any better way for doing this ?
Thanks, Romain.
[================ snippet ======================]
gboolean
on_treeview1_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
GtkTreeView *view = GTK_TREE_VIEW (tree_wnd);
GtkTreePath *path;
GtkTreeViewColumn *column;
GtkTreeIter iter;
struct menu *menu;
gint cx, cy;
gint tx, ty;
gint wx, wy;
tx = event->x;
ty = event->y;
gtk_tree_view_tree_to_widget_coords (view, tx, ty, &wx, &wy);
^^^^^^^^^^^
If you remove the call to gtk_tree_view_tree_to_widget_coords things
should work fine. There is no need to convert the coords here.
-Kris
gtk_tree_view_get_path_at_pos (view, wx, wy, &path, &column, &cx, &cy);
//printf("%i %i %i %i %i %i\n", tx, ty, wx, wy, cx, cy);
gtk_tree_view_get_cursor (view, &path, &column);
if(path == NULL) {
g_warning("button_press_event: path is NULL !\n");
return FALSE;
}
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, PTR_COLUMN, &menu, -1);
change_sym_value(menu, column2index(column));
set_node(&iter, menu, fill_row(menu));
return FALSE;
}
[================ snippet ======================]
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]