<commit_before>#
# 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 'girffi/builder'

GirFFI::Builder.build_module 'GObject'
GirFFI::Builder.build_module 'Gtk'
GirFFI::Builder.build_class 'Gtk', 'Window'
GirFFI::Builder.build_class 'Gtk', 'HBox'
GirFFI::Builder.build_class 'Gtk', 'Button'

# TODO: This is a little nasty, as we couldn't know from GIR that the
# second argument is a string here.
callback = FFI::Function.new(:void, [:pointer, :string]) do |widget, data|
  puts "Hello again - #{data} was pressed"
end

(my_len, my_args) = Gtk.init ARGV.length + 1, [$0, *ARGV]

win = Gtk::Window.new(:toplevel)
win.set_title "Hello Buttons!"
<commit_msg>Use realistic callback argument signature.<commit_after>#
# 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 'girffi/builder'

GirFFI::Builder.build_module 'GObject'
GirFFI::Builder.build_module 'Gtk'
GirFFI::Builder.build_class 'Gtk', 'Window'
GirFFI::Builder.build_class 'Gtk', 'HBox'
GirFFI::Builder.build_class 'Gtk', 'Button'

callback = FFI::Function.new(:void, [:pointer, :pointer]) do |widget, data|
  # TODO: Don't want to need this.
  str = data.read_string
  puts "Hello again - #{str} was pressed"
end

(my_len, my_args) = Gtk.init ARGV.length + 1, [$0, *ARGV]

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

{'fraction_non_alphanumeric': 0.16027655562539284, 'fraction_numerical': 0.01005656819610308, 'mean_word_length': 5.551440329218107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5881845', 'n_tokens_mistral': 621, 'n_tokens_neox': 600, 'n_words': 144}