gnope php gtk gui gnope.org  

How to implement double-clicks for TreeStore?

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Sun Jan 22, 2006 7:52 pm    Post subject: How to implement double-clicks for TreeStore? Reply with quote

Hello,

today's question is, how to implement a functionality for TreeStore, that a double click expand the Tree, to show the next level?

Or do I have not seen this in docs?

Greetings

Christian
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Sun Jan 22, 2006 8:53 pm    Post subject: Re: How to implement double-clicks for TreeStore? Reply with quote

Osiris wrote:
today's question is, how to implement a functionality for TreeStore, that a double click expand the Tree, to show the next level?

See the PEAR package Gtk2_VarDump. I implemented that for a single-click there.
Back to top
kingrs



Joined: 15 Jan 2006
Posts: 30
Location: Stafford, UK

PostPosted: Sun Jan 22, 2006 9:08 pm    Post subject: Reply with quote

I think you're look for the "row-activated" signal of the treeview.
Connect this to your row expand function.

http://www.pygtk.org/pygtk2reference/class-gtktreeview.html#signal-gtktreeview--row-activated
Back to top
karlbowden



Joined: 18 Dec 2005
Posts: 21
Location: Taree, NSW, Australia

PostPosted: Sun Jan 22, 2006 11:40 pm    Post subject: Reply with quote

Hey Osiris,

I had to find the same thing too.

Here's two bits of code straight out of the working program, but you'll have to rewrite my code to fit your program, but it should put you on the right path.

The true or false on the expand_row function is wether to expand all children too.


Code:
$this->tree_view->connect ('button_press_event', array ($this, 'tree_view_buttonpress'));

Code:
function tree_view_buttonpress ($widget, $event) {
 // Get currently selected items:
 list ($model, $iter) = $widget->get_selection ()->get_selected ();
 if (!$iter) {
  return;
 }
 $info = $model->get_value ($iter, 0);
 if ($event->button == 1 && $event->type == 5) {
  // Button == 1 // leftclick
  // type == 5 // doubleclick
  if ($info['type'] == 'submenu') {
   if ($this->tree_view->row_expanded ($model->get_path ($iter)))
    $this->tree_view->collapse_row ($model->get_path ($iter));
   else
    $this->tree_view->expand_row ($model->get_path ($iter), false);
  }
  else {
   echo "not submenu\n";
  }
 }
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.