shul 0.2.7 → 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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/shul.rb +253 -186
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 250018912dfe1c289cdcc291096db3b888153a1b
|
4
|
+
data.tar.gz: e2be69b41bd343e9702c403ce36757c4de1957f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5628cbfca17f5396003eec25ffef3691a25d87e84d100a8f3af618aa4b7f1f74aa40213feca23f8a73f09a88dbfb21679cdda06e504ccbca236973575abfabd6
|
7
|
+
data.tar.gz: c2dc301eb0a14c52bfc87fda3a5c3b79e4c1ab964f5ea660962594fc78683aa5a8f2b7ae5e6e35b181cec7f72c732a13b9aa9051df8ecc3d0d12b81b19fa4ea6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/shul.rb
CHANGED
@@ -22,9 +22,12 @@ Shoes.app {Shul.new self, xml}
|
|
22
22
|
=end
|
23
23
|
|
24
24
|
# resources:
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
25
|
+
# xul:
|
26
|
+
# https://en.wikipedia.org/wiki/Shoes_%28GUI_toolkit%29
|
27
|
+
# https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL
|
28
|
+
# http://www.xul.fr/tutorial/
|
29
|
+
# shoes:
|
30
|
+
# http://shoesrb.com/manual/Element.html
|
28
31
|
#------------------------------------------------------------------
|
29
32
|
|
30
33
|
require 'rexle'
|
@@ -33,240 +36,304 @@ require 'rxfhelper'
|
|
33
36
|
|
34
37
|
class Rexle::Element
|
35
38
|
|
36
|
-
def obj()
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def obj=(obj)
|
41
|
-
@obj = obj
|
42
|
-
end
|
39
|
+
def obj() @obj end
|
40
|
+
def obj=(obj) @obj = obj end
|
43
41
|
|
44
42
|
end
|
45
43
|
|
46
44
|
|
47
|
-
|
45
|
+
module Shul
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
@shoes = shoes
|
47
|
+
class Main
|
52
48
|
|
53
|
-
|
54
|
-
else
|
55
|
-
xml, _ = RXFHelper.read(source)
|
56
|
-
Rexle.new(xml)
|
57
|
-
end
|
49
|
+
def initialize(shoes, xml)
|
58
50
|
|
59
|
-
|
51
|
+
doc = Rexle.new xml
|
52
|
+
|
53
|
+
shoes.app(resizeable: false, width: 100, height: 100) do
|
60
54
|
|
61
|
-
|
62
|
-
|
55
|
+
shul = Shul::App.new self, doc
|
56
|
+
|
57
|
+
end
|
58
|
+
|
63
59
|
end
|
64
|
-
|
65
60
|
end
|
66
61
|
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
|
63
|
+
class App
|
64
|
+
|
65
|
+
def initialize(shoes_app, source)
|
66
|
+
|
67
|
+
doc = if source.is_a? Rexle then source
|
68
|
+
else
|
69
|
+
xml, _ = RXFHelper.read(source)
|
70
|
+
Rexle.new(xml)
|
71
|
+
end
|
72
|
+
|
73
|
+
# To find out the window dimensions we must first render the app
|
74
|
+
shul = Window.new(shoes_app, doc)
|
70
75
|
|
71
|
-
|
76
|
+
shoes_app.start do |app|
|
77
|
+
|
78
|
+
sleep 0.0001
|
79
|
+
|
80
|
+
box = doc.root.element('hbox | vbox').obj
|
81
|
+
|
82
|
+
h = {title: 'Shul', width: box.width, height: box.height}\
|
83
|
+
.merge doc.root.attributes
|
84
|
+
|
85
|
+
win = window(h) { Window.new self, doc }
|
86
|
+
win.start do |w|
|
87
|
+
sleep 0.0001
|
88
|
+
|
89
|
+
end
|
90
|
+
app.close # closes the initial shoes app
|
91
|
+
shul = nil
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
72
95
|
|
73
96
|
end
|
74
|
-
|
75
|
-
def buttonx(e, label = :label, oncommand = :oncommand)
|
76
97
|
|
77
|
-
|
78
|
-
label = h[label]
|
79
|
-
command = h[oncommand]
|
80
|
-
|
81
|
-
e.obj = @shoes.button label do
|
82
|
-
eval command if command
|
83
|
-
end
|
98
|
+
class Window
|
84
99
|
|
85
|
-
|
86
|
-
|
100
|
+
attr_reader :width, :height
|
101
|
+
|
102
|
+
def initialize(shoes, doc)
|
103
|
+
|
104
|
+
@shoes = shoes
|
105
|
+
@width, @height = 100, 100
|
106
|
+
|
107
|
+
@doc = doc
|
108
|
+
|
109
|
+
@doc.root.elements.each {|x| method(x.name.sub(':','_').to_sym).call(x) }
|
110
|
+
|
111
|
+
def @doc.element_by_id(id)
|
112
|
+
self.root.element("//*[@id='#{id}']")
|
113
|
+
end
|
114
|
+
|
115
|
+
|
87
116
|
end
|
117
|
+
|
118
|
+
private
|
88
119
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
h = e.attributes
|
94
|
-
|
95
|
-
@shoes.flow do
|
96
|
-
c = @shoes.check
|
97
|
-
c.checked = h[:checked] == 'true'
|
98
|
-
@shoes.para h[:label]
|
120
|
+
def button(e)
|
121
|
+
|
122
|
+
buttonx e
|
123
|
+
|
99
124
|
end
|
100
125
|
|
101
|
-
|
126
|
+
def buttonx(e, label = :label, oncommand = :oncommand)
|
102
127
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
e.obj = obj
|
128
|
+
h = e.attributes
|
129
|
+
label = h[label]
|
130
|
+
command = h[oncommand]
|
131
|
+
|
132
|
+
e.obj = @shoes.button label do
|
133
|
+
eval command if command
|
134
|
+
end
|
135
|
+
|
136
|
+
def e.label=(v)
|
137
|
+
self.obj.style[:text] = v
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
117
141
|
|
118
|
-
def e
|
119
|
-
self.attributes[:value]
|
120
|
-
end
|
142
|
+
def checkbox(e)
|
121
143
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
144
|
+
h = e.attributes
|
145
|
+
|
146
|
+
@shoes.flow do
|
147
|
+
c = @shoes.check
|
148
|
+
c.checked = h[:checked] == 'true'
|
149
|
+
@shoes.para h[:label]
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def description(e)
|
155
|
+
e.obj = @shoes.para e.attributes[:value]
|
156
|
+
end
|
126
157
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
#
|
131
|
-
def grid(e)
|
158
|
+
def doc()
|
159
|
+
@doc
|
160
|
+
end
|
132
161
|
|
133
|
-
|
134
|
-
|
162
|
+
def editbox(e, name = :edit_line)
|
163
|
+
|
164
|
+
obj = @shoes.method(name).call
|
165
|
+
obj.text = e.attributes[:value]
|
166
|
+
obj.change {|x| e.value = x.text() if e.value != e.text}
|
167
|
+
e.obj = obj
|
168
|
+
|
169
|
+
def e.value()
|
170
|
+
self.attributes[:value]
|
171
|
+
end
|
172
|
+
|
173
|
+
def e.value=(v)
|
174
|
+
self.attributes[:value] = v
|
175
|
+
self.obj.text = v
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
135
179
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
180
|
+
def find_max_dimensions(e)
|
181
|
+
|
182
|
+
a = e.elements.map(&:obj)
|
183
|
+
maxwidth = a.max_by{|x| x.width}.width
|
184
|
+
maxheight = a.inject(0) {|r,x2| r += x2.height }
|
185
|
+
|
186
|
+
[maxwidth.to_i, maxheight]
|
187
|
+
|
188
|
+
end
|
140
189
|
|
141
|
-
#
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
#
|
146
|
-
|
147
|
-
|
148
|
-
|
190
|
+
# This method is under-development
|
191
|
+
#
|
192
|
+
def grid(e)
|
193
|
+
|
194
|
+
# get the grid width
|
195
|
+
#grid_width = 100
|
196
|
+
|
197
|
+
# get the columns
|
198
|
+
columns = e.element 'columns'
|
199
|
+
cols = columns.xpath 'column'
|
200
|
+
cols_flex = cols.map {|x| x.attributes[:flex].to_s.to_i}
|
201
|
+
|
202
|
+
# get the rows
|
203
|
+
rows = e.element 'rows'
|
204
|
+
rows.each do |row|
|
205
|
+
a = row.xpath 'row'
|
206
|
+
# resize the width of each item
|
207
|
+
a.each do |x|
|
208
|
+
#x.width = 400
|
209
|
+
#puts "x: %s width: %s" + [x.inspect, x.width]
|
210
|
+
end
|
149
211
|
end
|
150
212
|
end
|
151
|
-
|
152
|
-
|
153
|
-
def hbox(e)
|
213
|
+
|
214
|
+
def hbox(e)
|
154
215
|
|
155
|
-
|
156
|
-
|
157
|
-
|
216
|
+
flow = @shoes.flow do
|
217
|
+
e.elements.each {|x| method(x.name.sub(':','_').to_sym).call(x) }
|
218
|
+
end
|
219
|
+
e.obj = flow
|
158
220
|
|
159
|
-
|
160
|
-
|
161
|
-
|
221
|
+
end
|
222
|
+
|
223
|
+
alias flow hbox
|
162
224
|
|
163
|
-
|
225
|
+
def html_a(e)
|
164
226
|
|
165
|
-
|
227
|
+
command = e.attributes[:oncommand]
|
166
228
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
229
|
+
@shoes.para(
|
230
|
+
e.obj = @shoes.link(e.text).click do
|
231
|
+
eval command if command
|
232
|
+
end
|
233
|
+
)
|
172
234
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
235
|
+
end
|
236
|
+
|
237
|
+
def html_em(e)
|
238
|
+
e.obj = obj = @shoes.em(e.text)
|
239
|
+
@shoes.para()
|
240
|
+
end
|
241
|
+
|
242
|
+
alias html_i html_em
|
181
243
|
|
182
|
-
|
244
|
+
def html_input(e)
|
245
|
+
|
246
|
+
case e.attributes[:type]
|
247
|
+
when 'text'
|
248
|
+
editbox e
|
249
|
+
when 'button'
|
250
|
+
buttonx e, :value, :onclick
|
251
|
+
end
|
252
|
+
end
|
183
253
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
when 'button'
|
188
|
-
buttonx e, :value, :onclick
|
254
|
+
def html_p(e)
|
255
|
+
e.obj = @shoes.para e.text
|
256
|
+
e.elements.each {|x| method(x.name.sub(':','_').to_sym).call(x) }
|
189
257
|
end
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
def html_strong(e)
|
202
|
-
e.obj = @shoes.strong e.text
|
203
|
-
end
|
204
|
-
|
205
|
-
alias html_b html_strong
|
206
|
-
|
207
|
-
def image(e)
|
208
|
-
h = e.attributes
|
209
|
-
e.obj = @shoes.image h[:src], top: h[:top], left: h[:left]
|
210
|
-
end
|
211
|
-
|
212
|
-
def label(e)
|
213
|
-
e.obj = @shoes.para e.attributes[:value]
|
214
|
-
end
|
215
|
-
|
216
|
-
def listbox(e)
|
217
|
-
a = e.xpath 'listem/attribute::label'
|
218
|
-
e.obj = @shoes.list_box items: a
|
219
|
-
end
|
220
|
-
|
221
|
-
def progressmeter(e)
|
222
|
-
e.obj = @shoes.progress
|
223
|
-
end
|
224
|
-
|
225
|
-
def radiogroup(e)
|
258
|
+
|
259
|
+
def html_span(e)
|
260
|
+
e.obj = @shoes.span e.text
|
261
|
+
end
|
262
|
+
|
263
|
+
def html_strong(e)
|
264
|
+
e.obj = @shoes.strong e.text
|
265
|
+
end
|
266
|
+
|
267
|
+
alias html_b html_strong
|
226
268
|
|
269
|
+
def image(e)
|
270
|
+
h = e.attributes
|
271
|
+
e.obj = @shoes.image h[:src], top: h[:top], left: h[:left]
|
272
|
+
end
|
273
|
+
|
274
|
+
def label(e)
|
275
|
+
e.obj = @shoes.para e.attributes[:value]
|
276
|
+
end
|
277
|
+
|
278
|
+
def listbox(e)
|
279
|
+
a = e.xpath 'listem/attribute::label'
|
280
|
+
e.obj = @shoes.list_box items: a
|
281
|
+
end
|
282
|
+
|
283
|
+
def progressmeter(e)
|
284
|
+
e.obj = @shoes.progress
|
285
|
+
end
|
227
286
|
|
228
|
-
e
|
287
|
+
def radiogroup(e)
|
288
|
+
|
229
289
|
|
230
|
-
|
231
|
-
def x.value=(v) self.attributes[:value] = v end
|
290
|
+
e.xpath('radio').each do |x|
|
232
291
|
|
233
|
-
|
234
|
-
|
235
|
-
@shoes.flow do
|
236
|
-
r = @shoes.radio :radiogroup01
|
292
|
+
def x.value() self.attributes[:value] end
|
293
|
+
def x.value=(v) self.attributes[:value] = v end
|
237
294
|
|
238
|
-
|
239
|
-
|
295
|
+
x.value = x.attributes[:value]
|
296
|
+
h = x.attributes
|
297
|
+
@shoes.flow do
|
298
|
+
r = @shoes.radio :radiogroup01
|
299
|
+
|
300
|
+
r.checked = h[:checked] == 'true'
|
301
|
+
@shoes.para h[:label]
|
302
|
+
end
|
303
|
+
|
240
304
|
end
|
241
305
|
|
242
306
|
end
|
243
307
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
eval e.text.unescape
|
248
|
-
end
|
308
|
+
def script(e)
|
309
|
+
eval e.text.unescape
|
310
|
+
end
|
249
311
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
312
|
+
def textbox(e)
|
313
|
+
|
314
|
+
name = if e.attributes[:multiline] \
|
315
|
+
and e.attributes[:multiline] == 'true' then
|
316
|
+
:edit_box
|
317
|
+
else
|
318
|
+
:edit_line
|
319
|
+
end
|
320
|
+
|
321
|
+
editbox e, name
|
322
|
+
|
256
323
|
end
|
257
324
|
|
258
|
-
|
259
|
-
|
260
|
-
end
|
261
|
-
|
262
|
-
def vbox(e)
|
325
|
+
def vbox(e)
|
263
326
|
|
264
|
-
|
265
|
-
|
266
|
-
|
327
|
+
stack = @shoes.stack do
|
328
|
+
e.elements.each {|x| method(x.name.sub(':','_').to_sym).call(x) }
|
329
|
+
end
|
330
|
+
|
331
|
+
e.obj = stack
|
332
|
+
|
267
333
|
|
334
|
+
end
|
335
|
+
|
336
|
+
alias stack vbox
|
337
|
+
|
268
338
|
end
|
269
|
-
|
270
|
-
alias stack vbox
|
271
|
-
|
272
339
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|