Sha256: 2544a130b4fd88e80bd91391cf1ba4f1c8cd7c09e1dead91a5dacbe5438e8912

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

#
# Based on the 'Upgraded Hello world' Gtk+ tutorial example at
# http://library.gnome.org/devel/gtk-tutorial/2.90/x344.html
#
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'gir_ffi'

GirFFI.setup :GObject
GirFFI.setup :Gtk

callback = FFI::Function.new :void, [:pointer, :pointer],
  &GirFFI::ArgHelper.mapped_callback_args { |widget, data|
    puts "Hello again - #{data} was pressed"
  }

Gtk.init

win = Gtk::Window.new(:toplevel)
win.set_title "Hello Buttons!"

GObject.signal_connect_data win, "delete-event", FFI::Function.new(:bool, [:pointer, :pointer]) {
  Gtk.main_quit
  false
}, nil, nil, 0

win.set_border_width 10

box = Gtk::HBox.new(false, 0)
win.add box

button = Gtk::Button.new_with_label("Button 1")
GObject.signal_connect_data button, "clicked", callback, "button 1", nil, 0
box.pack_start button, true, true, 0
button.show

button = Gtk::Button.new_with_label("Button 2")
GObject.signal_connect_data button, "clicked", callback, "button 2", nil, 0
box.pack_start button, true, true, 0
button.show

box.show
win.show

Gtk.main

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.0.3 examples/03_upgraded_hello_world.rb
gir_ffi-0.0.2 examples/03_upgraded_hello_world.rb
gir_ffi-0.0.1 examples/03_upgraded_hello_world.rb