Gtk::Menu question

J

Joe Laughlin

I have a Gtk::TreeView popuplated with rows. When the user right-clicks on
one of the rows, a menu pops up and the user has several choices. I can
attach a callback function to one of these menu choices and it's being
called correctly, but how can I pass to the callback function some type of a
reference to what row was right-clicked?

I hope that makes sense,
Joe
 
J

Joao Pedrosa

Hi,

--- Joe Laughlin said:
I have a Gtk::TreeView popuplated with rows. When
the user right-clicks on
one of the rows, a menu pops up and the user has
several choices. I can
attach a callback function to one of these menu
choices and it's being
called correctly, but how can I pass to the callback
function some type of a
reference to what row was right-clicked?

I hope that makes sense,
Joe

When the user right-clicks on a row, it gets selected
and the selected row can be retrieved with:

treeview.signal_connect('button-press-event'){|tv, eb|
if eb.button == 3
path, column = treeview.cursor
p path.to_s
end
}

Is that enough?

You could join us on the Ruby-GNOME2 mailing list at
http://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en

Cheers,
Joao



__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
 
J

Joe Laughlin

Joe said:
I have a Gtk::TreeView popuplated with rows. When the
user right-clicks on one of the rows, a menu pops up and
the user has several choices. I can attach a callback
function to one of these menu choices and it's being
called correctly, but how can I pass to the callback
function some type of a reference to what row was
right-clicked?

I hope that makes sense,
Joe

Another GTK question: Isn't there some type of a GTK timer event that I can
have call a given function or do a certain action every X milliseconds? I
looked through the API docs, but I couldn't see it, but I remember using
something like that with pygtk.
 
J

Joao Pedrosa

Hi,
Joe Laughlin wrote:
Another GTK question: Isn't there some type of a
GTK timer event that I can
have call a given function or do a certain action
every X milliseconds? I
looked through the API docs, but I couldn't see it,
but I remember using
something like that with pygtk.

Like this? :)

Gtk.timeout_add(5000){
p Time.new
# returns false to end the timer
false
}

Cheers,
Joao



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,405
Latest member
DavidCex

Latest Threads

Top