Sha256: b97f3ed944b6b4b954175b4693fea020f71a6d78defd6ab75dfcb4155285b542

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

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

GirFFI.setup :GObject
GirFFI.setup :Gtk

Gtk.init

win = Gtk::Window.new(:toplevel)
GObject.signal_connect_data win, "delete-event", FFI::Function.new(:bool, [:pointer, :pointer]) {
  puts "delete event occured"
  true
}, nil, nil, 0

GObject.signal_connect_data win, "destroy", Proc.new { Gtk.main_quit }, nil, nil, 0
win.set_border_width 10

but = Gtk::Button.new_with_label("Hello World")
GObject.signal_connect_data but, "clicked", Proc.new { win.destroy }, nil, nil, :swapped

win.add but

but.show
win.show

Gtk.main

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.0.3 examples/02_hello_world.rb
gir_ffi-0.0.2 examples/02_hello_world.rb
gir_ffi-0.0.1 examples/02_hello_world.rb