GtkSimpleLayout 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b44cf7d7f21d27bd3f547c892caa0f06bc69e74d1ce95b8124bfc9670010561e
4
+ data.tar.gz: f4d0ac95c666ebc40fe3110f19acd3ea27c9733e32035a5bf2cdce8b1e7b25db
5
+ SHA512:
6
+ metadata.gz: 5e4f694291ac3410341d7ce2fe77d29c3f744e108d07b55d0233d6627de0b3c35d4dc37a2036c57364934fe136397add63a5f6a1b342ff1053c5ed6221b0a8db
7
+ data.tar.gz: b3fe6690ae04f128c7a4beccb70d7547b5dc7214c998261c178a9bedb6f44eaca045fb2176117f081957e840d1b1bc0090fd41479ddf0822f4fa941411efb8ce
data/README CHANGED
@@ -1,9 +1,9 @@
1
1
  == GtkSimpleLayout ==
2
2
 
3
- The GtkSimpleLayout is a helper module for RubyGnome2, it provides a builder
3
+ The GtkSimpleLayout is a helper module for RubyGtk3, it provides a builder
4
4
  style layout producing much better readable UI codes.
5
5
 
6
- Copy Right 2009, Ricky Zheng <ricky_gz_zheng@yahoo.co.nz>
6
+ Copyright 2009, Ricky Zheng <ricky_gz_zheng@yahoo.co.nz>
7
7
 
8
8
  Licence: GPLv2
9
9
 
@@ -22,7 +22,7 @@ About inspector:
22
22
 
23
23
  == Example ==
24
24
 
25
- require 'gtk2'
25
+ require 'gtk3'
26
26
  require 'simple_layout'
27
27
 
28
28
  class MyWin < Gtk::Window
@@ -36,9 +36,9 @@ class MyWin < Gtk::Window
36
36
  end
37
37
 
38
38
  def my_layout
39
- vbox do
40
- label 'Hello'
41
- button 'World !'
39
+ _box :vertical do
40
+ _label 'Hello'
41
+ _button 'World !'
42
42
  end
43
43
  end
44
44
  end
@@ -1,21 +1,21 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
 
7
7
  def my_layout
8
- hbutton_box do
9
- button 'Click me !', :id => :btn_test
10
- button 'Hi !', :id => :btn_hi
11
- button 'Quit', :id => :btn_quit
8
+ _button_box :horizontal do
9
+ _button 'Click me !', :id => :btn_test
10
+ _button 'Hi !', :id => :btn_hi
11
+ _button 'Quit', :id => :btn_quit
12
12
  end
13
13
  end
14
14
 
15
15
  def initialize
16
16
  super
17
17
  @click_count = 0
18
- my_layout
18
+ add my_layout()
19
19
 
20
20
  register_auto_events() # enable the auto event map
21
21
 
data/example/basic.rb CHANGED
@@ -1,31 +1,31 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
  def initialize
7
7
  super
8
- my_layout
8
+ add my_layout()
9
9
  signal_connect('destroy') do
10
10
  Gtk.main_quit
11
11
  end
12
12
  end
13
13
 
14
14
  def my_layout
15
- vbox do
16
- frame 'frame 1' do
17
- hbox do
18
- label 'Label 1'
19
- button 'Button 1, fixed'
20
- button "Button 2, I'm flexiable", :layout => [true, true]
15
+ _box :vertical do
16
+ _frame 'frame 1' do
17
+ _box :horizontal do
18
+ _label 'Label 1'
19
+ _button 'Button 1, fixed'
20
+ _button "Button 2, I'm flexiable", layout: [padding: 15]
21
+ _button 'Button 3, fixed, at the end', layout: [:end, false, false]
21
22
  end
22
23
  end
23
- frame 'frame 2' do
24
- vbox do
25
- label 'Label 2'
26
- label 'Label 3'
27
- button 'Button 3'
28
- button 'Button 4'
24
+ _frame 'frame 2', layout: [expand: true, fill: true, padding: 20] do
25
+ _box :vertical do
26
+ _label 'Label 2'
27
+ _label 'Label 3'
28
+ _button 'Button 4, extend: true', layout: [:end, extend: true, fill: true]
29
29
  end
30
30
  end
31
31
  end
@@ -1,39 +1,39 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
 
7
7
  def initialize
8
8
  super
9
- my_layout
9
+ add my_layout()
10
10
  signal_connect('destroy') do
11
11
  Gtk.main_quit
12
12
  end
13
13
  end
14
14
 
15
15
  def my_layout
16
- vbox do
16
+ _vbox do
17
17
  with_attr :border_width => 3 do
18
- hbox do
19
- entry :id => :ent_input, :layout => [true, true, 5]
18
+ _hbox do
19
+ _entry :id => :ent_input, :layout => [true, true, 5]
20
20
  end
21
- hbox do
22
- frame do
23
- label 'M', :set_size_request => [20, 20]
21
+ _hbox do
22
+ _frame do
23
+ _label 'M', :set_size_request => [20, 20]
24
24
  end
25
- hbutton_box do
26
- button 'Backspace'
27
- button 'CE'
28
- button 'C'
25
+ _hbutton_box do
26
+ _button 'Backspace'
27
+ _button 'CE'
28
+ _button 'C'
29
29
  end
30
30
  end
31
- hbox do
32
- vbutton_box do
33
- button 'MC'
34
- button 'MR'
35
- button 'MS'
36
- button 'M+'
31
+ _hbox do
32
+ _vbutton_box do
33
+ _button 'MC'
34
+ _button 'MR'
35
+ _button 'MS'
36
+ _button 'M+'
37
37
  end
38
38
  with_attr :layout => [true, true] do
39
39
  number_and_operators_layout
@@ -44,14 +44,14 @@ class MyWin < Gtk::Window
44
44
  end
45
45
 
46
46
  def number_and_operators_layout
47
- vbox do
47
+ _vbox do
48
48
  [ ['7', '8', '9', '/', 'sqt'],
49
49
  ['4', '5', '6', '*', '%'],
50
50
  ['1', '2', '3', '-', '1/x'],
51
51
  ['0', '+/-', '.', '+', '=']].each do |cols|
