Web lists-archives.com

Tooltip for GtkTextView contents

Hi all.

I'd like to provide help on special text ( tokens in code ) in a
GtkSourceView / GtkTextView. I see my question is basically:

 ... and the important part of the response to this question was:

"Simply set text view's "has-tooltip" property to "TRUE" and connect handler to
"query-tooltip" signal. Use coordinates provided by callback to find
the word that cursor hovers over and then do the lookup. I think
things should be relatively simple."

So I've done attempted this in Perl:


sub on_PARAM_VALUE_query_tooltip {

    my ( $self, $sourceview, $window_x, $window_y, $keyboard_mode,
$tooltip ) = @_;

    my ( $buffer_x, $buffer_y ) = $sourceview->window_to_buffer_coords
( 'GTK_TEXT_WINDOW_TEXT', $window_x, $window_y );

    my ( $trailing, $iter ) = $sourceview->get_iter_at_position(
$buffer_x, $buffer_y );

    if ( ! $iter->inside_word ) {
        return FALSE;

    my $start_iter;

    if ( $iter->starts_word ) {
        $start_iter = $iter;
    } else {
        $start_iter = $iter;


    my $text = $sourceview->get_buffer->get_text( $start_iter, $iter, 1 );

    print "$text\n";



This code runs, produces iters where expected, but then never gets any text.

What have I done wrong?

Thanks :)

gtk-list mailing list