glimmer-dsl-gtk 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/LICENSE.txt +56 -20
  4. data/README.md +538 -36
  5. data/VERSION +1 -1
  6. data/bin/girb +58 -22
  7. data/bin/girb_runner.rb +58 -20
  8. data/glimmer-dsl-gtk.gemspec +0 -0
  9. data/lib/glimmer/dsl/gtk/dsl.rb +58 -18
  10. data/lib/glimmer/dsl/gtk/on_expression.rb +56 -18
  11. data/lib/glimmer/dsl/gtk/operation_expression.rb +79 -0
  12. data/lib/glimmer/dsl/gtk/property_expression.rb +59 -21
  13. data/lib/glimmer/dsl/gtk/shape_expression.rb +86 -0
  14. data/lib/glimmer/dsl/gtk/widget_expression.rb +57 -19
  15. data/lib/glimmer/gtk/shape/arc.rb +70 -0
  16. data/lib/glimmer/gtk/shape/circle.rb +67 -0
  17. data/lib/glimmer/gtk/shape/path.rb +109 -0
  18. data/lib/glimmer/gtk/shape/polygon.rb +92 -0
  19. data/lib/glimmer/gtk/shape/polyline.rb +91 -0
  20. data/lib/glimmer/gtk/shape/rectangle.rb +70 -0
  21. data/lib/glimmer/gtk/shape/rounded_rectangle.rb +70 -0
  22. data/lib/glimmer/gtk/shape/triangle.rb +67 -0
  23. data/lib/glimmer/gtk/shape.rb +198 -0
  24. data/lib/glimmer/gtk/widget_proxy/application_proxy.rb +56 -18
  25. data/lib/glimmer/gtk/widget_proxy/box_proxy.rb +56 -18
  26. data/lib/glimmer/gtk/widget_proxy/drawing_area_proxy.rb +93 -0
  27. data/lib/glimmer/gtk/widget_proxy/message_dialog_proxy.rb +56 -18
  28. data/lib/glimmer/gtk/widget_proxy/window_proxy.rb +56 -18
  29. data/lib/glimmer/gtk/widget_proxy.rb +70 -30
  30. data/lib/glimmer/gtk.rb +59 -21
  31. data/lib/glimmer-dsl-gtk.rb +56 -18
  32. data/samples/elaborate/widget_gallery.rb +141 -0
  33. data/samples/hello/hello_drawing_area.rb +86 -0
  34. data/samples/hello/hello_drawing_area_manual.rb +140 -0
  35. metadata +21 -6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for GTK 0.0.1
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for GTK 0.0.2
2
2
  ## Ruby-GNOME Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-gtk.svg)](http://badge.fury.io/rb/glimmer-dsl-gtk)