52
- hbox :layout => [true, true] do
52
+ _hbox :layout => [true, true] do
53
53
  cols.each do |txt|
54
- button txt, :id => txt.to_sym, :set_size_request => [30, 30], :layout => [true, true]
54
+ _button txt, :id => txt.to_sym, :set_size_request => [30, 30], :layout => [true, true]
55
55
  end
56
56
  end
57
57
  end
@@ -0,0 +1,28 @@
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
+
4
+ class MyWin < Gtk::Window
5
+ include SimpleLayout::Base
6
+ def initialize
7
+ super
8
+ add my_layout()
9
+ signal_connect('destroy') do
10
+ Gtk.main_quit
11
+ end
12
+ end
13
+
14
+ def my_layout
15
+ _vbox_in_hbox inner_layout: [padding: 10] do
16
+ with_attr :border_width => 5 do
17
+ _frame layout: [padding: 10] do
18
+ _label_in_vbox 'Label 1', inner_layout: [padding: 10]
19
+ end
20
+ _button 'Button 1'
21
+ _entry_in_vbox :id => :ent_input
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ MyWin.new.show_all
28
+ Gtk.main
@@ -1,19 +1,19 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
 
7
7
  def my_layout
8
- hbutton_box do
9
- button 'A', :id => :btn_a
10
- button 'B', :id => :btn_b
8
+ _button_box :horizontal do
9
+ _button 'A', :id => :btn_a
10
+ _button 'B', :id => :btn_b
11
11
  end
12
12
  end
13
13
 
14
14
  def initialize
15
15
  super
16
- my_layout
16
+ add my_layout()
17
17
 
18
18
  expose_components()
19
19
  # after call expose_components(), btn_a and btn_b become available
data/example/group.rb CHANGED
@@ -5,33 +5,33 @@ class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
 
7
7
  def my_layout
8
- vbox do
9
- hbox do
10
- button 'Change group A', :id => :btn_change_a
11
- button 'Change group B', :id => :btn_change_b
8
+ _box :vertical do
9
+ _box :horizontal do
10
+ _button 'Change group A', :id => :btn_change_a
11
+ _button 'Change group B', :id => :btn_change_b
12
12
  end
13
- hbutton_box do
13
+ _button_box :horizontal do
14
14
  group :A do # set group A
15
- button 'A'
16
- button 'A'
17
- button 'A'
15
+ _button 'A'
16
+ _button 'A'
17
+ _button 'A'
18
18
  end
19
19
  end
20
- hbutton_box do
20
+ button_box :horizontal do
21
21
  group :B do # set group B
22
- button 'B'
23
- button 'B'
24
- button 'B'
22
+ _button 'B'
23
+ _button 'B'
24
+ _button 'B'
25
25
  end
26
26
  end
27
- hbutton_box do
27
+ _button_box :horizontal do
28
28
  group :A do # you can set group A again !
29
- button 'A'
30
- button 'A'
29
+ _button 'A'
30
+ _button 'A'
31
31
  end
32
32
  group :B do # you can set group B again !
33
- button 'B'
34
- button 'B'
33
+ _button 'B'
34
+ _button 'B'
35
35
  end
36
36
  end
37
37
  end
@@ -41,7 +41,7 @@ class MyWin < Gtk::Window
41
41
  super
42
42
  @count_a = 0
43
43
  @count_b = 0
44
- my_layout
44
+ add my_layout()
45
45
 
46
46
  register_auto_events()
47
47
 
@@ -1,23 +1,23 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
  def initialize
7
7
  super
8
- my_layout
8
+ add my_layout()
9
9
  signal_connect('destroy') do
10
10
  Gtk.main_quit
11
11
  end
12
12
  end
13
13
 
14
14
  def my_layout
15
- hbox do
16
- label 'Hello, '
17
- button 'World !'
15
+ _box :horizontal do
16
+ _label 'Hello, '
17
+ _button 'World !'
18
18
  end
19
19
  end
20
20
  end
21
21
 
22
22
  MyWin.new.show_all
23
- Gtk.main
23
+ Gtk.main
data/example/menu.rb CHANGED
@@ -1,51 +1,47 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
  def initialize
7
7
  super
8
- my_layout
8
+ add my_layout()
9
9
  signal_connect('destroy') do
10
10
  Gtk.main_quit
11
11
  end
12
12
  end
13
13
 
14
14
  def my_layout
15
- vbox do
16
- factory_menu_bar "main", :type => :menu do
17
- factory_menu_item "<_File>" do
18
- factory_menu_item "_Open"
19
- factory_menu_item "_Close"
20
- factory_menu_item "---"
21
- factory_menu_item "_Quit", :id => :quit, :accel => "<control>Q"
22
- end
23
- factory_menu_item "<_Edit>" do
24
- factory_menu_item "<--->"
25
- factory_menu_item "Copy", :accel => "<control>C"
26
- factory_menu_item "Cut", :accel => "<control>X"
27
- factory_menu_item "Paste", :accel => "<control>V"
28
- factory_menu_item "<Advanced>", :accel => "<control>S" do
29
- factory_menu_item "<--->", :accel => "<control>A"
30
- factory_menu_item "Zoom In", :image => Gtk::Stock::ZOOM_IN, :accel => "<control>plus"
31
- factory_menu_item "Zoom Out", :image => Gtk::Stock::ZOOM_OUT, :accel => "<control>minus"
15
+ _box :vertical do
16
+
17
+ # menubar
18
+ _box :horizontal do
19
+ _menubar do
20
+ _menuitem 'File' do
21
+ _menu :id => :main, :accel_group => :main_accel_group do
22
+ _menuitem 'New', :id => :menu_new
23
+ _menuitem 'Open', :id => :menu_open
24
+ _menuitem 'Save', :id => :menu_save
25
+ _menuitem 'Save As', :id => :menu_save_as
26
+ _menuitem 'Quit', :id => :menu_quit, accel: "<cmd>Q"
27
+ end
32
28
  end
33
29
  end
34
- factory_menu_item ">>Help>>" do
35
- factory_menu_item "About"
36
- end
37
30
  end
