File: application.rb

package info (click to toggle)
ruby-gnome2 3.1.0-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,072 kB
  • ctags: 17,433
  • sloc: ansic: 93,621; ruby: 62,273; xml: 335; sh: 246; makefile: 25
file content (35 lines) | stat: -rwxr-xr-x 841 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby
=begin
  application.rb - Ruby/GTK version of the example-1.c at
  https://developer.gnome.org/gtk3/stable/gtk-getting-started.html
  Copyright (c) 2015  Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.
=end

require "gtk3"
myapp = Gtk::Application.new("org.gtk.example", :handles_command_line)
myapp.signal_connect "command-line" do |app, command_line|
  app.activate
  0
end

myapp.signal_connect "activate" do |app|
  win = Gtk::ApplicationWindow.new(app)
  win.set_title("window")
  win.set_default_size 200, 200

  button_box = Gtk::ButtonBox.new(:horizontal)
  win.add(button_box)

  button = Gtk::Button.new(:label => "Hello World")
  button.signal_connect "clicked" do
    puts "Hello World"
    win.destroy
  end

  button_box.add(button)

  win.show_all
end

myapp.run