class MyGtkSocket
Public Class Methods
new()
click to toggle source
Calls superclass method
Gtk::Window::new
# File gtk2/sample/misc/t-gtksocket.rb, line 18 def initialize super("Gtk::Socket Test") set_window_position(Gtk::Window::POS_CENTER) signal_connect("delete_event"){Gtk::main_quit} @buttons = [] 6.times {|n| @buttons << Gtk::Button.new("Plug #{n}") @buttons.last.signal_connect("clicked"){ plug(n) } } @table = Gtk::Table.new(1, 2) @table.set_size_request(320, 200) add(@table) @vbox = Gtk::VBox.new(true, 5) @buttons.each{|b| @vbox.add(b) } @vbox.set_size_request(150, 190) @table.attach(@vbox, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) @socket = Gtk::Socket.new @table.attach(@socket, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) @socket.set_size_request(150, 150) show_all @xid = @socket.id @pid = 0 end
Public Instance Methods
plug(arg)
click to toggle source
# File gtk2/sample/misc/t-gtksocket.rb, line 45 def plug(arg) if @pid != 0 Process.kill("SIGKILL", @pid) Process.waitpid(@pid) begin @table.remove(@socket) unless @socket.destroyed? rescue ArgumentError # socket has been destroyed because child process finished unexpectedly end @socket = Gtk::Socket.new @table.attach(@socket, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 5) @socket.set_size_request(150, 190) @socket.show @xid = @socket.id end @pid = fork { exec "ruby t-gtkplug.rb -x #{@xid} Plug#{arg}" } end