Re: Tooltip for GtkTextView contents
- From: Daniel Kasak <d j kasak dk gmail com>
- To: cecashon aol com
- Cc: "gtk-list gnome org" <gtk-list gnome org>
- Subject: Re: Tooltip for GtkTextView contents
- Date: Wed, 22 Feb 2017 16:05:25 +1100
Thanks for the response. It came down to a simple logic error. In this code:
my $start_iter;
if ( $iter->starts_word ) {
$start_iter = $iter;
} else {
$iter->backward_word_start;
$start_iter = $iter;
}
$iter->forward_word_end;
... I set $start_iter to be $iter. This *doesn't* make a copy of the
iter ... so when I call $iter->backward_word_start or
$iter->forward_word_end ... both $start_iter and $iter are pointing to
the same position. The correct method of getting 2 iters ( eg for
'start' and 'end' ) is to create them independently.
Dan
On Sat, Feb 18, 2017 at 6:51 AM, <cecashon aol com> wrote:
Hi Dan,
I am not very good with Perl but it looks like the iters aren't getting
moved forward and backwards on the word the cursor is over. In C, the
callback would look something like
static gboolean query_tooltip(GtkWidget *textview, gint x, gint y, gboolean
keyboard_mode, GtkTooltip *tooltip, gpointer user_data)
{
GtkTextIter start_iter;
GtkTextIter end_iter;
GtkTextBuffer *buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(textview), &end_iter,
x, y);
if(gtk_text_iter_inside_word(&end_iter))
{
start_iter=end_iter;
gtk_text_iter_forward_word_end(&end_iter);
gtk_text_iter_backward_word_start(&start_iter);
gchar *string=gtk_text_buffer_get_text(buffer, &start_iter,
&end_iter, TRUE);
gtk_tooltip_set_text(tooltip, string);
g_free(string);
return TRUE;
}
return FALSE;
}
Should be similar in Perl, right?
Eric
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]