38
- scrolled_window :layout => [true, true] do
39
- text_view :set_size_request => [300, 200]
31
+
32
+ # edit area
33
+ _scrolled_window :set_size_request => [300, 200], layout: [expand: true, fill: true] do
34
+ _text_view :layout => [:automatic, :automatic]
40
35
  end
41
36
  end
37
+
38
+ add_accel_group(component(:main_accel_group)) # add the accel group to the window
39
+
40
+ register_auto_events() # enable the auto event map
42
41
  end
43
42
 
44
- def menu_main_on_active(id, path, w)
45
- puts "menu: #{id}, path: #{path}"
46
- if id == :quit
47
- self.destroy
48
- end
43
+ def menu_quit_on_activate(w)
44
+ self.destroy
49
45
  end
50
46
 
51
47
  end
@@ -0,0 +1,59 @@
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
+
4
+ class MyWin < Gtk::Window
5
+ include SimpleLayout::Base
6
+ def initialize
7
+ super
8
+ vbox = Gtk::Box.new(:vertical, 5)
9
+ vbox.pack_start(Gtk::Label.new('Multiple Layouts'), expand: false, fill: false, padding: 10)
10
+ vbox.pack_start(my_layout1(), expand: true, fill: true, padding: 0)
11
+ vbox.pack_start(my_layout2(), expand: true, fill: true, padding: 0)
12
+ add vbox
13
+
14
+ register_auto_events() # enable the auto event map
15
+ expose_components() # expose the components to the methods access
16
+
17
+ signal_connect('destroy') do
18
+ Gtk.main_quit
19
+ end
20
+ end
21
+
22
+ def btn_a1_on_clicked(w)
23
+ @btn_a1_click_count ||= 0
24
+ @btn_a1_click_count += 1
25
+ lbl_a.text = "Button A1 clicked #{@btn_a1_click_count}"
26
+ end
27
+
28
+ def btn_b2_on_clicked(w)
29
+ @btn_b2_click_count ||= 0
30
+ @btn_b2_click_count += 1
31
+ lbl_b.text = "Button B2 clicked #{@btn_b2_click_count}"
32
+ end
33
+
34
+
35
+ def my_layout1
36
+ _frame 'layout 1', border_width: 5 do
37
+ _box :horizontal do
38
+ _label 'Label A', id: :lbl_a
39
+ _button 'Button A, fixed'
40
+ _button "Button A1, I'm flexiable", layout: [padding: 15], id: :btn_a1
41
+ _button 'Button A2, fixed, at the end', layout: [:end, false, false]
42
+ end
43
+ end
44
+ end
45
+
46
+ def my_layout2
47
+ _frame 'layout 2', border_width: 5 do
48
+ _box :vertical do
49
+ _label 'Label B', id: :lbl_b
50
+ _button 'Button B, fixed'
51
+ _button "Button B1, I'm flexiable", layout: [padding: 15]
52
+ _button 'Button B2, fixed, at the end', layout: [:end, false, false], id: :btn_b2
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ MyWin.new.show_all
59
+ Gtk.main
@@ -1,24 +1,24 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
 
7
7
  def my_layout
8
- frame 'Serial Port Setup', :border_width => 5 do
9
- vbox :border_width => 5 do
8
+ _frame 'Serial Port Setup', :border_width => 5 do
9
+ _box :vertical, :border_width => 5 do
10
10
  with_attr :border_width => 3, :layout => [true, true] do
11
- hbox do
12
- label 'Port name: '
13
- combobox :id => :comb_port, :layout => [true, true]
11
+ _box :horizontal do
12
+ _label 'Port name: '
13
+ _combobox :id => :comb_port, :layout => [true, true]
14
14
  end
15
- hbox do
16
- label 'Baud rate: '
17
- combobox :id => :comb_baudrate, :layout => [true, true]
15
+ _box :horizontal do
16
+ _label 'Baud rate: '
17
+ _combobox :id => :comb_baudrate, :layout => [true, true]
18
18
  end
19
- hbutton_box do
20
- button 'Open', :id => :btn_open, :sensitive => false
21
- button 'Close', :id => :btn_close, :sensitive => false
19
+ _button_box :horizontal do
20
+ _button 'Open', :id => :btn_open, :sensitive => false
21
+ _button 'Close', :id => :btn_close, :sensitive => false
22
22
  end
23
23
  end
24
24
  end
@@ -28,7 +28,7 @@ class MyWin < Gtk::Window
28
28
  def initialize
29
29
  super
30
30
 
31
- my_layout
31
+ add my_layout()
32
32
 
33
33
  register_auto_events()
34
34
  expose_components()
@@ -42,6 +42,10 @@ class MyWin < Gtk::Window
42
42
  (1..10).each do |n|
43
43
  comb_port.append_text "COM#{n}"
44
44
  end
45
+ elsif RUBY_PLATFORM =~ /darwin/
46
+ Dir.glob("/dev/cu.*").each do |name|
47
+ comb_port.append_text name
48
+ end
45
49
  else
46
50
  Dir.glob("/dev/ttyS*").each do |name|
47
51
  comb_port.append_text name
data/example/with_attr.rb CHANGED
@@ -1,38 +1,40 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
1
+ require 'gtk3'
2
+ require 'simple_layout'
3
3
 
4
4
  class MyWin < Gtk::Window
5
5
  include SimpleLayout::Base
6
6
  def initialize
7
7
  super
8
- my_layout
8
+ add my_layout()
9
9
  signal_connect('destroy') do
10
10
  Gtk.main_quit
11
11
  end
12
12
  end
13
13
 
14
14
  def my_layout
15
- vbox do
16
- frame 'default' do
17
- hbutton_box do
18
- button 'A'
19
- button 'B'
20
- button 'C'
15
+ _box :vertical do
16
+ with_attr :border_width => 10 do
17
+ _frame 'default' do
18
+ _button_box :horizontal do
19
+ _button 'A'
20
+ _button 'B'
21
+ _button 'C'
22
+ end
21
23
  end
22
- end
23
- frame 'set :border_width => 10 for each button' do
24
- hbutton_box do
25
- button 'A', :border_width => 10
26
- button 'B', :border_width => 10
27
- button 'C', :border_width => 10
24
+ _frame 'set :border_width => 10 for each button' do
25
+ _button_box :horizontal do
26
+ _button 'A', :border_width => 10
27
+ _button 'B', :border_width => 10
28
+ _button 'C', :border_width => 10
29
+ end
28
30
  end
