Re: GTK+ Tooltip and clist rows

From: Date: Sun, 05 Feb 2006 04:26:07 +0000
Subject: Re: GTK+ Tooltip and clist rows
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6654@lists.php.net to get a copy of this message
Hi all, after have made some try using tooltip but that's a real pain. Finally after many attempt I've finally achieve to this workaround to get some sort of per row tooltip support on GtkClist. It's certainly can be ameliorate but will do the job for me at this time. As this was a real pain for me and still can be usefull for old fashion people that still using phpgtk1, i just post it to the list. Hope this can be kind of help for anyone, best regards, nathan class ttip_list extends gtkclist{ function ttip_list($nbcols,$cols_titles){ gtkclist::gtkclist($nbcols,$cols_titles); } /** * set tooltip for a given row * @param int $rowid * @param string $ttipstr */ function set_row_tooltip($rowid,$ttipstr){ $this->row_ttips[$rowid] = $ttipstr; # keep trace of row tooltips if(! isset($this->ttip_show_handler)){ # register the tooltip handler if not already done $this->add_events(GDK_LEAVE_NOTIFY_MASK|GDK_POINTER_MOTION_MASK); $this->ttip_show_handler = $this->connect_object('motion-notify-event',array(&$this,'_show_row_tooltip')); } } /** * callback function for displaying tooltip* * @private */ function _show_row_tooltip($event){ static $ttip,$set,$label,$popup,$prevrow; # if first call then create necessary widgets if(! $set ){ $label = new gtklabel(); # don't put '&' before new else will crash! $popup = new gtkwindow(GTK_WINDOW_POPUP); $popup->add($label); # set some style $style = $popup->style; $style->bg[0] = $_gc = &new GdkColor('#ffffE0'); $style->fg[0] = $_gc = &new GdkColor('blue'); $popup->set_style($style); $label->set_style($style); $set = TRUE; } # get the hovered row list($row) = $this->get_selection_info( $event->x, $event->y ); # that's certainly not the best way to detect if we're still hover the list :/ if( isset($this->row_ttips[$row]) && $event->x > 5 && $event->y > 5 ){ if(! $row == $prevrow){ # change tooltip only if we have changed row $popup->hide(); # hide to force resize of both widget $label->set_text($this->row_ttips[$row]); } # set position near the mouse pointer $popup->set_uposition($event->x_root+15,$event->y_root+10); $popup->show_all(); $prevrow = $row; }else{ # no tooltip for this row or no more on the clist widget so hide the tooltip $popup->hide(); } } } 2005/11/30, Malk0 <malk0.phpgtk@gmail.com>: > Hi all, > > Just want to know if anyone have managed to add tooltip to a clist row or cell? > any idea welcome. > regards. > > nathan >

« previous php.gtk.general (#6654) next »