Web lists-archives.com

Re: Tooltip for GtkTextView contents





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



_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list