29
- end
30
- frame 'using with_attr :border_width => 10' do
31
- hbutton_box do
32
- with_attr :border_width => 10 do
33
- button 'A'
34
- button 'B'
35
- button 'C'
31
+ _frame 'using with_attr :border_width => 10' do
32
+ _button_box :horizontal do
33
+ with_attr :border_width => 10 do
34
+ _button 'A'
35
+ _button 'B'
36
+ _button 'C'
37
+ end
36
38
  end
37
39
  end
38
40
  end
data/lib/simple_layout.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'gtk2'
1
+ require 'gtk3'
2
2
 
3
3
  module SimpleLayout
4
4
 
@@ -32,67 +32,78 @@ module SimpleLayout
32
32
 
33
33
  def layout_class_maps
34
34
  @layout_class_maps_hash ||= {
35
- 'image' => Gtk::Image,
36
- 'label' => Gtk::Label,
37
- 'progress_bar' => Gtk::ProgressBar,
38
- 'status_bar' => Gtk::Statusbar,
39
- 'button' => Gtk::Button,
40
- 'check_button' => Gtk::CheckButton,
41
- 'radio_button' => Gtk::RadioButton,
42
- 'toggle_button' => Gtk::ToggleButton,
43
- 'link_button' => Gtk::LinkButton,
44
- 'entry' => Gtk::Entry,
45
- 'hscale' => Gtk::HScale,
46
- 'vscale' => Gtk::VScale,
47
- 'spin_button' => Gtk::SpinButton,
48
- 'text_view' => Gtk::TextView,
49
- 'tree_view' => Gtk::TreeView,
50
- 'cell_view' => Gtk::CellView,
51
- 'icon_view' => Gtk::IconView,
52
- 'combobox' => Gtk::ComboBox,
53
- 'combobox_entry' => Gtk::ComboBoxEntry,
54
- #'menu' => Gtk::Menu,
55
- #'menubar' => Gtk::MenuBar,
56
- 'toolbar' => Gtk::Toolbar,
57
- 'toolitem' => Gtk::ToolItem,
58
- 'separator_toolitem' => Gtk::SeparatorToolItem,
59
- 'tool_button' => Gtk::ToolButton,
60
- 'toggle_tool_button' => Gtk::ToggleToolButton,
61
- 'radio_tool_button' => Gtk::RadioToolButton,
62
- 'color_button' => Gtk::ColorButton,
63
- 'color_selection' => Gtk::ColorSelection,
64
- 'file_chooser_button' => Gtk::FileChooserButton,
65
- 'file_chooser_widget' => Gtk::FileChooserWidget,
66
- 'font_button' => Gtk::FontButton,
67
- 'font_selection' => Gtk::FontSelection,
68
- 'alignment' => Gtk::Alignment,
69
- 'aspect_frame' => Gtk::AspectFrame,
70
- 'hbox' => Gtk::HBox,
71
- 'vbox' => Gtk::VBox,
72
- 'hbutton_box' => Gtk::HButtonBox,
73
- 'vbutton_box' => Gtk::VButtonBox,
74
- 'hpaned' => Gtk::HPaned,
75
- 'vpaned' => Gtk::VPaned,
76
- 'layout' => Gtk::Layout,
77
- 'notebook' => Gtk::Notebook,
78
- 'table' => Gtk::Table,
79
- 'expander' => Gtk::Expander,
80
- 'frame' => Gtk::Frame,
81
- 'hseparator' => Gtk::HSeparator,
82
- 'vseparator' => Gtk::VSeparator,
83
- 'hscrollbar' => Gtk::HScrollbar,
84
- 'vscrollbar' => Gtk::VScrollbar,
85
- 'scrolled_window' => Gtk::ScrolledWindow,
86
- 'arrow' => Gtk::Arrow,
87
- 'calendar' => Gtk::Calendar,
88
- 'drawing_area' => Gtk::DrawingArea,
89
- 'event_box' => Gtk::EventBox,
90
- 'handle_box' => Gtk::HandleBox,
91
- 'viewport' => Gtk::Viewport,
92
- 'curve' => Gtk::Curve,
93
- 'gamma_curve' => Gtk::GammaCurve,
94
- 'hruler' => Gtk::HRuler,
95
- 'vruler' => Gtk::VRuler,
35
+ '_image' => Gtk::Image,
36
+ '_label' => Gtk::Label,
37
+ '_progress_bar' => Gtk::ProgressBar,
38
+ '_status_bar' => Gtk::Statusbar,
39
+ '_button' => Gtk::Button,
40
+ '_check_button' => Gtk::CheckButton,
41
+ '_radio_button' => Gtk::RadioButton,
42
+ '_toggle_button' => Gtk::ToggleButton,
43
+ '_link_button' => Gtk::LinkButton,
44
+ '_entry' => Gtk::Entry,
45
+ '_scale' => Gtk::Scale,
46
+ '_hscale' => [Gtk::Scale, :horizontal],
47
+ '_vscale' => [Gtk::Scale, :vertical],
48
+ '_spin_button' => Gtk::SpinButton,
49
+ '_text_view' => Gtk::TextView,
50
+ '_tree_view' => Gtk::TreeView,
51
+ '_cell_view' => Gtk::CellView,
52
+ '_icon_view' => Gtk::IconView,
53
+ '_combobox' => Gtk::ComboBoxText,
54
+ #'combobox_entry' => Gtk::ComboBoxEntry,
55
+ '_menu' => Gtk::Menu,
56
+ '_menubar' => Gtk::MenuBar,
57
+ '_menuitem' => Gtk::MenuItem,
58
+ '_menuitem_radio' => Gtk::RadioMenuItem,
59
+ '_menuitem_check' => Gtk::CheckMenuItem,
60
+ '_menuitem_separator' => Gtk::SeparatorMenuItem,
61
+ '_menuitem_teoroff' => Gtk::TearoffMenuItem,
62
+ '_toolbar' => Gtk::Toolbar,
63
+ '_toolitem' => Gtk::ToolItem,
64
+ '_separator_toolitem' => Gtk::SeparatorToolItem,
65
+ '_tool_button' => Gtk::ToolButton,
66
+ '_toggle_tool_button' => Gtk::ToggleToolButton,
67
+ '_radio_tool_button' => Gtk::RadioToolButton,
68
+ '_color_button' => Gtk::ColorButton,
69
+ '_color_chooser' => Gtk::ColorChooserWidget,
70
+ '_file_chooser_button' => Gtk::FileChooserButton,
71
+ '_file_chooser_widget' => Gtk::FileChooserWidget,
72
+ '_font_button' => Gtk::FontButton,
73
+ '_font_selection' => Gtk::FontSelection,
74
+ '_alignment' => Gtk::Alignment,
75
+ '_aspect_frame' => Gtk::AspectFrame,
76
+ '_box' => Gtk::Box,
77
+ '_vbox' => [Gtk::Box, :vertical],
78
+ '_hbox' => [Gtk::Box, :horizontal],
79
+ '_button_box' => Gtk::ButtonBox,
80
+ '_vbutton_box' => [Gtk::ButtonBox, :vertical],
81
+ '_hbutton_box' => [Gtk::ButtonBox, :horizontal],
82
+ '_paned' => Gtk::Paned,
83
+ '_hpaned' => [Gtk::Paned, :horizontal],
84
+ '_vpaned' => [Gtk::Paned, :vertical],
85
+ '_layout' => Gtk::Layout,
86
+ '_notebook' => Gtk::Notebook,
87
+ '_table' => Gtk::Table,
88
+ '_expander' => Gtk::Expander,
89
+ '_frame' => Gtk::Frame,
90
+ '_separator' => Gtk::Separator,
91
+ '_hseparator' => [Gtk::Separator, :horizontal],
92
+ '_vseparator' => [Gtk::Separator, :vertical],
93
+ '_scrollbar' => Gtk::Scrollbar,
94
+ '_hscrollbar' => [Gtk::Scrollbar, :horizontal],
95
+ '_vscrollbar' => [Gtk::Scrollbar, :vertical],
96
+ '_scrolled_window' => Gtk::ScrolledWindow,
97
+ '_arrow' => Gtk::Arrow,
98
+ '_calendar' => Gtk::Calendar,
99
+ '_drawing_area' => Gtk::DrawingArea,
100
+ '_event_box' => Gtk::EventBox,
101
+ '_handle_box' => Gtk::HandleBox,
102
+ '_viewport' => Gtk::Viewport,
103
+ #'curve' => Gtk::Curve,
104
+ #'gamma_curve' => Gtk::GammaCurve,
105
+ #'hruler' => Gtk::HRuler,
106
+ #'vruler' => Gtk::VRuler,
96
107
  }
