Re: catching unfocus of a treeview row
- From: Ken Rastatter <krastatter sensotec com>
- To: gtk-app-devel-list gnome org
- Subject: Re: catching unfocus of a treeview row
- Date: Mon, 3 Mar 2003 10:06:06 -0500
On Sun, 2 Mar 2003 Emmanuel Saracco wrote:
I would like to detect a focus lost on a treeview row. I catch the
"cursor_changed" signal and test the state of the row in my callback
with "gtk_tree_selection_iter_is_selected", but it always return me a
true value if the row was previously selected, so I could not known the
real state of a given row.
This is the trick I use to detect when the selection has changed. I use the
"select cursor row" signal to save the path of the selected row so that I can
compare it the next time the "select cursor row" signal occurs.
It works for GtkTreeView widgets that allow single selections. I haven't
considered multiple selections yet.
void
on_network_treeview_select_cursor_row (GtkTreeView *treeview,
gpointer user_data)
{
extern GtkTreeStore *treestore;
static GtkTreePath *lasttime_path;
GtkTreePath *path;
GtkTreeIter iter;
g_printerr("select cursor row: ");
// GET A PATH AND ITER OF THE SELECTED ROW
gtk_tree_view_get_cursor(treeview, &path, NULL);
gtk_tree_model_get_iter(GTK_TREE_MODEL(treestore), &iter, path);
// IF THE SELECTED ROW HASN'T CHANGED SINCE LAST TIME...
if (lasttime_path && (gtk_tree_path_compare(path, lasttime_path)==0))
{
g_printerr("same row as last time.\n");
}
else
// ... ELSE KEEP A COPY OF THE PATH FOR NEXT TIME
{
g_printerr("a new row was selected.\n");
if (lasttime_path)
gtk_tree_path_free(lasttime_path);
lasttime_path = gtk_tree_path_copy(path);
}
}
--
Ken Rastatter, Design Engineer
Sensotec, Inc.
2080 Arlingate Lane, Columbus, Ohio, 43228-4112 USA
Voice: (614)850-5000 Fax: (614)850-6041 Toll Free: 1-800-848-6564
Home Page: http://www.sensotec.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]