gnope php gtk gui gnope.org  

connecting clicked to a GtkTreeViewColumn

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



Joined: 15 May 2006
Posts: 20

PostPosted: Mon May 22, 2006 10:04 am    Post subject: connecting clicked to a GtkTreeViewColumn Reply with quote

Hi!

I am stuck again....

Code:
      $cell_renderer = new GtkCellRendererPixbuf();
      $colString = new GtkTreeViewColumn();
      $treeview->append_column($colString);
      $colString->pack_start($cell_renderer, true);
      $colString->set_attributes($cell_renderer, 'pixbuf', $storepos);       
      $colString->connect("clicked", array($this,"delete_klicked"), $this->store, $storepos );      


I have done this because the GtkCellRendererPixBuf doesnt emit signals.
But it seems that the Column doesnt emit that signal too. -- the doku says yes...

Whats wrong with my coding?

Have a nice week
Sven
Back to top
cweiske



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

PostPosted: Mon May 22, 2006 3:00 pm    Post subject: Reply with quote

GtkCellRenderer themselves can't emit signals as they aren't widgets. All a cell renderer gets is some coordinates (a rect) and the value that shall be drawn into the rect. Further, the cell renderer is used several times for each row - a widget could be used only at one place.

The column is a GtkObject, but no GtkWidget. You need to catch the mouse-press or mouse-release-events on the list and use the coordinate transformation methods to find out which row and which column has been clicked.
Back to top
ssiwek



Joined: 15 May 2006
Posts: 20

PostPosted: Tue May 23, 2006 4:18 pm    Post subject: Reply with quote

Hi!
Okay I have changed my coding:
Code:
      $treeview=$this->get_widget('treeview1');
      $treeview->set_model($this->store);
      $treeview->set_events(MY_MASK);
      $treeview->connect("button-press-event", array($this,"ButtonPressCallback"));

I can see the events in my function:
Code:
function ButtonPressCallback($widget, $event)
{
    $window  = $event->window;
    $pointer = $window->get_pointer();
   new Gtk2_VarDump($window, '');
   
}

But now I am stuck again. I only get the inner coordinates of my treeview. When I scroll down my ListStore I do get the same values in the Event... And the ListStore has no method set_events ...
What do I have to do now? How do I get the binding between my ListStore and the event? May be some one can give me a hint?
Thanks in advance
Sven
Back to top
cweiske



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

PostPosted: Wed May 24, 2006 11:26 am    Post subject: Reply with quote

GtkTreeView::get_path_at_pos(x, y);
Back to top
ssiwek



Joined: 15 May 2006
Posts: 20

PostPosted: Wed May 24, 2006 2:52 pm    Post subject: Reply with quote

cweiske wrote:
GtkTreeView::get_path_at_pos(x, y);


Thanks a lot.
Now I can click on a pixbuf in a treeview to remove the line from a liststore.
If someone is interested I put the codesnippets online.

Have a nice week and "Vatertag"
Sven
Back to top
Osiris



Joined: 17 Dec 2005
Posts: 65

PostPosted: Wed May 24, 2006 4:15 pm    Post subject: Reply with quote

Oh no, it's
"Christi Himmelfahrt", not "Vatertag", because the last one is a bad excuse for many men to drink too much on that day.
And with luck, there are many of these men in the rain, i ride(?) tomorrow to Vienna .....

Greetings
Christian
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.