97
108
  end
98
109
 
@@ -134,33 +145,54 @@ module SimpleLayout
134
145
 
135
146
  # add a widget to container (and/or become a new container as well).
136
147
  # do not call this function directly unless knowing what you are doing
137
- def add_component(w, container, layout_opt = nil)
148
+ def add_component(w, container, layout_opt)
138
149
  if @pass_on_stack.last.nil? || @pass_on_stack.last[0] == false
139
150
  if container.is_a?(Gtk::Box)
140
- layout_opt ||= [false, false, 0]
151
+ layout_opt ||= [expand: false, fill: false, padding: 0]
141
152
  pack_method = 'pack_start'
142
- if layout_opt.first.is_a?(Symbol)
143
- pack_method = 'pack_end' if layout_opt.shift == :end
153
+ railse LayoutError, "layout_opt should be an Array" unless layout_opt.is_a?(Array)
154
+ if layout_opt.first.is_a?(Symbol) && layout_opt[0] == :end
155
+ layout_opt.shift # remove the first ':end'
156
+ pack_method = 'pack_end'
157
+ end
158
+ if layout_opt.size == 1 && layout_opt.last.is_a?(Hash)
159
+ # if there is only one Hash in layout_opt, it's the keyword arguments for pack_start or pack_end
160
+ container.send(pack_method, w, **layout_opt.last)
161
+ else
162
+ # else it's the position arguments, old style, we need to conver to keyword arguments
163
+ opt = {expand: layout_opt[0], fill: layout_opt[1], padding: layout_opt[2]}
164
+ container.send(pack_method, w, **opt)
144
165
  end
145
- container.send(pack_method, w, *layout_opt)
146
166
  elsif container.is_a?(Gtk::Fixed) || container.is_a?(Gtk::Layout)
147
167
  layout_opt ||= [0, 0]
148
168
  container.put w, *layout_opt
149
- elsif container.is_a?(Gtk::MenuShell)
169
+ elsif container.is_a?(Gtk::MenuShell) || container.is_a?(Gtk::MenuBar) || container.is_a?(Gtk::Menu)
150
170
  container.append w
171
+ elsif container.is_a?(Gtk::MenuItem)
172
+ container.submenu = w
151
173
  elsif container.is_a?(Gtk::Toolbar)
152
174
  container.insert(container.n_items, w)
153
175
  elsif container.is_a?(Gtk::MenuToolButton)
154
176
  container.menu = w
177
+ elsif container.is_a?(Gtk::ScrolledWindow)
178
+ container.add_with_viewport(w)
179
+ if layout_opt && layout_opt.size > 0
180
+ if layout_opt.size == 1 && layout_opt.first.is_a?(Hash)
181
+ container.set_policy(**layout_opt.first)
182
+ else
183
+ container.set_policy(*layout_opt)
184
+ end
185
+ end
155
186
  elsif container.is_a?(Gtk::Table)
156
187
  # should use #grid or #grid_flx to add a child to Table
157
188
  elsif container.is_a?(Gtk::Notebook)
158
189
  # should use #page to add a child to Notebook
159
190
  elsif container.is_a?(Gtk::Paned)
160
191
  # should use #area_first or #area_second to add child to Paned
161
- elsif container.is_a?(Gtk::Container)
162
- layout_opt ||= []
163
- container.add(w, *layout_opt)
192
+ elsif container.is_a?(Gtk::Container) || container.respond_to?(:add)
193
+ # lastly, if it's a general container or respond to 'add', use #add to add child
194
+ args = [w, *layout_opt].flatten
195
+ container.add(*args)
164
196
  end
