Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Gtk2 Treeview/Simplelist and set_tooltip_row()

by zentara (Archbishop)
on Apr 23, 2008 at 16:03 UTC ( #682409=note: print w/replies, xml ) Need Help??

in reply to Gtk2 Treeview/Simplelist and set_tooltip_row()

Just for a quick hack check, I substituted in the code from the treeview tooltip example link from my previous response, derived the model from the $catagories SimpleList, and it seems to work( some minor problems to work out like popup position, columns not existing, and what to do with selected rows. Here it is if you care to work out the bugs, I'm lazy today. :-)
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use Gtk2 '-init'; use Gtk2::SimpleList; use constant TRUE => 1; use constant FALSE => 0; my $categories = Gtk2::SimpleList->new ('Categories' => 'text'); $categories->set_headers_visible(FALSE); @{$categories->{data}} = qw/Meat Beer Pizza Pasta Soda Juice Rabbitfoo +d/; $categories->set_has_tooltip(TRUE); # NOTE: thought this might help (n +ope) my $window = Gtk2::Window->new; $window->set_title ('SimpleList examples'); $window->signal_connect (delete_event => sub {Gtk2->main_quit; TRUE}); $window->set_default_size (800,600); $window->add($categories); $window->show_all; # This is our little tooltip window. my $tooltip_label = Gtk2::Label->new; my $tooltip = Gtk2::Window->new('popup'); $tooltip->set_decorated(0); $tooltip->set_position('mouse'); # We'll choose this to start with. $tooltip->add($tooltip_label); my $tooltip_displayed = FALSE; my $selected_row = 0; my $selected_col = 0; =head1 my $popup_hash; my $row = 0; foreach my $child(@children) { my $child_iter = $model->append ($iter); $model->set ($child_iter, 0, $child->{label}, 1, $child->{this}, 2, $child->{that}, 3, $child->{what}, 4, undef, ); # We'll populate the hash here my $path = "0:".$row; $popup_hash->{$path}->{1} = $child->{this_popup}; $popup_hash->{$path}->{2} = $child->{that_popup}; $popup_hash->{$path}->{3} = $child->{what_popup}; $row++; } print Dumper $popup_hash; =cut $categories->signal_connect('motion-notify-event' => sub { my ($self, $event) = @_; my ($path, $column, $cell_x, $cell_y) = $categories->get_path_ +at_pos ($event->x, $event->y); if ($path) { my $model = $categories->get_model; my $i = $column->{column_number}; my $row = $path->to_string(); # If a new cell is selected, then hide the tooltip # It'll be re-shown as required by the code down under if ($selected_row ne $row or $selected_col != $i) { $tooltip->hide; $tooltip_displayed = FALSE; $selected_row = $row; $selected_col = $i; } if ($row) { # Pick that popup string from our hash #my $str = $popup_hash->{$row}->{$i}; my $str = " row $row "; if ($str) { $tooltip_label->set_label($str); if (!$tooltip_displayed) { $tooltip->show_all; my ($thisx, $thisy) = $tooltip->window->get_or +igin; # I want the window to be a bit away from the +mouse pointer. # Just a personal choice :) $tooltip->move($thisx +10, $thisy+10); $tooltip_displayed = TRUE; } } } return 0; } } ); Gtk2->main;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://682409]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2018-04-27 03:10 GMT
Find Nodes?
    Voting Booth?