views:

51

answers:

1

I'm creating a application with panes in Ruby/Gtk. When the panes are resized, I need to do some stuff. But I cannot figure out which signal to use. I think it is 'accept_position' - but it don't seem to work. This is a sample app that illustrates my problem...

#!/usr/bin/env ruby

require 'gtk2'

window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
window.set_title  "Panes"
window.border_width = 10
window.set_size_request(225, 150)
window.signal_connect('destroy') { Gtk.main_quit }
window.signal_connect('delete_event') { false }

button1 = Gtk::Button.new("Resize")
button2 = Gtk::Button.new("Me")

button1.signal_connect( "clicked" ) { window.destroy }
button2.signal_connect( "clicked" ) { window.destroy }

paned = Gtk::VPaned.new
paned.add1(button1)
paned.add2(button2)

paned.signal_connect( "accept_position" ) { 
 puts "hello"
 false
}

window.add(paned)
window.show_all
Gtk.main

The 'accept_position' call is never fired. Any idea what is causing this/how to fix it?

+3  A: 

'accept_position' is a keybinding signal, only emitted when the pane is resized using the keyboard.

I don't know Ruby, but in C the signal you want is 'notify::position'. notify is a GObject signal which fires whenever a property changes its value. If you add a detail, such as position, to the signal name when connecting it, then it only fires when that specific property changes its value.

ptomato
Not exactly what I wanted - but close enough. Thanks!
Binny V A