165
197
  else
166
198
  fun_name, args = *(@pass_on_stack.last[1])
@@ -201,6 +233,7 @@ module SimpleLayout
201
233
  :insp => misc[:insp],
202
234
  :layout => misc[:layout],
203
235
  :options => misc[:options],
236
+ :accel_group => misc[:accel_group],
204
237
  :name => nil,
205
238
  }
206
239
  @containers.push [cnt, m]
@@ -252,7 +285,7 @@ module SimpleLayout
252
285
  items.each do |x|
253
286
  # TODO: ...
254
287
  end
255
- layout_component(fact.get_widget("<#{name}>"), options)
288
+ layout_component(fact.get_widget("<#{name}>"), [], options)
256
289
  end
257
290
 
258
291
  def factory_menu_item(name, options = {}, &block)
@@ -301,7 +334,11 @@ module SimpleLayout
301
334
  end
302
335
 
303
336
  # layout the new UI component (container or widget)
304
- def layout_component(w, options = {}, &block)
337
+ # w: the widget
338
+ # args: the arguments for creating the widget (just for inspection purpose)
339
+ # options: the options for layout the widget
340
+ # block: the block for creating the children
341
+ def layout_component(w, args, options = {}, &block)
305
342
  @containers ||= []
306
343
  @pass_on_stack ||= []
307
344
  @components ||= {}
@@ -310,58 +347,75 @@ module SimpleLayout
310
347
 
311
348
  add_singleton_event_map(w) # so that you can use: w.on_clicked{|*args| ... }
312
349
 
350
+ # there are some special options: :id, :gid, :layout
351
+ # :id is the name of the component, :gid is the group name of the component, if :gid is not given, use :id as group name
352
+ # :layout is the layout options for the component
313
353
  name = options.delete(:id)
314
354
  group_name = options.delete(:gid) || name
315
355
  layout_opt = options.delete(:layout)
316
- keep_top_cnt = options.delete(:keep_top_container)
356
+ accel_group = options.delete(:accel_group)
357
+ accel = options.delete(:accel)
317
358
 
359
+ # the rest of the key-value pairs are turn into the function calls if the widget response to the key
318
360
  options.each do |k, v|
319
- if v.is_a?(Array)
361
+ if v.is_a?(Array) # e.g. :set_size_request => [100, 100] turn into w.set_size_request(100, 100)
320
362
  w.send(k.to_s, *v) if w.respond_to?(k.to_s)
321
- else
363
+ else # e.g. :size => 10 turn into w.size = 10
322
364
  w.send(k.to_s + '=', v) if w.respond_to?(k.to_s + '=')
323
365
  end
324
366
  end
325
367
 
326
- @components[name] = w if name
368
+ @components[name] = w if name # add the widget to the components hash, if 'name' is given
369
+
370
+ # if :gid is given, create the group if the group is not exist
327
371
  gs = (group_name ? [group_name].flatten : [])
328
372
  gs.each{|g| @component_children[g] ||= [] }
329
373
 
330
- misc = nil
374
+ parent, param = nil, nil
331
375
  if @containers.size > 0
332
- container, misc = @containers.last
333
- misc[:groups].each{ |g| @component_children[g].push w }
334
- misc[:sibling] += 1
376
+ parent, param = @containers.last
377
+ param[:groups].each{ |g| @component_children[g].push w } # add the widget to the parent's children group
378
+ param[:sibling] += 1 # record the sibling count
379
+
380
+ # if the widget is a menuitem, add the accelerator to the menuitem
381
+ menuitem_add_accel_group(w, accel, param[:accel_group]) if accel && param[:accel_group]
382
+
335
383
  end
336
384
 
337
- unless container and container.is_a? Gtk::ScrolledWindow
338
- insp_evb = make_inspect_evb(misc, w, name, layout_opt, options)
385
+ # if parent is a ScrolledWindow, create the inspector eventbox around the widget
386
+ insp_evb = nil
387
+ unless parent and parent.is_a?(Gtk::ScrolledWindow)
388
+ insp_evb = make_inspect_evb(param, w, name, args, layout_opt, options)
339
389
  end
340
390
 
341
- if block # if given block, it's a container as well
391
+ if block # if given block, it's a container
392
+
393
+ # if the widget options has :accel_group (a menu widget), create a new accelerator group to the container(menu)
394
+ @components[accel_group] = Gtk::AccelGroup.new if accel_group
342
395
  m = { :groups => gs,
343
396
  :sibling => 0,
344
397
  :insp => insp_evb,
345
398
  :name => name,
346
399
  :layout => layout_opt,
347
400
  :options => options,
401
+ :args => args,
402
+ :accel_group => accel_group,
348
403
  }
349
- @containers.push [w, m]
404
+ @containers.push [w, m] # push the new container to the stack
350
405
  @pass_on_stack.push [false, nil]
351
406
  @common_attribute.push({})
352
- block.call(w) if block
407
+ block.call(w) # create the children
353
408
  @common_attribute.pop
354
409
  @pass_on_stack.pop
355
410
  @containers.pop
356
411
  end
357
412
 
358
413
  if @containers.size > 0
359
- add_component(insp_evb || w, container, layout_opt) # add myself to parent
414
+ add_component(insp_evb || w, parent, layout_opt) # add myself to parent
360
415
  else
361
- add_component(insp_evb || w, self, layout_opt) unless keep_top_cnt # add top container to host
362
416
  @components[:self] = self # add host as ':self'
363
417
  end
364
- w
418
+ insp_evb || w
365
419
  end
366
420
 
367
421
  private
@@ -380,18 +434,79 @@ module SimpleLayout
380
434
  end
381
435
  end
382
436
 
