Re: Gtk2 Treeview/Simplelist and set_tooltip_row()
- From: muppet <scott asofyet org>
- To: Paul Miller <paul voltar org>
- Cc: gtk-perl-list gnome org
- Subject: Re: Gtk2 Treeview/Simplelist and set_tooltip_row()
- Date: Tue, 29 Apr 2008 00:13:00 -0400
On Apr 24, 2008, at 11:13 AM, Paul Miller wrote:
Is there some trick to getting
$a_simple_list->set_tooltip_row($tip, $path); to work?
It seems like it should let me add a non-deprecated tooltip to a
row of a treeview, but I can't get it to work.
I suspect I'm missing something simple or that it's quite a bit
harder than I think it should be.
-Paul
(I posted this question on perlmonks also
http://perlmonks.org/?node_id=682039, the full source of my
problem demo is here:
http://perlmonks.org/?abspart=1;displaytype=displaycode;node_id=682039;part=1)
Close. You were on the right track, but just needed to go a little
further. You don't create a Tooltip object, gtk+ will create it for
you, and ask you to set it up.
http://library.gnome.org/devel/gtk/stable/GtkTooltip.html#id4209774
http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-query-tooltip
http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-set-tooltip-row
Here's your program again, but with working tooltips.
use strict;
use Data::Dumper;
use Gtk2 '-init';
use Gtk2::SimpleList;
use constant TRUE => 1;
use constant FALSE => 0;
$categories = Gtk2::SimpleList->new ('Categories' => 'text');
$categories->set_headers_visible(FALSE);
@{$categories->{data}} = qw/Meat Beer Pizza Pasta Soda Juice
Rabbitfood/;
# This turns on the tooltip event monitoring in the widget...
$categories->set_has_tooltip(TRUE);
# Tooltip event monitoring causes the query-tooltip signal to be
emitted.
$categories->signal_connect (query_tooltip => sub {
my ($widget, $x, $y, $keyboard_mode, $tooltip) = @_;
# First, find out where the pointer is:
$path = $categories->get_path_at_pos ($x, $y);
# If we're not pointed at a row, then return FALSE to say
# "don't show a tip".
return FALSE unless $path;
# Otherwise, ask the TreeView to set up the tip's area according
# to the row's rectangle.
$categories->set_tooltip_row($tooltip, $path);
# And then load it up with some meaningful text. This is much
# more interesting when you have columns that aren't visible,
# or the TreeView is too narrow to see all of your column.
my $index = ($path->get_indices)[0];
$tooltip->set_text(${ $categories->{data} }[$index][0]);
# Return true to say "show the tip".
return TRUE;
});
$window = Gtk2::Window->new;
$window->set_title ('SimpleList examples');
$window->signal_connect (delete_event => sub {Gtk2->main_quit; TRUE});
$window->add($categories);
$window->show_all;
Gtk2->main;
__END__
--
zella (crying): I want...
us: What?
zella (still crying): I want... something!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]