TreeView and Selection/Selected in Ruby-Gnome2?

Hi,

I am currently trying to implement a simple Midnight-commander
like ruby-gnome2 Interface. My problem is that I dont seem to be
able to get the proper selection, i.e. when the user clicks on
an entry.

However the problem I have seem to be that I do not actually
get the current selection, but instead the selection before
the current selection. :\

Is

@tree_view.signal_connect('button_press_event') do |widget,event|
  puts "Selection was: "+widget.selection.selected[0]
end

a proper way to get the current selection at all?

Here is example code, maybe someone can have a look
and tell me what is wrong here:

require ‘gtk2’

SimpleTreeView.new

class SimpleTreeView

=== initialize

def initialize
@main_window = Gtk::Window.new
@main_window.set_size_request 555,255
create_parts
end

def create_parts
@renderer=Gtk::CellRendererText.new
@renderer.set_property( ‘background’, ‘lavender’ )
@renderer.set_property( ‘foreground’, ‘black’ )

@list_store  = Gtk::ListStore.new(String)
@tree_view = Gtk::TreeView.new(@list_store)
@tree_view_column = Gtk::TreeViewColumn.new('Laaa',
  @renderer, {:text => 0})
@tree_view.append_column(@tree_view_column)

# Example Data:
iter = @list_store.append
iter.set_value(0, 'aaa')
iter = @list_store.append
iter.set_value(0, 'bbb')
iter = @list_store.append
iter.set_value(0, 'ccc')

@tree_view.signal_connect('button_press_event') do |widget,event|
  puts "Selection was: "+widget.selection.selected[0]
end

@main_window.add @tree_view
@main_window.show_all
Gtk.main

end
end
SimpleTreeView.new

Thanks


Get your free email from http://www.linuxmail.org

Powered by Outblaze


Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Roebe XXX wrote:

Is

@tree_view.signal_connect('button_press_event') do |widget,event|
  puts "Selection was: "+widget.selection.selected[0]
end

how about:
selection.signal_connect(‘changed’) do |widget|

Gtk::TreeView.selection is a Gtk::TreeSelection, who has a
Gtk::TreeSelection::changed signal, that’s what i like to use