gtk2html 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/gtk2html.rb +148 -27
- metadata +2 -2
- 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: c80dee92494fdba1f1733f682343d08a32ee37c2
|
4
|
+
data.tar.gz: 4605a22228a85ea5dc97297a212bb2b198802b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4d5a4c6494e12b79ee0fc14375a8f07e88876bb44281a1ca9d6b7de13ffca01ca80703552694a14685f00aa6514842b0dbbe455ca01b177f7ff357913a6abbd
|
7
|
+
data.tar.gz: dcde178eaaf6f6d85dd43fec8d8c34b0ca8bd6c0ee5716793f120be74bddbc7d7f53848cf2e8cfba5deb38203d893c2254915488f747b26da9e5fdd8dee512e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/gtk2html.rb
CHANGED
@@ -60,6 +60,15 @@ module Gtk2HTML
|
|
60
60
|
|
61
61
|
[[:draw_box, margin, coords, padding, style], render_all(e)]
|
62
62
|
end
|
63
|
+
|
64
|
+
def input(e, attributes, style)
|
65
|
+
|
66
|
+
margin = [0, 0, 0, 0] # style[:margin].values
|
67
|
+
coords = [0, 0, @width, @height]
|
68
|
+
padding = [0, 0, 0, 0] # style[:padding].values
|
69
|
+
|
70
|
+
[[:add_inputbox, margin, coords, padding, style], render_all(e)]
|
71
|
+
end
|
63
72
|
|
64
73
|
def style(*args)
|
65
74
|
|
@@ -137,7 +146,6 @@ module Gtk2HTML
|
|
137
146
|
|
138
147
|
if inspect or verbose then
|
139
148
|
scan @a
|
140
|
-
puts
|
141
149
|
@a
|
142
150
|
else
|
143
151
|
@a
|
@@ -257,12 +265,14 @@ module Gtk2HTML
|
|
257
265
|
|
258
266
|
class DrawingInstructions
|
259
267
|
|
260
|
-
attr_accessor :
|
268
|
+
attr_accessor :layout
|
269
|
+
attr_reader :widgets
|
261
270
|
|
262
271
|
|
263
|
-
def initialize(
|
272
|
+
def initialize(layout=nil)
|
264
273
|
|
265
|
-
@
|
274
|
+
@layout = layout if layout
|
275
|
+
@widgets = []
|
266
276
|
|
267
277
|
end
|
268
278
|
|
@@ -277,9 +287,10 @@ module Gtk2HTML
|
|
277
287
|
height = y2 - y1
|
278
288
|
|
279
289
|
gc = gc_ini(h2)
|
280
|
-
@
|
290
|
+
@layout.bin_window.draw_rectangle(gc, 1, x1, y1, width, height)
|
281
291
|
end
|
282
292
|
|
293
|
+
|
283
294
|
def draw_layout(text, coords, style)
|
284
295
|
|
285
296
|
x, y = coords
|
@@ -294,7 +305,7 @@ module Gtk2HTML
|
|
294
305
|
layout.text = text
|
295
306
|
|
296
307
|
gc = gc_ini(h2)
|
297
|
-
@
|
308
|
+
@layout.bin_window.draw_layout(gc, x, y, layout)
|
298
309
|
end
|
299
310
|
|
300
311
|
def window(args)
|
@@ -312,13 +323,15 @@ module Gtk2HTML
|
|
312
323
|
private
|
313
324
|
|
314
325
|
def draw(a)
|
315
|
-
|
326
|
+
|
316
327
|
return unless a
|
317
328
|
|
318
329
|
if a.first.is_a? Symbol then
|
319
330
|
|
320
331
|
name, margin, coords, padding, style, _, *children = a
|
321
|
-
|
332
|
+
|
333
|
+
method(name).call(margin, coords, padding, style) if name =~ /^draw_/
|
334
|
+
|
322
335
|
draw children
|
323
336
|
|
324
337
|
elsif a.first.is_a? String and not a.first.empty?
|
@@ -340,7 +353,7 @@ module Gtk2HTML
|
|
340
353
|
|
341
354
|
name, margin, coords, padding, style, _, *children = x
|
342
355
|
|
343
|
-
method(name).call(margin, coords, padding, style)
|
356
|
+
method(name).call(margin, coords, padding, style) if name =~ /^draw_/
|
344
357
|
draw children
|
345
358
|
|
346
359
|
when :'Rexle::Element::Value' then
|
@@ -352,17 +365,14 @@ module Gtk2HTML
|
|
352
365
|
method(:draw_layout).call(*row)
|
353
366
|
|
354
367
|
when :Array
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
else
|
359
|
-
draw row[-1]
|
360
|
-
end
|
368
|
+
|
369
|
+
draw row
|
370
|
+
|
361
371
|
else
|
362
372
|
|
363
373
|
name, *args = x
|
364
374
|
|
365
|
-
method(name).call(args)
|
375
|
+
method(name).call(args) if name =~ /^draw_/
|
366
376
|
draw row[-1]
|
367
377
|
end
|
368
378
|
|
@@ -392,7 +402,7 @@ module Gtk2HTML
|
|
392
402
|
|
393
403
|
def gc_ini(style)
|
394
404
|
|
395
|
-
gc = Gdk::GC.new(@
|
405
|
+
gc = Gdk::GC.new(@layout.bin_window)
|
396
406
|
|
397
407
|
color, bgcolor = style[:color], style[:'background-color']
|
398
408
|
|
@@ -404,10 +414,103 @@ module Gtk2HTML
|
|
404
414
|
|
405
415
|
end
|
406
416
|
|
417
|
+
class WidgetInstructions
|
418
|
+
|
419
|
+
attr_accessor :layout
|
420
|
+
|
421
|
+
|
422
|
+
def initialize(layout=nil)
|
423
|
+
|
424
|
+
@layout = layout if layout
|
425
|
+
|
426
|
+
end
|
427
|
+
|
428
|
+
|
429
|
+
def add_inputbox(margin, coords, padding, style)
|
430
|
+
|
431
|
+
h2 = style.clone
|
432
|
+
h2.delete :color
|
433
|
+
|
434
|
+
x1, y1, x2, y2 = coords
|
435
|
+
|
436
|
+
width = x2 - x1
|
437
|
+
height = y2 - y1
|
438
|
+
|
439
|
+
entry = Gtk::Entry.new
|
440
|
+
entry.set_text('type something')
|
441
|
+
@layout.put entry, 10,40
|
442
|
+
|
443
|
+
end
|
444
|
+
|
445
|
+
def render(a)
|
446
|
+
add a
|
447
|
+
end
|
448
|
+
|
449
|
+
|
450
|
+
private
|
451
|
+
|
452
|
+
def add(a)
|
453
|
+
|
454
|
+
return unless a
|
455
|
+
|
456
|
+
if a.first.is_a? Symbol then
|
457
|
+
|
458
|
+
name, margin, coords, padding, style, _, *children = a
|
459
|
+
return if name =~ /^draw_/
|
460
|
+
method(name).call(margin, coords, padding, style)
|
461
|
+
add children
|
462
|
+
|
463
|
+
else
|
464
|
+
|
465
|
+
a.each do |row|
|
466
|
+
|
467
|
+
next unless row
|
468
|
+
|
469
|
+
x = row
|
470
|
+
|
471
|
+
case row[0].class.to_s.to_sym
|
472
|
+
|
473
|
+
when :Symbol
|
474
|
+
|
475
|
+
name, margin, coords, padding, style, _, *children = x
|
476
|
+
|
477
|
+
next if name =~ /^draw_/
|
478
|
+
method(name).call(margin, coords, padding, style)
|
479
|
+
add children
|
480
|
+
|
481
|
+
when :'Rexle::Element::Value' then
|
482
|
+
|
483
|
+
next
|
484
|
+
|
485
|
+
when :Array
|
486
|
+
|
487
|
+
if row[-1][0].is_a? String then
|
488
|
+
next
|
489
|
+
else
|
490
|
+
add row[-1]
|
491
|
+
end
|
492
|
+
else
|
493
|
+
|
494
|
+
name, *args = x
|
495
|
+
|
496
|
+
next if name =~ /^draw_/
|
497
|
+
method(name).call(args)
|
498
|
+
add row[-1]
|
499
|
+
end
|
500
|
+
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
end
|
505
|
+
|
506
|
+
|
507
|
+
end
|
508
|
+
|
509
|
+
|
407
510
|
class Main
|
408
511
|
|
409
512
|
|
410
|
-
attr_accessor :doc, :html
|
513
|
+
attr_accessor :doc, :html, :layout_instructions
|
411
514
|
attr_reader :width, :height, :window
|
412
515
|
|
413
516
|
def initialize(html, irb: false)
|
@@ -416,6 +519,10 @@ module Gtk2HTML
|
|
416
519
|
@doc = Htmle.new(html, callback: self)
|
417
520
|
|
418
521
|
@area = area = Gtk::DrawingArea.new
|
522
|
+
@layout = layout = Gtk::Layout.new
|
523
|
+
widgets = nil
|
524
|
+
|
525
|
+
|
419
526
|
client_code = []
|
420
527
|
|
421
528
|
window = Gtk::Window.new
|
@@ -428,7 +535,7 @@ module Gtk2HTML
|
|
428
535
|
@dirty = true
|
429
536
|
|
430
537
|
|
431
|
-
|
538
|
+
layout.signal_connect("expose_event") do
|
432
539
|
|
433
540
|
width, height = window.size
|
434
541
|
|
@@ -436,18 +543,14 @@ module Gtk2HTML
|
|
436
543
|
|
437
544
|
|
438
545
|
if @dirty then
|
439
|
-
|
440
|
-
Thread.new { @doc.root.xpath('//script').each {|x| eval x.text.unescape } }
|
441
546
|
|
442
|
-
@
|
443
|
-
instructions = Gtk2HTML::Render.new(@doc, @width, @height).to_a
|
444
|
-
|
445
|
-
@layout_instructions = Gtk2HTML::Layout.new(instructions).to_a
|
547
|
+
@layout_instructions = prepare_layout @doc
|
446
548
|
|
447
549
|
end
|
448
550
|
|
449
|
-
drawing = Gtk2HTML::DrawingInstructions.new
|
551
|
+
drawing = Gtk2HTML::DrawingInstructions.new layout
|
450
552
|
drawing.render @layout_instructions
|
553
|
+
|
451
554
|
@dirty = false
|
452
555
|
|
453
556
|
end
|
@@ -473,8 +576,15 @@ module Gtk2HTML
|
|
473
576
|
|
474
577
|
end
|
475
578
|
end
|
579
|
+
|
580
|
+
layout_instructions = prepare_layout @doc
|
581
|
+
|
582
|
+
widgets = Gtk2HTML::WidgetInstructions.new layout
|
583
|
+
widgets.render layout_instructions
|
584
|
+
|
585
|
+
@layout.put area, 0, 0
|
476
586
|
|
477
|
-
window.add(
|
587
|
+
window.add(@layout).show_all
|
478
588
|
window.show_all.signal_connect("destroy"){Gtk.main_quit}
|
479
589
|
|
480
590
|
irb ? Thread.new {Gtk.main } : Gtk.main
|
@@ -494,6 +604,17 @@ module Gtk2HTML
|
|
494
604
|
@doc = Htmle.new(svg, callback: self)
|
495
605
|
end
|
496
606
|
|
607
|
+
private
|
608
|
+
|
609
|
+
def prepare_layout(doc)
|
610
|
+
|
611
|
+
Thread.new { doc.root.xpath('//script').each {|x| eval x.text.unescape } }
|
612
|
+
|
613
|
+
@width, @height = window.size
|
614
|
+
instructions = Gtk2HTML::Render.new(doc, @width, @height).to_a
|
615
|
+
|
616
|
+
Gtk2HTML::Layout.new(instructions).to_a
|
617
|
+
end
|
497
618
|
end
|
498
619
|
|
499
620
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
HcgEV5WVgO2X3OsEEkfaHgi8R+LiEsmUOYiPgzi3ImiJBJCRzkvK0iQFtQENVbdN
|
32
32
|
OFyd/PIiSrxPFA==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-12-
|
34
|
+
date: 2016-12-22 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: gtk2svg
|
metadata.gz.sig
CHANGED
Binary file
|