4
4
  [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -26,11 +26,11 @@ window {
26
26
  }.show
27
27
  ```
28
28
 
29
- Mac Screenshot:
29
+ Linux | Mac | Windows
30
+ ------|-----|--------
31
+ ![hello world screenshot Windows](/screenshots/glimmer-dsl-gtk-linux-hello-world.png) | ![hello world screenshot Mac](/screenshots/glimmer-dsl-gtk-mac-hello-world.png) | ![hello world screenshot Windows](/screenshots/glimmer-dsl-gtk-windows-hello-world.png)
30
32
 
31
- ![hello world screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-world.png)
32
-
33
- NOTE: Glimmer DSL for GTK is currently in early alpha mode (incomplete proof-of-concept). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
33
+ NOTE: Glimmer DSL for GTK is currently in early alpha mode (incomplete proof-of-concept). If you want it developed faster, then [open an issue report](https://github.com/AndyObtiva/glimmer-dsl-gtk/issues/new). I have completed some GitHub project features much faster before due to [issue reports](https://github.com/AndyObtiva/glimmer-dsl-gtk/issues) and [pull requests](https://github.com/AndyObtiva/glimmer-dsl-gtk/pulls). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
34
34
 
35
35
  Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
36
36
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -40,6 +40,32 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
40
40
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
41
41
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
42
42
 
43
+ ## Prerequisites
44
+
45
+ ### Linux
46
+
47
+ GNOME-based Linux installations do not need any pre-requisites since they have GTK built-in, so you can skip to [Setup](#setup) right away.
48
+
49
+ Still, if you run into issues installing the GTK gem in [Setup](#setup), you may try these commands first:
50
+ ```
51
+ sudo apt-get install libgtk-3-dev
52
+ ```
53
+
54
+ Or run this command if all else fails:
55
+ ```
56
+ sudo apt install -y -V libgirepository1.0-dev
57
+ ```
58
+
59
+ ### Mac
60
+
61
+ On the Mac, make sure to:
62
+ - Have [Homebrew](https://brew.sh/) installed
63
+ - Run this [Homebrew](https://brew.sh/) command to have GTK display GUI icons: `brew install adwaita-icon-theme`
64
+
65
+ ### Windows
66
+
67
+ Make sure to install [Ruby](https://www.ruby-lang.org) with MSYS & MING toolchains from [RubyInstaller](https://rubyinstaller.org/downloads/)
68
+
43
69
  ## Setup
44
70
 
45
71
  ### Option 1: Install
@@ -53,7 +79,7 @@ gem install glimmer-dsl-gtk
53
79
 
54
80
  Add the following to `Gemfile`:
55
81
  ```
56
- gem 'glimmer-dsl-gtk', '~> 0.0.1'
82
+ gem 'glimmer-dsl-gtk', '~> 0.0.2'
57
83
  ```
58
84
 
59
85
  And, then run:
@@ -80,9 +106,9 @@ window {
80
106
  }.show
81
107
  ```
82
108
 
83
- For actual application development outside of simple demos, mixin the `Glimmer` module into an application class instead:
109
+ For actual application development outside of simple demos, mixin the `Glimmer` module into a custom application class instead:
84
110
 
85
- ```
111
+ ```ruby
86
112
  require 'glimmer-dsl-gtk'
87
113
 
88
114
  class SomeGlimmerApplication
@@ -117,7 +143,17 @@ You can run the `girb` command (`bin/girb` if you cloned the project locally):
117
143
  girb
118
144
  ```
119
145
 
120
- ![girb screenshot](/screenshots/glimmer-dsl-gtk-mac-girb.png)
146
+ Linux
147
+
148
+ ![girb screenshot linux](/screenshots/glimmer-dsl-gtk-linux-girb.png)
149
+
150
+ Mac
151
+
152
+ ![girb screenshot mac](/screenshots/glimmer-dsl-gtk-mac-girb.png)
153
+
154
+ Windows
155
+
156
+ ![girb screenshot windows](/screenshots/glimmer-dsl-gtk-windows-girb.png)
121
157
 
122
158
  This gives you `irb` with the `glimmer-dsl-gtk` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.
123
159
 
@@ -125,15 +161,17 @@ Gotcha: On the Mac, when you close a window opened in `girb`, it remains open un
125
161
 
126
162
  ## Samples
127
163
 
164
+ You may checkout the [samples](samples) directory for examples of using [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk).
165
+
128
166
  ### Hello Samples
129
167
 
130
168
  #### Hello, World!
131
169
 
132
170
  [samples/hello/hello_world.rb](/samples/hello/hello_world.rb)
133
171
 
134
- Mac Screenshot:
135
-
136
- ![hello world screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-world.png)
172
+ Linux | Mac | Windows
173
+ ------|-----|--------
174
+ ![hello world screenshot Windows](/screenshots/glimmer-dsl-gtk-linux-hello-world.png) | ![hello world screenshot Mac](/screenshots/glimmer-dsl-gtk-mac-hello-world.png) | ![hello world screenshot Windows](/screenshots/glimmer-dsl-gtk-windows-hello-world.png)
137
175
 
138
176
  Run (via installed gem):
139
177
 
@@ -161,9 +199,9 @@ window {
161
199
 
162
200
  [samples/hello/hello_application.rb](/samples/hello/hello_application.rb)
163
201
 
164
- Mac Screenshot:
165
-
166
- ![hello application screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-application.png)
202
+ Linux | Mac | Windows
203
+ ------|-----|--------
204
+ ![hello application screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-application.png) | ![hello application screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-application.png) | ![hello application screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-application.png)
167
205
 
168
206
  Run (via installed gem):
169
207
 
@@ -197,11 +235,9 @@ application('org.glimmer.hello-application', :flags_none) {
197
235
 
198
236
  [samples/hello/hello_button.rb](/samples/hello/hello_button.rb)
199
237
 
200
- Mac Screenshot:
201
-
202
- ![hello button screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button.png)
203
-
204
- ![hello button clicked screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button-clicked.png)
238
+ Linux | Mac | Windows
239
+ ------|-----|--------
240
+ ![hello button screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-button.png) ![hello button clicked screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-button-clicked.png) | ![hello button screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button.png) ![hello button clicked screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button-clicked.png) | ![hello button screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-button.png) ![hello button clicked screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-button-clicked.png)
205
241
 
206
242
  Run (via installed gem):
207
243
 
@@ -244,11 +280,9 @@ window { |w|
244
280
 
245
281
  [samples/hello/hello_entry.rb](/samples/hello/hello_entry.rb)
246
282
 
247
- Mac Screenshot:
248
-
249
- ![hello entry screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry.png)
250
-
251
- ![hello entry submitted screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry-submitted.png)
283
+ Linux | Mac | Windows
284
+ ------|-----|--------
285
+ ![hello entry screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-entry.png) ![hello entry submitted screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-entry-submitted.png) | ![hello entry screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry.png) ![hello entry submitted screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry-submitted.png) | ![hello entry screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-entry.png) ![hello entry submitted screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-entry-submitted.png)
252
286
 
253
287
  Run (via installed gem):
254
288
 
@@ -297,6 +331,484 @@ window { |w|
297
331
  }.show
298
332
  ```
299
333
 
334
+ #### Hello, Drawing Area!
335
+
336
+ This demonstrates the very intuitive (Glimmer-only) declarative cairo shape drawing syntax for the `drawing_area` widget.
337
+
338
+ [samples/hello/hello_drawing_area.rb](/samples/hello/hello_drawing_area.rb)
339
+
340
+ Linux | Mac | Windows
341
+ ------|-----|--------
342
+ ![hello drawing area screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-drawing-area.png) | ![hello drawing area screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-drawing-area.png) | ![hello drawing area screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-drawing-area.png)
343
+
344
+ Run (via installed gem):
345
+
346
+ ```
347
+ ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_drawing_area'"
348
+ ```
349
+
350
+ Run (via locally cloned project):
351
+
352
+ ```
353
+ ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_drawing_area.rb
354
+ ```
355
+
356
+ Code:
357
+
358
+ ```ruby
359
+ require 'glimmer-dsl-gtk'
360
+
361
+ include Glimmer
362
+
363
+ window {
364
+ title 'Hello, Drawing Area!'
365
+ default_size 400, 400
366
+
367
+ drawing_area {
368
+ rectangle(0, 0, 400, 400) {
369
+ fill 255, 255, 255
370
+ }
371
+
372
+ arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90) {
373
+ fill 255, 0, 0
374
+ stroke 0, 128, 255
375
+ line_width 3
376
+ }
377
+
378
+ arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30) {
379
+ fill 255, 0, 0
380
+ stroke 0, 128, 255
381
+ line_width 3
382
+ }
383
+
384
+ circle(85, 285, 45) {
385
+ fill 255, 0, 0
386
+ stroke 0, 128, 255
387
+ line_width 3
388
+ }
389
+
390
+ rectangle(140, 40, 180, 90) {
391
+ fill 255, 255, 0
392
+ stroke 255, 0, 0
393
+ line_width 3
394
+ }
395
+
396
+ rounded_rectangle(140, 140, 180, 90, 30, 20) {
397
+ fill 255, 255, 0
398
+ stroke 255, 0, 0
399
+ line_width 3
400
+ }
401
+
402
+ triangle(140, 240, 320, 240, 230, 330) {
403
+ fill 255, 255, 0
404
+ stroke 255, 0, 0
405
+ line_width 3
406
+ }
407
+
408
+ path {
409
+ move_to 160, 100
410
+ curve_to 190, 60, 200, 80, 210, 70
411
+ curve_to 240, 80, 250, 100, 260, 90
412
+ curve_to 290, 90, 300, 110, 310, 100
413
+
414
+ fill 0, 255, 0
415
+ stroke 0, 0, 255
416
+ line_width 3
417
+ }
418
+
419
+ path {
420
+ move_to 200, 150
421
+ line_to 270, 170
422
+ line_to 250, 220
423
+ line_to 220, 190
424
+ line_to 200, 200
425
+ line_to 180, 170
426
+ close_path
427
+
428
+ fill 0, 255, 0
429
+ stroke 0, 0, 255
430
+ line_width 3
431
+ }
432
+
433
+ polygon(200, 260, 270, 270, 250, 290, 220, 290, 200, 280, 180, 270) {
434
+ fill 0, 255, 0
435
+ stroke 0, 0, 255
436
+ line_width 3
437
+ }
438
+
439
+ polyline(270, 320, 250, 340, 220, 340, 200, 330, 180, 320) {
440
+ stroke 0, 0, 255
441
+ line_width 3
442
+ }
443
+ }
444
+ }.show
445
+ ```
446
+
447
+ #### Hello, Drawing Area (Manual)!
448
+
449
+ This demonstrates the manual (non-Glimmer) imperative cairo shape drawing syntax for the `drawing_area` widget (might be useful in very exceptional rare cases).
450
+
451
+ [samples/hello/hello_drawing_area_manual.rb](/samples/hello/hello_drawing_area_manual.rb)
452
+
453
+ Linux | Mac | Windows
454
+ ------|-----|--------
455
+ ![hello drawing area manual screenshot](/screenshots/glimmer-dsl-gtk-linux-hello-drawing-area-manual.png) | ![hello drawing area manual screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-drawing-area-manual.png) | ![hello drawing area manual screenshot](/screenshots/glimmer-dsl-gtk-windows-hello-drawing-area-manual.png)
456
+
457
+ Run (via installed gem):
458
+
459
+ ```
460
+ ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_drawing_area_manual'"
461
+ ```
462
+
463
+ Run (via locally cloned project):
464
+
465
+ ```
466
+ ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_drawing_area_manual.rb
467
+ ```
468
+
469
+ Code:
470
+
471
+ ```ruby
472
+ require 'glimmer-dsl-gtk'
473
+
474
+ include Glimmer
475
+
476
+ window {
477
+ title 'Hello, Drawing Area (Manual)!'
478
+ default_size 400, 400
479
+
480
+ drawing_area {
481
+ on(:draw) do |drawing_area_widget, cairo_context|
482
+ cairo_context.rectangle(0, 0, 400, 400)
483
+ cairo_context.set_source_rgb(255, 255, 255)
484
+ cairo_context.fill
485
+
486
+ cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
487
+ cairo_context.set_source_rgb(255, 0, 0)
488
+ cairo_context.fill
489
+
490
+ cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
491
+ cairo_context.set_source_rgb(0, 128, 255)
492
+ cairo_context.set_line_width(3)
493
+ cairo_context.stroke
494
+
495
+ cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
496
+ cairo_context.set_source_rgb(255, 0, 0)
497
+ cairo_context.fill
498
+
499
+ cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
500
+ cairo_context.set_source_rgb(0, 128, 255)
501
+ cairo_context.set_line_width(3)
502
+ cairo_context.stroke
503
+
504
+ cairo_context.circle(85, 285, 45)
505
+ cairo_context.set_source_rgb(255, 0, 0)
506
+ cairo_context.fill
507
+
508
+ cairo_context.circle(85, 285, 45)
509
+ cairo_context.set_source_rgb(0, 128, 255)
510
+ cairo_context.set_line_width(3)
511
+ cairo_context.stroke
512
+
513
+ cairo_context.rectangle(140, 40, 180, 90)
514
+ cairo_context.set_source_rgb(255, 255, 0)
515
+ cairo_context.fill
516
+
517
+ cairo_context.rectangle(140, 40, 180, 90)
518
+ cairo_context.set_source_rgb(255, 0, 0)
519
+ cairo_context.set_line_width(3)
520
+ cairo_context.stroke
521
+
522
+ cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
523
+ cairo_context.set_source_rgb(255, 255, 0)
524
+ cairo_context.fill
525
+
526
+ cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
527
+ cairo_context.set_source_rgb(255, 0, 0)
528
+ cairo_context.set_line_width(3)
529
+ cairo_context.stroke
530
+
531
+ cairo_context.triangle(140, 240, 320, 240, 230, 330)
532
+ cairo_context.set_source_rgb(255, 255, 0)
533
+ cairo_context.fill
534
+
535
+ cairo_context.triangle(140, 240, 320, 240, 230, 330)
536
+ cairo_context.set_source_rgb(255, 0, 0)
537
+ cairo_context.set_line_width(3)
538
+ cairo_context.stroke
539
+
540
+ cairo_context.new_path
541
+ cairo_context.move_to 160, 100
542
+ cairo_context.curve_to 190, 60, 200, 80, 210, 70
543
+ cairo_context.curve_to 240, 80, 250, 100, 260, 90
544
+ cairo_context.curve_to 290, 90, 300, 110, 310, 100
545
+ cairo_context.set_source_rgb(0, 255, 0)
546
+ cairo_context.fill
547
+
548
+ cairo_context.new_path
549
+ cairo_context.move_to 160, 100
550
+ cairo_context.curve_to 190, 60, 200, 80, 210, 70
551
+ cairo_context.curve_to 240, 80, 250, 100, 260, 90
552
+ cairo_context.curve_to 290, 90, 300, 110, 310, 100
553
+ cairo_context.set_source_rgb(0, 0, 255)
554
+ cairo_context.stroke
555
+
556
+ cairo_context.new_path
557
+ cairo_context.move_to 200, 150
558
+ cairo_context.line_to 270, 170
559
+ cairo_context.line_to 250, 220
560
+ cairo_context.line_to 220, 190
561
+ cairo_context.line_to 200, 200
562
+ cairo_context.line_to 180, 170
563
+ cairo_context.close_path
564
+ cairo_context.set_source_rgb(0, 255, 0)
565
+ cairo_context.fill
566
+
567
+ cairo_context.new_path
568
+ cairo_context.move_to 200, 150
569
+ cairo_context.line_to 270, 170
570
+ cairo_context.line_to 250, 220
571
+ cairo_context.line_to 220, 190
572
+ cairo_context.line_to 200, 200
573
+ cairo_context.line_to 180, 170
574
+ cairo_context.close_path
575
+ cairo_context.set_source_rgb(0, 0, 255)
576
+ cairo_context.stroke
577
+
578
+ cairo_context.new_path
579
+ cairo_context.move_to 200, 260
580
+ cairo_context.line_to 270, 270
581
+ cairo_context.line_to 250, 290
582
+ cairo_context.line_to 220, 290
583
+ cairo_context.line_to 200, 280
584
+ cairo_context.line_to 180, 270
585
+ cairo_context.close_path
586
+ cairo_context.set_source_rgb(0, 255, 0)
587
+ cairo_context.fill
588
+
589
+ cairo_context.new_path
590
+ cairo_context.move_to 200, 260
591
+ cairo_context.line_to 270, 270
592
+ cairo_context.line_to 250, 290
593
+ cairo_context.line_to 220, 290
594
+ cairo_context.line_to 200, 280
595
+ cairo_context.line_to 180, 270
596
+ cairo_context.close_path
597
+ cairo_context.set_source_rgb(0, 0, 255)
598
+ cairo_context.stroke
599
+
600
+ cairo_context.new_path
601
+ cairo_context.move_to 200, 260
602
+ cairo_context.move_to 270, 320
603
+ cairo_context.line_to 250, 340
604
+ cairo_context.line_to 220, 340
605
+ cairo_context.line_to 200, 330
606
+ cairo_context.line_to 180, 320
607
+ cairo_context.set_source_rgb(0, 0, 255)
608
+ cairo_context.stroke
609
+ end
610
+ }
611
+ }.show
612
+ ```
613
+
614
+ ### Elaborate Samples
615
+
616
+ #### Widget Gallery
617
+
618
+ [samples/elaborate/widget_gallery.rb](/samples/elaborate/widget_gallery.rb)
619
+
620
+ Linux | Mac | Windows
621
+ ------|-----|--------
622
+ ![widget gallery text](/screenshots/glimmer-dsl-gtk-linux-widget-gallery-text.png) ![widget gallery button](/screenshots/glimmer-dsl-gtk-linux-widget-gallery-button.png) ![widget gallery selection](/screenshots/glimmer-dsl-gtk-linux-widget-gallery-selection.png) ![widget gallery organizer](/screenshots/glimmer-dsl-gtk-linux-widget-gallery-organizer.png) ![widget gallery progress](/screenshots/glimmer-dsl-gtk-linux-widget-gallery-progress.png) | ![widget gallery text](/screenshots/glimmer-dsl-gtk-mac-widget-gallery-text.png) ![widget gallery button](/screenshots/glimmer-dsl-gtk-mac-widget-gallery-button.png) ![widget gallery selection](/screenshots/glimmer-dsl-gtk-mac-widget-gallery-selection.png) ![widget gallery organizer](/screenshots/glimmer-dsl-gtk-mac-widget-gallery-organizer.png) ![widget gallery progress](/screenshots/glimmer-dsl-gtk-mac-widget-gallery-progress.png) | ![widget gallery text](/screenshots/glimmer-dsl-gtk-windows-widget-gallery-text.png) ![widget gallery button](/screenshots/glimmer-dsl-gtk-windows-widget-gallery-button.png) ![widget gallery selection](/screenshots/glimmer-dsl-gtk-windows-widget-gallery-selection.png) ![widget gallery organizer](/screenshots/glimmer-dsl-gtk-windows-widget-gallery-organizer.png) ![widget gallery progress](/screenshots/glimmer-dsl-gtk-windows-widget-gallery-progress.png)
623
+
624
+ Run (via installed gem):
625
+
626
+ ```
627
+ ruby -r glimmer-dsl-gtk -e "require 'samples/elaborate/widget_gallery'"
628
+ ```
629
+
630
+ Run (via locally cloned project):
631
+
632
+ ```
633
+ ruby -r ./lib/glimmer-dsl-gtk.rb samples/elaborate/widget_gallery.rb
634
+ ```
635
+
636
+ Code:
637
+
638
+ ```ruby
639
+ require 'glimmer-dsl-gtk'
640
+
641
+ include Glimmer
642
+
643
+ application('org.glimmer.hello-application') {
644
+ on(:activate) do |app|
645
+ application_window(app) {
646
+ title 'Widget Gallery'
647
+
648
+ notebook { |n|
649
+ f1 = frame {
650
+ alignment(1, 1, 1, 1) {
651
+ padding 15, 15, 15, 15
652
+
653
+ box(:vertical) {
654
+ spacing 10
655
+
656
+ label('Entry')
657
+ entry {
658
+ text 'Enter One Line of Text'
659
+ }
660
+
661
+ label('Search Entry')
662
+ search_entry {
663
+ text 'Enter Search Term'
664
+ }
665
+
666
+ label('Spin Button')
667
+ spin_button(1, 100, 1) {
668
+ }
669
+
670
+ label('Combo Box Text')
671
+ cb = combo_box_text {
672
+ }
673
+ 3.times { |n| cb.append_text "Option #{n + 1}" }
674
+ }
675
+ }
676
+ }
677
+ n.set_tab_label_text(f1.gtk, 'Text')
678
+
679
+ f2 = frame {
680
+ alignment(1, 1, 1, 1) {
681
+ padding 15, 15, 15, 15
682
+
683
+ box(:vertical) {
684
+ spacing 10
685
+
686
+ label('Button')
687
+ button('Push Me')
688
+
689
+ label('Radio Button')
690
+ box(:horizontal) {
691
+ rb = radio_button('One')
692
+ radio_button(rb, 'Two')
693
+ radio_button(rb, 'Three')
694
+ }
695
+
696
+ label('Check Button')
697
+ box(:horizontal) {
698
+ check_button('One')
699
+ check_button('Two')
700
+ check_button('Three')
701
+ }
702
+ }
703
+ }
704
+ }
705
+ n.set_tab_label_text(f2.gtk, 'Button')
706
+
707
+ f3 = frame {
708
+ alignment(1, 1, 1, 1) {
709
+ padding 15, 15, 15, 15
710
+
711
+ box(:vertical) {
712
+ spacing 10
713
+
714
+ label('Horizontal Scale')
715
+ h_scale(1, 100, 1) {
716
+ visible true
717
+ }
718
+
719
+ label('Vertical Scale')
720
+ v_scale(1, 100, 1) {
721
+ visible true
722
+ height_request 200
723
+ }
724
+ }
725
+ }
726
+ }
727
+ n.set_tab_label_text(f3.gtk, 'Selection')
728
+
729
+ f4 = frame {
730
+ alignment(1, 1, 1, 1) {
731
+ padding 15, 15, 15, 15
732
+
733
+ box(:vertical) {
734
+ spacing 10
735
+
736
+ label('Expander')
737
+ 3.times do |n|
738
+ expander {
739
+ label "Item #{n + 1}"
740
+
741
+ label("Item #{n + 1} Expanded") {
742
+ }
743
+ }
744
+ end
745
+ }
746
+ }
747
+ }
748
+ n.set_tab_label_text(f4.gtk, 'Organizer')
749
+
750
+ f5 = frame {
751
+ alignment(1, 1, 1, 1) {
752
+ padding 15, 15, 15, 15
753
+
754
+ box(:vertical) {
755
+ spacing 10
756
+
757
+ label('Progress Bar')
758
+ pb = progress_bar {
759
+ text 'Progress Bar'
760
+ }
761
+ Thread.new do
762
+ 101.times.cycle do |n|
763
+ pb.fraction = n / 100.0
764
+ sleep(0.1) # yields back to main GUI thread
765
+ end
766
+ end
767
+
768
+ label('Spinner')
769
+ spinner {
770
+ active true
771
+ }
772
+ }
773
+ }
774
+ }
775
+ n.set_tab_label_text(f5.gtk, 'Progress')
776
+ }
777
+ }.present
778
+ end
779
+ }.run
780
+ ```
781
+
782
+ ## Resources
783
+
784
+ - Ruby-Gnome Project: https://github.com/ruby-gnome/ruby-gnome
785
+ - GTK3 API Documentation: https://gnome.pages.gitlab.gnome.org/gtk/gtk3/
786
+ - GTK3 Widget Gallery: https://docs.gtk.org/gtk3/visual_index.html
787
+
788
+ ## Process
789
+
790
+ [Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
791
+
792
+ ## Help
793
+
794
+ ### Issues
795
+
796
+ If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-gtk/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use GTK than what is possible with [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-gtk/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-gtk/compare) on [GitHub](https://github.com). In the meantime while waiting for a fix, you may try older gem versions of [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk) in case you find one that does not have the issue and actually works.
797
+
798
+ ### Chat
799
+
800
+ If you need live help, try to [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
801
+
802
+ ## Planned Features and Feature Suggestions
803
+
804
+ These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk). You are welcome to contribute more feature suggestions.
805
+
806
+ [TODO.md](TODO.md)
807
+
808
+ ## Change Log
809
+
810
+ [CHANGELOG.md](CHANGELOG.md)
811
+
300
812
  ## Contributing
301
813
 
302
814
  - Check out the latest master to make sure the feature hasn't been
@@ -313,16 +825,6 @@ window { |w|
313
825
  is fine, but please isolate to its own commit so I can cherry-pick
314
826
  around it.
315
827
 
316
- ## Planned Features and Feature Suggestions
317
-
318
- These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk). You are welcome to contribute more feature suggestions.
319
-
320
- [TODO.md](TODO.md)
321
-
322
- ## Change Log
323
-
324
- [CHANGELOG.md](CHANGELOG.md)
325
-
326
828
  ## Contributors
327
829
 
328
830
  * [Andy Maleh](https://github.com/AndyObtiva) (Founder)
@@ -331,7 +833,7 @@ These features have been planned or suggested. You might see them in a future ve
331
833
 
332
834
  ## Copyright
333
835
 
334
- [MIT](LICENSE.txt)
836
+ [LGPL](LICENSE.txt)
335
837
 
336
838
  Copyright (c) 2021 Andy Maleh.
337
839
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2