unset default row in a treeview (treesort)
Hi to all, I try to set the active row in a treeview(treesort) to another row than 0. This works but the row 0 is always highlighted (light). Here's my code: my $row_path = $theme_center_list_real_hash{$row_name}; # e.g "4:2" my $tree_model = $tree_view_object->get_model(); my $treeiter = $tree_model->get_iter_from_string($row_path); my $treepath = $tree_model->get_path ($treeiter); my $treeselection = $tree_view_object->get_selection(); $treeselection->select_iter($treeiter); If I printout the path list with @paths = $treeselection->get_selected_rows; only the selected row I want is listed. So I guess the light higlighted row is an old display state. How can I clear this "state"? After clicking to another row it will be cleared but at the beginning when the program starts it looks unpleasantly. Thanks in advance, Thomas ___ GRATIS! Movie-FLAT mit über 300 Videos. Jetzt freischalten unter http://movieflat.web.de ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
Thomas Funk wrote: > Hi to all, > I try to set the active row in a treeview(treesort) to another row than 0. > This works but the row 0 is always highlighted (light). > Here's my code: > my $row_path = $theme_center_list_real_hash{$row_name}; # e.g "4:2" > my $tree_model = $tree_view_object->get_model(); > my $treeiter = $tree_model->get_iter_from_string($row_path); > my $treepath = $tree_model->get_path ($treeiter); > my $treeselection = $tree_view_object->get_selection(); > $treeselection->select_iter($treeiter); > > If I printout the path list with > @paths = $treeselection->get_selected_rows; > only the selected row I want is listed. So I guess the light higlighted row > is an old display state. > > How can I clear this "state"? > After clicking to another row it will be cleared but at the beginning when > the program starts it looks unpleasantly. It sounds like you perhaps aren't allowing the program to process events? After you call select_iter how is control passed back to the event loop? Cheers, Dave ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Thomas Funk" writes: > > So I guess the light higlighted row is an old display state. It's not just the cursor thingie is it? Maybe set_cursor() and scroll_to_cell() to start on the initial choice? ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Kevin Ryde" wrote: >It's not just the cursor thingie is it? Maybe set_cursor() and >scroll_to_cell() to start on the initial choice? I tried $treeselection->select_iter($treeiter); $tree_view_object->set_cursor ($treepath, undef, FALSE); but it ends in an "endless" loop with a seg fault :-( In which module can I find scroll_to_cell() ? --Thomas ___ GRATIS! Movie-FLAT mit über 300 Videos. Jetzt freischalten unter http://movieflat.web.de ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Dave Howorth" wrote: >It sounds like you perhaps aren't allowing the program to process >events? After you call select_iter how is control passed back to the >event loop? I don't know how to do it ... I red many tuts but I don't understand how to implement this. As the program starts the event "cursor-changed" occurs, so I implemented this event in my sub sub theme_center_options_treeview() { : # create a treeview, specify $tree_store as its model my $tree_view = Gtk2::TreeView->new($tree_store); $object{'theme_center_options_treeview'} = $tree_view; $tree_view->signal_connect("cursor-changed" => \&on_theme_center_options_treeview_cursor_changed); # create a Gtk2::TreeViewColumn to add to $tree_view : } In the callback sub I check if the event occurs at start time or later when a row will be clicked: sub on_theme_center_options_treeview_cursor_changed() { my $treeview_object = $object{'theme_center_options_treeview'}; my $selected_row; if ($start_init == FALSE) { my $treeselection = $treeview_object->get_selection(); $selected_row = get_treeview_row(\$treeselection); } else { my $treeselection = &set_treeview_row($treeview_object, "Theme Manager"); $start_init = FALSE; } } By checking the Gtk2::tree*** modules I found in Gtk2::TreeModel $tree_model->row_changed ($path, $iter) so I tried $treeselection->select_iter($treeiter); $tree_model->row_changed ($treepath, $treeiter); but it doesn't help :-( ___ Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02 ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Thomas Funk" writes: > > but it ends in an "endless" loop with a seg fault :-( You'll have to stick it under the debugger, or post a complete program ... > In which module can I find scroll_to_cell() ? Another Gtk2::TreeView method. -- Nobody knows nothing. -- all you need to understand about investment to succeed in the stockbroking business ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Thomas Funk" writes: > > my $treeselection = &set_treeview_row($treeview_object, "Theme Manager"); > $start_init = FALSE; >} Oh, a set_cursor() under a "cursor-changed" might immediately recurse to run "cursor-changed again. Perhaps clear the $start_init before doing the set_cursor(). Assuming a set_cursor() is in fact what you want! Are you sure you don't want to make the initial selection and/or cursor position when first setting in a model? Or when the model is first populated? ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Re: unset default row in a treeview (treesort)
"Kevin Ryde" wrote: >Oh, a set_cursor() under a "cursor-changed" might immediately recurse to >run "cursor-changed again. Perhaps clear the $start_init before doing >the set_cursor(). Assuming a set_cursor() is in fact what you want! > >Are you sure you don't want to make the initial selection and/or cursor >position when first setting in a model? Or when the model is first >populated? Aaah great! Yes you're right :D with sub on_theme_center_options_treeview_cursor_changed() { : if ($start_init == FALSE) { : } else { $start_init = FALSE; # set 10th row in ThemeCenter list -> Theme manager &set_treeview_row($treeview_object, "Theme Manager"); $selected_row = $theme_center_list_hash{"Theme Manager"}; } and sub set_treeview_row($$) { : my $treeiter = $tree_model->get_iter_from_string($row_path); &dprint(" treeiter: $treeiter\n"); my $treepath = $tree_model->get_path ($treeiter); &dprint(" treepath: $treepath\n"); $tree_view_object->set_cursor ($treepath, undef, FALSE); } it works like a charme!!! Thank you very much!! --Thomas ___ Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02 ___ gtk-perl-list mailing list gtk-perl-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-perl-list