diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-02-05 02:17:00 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-02-05 10:58:50 -0500 |
commit | 2e093cdc207ced887081c9ae92cababb35b21e93 (patch) | |
tree | 0c0176b7594dffaa2a2e831584375121e19ba10d /tests/testtreepos.c | |
parent | c0ba1c96d4c2470f1d92664b6bd6ede88d8389de (diff) | |
download | gtk+-2e093cdc207ced887081c9ae92cababb35b21e93.tar.gz |
Demonstrate the problem with a workaround
Diffstat (limited to 'tests/testtreepos.c')
-rw-r--r-- | tests/testtreepos.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/testtreepos.c b/tests/testtreepos.c index 09e08ecced..20db78f7e0 100644 --- a/tests/testtreepos.c +++ b/tests/testtreepos.c @@ -10,15 +10,32 @@ clicked_icon (GtkTreeView *tv, gint cell_x, cell_y; gint cell_pos, cell_width; GList *cells, *l; + gint depth; + gint level_indentation; + gint expander_size; + gint indent; if (gtk_tree_view_get_path_at_pos (tv, x, y, path, &col, &cell_x, &cell_y)) { cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); +#if 1 + /* ugly workaround to fix the problem: + * manually calculate the indent for the row + */ + depth = gtk_tree_path_get_depth (*path); + level_indentation = gtk_tree_view_get_level_indentation (tv); + gtk_widget_style_get (GTK_WIDGET (tv), "expander-size", &expander_size, NULL); + expander_size += 4; + indent = (depth - 1) * level_indentation + depth * expander_size; +#else + indent = 0; +#endif + for (l = cells; l; l = l->next) { gtk_tree_view_column_cell_get_position (col, l->data, &cell_pos, &cell_width); - if (cell_pos <= cell_x && cell_x <= cell_pos + cell_width) + if (cell_pos + indent <= cell_x && cell_x <= cell_pos + indent + cell_width) { g_print ("clicked in %s\n", g_type_name_from_instance (l->data)); if (GTK_IS_CELL_RENDERER_PIXBUF (l->data)) |