437
+ # add accelerator to the munuitem
438
+ # w: the menuitem widget
439
+ # accel: the accelerator string
440
+ # accel_group: the accelerator group id
441
+ def menuitem_add_accel_group(w, accel, accel_group)
442
+ # if accel is given, the widget is a menuitem, parse the accel string and add the accelerator to the widget
443
+ if w && @components[accel_group] && accel && w.is_a?(Gtk::MenuItem) #w.respond_to?(:add_accelerator)
444
+ if accel.to_s =~ /^<(.+)>(.*)$/
445
+ ctl, key = $1, $2
446
+ mask, kc = nil, nil
447
+ case ctl.downcase
448
+ when 'ctrl', 'control'
449
+ mask = Gdk::ModifierType::CONTROL_MASK
450
+ when 'alt'
451
+ mask = Gdk::ModifierType::MOD1_MASK
452
+ when 'meta', 'cmd', 'command'
453
+ if RUBY_PLATFORM =~ /darwin/
454
+ mask = Gdk::ModifierType::META_MASK
455
+ else
456
+ mask = Gdk::ModifierType::MOD1_MASK # for non-Mac, use Alt
457
+ end
458
+ when 'shift'
459
+ mask = Gdk::ModifierType::SHIFT_MASK
460
+ else
461
+ mask = nil
462
+ end
463
+
464
+ case key.downcase
465
+ when 'f1'..'f12'
466
+ kc = Gdk::Keyval.const_get("GDK_KEY_#{key}")
467
+ when 'a'..'z'
468
+ kc = Gdk::Keyval.const_get("KEY_#{key.upcase}")
469
+ when 'plus'
470
+ kc = Gdk::Keyval::GDK_PLUS
471
+ when 'minus'
472
+ kc = Gdk::Keyval::GDK_MINUS
473
+ else
474
+ kc = nil
475
+ end
476
+
477
+ if mask && kc
478
+ w.add_accelerator('activate', @components[accel_group], kc, mask, Gtk::AccelFlags::VISIBLE)
479
+ end
480
+ end
481
+ end
482
+
483
+ end
484
+
485
+ # create the inspector eventbox color
486
+ # level: the level of the container stack
487
+ # mode: :enter or :leave
488
+ def inspect_box_color(level:, mode:)
489
+ @evb_colors ||= {} # color cache
490
+ rgb = 1 - (level+2) / 12.0
491
+ case mode
492
+ when :enter
493
+ @evb_colors["#{level}_#{mode}"] ||= Gdk::RGBA.new(rgb, rgb + 0.2, rgb + 0.2, 1)
494
+ when :leave
495
+ @evb_colors["#{level}_#{mode}"] ||= Gdk::RGBA.new(rgb, rgb, rgb, 0.6)
496
+ end
497
+ end
498
+
383
499
  # create the inspector eventbox for widget
384
- def make_inspect_evb(cnt_misc, w, name, layout_opt, options)
500
+ def make_inspect_evb(cnt_misc, w, name, args, layout_opt, options)
385
501
  insp_evb = nil
386
502
  insp_opt = self.class.inspector_opt
387
503
  if insp_opt[:enable]
388
- rgb = 0xffff - @containers.size * 0x1000
389
504
  insp_evb = evb = Gtk::EventBox.new
390
505
  sub_evb = Gtk::EventBox.new
391
506
  sub_evb.add w
392
507
  evb.add sub_evb
393
- sub_evb.border_width = insp_opt[:border_width]
394
- evb.modify_bg Gtk::STATE_NORMAL, Gdk::Color.new(rgb, rgb, rgb)
508
+ sub_evb.border_width = insp_opt[:border_width].to_i
509
+ evb.override_background_color :normal, inspect_box_color(level: @containers.size, mode: :leave)
395
510
  evbs = []
396
511
  tips = ""
397
512
  @containers.size.times do |i|
@@ -399,6 +514,7 @@ module SimpleLayout
399
514
  if m[:insp] && (not m[:virtual])
400
515
  evbs << m[:insp]
