1
votes

When a new GtkTreeView is exposed, one finds it in a state without any cursor displayed. Once focused, the cursor is there, even when the focus is lost. I am looking for a method to get rid of the cursor on demand.

The GTK+ reference claims, that the function gtk_tree_view_set_cursor does the job whenever the GtkTreePath* argument is invalid for the GtkTreeView*. The term "invalid" can be interpreted in many ways. I experimented with many possibilities with results ranging between segfault and no effect at all. Therefore I would like ask:

Q1: Is it even possible to unset a cursor on a GtkTreeView?

Q2: If so, would you please provide a simple example, preferably in plain C?

2

2 Answers

3
votes

For the record:

I've tried using gtk_tree_view_set_cursor() to no avail.

Anyway, you can unset the cursor of a GtkTreeView using gtk_tree_view_get_selection() and then calling gtk_tree_selection_unselect_all() on the resulting GtkTreeSelection.

0
votes

I don't know if I understood your question correctly but I believe I can help.

First of all, the documentation says that:

If path is invalid for model, the current cursor (if any) will be unset and the function will return without failing.

So the term invalid would refer to an invalid path for the GtkTreeModel.

Anyway, it also says that "This function is often followed by gtk_widget_grab_focus (tree_view) in order to give keyboard focus to the widget". I don't know if you've tried it since you said "even when the focus is lost", but maybe giving the focus to another widget with gtk_widget_grab_focus will solve your problem.