GtkSimpleLayout 0.2.1 → 0.3.0
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 +7 -0
- data/README +6 -6
- data/example/auto_event_map.rb +6 -6
- data/example/basic.rb +14 -14
- data/example/calculator.rb +21 -21
- data/example/expose_components.rb +5 -5
- data/example/group.rb +17 -17
- data/example/hello_world.rb +6 -6
- data/example/menu.rb +25 -29
- data/example/serial_port_setup.rb +17 -13
- data/example/with_attr.rb +23 -21
- data/lib/simple_layout.rb +253 -135
- metadata +32 -51
- data/example/composit_layout.rb +0 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 63da04a080c9692caa7a4d73c64cd039cc925767c056668fdd44d1054ccec355
|
4
|
+
data.tar.gz: 4f784f8a7c76dee45b23c50e020f88d06a52a928a79903bb3351bf4a0d5fcc25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 820c45c85a73d4f0972ac2c5aa893edc001c1cccba316b1b39f6cb8d7bfd523b924b43bf4f78a734ee9ad839f4a47fe1b462ef14665f67ccad3d9390a9147a4b
|
7
|
+
data.tar.gz: efc1b63c51fcd7f2126bbfc64fd9e5e07f4329a8608aa5873fbfd2733787cd1a88f4871cecb277a6bfd364cc0922d14f794d009d4401372b4e6fdde89b954054
|
data/README
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
== GtkSimpleLayout ==
|
2
2
|
|
3
|
-
The GtkSimpleLayout is a helper module for
|
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
|
-
|
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 '
|
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
|
-
|
40
|
-
|
41
|
-
|
39
|
+
_box :vertical do
|
40
|
+
_label 'Hello'
|
41
|
+
_button 'World !'
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/example/auto_event_map.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
require
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
|
data/example/basic.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'gtk3'
|
2
|
+
require 'simple_layout'
|
3
3
|
|
4
4
|
class MyWin < Gtk::Window
|
5
5
|
include SimpleLayout::Base
|
@@ -12,20 +12,20 @@ class MyWin < Gtk::Window
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def my_layout
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
data/example/calculator.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'gtk3'
|
2
|
+
require 'simple_layout'
|
3
3
|
|
4
4
|
class MyWin < Gtk::Window
|
5
5
|
include SimpleLayout::Base
|
@@ -13,27 +13,27 @@ class MyWin < Gtk::Window
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def my_layout
|
16
|
-
|
16
|
+
_box :vertical do
|
17
17
|
with_attr :border_width => 3 do
|
18
|
-
|
19
|
-
|
18
|
+
_box :horizontal do
|
19
|
+
_entry :id => :ent_input, :layout => [true, true, 5]
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
_box :horizontal do
|
22
|
+
_frame do
|
23
|
+
_label 'M', :set_size_request => [20, 20]
|
24
24
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
_button_box :horizontal do
|
26
|
+
_button 'Backspace'
|
27
|
+
_button 'CE'
|
28
|
+
_button 'C'
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
_box :horizontal do
|
32
|
+
_button_box :vertical 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
|
-
|
47
|
+
_box :vertical 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
|
-
|
52
|
+
_box :horizontal, :layout => [true, true] do
|
53
53
|
cols.each do |txt|
|
54
|
-
|
54
|
+
_button txt, :id => txt.to_sym, :set_size_request => [30, 30], :layout => [true, true]
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require
|
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
|
-
|
9
|
-
|
10
|
-
|
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
|
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
13
|
+
_button_box :horizontal do
|
14
14
|
group :A do # set group A
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
_button 'A'
|
16
|
+
_button 'A'
|
17
|
+
_button 'A'
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
button_box :horizontal do
|
21
21
|
group :B do # set group B
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
_button 'B'
|
23
|
+
_button 'B'
|
24
|
+
_button 'B'
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
_button_box :horizontal do
|
28
28
|
group :A do # you can set group A again !
|
29
|
-
|
30
|
-
|
29
|
+
_button 'A'
|
30
|
+
_button 'A'
|
31
31
|
end
|
32
32
|
group :B do # you can set group B again !
|
33
|
-
|
34
|
-
|
33
|
+
_button 'B'
|
34
|
+
_button 'B'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/example/hello_world.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'gtk3'
|
2
|
+
require 'simple_layout'
|
3
3
|
|
4
4
|
class MyWin < Gtk::Window
|
5
5
|
include SimpleLayout::Base
|
@@ -12,12 +12,12 @@ class MyWin < Gtk::Window
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def my_layout
|
15
|
-
|
16
|
-
|
17
|
-
|
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,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'gtk3'
|
2
|
+
require 'simple_layout'
|
3
3
|
|
4
4
|
class MyWin < Gtk::Window
|
5
5
|
include SimpleLayout::Base
|
@@ -12,40 +12,36 @@ class MyWin < Gtk::Window
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def my_layout
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
39
|
-
|
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
|
45
|
-
|
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
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require '
|
2
|
-
require
|
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
|
-
|
9
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
11
|
+
_box :horizontal do
|
12
|
+
_label 'Port name: '
|
13
|
+
_combobox :id => :comb_port, :layout => [true, true]
|
14
14
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
_box :horizontal do
|
16
|
+
_label 'Baud rate: '
|
17
|
+
_combobox :id => :comb_baudrate, :layout => [true, true]
|
18
18
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
@@ -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,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
require
|
1
|
+
require 'gtk3'
|
2
|
+
require 'simple_layout'
|
3
3
|
|
4
4
|
class MyWin < Gtk::Window
|
5
5
|
include SimpleLayout::Base
|
@@ -12,27 +12,29 @@ class MyWin < Gtk::Window
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def my_layout
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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 '
|
1
|
+
require 'gtk3'
|
2
2
|
|
3
3
|
module SimpleLayout
|
4
4
|
|
@@ -32,67 +32,70 @@ module SimpleLayout
|
|
32
32
|
|
33
33
|
def layout_class_maps
|
34
34
|
@layout_class_maps_hash ||= {
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
46
|
-
'
|
47
|
-
'
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
'combobox_entry' => Gtk::ComboBoxEntry,
|
54
|
-
|
55
|
-
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
61
|
-
'
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'
|
65
|
-
'
|
66
|
-
'
|
67
|
-
'
|
68
|
-
'
|
69
|
-
'
|
70
|
-
'
|
71
|
-
'
|
72
|
-
'
|
73
|
-
'
|
74
|
-
'
|
75
|
-
'
|
76
|
-
'
|
77
|
-
'
|
78
|
-
'
|
79
|
-
'
|
80
|
-
'
|
81
|
-
'
|
82
|
-
'
|
83
|
-
'
|
84
|
-
'
|
85
|
-
'
|
86
|
-
'
|
87
|
-
'
|
88
|
-
'
|
89
|
-
'
|
90
|
-
'
|
91
|
-
'
|
92
|
-
'
|
93
|
-
'
|
94
|
-
'
|
95
|
-
'
|
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::ComboBoxText,
|
53
|
+
#'combobox_entry' => Gtk::ComboBoxEntry,
|
54
|
+
'_menu' => Gtk::Menu,
|
55
|
+
'_menubar' => Gtk::MenuBar,
|
56
|
+
'_menuitem' => Gtk::MenuItem,
|
57
|
+
'_menuitem_radio' => Gtk::RadioMenuItem,
|
58
|
+
'_menuitem_check' => Gtk::CheckMenuItem,
|
59
|
+
'_menuitem_separator' => Gtk::SeparatorMenuItem,
|
60
|
+
'_menuitem_teoroff' => Gtk::TearoffMenuItem,
|
61
|
+
'_toolbar' => Gtk::Toolbar,
|
62
|
+
'_toolitem' => Gtk::ToolItem,
|
63
|
+
'_separator_toolitem' => Gtk::SeparatorToolItem,
|
64
|
+
'_tool_button' => Gtk::ToolButton,
|
65
|
+
'_toggle_tool_button' => Gtk::ToggleToolButton,
|
66
|
+
'_radio_tool_button' => Gtk::RadioToolButton,
|
67
|
+
'_color_button' => Gtk::ColorButton,
|
68
|
+
'_color_chooser' => Gtk::ColorChooserWidget,
|
69
|
+
'_file_chooser_button' => Gtk::FileChooserButton,
|
70
|
+
'_file_chooser_widget' => Gtk::FileChooserWidget,
|
71
|
+
'_font_button' => Gtk::FontButton,
|
72
|
+
'_font_selection' => Gtk::FontSelection,
|
73
|
+
'_alignment' => Gtk::Alignment,
|
74
|
+
'_aspect_frame' => Gtk::AspectFrame,
|
75
|
+
'_box' => Gtk::Box,
|
76
|
+
'_button_box' => Gtk::ButtonBox,
|
77
|
+
'_hpaned' => Gtk::HPaned,
|
78
|
+
'_vpaned' => Gtk::VPaned,
|
79
|
+
'_layout' => Gtk::Layout,
|
80
|
+
'_notebook' => Gtk::Notebook,
|
81
|
+
'_table' => Gtk::Table,
|
82
|
+
'_expander' => Gtk::Expander,
|
83
|
+
'_frame' => Gtk::Frame,
|
84
|
+
'_hseparator' => Gtk::HSeparator,
|
85
|
+
'_vseparator' => Gtk::VSeparator,
|
86
|
+
'_hscrollbar' => Gtk::HScrollbar,
|
87
|
+
'_vscrollbar' => Gtk::VScrollbar,
|
88
|
+
'_scrolled_window' => Gtk::ScrolledWindow,
|
89
|
+
'_arrow' => Gtk::Arrow,
|
90
|
+
'_calendar' => Gtk::Calendar,
|
91
|
+
'_drawing_area' => Gtk::DrawingArea,
|
92
|
+
'_event_box' => Gtk::EventBox,
|
93
|
+
'_handle_box' => Gtk::HandleBox,
|
94
|
+
'_viewport' => Gtk::Viewport,
|
95
|
+
#'curve' => Gtk::Curve,
|
96
|
+
#'gamma_curve' => Gtk::GammaCurve,
|
97
|
+
#'hruler' => Gtk::HRuler,
|
98
|
+
#'vruler' => Gtk::VRuler,
|
96
99
|
}
|
97
100
|
end
|
98
101
|
|
@@ -134,33 +137,54 @@ module SimpleLayout
|
|
134
137
|
|
135
138
|
# add a widget to container (and/or become a new container as well).
|
136
139
|
# do not call this function directly unless knowing what you are doing
|
137
|
-
def add_component(w, container, layout_opt
|
140
|
+
def add_component(w, container, layout_opt)
|
138
141
|
if @pass_on_stack.last.nil? || @pass_on_stack.last[0] == false
|
139
142
|
if container.is_a?(Gtk::Box)
|
140
|
-
layout_opt ||= [false, false, 0]
|
143
|
+
layout_opt ||= [expand: false, fill: false, padding: 0]
|
141
144
|
pack_method = 'pack_start'
|
142
|
-
|
143
|
-
|
145
|
+
railse LayoutError, "layout_opt should be an Array" unless layout_opt.is_a?(Array)
|
146
|
+
if layout_opt.first.is_a?(Symbol) && layout_opt[0] == :end
|
147
|
+
layout_opt.shift # remove the first ':end'
|
148
|
+
pack_method = 'pack_end'
|
149
|
+
end
|
150
|
+
if layout_opt.size == 1 && layout_opt.last.is_a?(Hash)
|
151
|
+
# if there is only one Hash in layout_opt, it's the keyword arguments for pack_start or pack_end
|
152
|
+
container.send(pack_method, w, **layout_opt.last)
|
153
|
+
else
|
154
|
+
# else it's the position arguments, old style, we need to conver to keyword arguments
|
155
|
+
opt = {expand: layout_opt[0], fill: layout_opt[1], padding: layout_opt[2]}
|
156
|
+
container.send(pack_method, w, **opt)
|
144
157
|
end
|
145
|
-
container.send(pack_method, w, *layout_opt)
|
146
158
|
elsif container.is_a?(Gtk::Fixed) || container.is_a?(Gtk::Layout)
|
147
159
|
layout_opt ||= [0, 0]
|
148
160
|
container.put w, *layout_opt
|
149
|
-
elsif container.is_a?(Gtk::MenuShell)
|
161
|
+
elsif container.is_a?(Gtk::MenuShell) || container.is_a?(Gtk::MenuBar) || container.is_a?(Gtk::Menu)
|
150
162
|
container.append w
|
163
|
+
elsif container.is_a?(Gtk::MenuItem)
|
164
|
+
container.submenu = w
|
151
165
|
elsif container.is_a?(Gtk::Toolbar)
|
152
166
|
container.insert(container.n_items, w)
|
153
167
|
elsif container.is_a?(Gtk::MenuToolButton)
|
154
168
|
container.menu = w
|
169
|
+
elsif container.is_a?(Gtk::ScrolledWindow)
|
170
|
+
container.add_with_viewport(w)
|
171
|
+
if layout_opt && layout_opt.size > 0
|
172
|
+
if layout_opt.size == 1 && layout_opt.first.is_a?(Hash)
|
173
|
+
container.set_policy(**layout_opt.first)
|
174
|
+
else
|
175
|
+
container.set_policy(*layout_opt)
|
176
|
+
end
|
177
|
+
end
|
155
178
|
elsif container.is_a?(Gtk::Table)
|
156
179
|
# should use #grid or #grid_flx to add a child to Table
|
157
180
|
elsif container.is_a?(Gtk::Notebook)
|
158
181
|
# should use #page to add a child to Notebook
|
159
182
|
elsif container.is_a?(Gtk::Paned)
|
160
183
|
# should use #area_first or #area_second to add child to Paned
|
161
|
-
elsif container.is_a?(Gtk::Container)
|
162
|
-
|
163
|
-
|
184
|
+
elsif container.is_a?(Gtk::Container) || container.respond_to?(:add)
|
185
|
+
# lastly, if it's a general container or respond to 'add', use #add to add child
|
186
|
+
args = [w, *layout_opt].flatten
|
187
|
+
container.add(*args)
|
164
188
|
end
|
165
189
|
else
|
166
190
|
fun_name, args = *(@pass_on_stack.last[1])
|
@@ -201,6 +225,7 @@ module SimpleLayout
|
|
201
225
|
:insp => misc[:insp],
|
202
226
|
:layout => misc[:layout],
|
203
227
|
:options => misc[:options],
|
228
|
+
:accel_group => misc[:accel_group],
|
204
229
|
:name => nil,
|
205
230
|
}
|
206
231
|
@containers.push [cnt, m]
|
@@ -252,7 +277,7 @@ module SimpleLayout
|
|
252
277
|
items.each do |x|
|
253
278
|
# TODO: ...
|
254
279
|
end
|
255
|
-
layout_component(fact.get_widget("<#{name}>"), options)
|
280
|
+
layout_component(fact.get_widget("<#{name}>"), [], options)
|
256
281
|
end
|
257
282
|
|
258
283
|
def factory_menu_item(name, options = {}, &block)
|
@@ -301,7 +326,11 @@ module SimpleLayout
|
|
301
326
|
end
|
302
327
|
|
303
328
|
# layout the new UI component (container or widget)
|
304
|
-
|
329
|
+
# w: the widget
|
330
|
+
# args: the arguments for creating the widget (just for inspection purpose)
|
331
|
+
# options: the options for layout the widget
|
332
|
+
# block: the block for creating the children
|
333
|
+
def layout_component(w, args, options = {}, &block)
|
305
334
|
@containers ||= []
|
306
335
|
@pass_on_stack ||= []
|
307
336
|
@components ||= {}
|
@@ -310,53 +339,72 @@ module SimpleLayout
|
|
310
339
|
|
311
340
|
add_singleton_event_map(w) # so that you can use: w.on_clicked{|*args| ... }
|
312
341
|
|
342
|
+
# there are some special options: :id, :gid, :layout, :keep_top_container
|
343
|
+
# :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
|
344
|
+
# :layout is the layout options for the component, :keep_top_container is to keep the top container
|
313
345
|
name = options.delete(:id)
|
314
346
|
group_name = options.delete(:gid) || name
|
315
347
|
layout_opt = options.delete(:layout)
|
316
348
|
keep_top_cnt = options.delete(:keep_top_container)
|
349
|
+
accel_group = options.delete(:accel_group)
|
350
|
+
accel = options.delete(:accel)
|
317
351
|
|
352
|
+
# the rest of the key-value pairs are turn into the function calls if the widget response to the key
|
318
353
|
options.each do |k, v|
|
319
|
-
if v.is_a?(Array)
|
354
|
+
if v.is_a?(Array) # e.g. :set_size_request => [100, 100] turn into w.set_size_request(100, 100)
|
320
355
|
w.send(k.to_s, *v) if w.respond_to?(k.to_s)
|
321
|
-
else
|
356
|
+
else # e.g. :size => 10 turn into w.size = 10
|
322
357
|
w.send(k.to_s + '=', v) if w.respond_to?(k.to_s + '=')
|
323
358
|
end
|
324
359
|
end
|
325
360
|
|
326
|
-
@components[name] = w if name
|
361
|
+
@components[name] = w if name # add the widget to the components hash, if 'name' is given
|
362
|
+
|
363
|
+
# if :gid is given, create the group if the group is not exist
|
327
364
|
gs = (group_name ? [group_name].flatten : [])
|
328
365
|
gs.each{|g| @component_children[g] ||= [] }
|
329
366
|
|
330
|
-
|
367
|
+
parent, param = nil, nil
|
331
368
|
if @containers.size > 0
|
332
|
-
|
333
|
-
|
334
|
-
|
369
|
+
parent, param = @containers.last
|
370
|
+
param[:groups].each{ |g| @component_children[g].push w } # add the widget to the parent's children group
|
371
|
+
param[:sibling] += 1 # record the sibling count
|
372
|
+
|
373
|
+
# if the widget is a menuitem, add the accelerator to the menuitem
|
374
|
+
menuitem_add_accel_group(w, accel, param[:accel_group]) if accel && param[:accel_group]
|
375
|
+
|
335
376
|
end
|
336
377
|
|
337
|
-
|
338
|
-
|
378
|
+
# if parent is a ScrolledWindow, create the inspector eventbox around the widget
|
379
|
+
insp_evb = nil
|
380
|
+
unless parent and parent.is_a?(Gtk::ScrolledWindow)
|
381
|
+
insp_evb = make_inspect_evb(param, w, name, args, layout_opt, options)
|
339
382
|
end
|
340
383
|
|
341
|
-
if block # if given block, it's a container
|
384
|
+
if block # if given block, it's a container
|
385
|
+
|
386
|
+
# if the widget options has :accel_group (a menu widget), create a new accelerator group to the container(menu)
|
387
|
+
@components[accel_group] = Gtk::AccelGroup.new if accel_group
|
342
388
|
m = { :groups => gs,
|
343
389
|
:sibling => 0,
|
344
390
|
:insp => insp_evb,
|
345
391
|
:name => name,
|
346
392
|
:layout => layout_opt,
|
347
393
|
:options => options,
|
394
|
+
:args => args,
|
395
|
+
:accel_group => accel_group,
|
348
396
|
}
|
349
|
-
@containers.push [w, m]
|
397
|
+
@containers.push [w, m] # push the new container to the stack
|
350
398
|
@pass_on_stack.push [false, nil]
|
351
399
|
@common_attribute.push({})
|
352
|
-
block.call(w)
|
400
|
+
block.call(w) # create the children
|
353
401
|
@common_attribute.pop
|
354
402
|
@pass_on_stack.pop
|
355
403
|
@containers.pop
|
356
404
|
end
|
357
405
|
|
358
406
|
if @containers.size > 0
|
359
|
-
add_component(insp_evb || w,
|
407
|
+
add_component(insp_evb || w, parent, layout_opt) # add myself to parent
|
360
408
|
else
|
361
409
|
add_component(insp_evb || w, self, layout_opt) unless keep_top_cnt # add top container to host
|
362
410
|
@components[:self] = self # add host as ':self'
|
@@ -380,18 +428,79 @@ module SimpleLayout
|
|
380
428
|
end
|
381
429
|
end
|
382
430
|
|
431
|
+
# add accelerator to the munuitem
|
432
|
+
# w: the menuitem widget
|
433
|
+
# accel: the accelerator string
|
434
|
+
# accel_group: the accelerator group id
|
435
|
+
def menuitem_add_accel_group(w, accel, accel_group)
|
436
|
+
# if accel is given, the widget is a menuitem, parse the accel string and add the accelerator to the widget
|
437
|
+
if w && @components[accel_group] && accel && w.is_a?(Gtk::MenuItem) #w.respond_to?(:add_accelerator)
|
438
|
+
if accel.to_s =~ /^<(.+)>(.*)$/
|
439
|
+
ctl, key = $1, $2
|
440
|
+
mask, kc = nil, nil
|
441
|
+
case ctl.downcase
|
442
|
+
when 'ctrl', 'control'
|
443
|
+
mask = Gdk::ModifierType::CONTROL_MASK
|
444
|
+
when 'alt'
|
445
|
+
mask = Gdk::ModifierType::MOD1_MASK
|
446
|
+
when 'meta', 'cmd', 'command'
|
447
|
+
if RUBY_PLATFORM =~ /darwin/
|
448
|
+
mask = Gdk::ModifierType::META_MASK
|
449
|
+
else
|
450
|
+
mask = Gdk::ModifierType::MOD1_MASK # for non-Mac, use Alt
|
451
|
+
end
|
452
|
+
when 'shift'
|
453
|
+
mask = Gdk::ModifierType::SHIFT_MASK
|
454
|
+
else
|
455
|
+
mask = nil
|
456
|
+
end
|
457
|
+
|
458
|
+
case key.downcase
|
459
|
+
when 'f1'..'f12'
|
460
|
+
kc = Gdk::Keyval.const_get("GDK_KEY_#{key}")
|
461
|
+
when 'a'..'z'
|
462
|
+
kc = Gdk::Keyval.const_get("KEY_#{key.upcase}")
|
463
|
+
when 'plus'
|
464
|
+
kc = Gdk::Keyval::GDK_PLUS
|
465
|
+
when 'minus'
|
466
|
+
kc = Gdk::Keyval::GDK_MINUS
|
467
|
+
else
|
468
|
+
kc = nil
|
469
|
+
end
|
470
|
+
|
471
|
+
if mask && kc
|
472
|
+
w.add_accelerator('activate', @components[accel_group], kc, mask, Gtk::AccelFlags::VISIBLE)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
end
|
478
|
+
|
479
|
+
# create the inspector eventbox color
|
480
|
+
# level: the level of the container stack
|
481
|
+
# mode: :enter or :leave
|
482
|
+
def inspect_box_color(level:, mode:)
|
483
|
+
@evb_colors ||= {} # color cache
|
484
|
+
rgb = 1 - (level+2) / 12.0
|
485
|
+
case mode
|
486
|
+
when :enter
|
487
|
+
@evb_colors["#{level}_#{mode}"] ||= Gdk::RGBA.new(rgb, rgb + 0.2, rgb + 0.2, 1)
|
488
|
+
when :leave
|
489
|
+
@evb_colors["#{level}_#{mode}"] ||= Gdk::RGBA.new(rgb, rgb, rgb, 0.6)
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
383
493
|
# create the inspector eventbox for widget
|
384
|
-
def make_inspect_evb(cnt_misc, w, name, layout_opt, options)
|
494
|
+
def make_inspect_evb(cnt_misc, w, name, args, layout_opt, options)
|
385
495
|
insp_evb = nil
|
386
496
|
insp_opt = self.class.inspector_opt
|
387
497
|
if insp_opt[:enable]
|
388
|
-
rgb = 0xffff - @containers.size * 0x1000
|
389
498
|
insp_evb = evb = Gtk::EventBox.new
|
390
499
|
sub_evb = Gtk::EventBox.new
|
391
500
|
sub_evb.add w
|
392
501
|
evb.add sub_evb
|
393
|
-
sub_evb.border_width = insp_opt[:border_width]
|
394
|
-
evb.
|
502
|
+
sub_evb.border_width = insp_opt[:border_width].to_i
|
503
|
+
evb.override_background_color :normal, inspect_box_color(level: @containers.size, mode: :leave)
|
395
504
|
evbs = []
|
396
505
|
tips = ""
|
397
506
|
@containers.size.times do |i|
|
@@ -399,6 +508,7 @@ module SimpleLayout
|
|
399
508
|
if m[:insp] && (not m[:virtual])
|
400
509
|
evbs << m[:insp]
|
401
510
|
tips << "<b>container[#{i}]: #{cnt.class}#{m[:name] ? " (#{m[:name]})" : ''}</b>\n"
|
511
|
+
tips << " args: #{m[:args].inspect}\n" if m[:args] && m[:args].size > 0
|
402
512
|
tips << " layout: #{m[:layout].inspect}\n" if m[:layout]
|
403
513
|
tips << " options: #{m[:options].inspect}\n" if m[:options] && m[:options].size > 0
|
404
514
|
tips << " groups: #{m[:groups].inspect}\n" if m[:groups].size > 0
|
@@ -406,24 +516,25 @@ module SimpleLayout
|
|
406
516
|
end
|
407
517
|
evbs << evb
|
408
518
|
tips << "<b>widget: #{w.class}#{name ? " (#{name})" : ''}</b>\n"
|
519
|
+
tips << " args: #{args.inspect}\n" if args && args.size > 0
|
409
520
|
tips << " layout: #{layout_opt.inspect}\n" if layout_opt
|
410
521
|
tips << " options: #{options.inspect}\n" if options && options.size > 0
|
411
522
|
tips << " groups: #{cnt_misc[:groups].inspect}\n" if cnt_misc && cnt_misc[:groups].size > 0
|
412
523
|
|
413
|
-
evb.signal_connect('event') do |b,
|
524
|
+
evb.signal_connect('enter-notify-event') do |b, _|
|
414
525
|
b.tooltip_markup = tips
|
415
|
-
|
416
|
-
|
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
|
526
|
+
evbs.size.times do |i|
|
527
|
+
evbs[i].override_background_color :normal, inspect_box_color(level: i, mode: :enter)
|
425
528
|
end
|
426
529
|
end
|
530
|
+
|
531
|
+
evb.signal_connect('leave-notify-event') do |b, _|
|
532
|
+
b.tooltip_markup = nil
|
533
|
+
evbs.size.times do |i|
|
534
|
+
evbs[i].override_background_color :normal, inspect_box_color(level: i, mode: :leave)
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
427
538
|
end
|
428
539
|
insp_evb
|
429
540
|
end
|
@@ -435,8 +546,19 @@ module SimpleLayout
|
|
435
546
|
options = args.pop if args.last.is_a?(Hash)
|
436
547
|
options.merge! @common_attribute.last if @common_attribute.last
|
437
548
|
|
438
|
-
|
439
|
-
|
549
|
+
if args.size == 1 && args.first.is_a?(Array) && args.first.size == 1 && args.first.first.is_a?(Hash)
|
550
|
+
w = component_class.new(**args.first.first)
|
551
|
+
else
|
552
|
+
case component_class.to_s
|
553
|
+
when /(Button)$/
|
554
|
+
w = component_class.new(label: args[0])
|
555
|
+
when /(MenuItem)$/
|
556
|
+
w = component_class.new(label: args[0])
|
557
|
+
else
|
558
|
+
w = component_class.new(*args)
|
559
|
+
end
|
560
|
+
end
|
561
|
+
layout_component(w, args, options, &block)
|
440
562
|
end
|
441
563
|
|
442
564
|
def container_pass_on(container_class, fun_name, *args)
|
@@ -451,38 +573,34 @@ module SimpleLayout
|
|
451
573
|
end
|
452
574
|
end
|
453
575
|
|
454
|
-
alias_method :simple_layout_method_missing_alias, :method_missing
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
end
|
483
|
-
end
|
484
|
-
simple_layout_method_missing_alias(sym, *args, &block)
|
485
|
-
end
|
576
|
+
# alias_method :simple_layout_method_missing_alias, :method_missing
|
577
|
+
# def method_missing(sym, *args, &block)
|
578
|
+
# if sym.to_s =~ /^(.+)_in_(.+)$/
|
579
|
+
# maps = self.class.layout_class_maps
|
580
|
+
# inner, outter = $1, $2
|
581
|
+
# if maps[inner] && maps[outter]
|
582
|
+
# if args.last.is_a?(Hash)
|
583
|
+
# options = {}
|
584
|
+
# options = args.pop if args.last.is_a?(Hash)
|
585
|
+
# # default args pass to inner component, execpt:
|
586
|
+
# # :layout pass to outter :layout
|
587
|
+
# # :inner_layout pass to inner :layout
|
588
|
+
# # :outter_args pass to outter args
|
589
|
+
# outter_args, outter_layout_opt, options[:layout] =
|
590
|
+
# options.delete(:outter_args), options.delete(:layout), options.delete(:inner_layout)
|
591
|
+
# outter_args = (outter_args ? [outter_args] : []) unless outter_args.is_a?(Array)
|
592
|
+
# outter_args << {} unless outter_args.last.is_a?(Hash)
|
593
|
+
# outter_args.last[:layout] ||= outter_layout_opt
|
594
|
+
# args.push options # push back inner options
|
595
|
+
# end
|
596
|
+
# inner_proc = Proc.new do
|
597
|
+
# create_component(maps[inner], args, block)
|
598
|
+
# end
|
599
|
+
# return create_component(maps[outter], outter_args || [], inner_proc)
|
600
|
+
# end
|
601
|
+
# end
|
602
|
+
# simple_layout_method_missing_alias(sym, *args, &block)
|
603
|
+
# end
|
486
604
|
|
487
605
|
end
|
488
606
|
end
|
metadata
CHANGED
@@ -1,78 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: GtkSimpleLayout
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
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-08 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
20
|
-
|
21
|
-
|
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/expose_components.rb
|
35
30
|
- example/group.rb
|
36
|
-
- example/composit_layout.rb
|
37
31
|
- example/hello_world.rb
|
38
32
|
- example/menu.rb
|
39
33
|
- example/serial_port_setup.rb
|
40
|
-
- example/expose_components.rb
|
41
34
|
- example/with_attr.rb
|
42
|
-
- example/basic.rb
|
43
|
-
- example/calculator.rb
|
44
35
|
- lib/simple_layout.rb
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
post_install_message:
|
36
|
+
homepage: https://github.com/rickyzheng/GtkSimpleLayout
|
37
|
+
licenses:
|
38
|
+
- GPL-2.0-or-later
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
50
41
|
rdoc_options: []
|
51
|
-
|
52
|
-
require_paths:
|
42
|
+
require_paths:
|
53
43
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
|
56
|
-
requirements:
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
57
46
|
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
|
-
requirements:
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.5.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
65
51
|
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
- 0
|
69
|
-
version: "0"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
70
54
|
requirements: []
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
specification_version: 3
|
76
|
-
summary: A simple builder style layout helper for RubyGnome2
|
55
|
+
rubygems_version: 3.5.17
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: A simple builder style layout helper for Ruby GTK3
|
77
59
|
test_files: []
|
78
|
-
|
data/example/composit_layout.rb
DELETED
@@ -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
|