-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwidget_gallery.rb
152 lines (126 loc) · 3.89 KB
/
widget_gallery.rb
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
require 'glimmer-dsl-gtk'
include Glimmer
application('org.glimmer.hello-application') {
on(:activate) do |app|
application_window(app) { |aw|
title 'Widget Gallery'
notebook { |n|
f1 = frame {
alignment(1, 1, 1, 1) {
padding 15, 15, 15, 15
box(:vertical) {
spacing 10
label('Entry')
entry {
text 'Enter One Line of Text'
}
label('Search Entry')
search_entry {
text 'Enter Search Term'
}
label('Spin Button')
spin_button(1, 100, 1) {
}
label('Combo Box Text')
cb = combo_box_text {
}
3.times { |n| cb.append_text "Option #{n + 1}" }
}
}
}
n.set_tab_label_text(f1.gtk, 'Text')
f2 = frame {
alignment(1, 1, 1, 1) {
padding 15, 15, 15, 15
box(:vertical) {
spacing 10
label('Button')
button(label: 'Push Me') {
on(:clicked) do
message_dialog(parent: aw) { |md|
title 'Information'
text 'You clicked the button'
on(:response) do
md.destroy
end
}.show
end
}
label('Radio Button')
box(:horizontal) {
rb = radio_button(label: 'One')
radio_button(label: 'Two', member: rb)
radio_button(label: 'Three', member: rb)
}
label('Check Button')
box(:horizontal) {
check_button('One')
check_button('Two')
check_button('Three')
}
}
}
}
n.set_tab_label_text(f2.gtk, 'Button')
f3 = frame {
alignment(1, 1, 1, 1) {
padding 15, 15, 15, 15
box(:vertical) {
spacing 10
label('Horizontal Scale')
scale(:horizontal, 1, 100, 1) {
visible true
}
label('Vertical Scale')
scale(:vertical, 1, 100, 1) {
visible true
height_request 200
}
}
}
}
n.set_tab_label_text(f3.gtk, 'Selection')
f4 = frame {
alignment(1, 1, 1, 1) {
padding 15, 15, 15, 15
box(:vertical) {
spacing 10
label('Expander')
3.times do |n|
expander {
label "Item #{n + 1}"
label("Item #{n + 1} Expanded") {
}
}
end
}
}
}
n.set_tab_label_text(f4.gtk, 'Organizer')
f5 = frame {
alignment(1, 1, 1, 1) {
padding 15, 15, 15, 15
box(:vertical) {
spacing 10
label('Progress Bar')
pb = progress_bar {
text 'Progress Bar'
}
Thread.new do
101.times.cycle do |n|
pb.fraction = n / 100.0
sleep(0.1) # yields back to main GUI thread
end
end
label('Spinner')
spinner {
active true
}
}
}
}
n.set_tab_label_text(f5.gtk, 'Progress')
}
}.present
end
}.run