Sha256: d68b544fa0e8b244d625a98150c9bea1699f3509fcc2e6d796cce61a230d6ec8

Contents?: true

Size: 1.17 KB

Versions: 184

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby
=begin
  dialog.rb - Ruby/GTK2 sample script.

  Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.

  $Id: dialog.rb,v 1.6 2006/06/17 13:18:12 mutoh Exp $
=end

require 'gtk2'

window = Gtk::Window.new("Gtk::Dialog sample")
button = Gtk::Button.new("Create Dialog")
button.signal_connect("clicked") do 
  dialog = Gtk::Dialog.new
  dialog.title = "Gtk::Dialog Sample"
  dialog.transient_for = window
  dialog.set_default_size(300, 300)
  dialog.vbox.add(Gtk::Label.new("Gtk::Dialog Sample"))


  dialog.add_button("OK", Gtk::Dialog::RESPONSE_OK)
  dialog.add_button(Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL)
  dialog.add_button(Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_CLOSE)
  dialog.set_default_response(Gtk::Dialog::RESPONSE_CANCEL)

  dialog.signal_connect("response") do |widget, response|
    case response
    when Gtk::Dialog::RESPONSE_OK
      p "OK"
    when Gtk::Dialog::RESPONSE_CANCEL
      p "Cancel"
    when Gtk::Dialog::RESPONSE_CLOSE
      p "Close"
      dialog.destroy
    end
  end
  dialog.show_all
end

window.add(button).show_all.signal_connect("destroy"){Gtk.main_quit}

Gtk.main

Version data entries

184 entries across 184 versions & 1 rubygems

Version Path
gtk2-3.1.4 sample/misc/dialog.rb
gtk2-3.1.3-x64-mingw32 sample/misc/dialog.rb
gtk2-3.1.3-x86-mingw32 sample/misc/dialog.rb
gtk2-3.1.3 sample/misc/dialog.rb
gtk2-3.1.2-x64-mingw32 sample/misc/dialog.rb
gtk2-3.1.2-x86-mingw32 sample/misc/dialog.rb
gtk2-3.1.2 sample/misc/dialog.rb
gtk2-3.1.1-x64-mingw32 sample/misc/dialog.rb
gtk2-3.1.1-x86-mingw32 sample/misc/dialog.rb
gtk2-3.1.1 sample/misc/dialog.rb
gtk2-3.1.0-x64-mingw32 sample/misc/dialog.rb
gtk2-3.1.0-x86-mingw32 sample/misc/dialog.rb
gtk2-3.1.0 sample/misc/dialog.rb
gtk2-3.0.9-x64-mingw32 sample/misc/dialog.rb
gtk2-3.0.9-x86-mingw32 sample/misc/dialog.rb
gtk2-3.0.9 sample/misc/dialog.rb
gtk2-3.0.8-x86-mingw32 sample/misc/dialog.rb
gtk2-3.0.8-x64-mingw32 sample/misc/dialog.rb
gtk2-3.0.8 sample/misc/dialog.rb
gtk2-3.0.7-x86-mingw32 sample/misc/dialog.rb