401
516
  tips << "<b>container[#{i}]: #{cnt.class}#{m[:name] ? " (#{m[:name]})" : ''}</b>\n"
517
+ tips << " args: #{m[:args].inspect}\n" if m[:args] && m[:args].size > 0
402
518
  tips << " layout: #{m[:layout].inspect}\n" if m[:layout]
403
519
  tips << " options: #{m[:options].inspect}\n" if m[:options] && m[:options].size > 0
404
520
  tips << " groups: #{m[:groups].inspect}\n" if m[:groups].size > 0
@@ -406,37 +522,55 @@ module SimpleLayout
406
522
  end
407
523
  evbs << evb
408
524
  tips << "<b>widget: #{w.class}#{name ? " (#{name})" : ''}</b>\n"
525
+ tips << " args: #{args.inspect}\n" if args && args.size > 0
409
526
  tips << " layout: #{layout_opt.inspect}\n" if layout_opt
410
527
  tips << " options: #{options.inspect}\n" if options && options.size > 0
411
528
  tips << " groups: #{cnt_misc[:groups].inspect}\n" if cnt_misc && cnt_misc[:groups].size > 0
412
529
 
413
- evb.signal_connect('event') do |b, evt|
530
+ evb.signal_connect('enter-notify-event') do |b, _|
414
531
  b.tooltip_markup = tips
415
- case evt.event_type
416
- when Gdk::Event::ENTER_NOTIFY, Gdk::Event::LEAVE_NOTIFY
417
- evbs.size.times do |i|
418
- rgb = 0xffff - i * 0x1000
419
- if evt.event_type == Gdk::Event::ENTER_NOTIFY
420
- evbs[i].modify_bg Gtk::STATE_NORMAL, Gdk::Color.new(rgb, rgb - 0x2000, rgb - 0x2000)
421
- elsif evt.event_type == Gdk::Event::LEAVE_NOTIFY
422
- evbs[i].modify_bg Gtk::STATE_NORMAL, Gdk::Color.new(rgb, rgb, rgb)
423
- end
424
- end
532
+ evbs.size.times do |i|
533
+ evbs[i].override_background_color :normal, inspect_box_color(level: i, mode: :enter)
425
534
  end
426
535
  end
536
+
537
+ evb.signal_connect('leave-notify-event') do |b, _|
538
+ b.tooltip_markup = nil
539
+ evbs.size.times do |i|
540
+ evbs[i].override_background_color :normal, inspect_box_color(level: i, mode: :leave)
541
+ end
542
+ end
543
+
427
544
  end
428
545
  insp_evb
429
546
  end
430
547
 
431
548
  # create a new UI component (container or widget)
432
- def create_component(component_class, args, block)
549
+ def create_component(class_desc, args, block)
433
550
  @common_attribute ||= []
434
551
  options = {}
552
+ if class_desc.is_a?(Array) # for virtual widget that use existing widget with specific args, e.g [Gtk::Box, :vertical]
553
+ component_class = class_desc[0]
554
+ args = class_desc[1..-1] + args
555
+ else
556
+ component_class = class_desc
557
+ end
435
558
  options = args.pop if args.last.is_a?(Hash)
436
559
  options.merge! @common_attribute.last if @common_attribute.last
437
560
 
438
- w = component_class.new(*args)
439
- layout_component(w, options, &block)
561
+ if args.size == 1 && args.first.is_a?(Array) && args.first.size == 1 && args.first.first.is_a?(Hash)
562
+ w = component_class.new(**args.first.first)
563
+ else
564
+ case component_class.to_s
565
+ when /(Button)$/
566
+ w = component_class.new(label: args[0])
567
+ when /(MenuItem)$/
568
+ w = component_class.new(label: args[0])
569
+ else
570
+ w = component_class.new(*args)
571
+ end
572
+ end
573
+ layout_component(w, args, options, &block)
440
574
  end
441
575
 
442
576
  def container_pass_on(container_class, fun_name, *args)
@@ -452,29 +586,25 @@ module SimpleLayout
452
586
  end
453
587
 
454
588
  alias_method :simple_layout_method_missing_alias, :method_missing
455
-
456
589
  def method_missing(sym, *args, &block)
457
- if sym.to_s =~ /^(.+)_in_(.+)$/
590
+ if sym.to_s =~ /^(.+)_in(_.+)$/
458
591
  maps = self.class.layout_class_maps
459
592
  inner, outter = $1, $2
460
593
  if maps[inner] && maps[outter]
461
594
  if args.last.is_a?(Hash)
462
595
  options = {}
463
596
  options = args.pop if args.last.is_a?(Hash)
464
-
465
597
  # default args pass to inner component, execpt:
466
598
  # :layout pass to outter :layout
467
599
  # :inner_layout pass to inner :layout
468
600
  # :outter_args pass to outter args
469
601
  outter_args, outter_layout_opt, options[:layout] =
470
602
  options.delete(:outter_args), options.delete(:layout), options.delete(:inner_layout)
471
-
472
603
  outter_args = (outter_args ? [outter_args] : []) unless outter_args.is_a?(Array)
473
604
  outter_args << {} unless outter_args.last.is_a?(Hash)
474
605
  outter_args.last[:layout] ||= outter_layout_opt
475
606
  args.push options # push back inner options
476
607
  end
477
-
478
608
  inner_proc = Proc.new do
479
609
  create_component(maps[inner], args, block)
480
610
  end
metadata CHANGED
@@ -1,78 +1,61 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: GtkSimpleLayout
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Ricky Zheng
13
- autorequire:
8
+ autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2010-12-19 00:00:00 +13:00
18
- default_executable:
11
+ date: 2024-09-14 00:00:00.000000000 Z
19
12
  dependencies: []
20
-
21
- description: A simple builder style layout helper for RubyGnome2
13
+ description: A simple builder style layout helper for Ruby GTK3, it helps you to build
14
+ ruby GTK3 UI codes in a much more readable way. It also includes a UI inspector
15
+ to debug the UI.
22
16
  email: ricky_gz_zheng@yahoo.co.nz
23
17
  executables: []
24
-
25
18
  extensions: []
26
-
27
- extra_rdoc_files:
19
+ extra_rdoc_files:
28
20
  - README
29
21
  - LICENSE
30
- files:
22
+ files:
31
23
  - LICENSE
32
24
  - README
33
25
  - Rakefile
34
26
  - example/auto_event_map.rb
27
+ - example/basic.rb
28
+ - example/calculator.rb
29
+ - example/composit.rb
30
+ - example/expose_components.rb
35
31
  - example/group.rb
36
- - example/composit_layout.rb
37
32
  - example/hello_world.rb
38
33
  - example/menu.rb
34
+ - example/multiple_layouts.rb
39
35
  - example/serial_port_setup.rb
40
- - example/expose_components.rb
41
36
  - example/with_attr.rb
42
- - example/basic.rb
43
- - example/calculator.rb
44
37
  - lib/simple_layout.rb
45
- has_rdoc: true
46
- homepage:
47
- licenses: []
48
-
49
- post_install_message:
38
+ homepage: https://github.com/rickyzheng/GtkSimpleLayout
39
+ licenses:
40
+ - GPL-2.0-or-later
41
+ metadata: {}
42
+ post_install_message:
50
43
  rdoc_options: []
51
-
52
- require_paths:
44
+ require_paths:
53
45
  - lib
54
- required_ruby_version: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
57
48
  - - ">="
58
- - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
- version: "0"
62
- required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
49
+ - !ruby/object:Gem::Version
50
+ version: 2.5.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
65
53
  - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
70
56
  requirements: []
71
-
72
- rubyforge_project:
73
- rubygems_version: 1.3.7
74
- signing_key:
75
- specification_version: 3
76
- summary: A simple builder style layout helper for RubyGnome2
57
+ rubygems_version: 3.5.17
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: A simple builder style layout helper for Ruby GTK3
77
61
  test_files: []
78
-
@@ -1,26 +0,0 @@
1
- require 'gtk2'
2
- require File.dirname(__FILE__) + '/../lib/simple_layout'
3
-
4
- class MyWin < Gtk::Window
5
- include SimpleLayout::Base
6
- def initialize
7
- super
8
- my_layout
9
- signal_connect('destroy') do
10
- Gtk.main_quit
11
- end
12
- end
13
-
14
- def my_layout
15
- vbox do
16
- with_attr :border_width => 10 do
17
- label_in_hbox "I'm a label, in a hbox"
18
- button_in_frame "I'm a button, in a frame", :border_width => 10
19
- label_in_hbox "I'm a label, in a hbox, with inner_layout[:end, false, false]", :inner_layout => [:end, false, false]
20
- end
21
- end
22
- end
23
- end
24
-
25
- MyWin.new.show_all
26
- Gtk.main