Re: Scrolling a Tree View before it's realized



Attilio Fiandrotti wrote:
Hi

In an application i add many items to a ListStore and make it scroll on the fly to the default option row, like this

for (i = 0; i < NUMBER_OF_ITEMS; i++) {
     gtk_list_store_append (store, &iter);
     gtk_list_store_set (store, &iter, MY_COLUMN, mystrings[i], -1);
     if (default_option_index == i) {
         path = gtk_tree_model_get_path(model, &iter);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(view), path, NULL, FALSE, 0.5, 0);
         gtk_tree_view_set_cursor (GTK_TREE_VIEW(view), path, NULL, FALSE);
         gtk_tree_path_free (path);
     }
}

Later i pack the TreeView into proper box hierarchy and eventually show the gtkwindow and within contained widgets.

Now, scrolling works inconsistently, as the row gets indeed selected but the scrolling is only "partial". I wonder if this is because i'm attempting to scroll to a row in a treeview which has not been realized yet. In the case, does performing scroll after widget realization, from within a proper callback, will solve this issue?

I eventually managed this by scrolling the treeview from a callback that gets fired after the expose event is fired. In order to have scrolling performed only the first time expose event is fired, i use a global flag which i reset from inside the callback the first time it's run. I now would like to know if there is a way to run a signal handler only once and without using a second signal handler or global flags.

thanks

Attilio



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]