gtk3 3.1.0-x86-mingw32 → 3.1.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/2.2/gtk3.so +0 -0
- data/lib/2.3/gtk3.so +0 -0
- data/lib/2.4/gtk3.so +0 -0
- data/lib/gtk3/container.rb +2 -7
- data/lib/gtk3/dialog.rb +10 -1
- data/lib/gtk3/loader.rb +0 -14
- data/lib/gtk3/tree-selection.rb +0 -2
- data/lib/gtk3/tree-view-column.rb +34 -8
- data/sample/gtk-demo/TODO +19 -20
- data/sample/gtk-demo/assistant.rb +0 -2
- data/sample/gtk-demo/blendmodes.ui +391 -0
- data/sample/gtk-demo/blends.png +0 -0
- data/sample/gtk-demo/button_box.rb +16 -19
- data/sample/gtk-demo/clipboard.rb +2 -3
- data/sample/gtk-demo/cmy.jpg +0 -0
- data/sample/gtk-demo/colorsel.rb +1 -2
- data/sample/gtk-demo/context_menu_cursor.png +0 -0
- data/sample/gtk-demo/css_accordion.css +1 -1
- data/sample/gtk-demo/css_blendmodes.css +77 -0
- data/sample/gtk-demo/cssview.css +1 -1
- data/sample/gtk-demo/data/16x16/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/16x16/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/demo.gresource.xml +15 -2
- data/sample/gtk-demo/demo.ui +2 -1
- data/sample/gtk-demo/dialog.rb +2 -3
- data/sample/gtk-demo/drawingarea.rb +1 -2
- data/sample/gtk-demo/ducky.png +0 -0
- data/sample/gtk-demo/editable_cells.rb +1 -1
- data/sample/gtk-demo/entry_buffer.rb +1 -1
- data/sample/gtk-demo/entry_completion.rb +1 -1
- data/sample/gtk-demo/filtermodel.ui +15 -6
- data/sample/gtk-demo/fishbowl.ui +49 -0
- data/sample/gtk-demo/{glarea-fragment.glsl → glarea-gl.fs.glsl} +0 -0
- data/sample/gtk-demo/{glarea-vertex.glsl → glarea-gl.vs.glsl} +0 -0
- data/sample/gtk-demo/glarea-gles.fs.glsl +7 -0
- data/sample/gtk-demo/glarea-gles.vs.glsl +7 -0
- data/sample/gtk-demo/glarea.rb +15 -6
- data/sample/gtk-demo/hypertext.rb +0 -1
- data/sample/gtk-demo/images.rb +151 -168
- data/sample/gtk-demo/infobar.rb +5 -3
- data/sample/gtk-demo/links.rb +0 -1
- data/sample/gtk-demo/list_store.rb +1 -1
- data/sample/gtk-demo/listbox.ui +1 -1
- data/sample/gtk-demo/main.rb +4 -1
- data/sample/gtk-demo/markup.rb +2 -0
- data/sample/gtk-demo/menus.rb +0 -2
- data/sample/gtk-demo/no_drop_cursor.png +0 -0
- data/sample/gtk-demo/{cairo-arc-negative.rb → old_demos/cairo-arc-negative.rb} +0 -0
- data/sample/gtk-demo/{cairo-arc.rb → old_demos/cairo-arc.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-image.rb → old_demos/cairo-clip-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-rectangle.rb → old_demos/cairo-clip-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip.rb → old_demos/cairo-clip.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-rectangle.rb → old_demos/cairo-curve-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-to.rb → old_demos/cairo-curve-to.rb} +0 -0
- data/sample/gtk-demo/{cairo-dash.rb → old_demos/cairo-dash.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke.rb → old_demos/cairo-fill-and-stroke.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke2.rb → old_demos/cairo-fill-and-stroke2.rb} +0 -0
- data/sample/gtk-demo/{cairo-gradient.rb → old_demos/cairo-gradient.rb} +0 -0
- data/sample/gtk-demo/{cairo-image-pattern.rb → old_demos/cairo-image-pattern.rb} +0 -0
- data/sample/gtk-demo/{cairo-image.rb → old_demos/cairo-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-cap.rb → old_demos/cairo-line-cap.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-join.rb → old_demos/cairo-line-join.rb} +0 -0
- data/sample/gtk-demo/{cairo-long-lines.rb → old_demos/cairo-long-lines.rb} +0 -0
- data/sample/gtk-demo/{cairo-operator.rb → old_demos/cairo-operator.rb} +0 -0
- data/sample/gtk-demo/{cairo-path.rb → old_demos/cairo-path.rb} +0 -0
- data/sample/gtk-demo/{cairo-pattern-fill.rb → old_demos/cairo-pattern-fill.rb} +0 -0
- data/sample/gtk-demo/{cairo-self-intersect.rb → old_demos/cairo-self-intersect.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-align-center.rb → old_demos/cairo-text-align-center.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-extents.rb → old_demos/cairo-text-extents.rb} +0 -0
- data/sample/gtk-demo/{cairo-text.rb → old_demos/cairo-text.rb} +0 -0
- data/sample/gtk-demo/{changedisplay.rb → old_demos/changedisplay.rb} +0 -0
- data/sample/gtk-demo/{common.rb → old_demos/common.rb} +0 -0
- data/sample/gtk-demo/{item_factory.rb → old_demos/item_factory.rb} +0 -0
- data/sample/gtk-demo/{stock_browser.rb → old_demos/stock_browser.rb} +0 -0
- data/sample/gtk-demo/old_demos/textview.rb +436 -0
- data/sample/gtk-demo/{tree_store.rb → old_demos/tree_store.rb} +0 -0
- data/sample/gtk-demo/panes.rb +2 -3
- data/sample/gtk-demo/pickers.rb +6 -5
- data/sample/gtk-demo/popover.rb +2 -7
- data/sample/gtk-demo/popover.ui +1 -0
- data/sample/gtk-demo/revealer.rb +4 -2
- data/sample/gtk-demo/revealer.ui +0 -1
- data/sample/gtk-demo/scale.ui +7 -1
- data/sample/gtk-demo/search_entry.rb +1 -2
- data/sample/gtk-demo/search_entry2.rb +0 -3
- data/sample/gtk-demo/shortcuts-builder.ui +42 -27
- data/sample/gtk-demo/sizegroup.rb +15 -14
- data/sample/gtk-demo/spinner.rb +1 -1
- data/sample/gtk-demo/textview.rb +358 -382
- data/sample/gtk-demo/theming.ui +0 -29
- data/sample/gtk-demo/theming_style_classes.rb +0 -1
- data/sample/gtk-demo/transparent.rb +0 -1
- data/test/test-gtk-tree-view-column.rb +44 -1
- metadata +77 -63
File without changes
|
data/sample/gtk-demo/panes.rb
CHANGED
@@ -19,14 +19,13 @@ class PanesDemo
|
|
19
19
|
@window = Gtk::Window.new(:toplevel)
|
20
20
|
@window.screen = main_window.screen
|
21
21
|
@window.title = "Paned Widgets"
|
22
|
-
@window.border_width = 0
|
23
22
|
|
24
23
|
vbox = Gtk::Box.new(:vertical, 0)
|
25
24
|
@window.add(vbox)
|
26
25
|
|
27
26
|
vpaned = Gtk::Paned.new(:vertical)
|
28
27
|
vbox.pack_start(vpaned, :expand => true, :fill => true, :padding => 0)
|
29
|
-
vpaned.
|
28
|
+
vpaned.margin = 5
|
30
29
|
|
31
30
|
@hpaned = Gtk::Paned.new(:horizontal)
|
32
31
|
vpaned.add1(@hpaned)
|
@@ -76,7 +75,7 @@ class PanesDemo
|
|
76
75
|
child1 = @hpaned.child1
|
77
76
|
child2 = @hpaned.child2
|
78
77
|
frame = Gtk::Frame.new(frame_label)
|
79
|
-
frame.
|
78
|
+
frame.margin = 4
|
80
79
|
|
81
80
|
@table = Gtk::Grid.new
|
82
81
|
frame.add(@table)
|
data/sample/gtk-demo/pickers.rb
CHANGED
@@ -12,7 +12,6 @@ class PickersDemo
|
|
12
12
|
@window = Gtk::Window.new(:toplevel)
|
13
13
|
@window.screen = main_window.screen
|
14
14
|
@window.title = "Pickers"
|
15
|
-
@window.border_width = 10
|
16
15
|
|
17
16
|
initialize_grid
|
18
17
|
|
@@ -28,6 +27,7 @@ class PickersDemo
|
|
28
27
|
|
29
28
|
label = generate_label("File:")
|
30
29
|
picker = Gtk::FileChooserButton.new("Pick a file", :open)
|
30
|
+
picker.local_only = true
|
31
31
|
@table.attach(label, 0, 2, 1, 1)
|
32
32
|
@table.attach(picker, 1, 2, 1, 1)
|
33
33
|
|
@@ -38,7 +38,7 @@ class PickersDemo
|
|
38
38
|
|
39
39
|
label = generate_label("Mail:")
|
40
40
|
picker = Gtk::AppChooserButton.new("x-scheme-handler/mailto")
|
41
|
-
picker.
|
41
|
+
picker.show_dialog_item = true
|
42
42
|
@table.attach(label, 0, 4, 1, 1)
|
43
43
|
@table.attach(picker, 1, 4, 1, 1)
|
44
44
|
end
|
@@ -58,14 +58,15 @@ class PickersDemo
|
|
58
58
|
@table = Gtk::Grid.new
|
59
59
|
@table.row_spacing = 3
|
60
60
|
@table.column_spacing = 10
|
61
|
+
@table.margin = 20
|
61
62
|
@window.add(@table)
|
62
63
|
end
|
63
64
|
|
64
65
|
def generate_label(label)
|
65
66
|
label = Gtk::Label.new(label)
|
66
|
-
label.
|
67
|
-
label.
|
68
|
-
label.
|
67
|
+
label.halign = :start
|
68
|
+
label.valign = :center
|
69
|
+
label.hexpand = :true
|
69
70
|
label
|
70
71
|
end
|
71
72
|
end
|
data/sample/gtk-demo/popover.rb
CHANGED
@@ -13,7 +13,7 @@ class PopoverDemo
|
|
13
13
|
@window = Gtk::Window.new(:toplevel)
|
14
14
|
@window.screen = main_window.screen
|
15
15
|
box = Gtk::Box.new(:vertical, 24)
|
16
|
-
box.
|
16
|
+
box.margin = 24
|
17
17
|
@window.add(box)
|
18
18
|
|
19
19
|
widget = add_toggle_button_with_popover
|
@@ -39,7 +39,7 @@ class PopoverDemo
|
|
39
39
|
popover = Gtk::Popover.new(parent)
|
40
40
|
popover.position = pos
|
41
41
|
popover.add(child)
|
42
|
-
|
42
|
+
child.margin = 6
|
43
43
|
child.show
|
44
44
|
popover
|
45
45
|
end
|
@@ -51,11 +51,6 @@ class PopoverDemo
|
|
51
51
|
content.parent.remove(content)
|
52
52
|
window.destroy
|
53
53
|
popover = create_popover(parent, content, pos)
|
54
|
-
popover.set_size_request(200, -1)
|
55
|
-
popover.vexpand = true
|
56
|
-
popover.margin_start = 10
|
57
|
-
popover.margin_end = 10
|
58
|
-
popover.margin_bottom = 10
|
59
54
|
popover
|
60
55
|
end
|
61
56
|
|
data/sample/gtk-demo/popover.ui
CHANGED
@@ -59,6 +59,7 @@
|
|
59
59
|
<property name="visible">1</property>
|
60
60
|
<property name="can_focus">1</property>
|
61
61
|
<property name="shadow_type">in</property>
|
62
|
+
<property name="max-content-height">100</property>
|
62
63
|
<child>
|
63
64
|
<object class="GtkTreeView" id="treeview1">
|
64
65
|
<property name="visible">1</property>
|
data/sample/gtk-demo/revealer.rb
CHANGED
@@ -45,8 +45,10 @@ class RevealerDemo
|
|
45
45
|
revealer.reveal_child = true
|
46
46
|
|
47
47
|
revealer.signal_connect "notify::child-revealed" do |widget|
|
48
|
-
|
49
|
-
|
48
|
+
if widget.mapped?
|
49
|
+
revealed = widget.child_revealed?
|
50
|
+
widget.reveal_child = !revealed
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
@count += 1
|
data/sample/gtk-demo/revealer.ui
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
<interface>
|
3
3
|
<!-- interface-requires gtk+ 3.6 -->
|
4
4
|
<object class="GtkWindow" id="window">
|
5
|
-
<property name="border_width">5</property>
|
6
5
|
<property name="default_width">300</property>
|
7
6
|
<property name="default_height">300</property>
|
8
7
|
<property name="title">Revealer</property>
|
data/sample/gtk-demo/scale.ui
CHANGED
@@ -4,23 +4,29 @@
|
|
4
4
|
<object class="GtkAdjustment" id="adjustment1">
|
5
5
|
<property name="upper">4</property>
|
6
6
|
<property name="value">2</property>
|
7
|
+
<property name="step-increment">0.1</property>
|
8
|
+
<property name="page-increment">1</property>
|
7
9
|
</object>
|
8
10
|
<object class="GtkAdjustment" id="adjustment2">
|
9
11
|
<property name="upper">4</property>
|
10
12
|
<property name="value">2</property>
|
13
|
+
<property name="step-increment">0.1</property>
|
14
|
+
<property name="page-increment">1</property>
|
11
15
|
</object>
|
12
16
|
<object class="GtkAdjustment" id="adjustment3">
|
13
17
|
<property name="upper">4</property>
|
14
18
|
<property name="value">2</property>
|
19
|
+
<property name="step-increment">0.1</property>
|
20
|
+
<property name="page-increment">1</property>
|
15
21
|
</object>
|
16
22
|
<object class="GtkWindow" id="window1">
|
17
23
|
<property name="title" translatable="yes">Scales</property>
|
18
|
-
<property name="border-width" translatable="yes">20</property>
|
19
24
|
<child>
|
20
25
|
<object class="GtkGrid" id="grid1">
|
21
26
|
<property name="visible">1</property>
|
22
27
|
<property name="row-spacing">10</property>
|
23
28
|
<property name="column-spacing">10</property>
|
29
|
+
<property name="margin">20</property>
|
24
30
|
<child>
|
25
31
|
<object class="GtkLabel">
|
26
32
|
<property name="visible">1</property>
|
@@ -40,7 +40,7 @@ class SearchEntryDemo
|
|
40
40
|
def initialize_box
|
41
41
|
@vbox = Gtk::Box.new(:vertical, 5)
|
42
42
|
@window.add(@vbox)
|
43
|
-
@vbox.
|
43
|
+
@vbox.margin = 5
|
44
44
|
|
45
45
|
label = Gtk::Label.new("")
|
46
46
|
label.markup = "Search entry demo"
|
@@ -48,7 +48,6 @@ class SearchEntryDemo
|
|
48
48
|
|
49
49
|
@hbox = Gtk::Box.new(:horizontal, 10)
|
50
50
|
@vbox.pack_start(@hbox, :expand => true, :fill => true, :padding => 0)
|
51
|
-
@hbox.border_width = 0
|
52
51
|
end
|
53
52
|
|
54
53
|
def initialize_entry
|
@@ -61,7 +61,6 @@ class SearchEntry2Demo
|
|
61
61
|
def initialize_vbox
|
62
62
|
@vbox = Gtk::Box.new(:vertical, 0)
|
63
63
|
@window.add(@vbox)
|
64
|
-
@vbox.border_width = 0
|
65
64
|
end
|
66
65
|
|
67
66
|
def initialize_help_label
|
@@ -81,7 +80,6 @@ class SearchEntry2Demo
|
|
81
80
|
def initialize_result_hbox
|
82
81
|
hbox = Gtk::Box.new(:horizontal, 10)
|
83
82
|
@vbox.pack_start(hbox, :expand => true, :fill => true, :padding => 0)
|
84
|
-
hbox.border_width = 0
|
85
83
|
|
86
84
|
# Result
|
87
85
|
label = Gtk::Label.new("Result:")
|
@@ -101,7 +99,6 @@ class SearchEntry2Demo
|
|
101
99
|
def initialize_signal_hbox
|
102
100
|
hbox = Gtk::Box.new(:horizontal, 10)
|
103
101
|
@vbox.pack_start(hbox, :expand => true, :fill => true, :padding => 0)
|
104
|
-
hbox.border_width = 0
|
105
102
|
|
106
103
|
label = Gtk::Label.new("Signal:")
|
107
104
|
label.xalign = 0.0
|
@@ -375,6 +375,7 @@
|
|
375
375
|
<child>
|
376
376
|
<object class="GtkShortcutsSection">
|
377
377
|
<property name="visible">1</property>
|
378
|
+
<property name="max-height">16</property>
|
378
379
|
<property name="section-name">terminal</property>
|
379
380
|
<property name="title" translatable="yes">Terminal Shortcuts</property>
|
380
381
|
<child>
|
@@ -452,6 +453,43 @@
|
|
452
453
|
</object>
|
453
454
|
</child>
|
454
455
|
|
456
|
+
<child>
|
457
|
+
<object class="GtkShortcutsGroup">
|
458
|
+
<property name="visible">1</property>
|
459
|
+
<property name="title" translatable="yes">'Special' combinations</property>
|
460
|
+
|
461
|
+
<child>
|
462
|
+
<object class="GtkShortcutsShortcut">
|
463
|
+
<property name="visible">1</property>
|
464
|
+
<property name="accelerator">t+t</property>
|
465
|
+
<property name="title" translatable="yes">You want tea ?</property>
|
466
|
+
</object>
|
467
|
+
</child>
|
468
|
+
<child>
|
469
|
+
<object class="GtkShortcutsShortcut">
|
470
|
+
<property name="visible">1</property>
|
471
|
+
<property name="accelerator"><shift><ctrl></property>
|
472
|
+
<property name="title" translatable="yes">Shift Control</property>
|
473
|
+
</object>
|
474
|
+
</child>
|
475
|
+
<child>
|
476
|
+
<object class="GtkShortcutsShortcut">
|
477
|
+
<property name="visible">1</property>
|
478
|
+
<property name="accelerator"><ctrl>&<ctrl></property>
|
479
|
+
<property name="title" translatable="yes">Control Control</property>
|
480
|
+
</object>
|
481
|
+
</child>
|
482
|
+
<child>
|
483
|
+
<object class="GtkShortcutsShortcut">
|
484
|
+
<property name="visible">1</property>
|
485
|
+
<property name="accelerator">Control_L&Control_R</property>
|
486
|
+
<property name="title" translatable="yes">Left and right control</property>
|
487
|
+
</object>
|
488
|
+
</child>
|
489
|
+
|
490
|
+
</object>
|
491
|
+
</child>
|
492
|
+
|
455
493
|
<child>
|
456
494
|
<object class="GtkShortcutsGroup">
|
457
495
|
<property name="visible">1</property>
|
@@ -499,41 +537,18 @@
|
|
499
537
|
<property name="title" translatable="yes">A stock swipe gesture</property>
|
500
538
|
</object>
|
501
539
|
</child>
|
502
|
-
|
503
|
-
</object>
|
504
|
-
</child>
|
505
|
-
|
506
|
-
<child>
|
507
|
-
<object class="GtkShortcutsGroup">
|
508
|
-
<property name="visible">1</property>
|
509
|
-
<property name="title" translatable="yes">'Special' combinations</property>
|
510
|
-
|
511
540
|
<child>
|
512
541
|
<object class="GtkShortcutsShortcut">
|
513
542
|
<property name="visible">1</property>
|
514
|
-
<property name="
|
515
|
-
<property name="title" translatable="yes">
|
516
|
-
</object>
|
517
|
-
</child>
|
518
|
-
<child>
|
519
|
-
<object class="GtkShortcutsShortcut">
|
520
|
-
<property name="visible">1</property>
|
521
|
-
<property name="accelerator"><shift><ctrl></property>
|
522
|
-
<property name="title" translatable="yes">Shift Control</property>
|
523
|
-
</object>
|
524
|
-
</child>
|
525
|
-
<child>
|
526
|
-
<object class="GtkShortcutsShortcut">
|
527
|
-
<property name="visible">1</property>
|
528
|
-
<property name="accelerator"><ctrl>&<ctrl></property>
|
529
|
-
<property name="title" translatable="yes">Control Control</property>
|
543
|
+
<property name="shortcut-type">gesture-swipe-left</property>
|
544
|
+
<property name="title" translatable="yes">A stock swipe gesture</property>
|
530
545
|
</object>
|
531
546
|
</child>
|
532
547
|
<child>
|
533
548
|
<object class="GtkShortcutsShortcut">
|
534
549
|
<property name="visible">1</property>
|
535
|
-
<property name="
|
536
|
-
<property name="title" translatable="yes">
|
550
|
+
<property name="shortcut-type">gesture-swipe-right</property>
|
551
|
+
<property name="title" translatable="yes">A stock swipe gesture</property>
|
537
552
|
</object>
|
538
553
|
</child>
|
539
554
|
|
@@ -29,7 +29,7 @@ class SizegroupDemo
|
|
29
29
|
|
30
30
|
@vbox = Gtk::Box.new(:vertical, 5)
|
31
31
|
@window.add(@vbox)
|
32
|
-
@vbox.
|
32
|
+
@vbox.margin = 5
|
33
33
|
|
34
34
|
size_group = Gtk::SizeGroup.new(:horizontal)
|
35
35
|
|
@@ -45,15 +45,16 @@ class SizegroupDemo
|
|
45
45
|
|
46
46
|
# And a check button to turn grouping on and off
|
47
47
|
check_button = Gtk::CheckButton.new("_Enable grouping")
|
48
|
-
check_button.
|
48
|
+
check_button.use_underline = true
|
49
|
+
check_button.active = true
|
49
50
|
@vbox.pack_start(check_button,
|
50
51
|
:expand => false, :fill => false, :padding => 0)
|
51
52
|
|
52
53
|
check_button.signal_connect("toggled") do |widget|
|
53
54
|
if widget.active?
|
54
|
-
size_group.
|
55
|
+
size_group.mode = :horizontal
|
55
56
|
else
|
56
|
-
size_group.
|
57
|
+
size_group.mode = :none
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
@@ -74,24 +75,24 @@ class SizegroupDemo
|
|
74
75
|
@vbox.pack_start(frame, :expand => false, :fill => false, :padding => 0)
|
75
76
|
|
76
77
|
table = Gtk::Grid.new
|
77
|
-
table.
|
78
|
-
table.
|
79
|
-
table.
|
78
|
+
table.margin = 5
|
79
|
+
table.row_spacing = 5
|
80
|
+
table.column_spacing = 10
|
80
81
|
frame.add(table)
|
81
82
|
table
|
82
83
|
end
|
83
84
|
|
84
85
|
def add_row(table, row, size_group, label_text, options)
|
85
86
|
label = Gtk::Label.new(label_text, :use_underline => true)
|
86
|
-
label.
|
87
|
-
label.
|
88
|
-
label.
|
87
|
+
label.halign = :start
|
88
|
+
label.valign = :baseline
|
89
|
+
label.hexpand = true
|
89
90
|
table.attach(label, 0, row, 1, 1)
|
90
91
|
|
91
92
|
combo_box = create_combo_box(options)
|
92
|
-
label.
|
93
|
-
combo_box.
|
94
|
-
combo_box.
|
93
|
+
label.mnemonic_widget = combo_box
|
94
|
+
combo_box.halign = :end
|
95
|
+
combo_box.valign = :baseline
|
95
96
|
size_group.add_widget(combo_box)
|
96
97
|
table.attach(combo_box, 1, row, 1, 1)
|
97
98
|
end
|
@@ -101,7 +102,7 @@ class SizegroupDemo
|
|
101
102
|
options.each do |o|
|
102
103
|
combo_box.append_text(o)
|
103
104
|
end
|
104
|
-
combo_box.
|
105
|
+
combo_box.active = 0
|
105
106
|
combo_box
|
106
107
|
end
|
107
108
|
end
|
data/sample/gtk-demo/spinner.rb
CHANGED
data/sample/gtk-demo/textview.rb
CHANGED
@@ -1,436 +1,412 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team
|
1
|
+
# Copyright (c) 2017 Ruby-GNOME2 Project Team
|
3
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
4
3
|
#
|
5
|
-
# $Id: textview.rb,v 1.8 2005/02/06 18:25:13 kzys Exp $
|
6
4
|
=begin
|
7
|
-
=
|
5
|
+
= Text View/Multiple Views
|
8
6
|
|
9
|
-
The
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
=end
|
14
|
-
require 'common'
|
15
|
-
|
16
|
-
module Demo
|
17
|
-
class TextView < BasicWindow
|
18
|
-
|
19
|
-
GRAY50_WIDTH = 2
|
20
|
-
GRAY50_HEIGHT = 2
|
21
|
-
GRAY50_BITS = [0x02, 0x01].pack("c")
|
22
|
-
@@nest_window = nil
|
23
|
-
|
24
|
-
def initialize
|
25
|
-
super("TextView Window")
|
26
|
-
|
27
|
-
set_default_size(450, 450)
|
28
|
-
|
29
|
-
set_title("TextView")
|
30
|
-
set_border_width(0)
|
31
|
-
|
32
|
-
vpaned = Gtk::VPaned.new
|
33
|
-
vpaned.set_border_width(5)
|
34
|
-
add(vpaned)
|
35
|
-
##
|
36
|
-
# For convenience, we just use the autocreated buffer from
|
37
|
-
# the first text view; you could also create the buffer
|
38
|
-
# by itself with Gtk::TextBuffer.new, then later create
|
39
|
-
# a view widget.
|
40
|
-
#
|
41
|
-
view1 = Gtk::TextView.new
|
42
|
-
buffer = view1.buffer
|
43
|
-
view2 = Gtk::TextView.new(buffer)
|
44
|
-
|
45
|
-
sw = Gtk::ScrolledWindow.new(nil, nil)
|
46
|
-
sw.set_policy(:automatic,
|
47
|
-
:automatic)
|
48
|
-
vpaned.add1(sw)
|
49
|
-
|
50
|
-
sw.add(view1)
|
51
|
-
|
52
|
-
sw = Gtk::ScrolledWindow.new(nil, nil)
|
53
|
-
sw.set_policy(:automatic,
|
54
|
-
:automatic)
|
55
|
-
vpaned.add2(sw)
|
56
|
-
|
57
|
-
sw.add(view2)
|
58
|
-
|
59
|
-
create_tags(buffer)
|
60
|
-
insert_text(buffer)
|
61
|
-
|
62
|
-
attach_widgets(view1)
|
63
|
-
attach_widgets(view2)
|
64
|
-
|
65
|
-
vpaned.show_all
|
66
|
-
|
67
|
-
self.show
|
68
|
-
end
|
69
|
-
|
70
|
-
def create_tags(buffer)
|
71
|
-
##
|
72
|
-
# Create a bunch of tags. Note that it's also possible to
|
73
|
-
# create tags with Gtk::TextTag.new then add them to the
|
74
|
-
# tag table for the buffer, Gtk::TextBuffer#create_tag is
|
75
|
-
# just a convenience function. Also note that you don't have
|
76
|
-
# to give tags a name; pass NULL for the name to create an
|
77
|
-
# anonymous tag.
|
78
|
-
#
|
79
|
-
# In any real app, another useful optimization would be to create
|
80
|
-
# a Gtk::TextTagTable in advance, and reuse the same tag table for
|
81
|
-
# all the buffers with the same tag set, instead of creating
|
82
|
-
# new copies of the same tags for every buffer.
|
83
|
-
#
|
84
|
-
# Tags are assigned default priorities in order of addition to the
|
85
|
-
# tag table. That is, tags created later that affect the same text
|
86
|
-
# property affected by an earlier tag will override the earlier
|
87
|
-
# tag. You can modify tag priorities with
|
88
|
-
# Gtk::TextTag#set_priority.
|
89
|
-
#
|
90
|
-
|
91
|
-
buffer.create_tag('heading',
|
92
|
-
'weight' => Pango::FontDescription::WEIGHT_BOLD,
|
93
|
-
'size' => 15 * Pango::SCALE)
|
94
|
-
|
95
|
-
buffer.create_tag("italic",
|
96
|
-
"style" => Pango::FontDescription::STYLE_ITALIC)
|
97
|
-
|
98
|
-
buffer.create_tag("bold",
|
99
|
-
"weight" => Pango::FontDescription::WEIGHT_BOLD)
|
100
|
-
|
101
|
-
buffer.create_tag("big",
|
102
|
-
# points times the PANGO_SCALE factor
|
103
|
-
"size" => 20 * Pango::SCALE)
|
7
|
+
The GtkTextView widget displays a GtkTextBuffer. One GtkTextBuffer
|
8
|
+
can be displayed by multiple GtkTextViews. This demo has two views
|
9
|
+
displaying a single buffer, and shows off the widget's text
|
10
|
+
formatting features.
|
104
11
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
buffer.create_tag("blue_foreground", "foreground" => "blue")
|
114
|
-
|
115
|
-
buffer.create_tag("red_background", "background" => "red")
|
116
|
-
|
117
|
-
stipple = Gdk::Pixmap.create_from_data(nil, GRAY50_BITS, GRAY50_WIDTH,
|
118
|
-
GRAY50_HEIGHT)
|
119
|
-
|
120
|
-
buffer.create_tag("background_stipple",
|
121
|
-
"background_stipple" => stipple)
|
122
|
-
|
123
|
-
buffer.create_tag("foreground_stipple",
|
124
|
-
"foreground_stipple" => stipple)
|
125
|
-
|
126
|
-
buffer.create_tag("big_gap_before_line",
|
127
|
-
"pixels_above_lines" => 30)
|
128
|
-
|
129
|
-
buffer.create_tag("big_gap_after_line",
|
130
|
-
"pixels_below_lines" => 30)
|
131
|
-
|
132
|
-
buffer.create_tag("double_spaced_line",
|
133
|
-
"pixels_inside_wrap" => 10)
|
134
|
-
|
135
|
-
buffer.create_tag("not_editable",
|
136
|
-
"editable" => false)
|
137
|
-
|
138
|
-
buffer.create_tag("word_wrap",
|
139
|
-
"wrap_mode" => :word)
|
140
|
-
|
141
|
-
buffer.create_tag("char_wrap",
|
142
|
-
"wrap_mode" => Gtk::TextTag::WRAP_CHAR)
|
143
|
-
|
144
|
-
buffer.create_tag("no_wrap",
|
145
|
-
"wrap_mode" => :none)
|
12
|
+
=end
|
13
|
+
class TextviewDemo
|
14
|
+
def initialize(main_window)
|
15
|
+
@window = Gtk::Window.new(:toplevel)
|
16
|
+
@window.screen = main_window.screen
|
17
|
+
@window.set_default_size(450, 450)
|
18
|
+
@window.title = "Multiple Views"
|
146
19
|
|
147
|
-
|
148
|
-
|
20
|
+
vpaned = Gtk::Paned.new(:vertical)
|
21
|
+
@window.add(vpaned)
|
149
22
|
|
150
|
-
|
151
|
-
|
23
|
+
# For convenience, we just use the autocreated buffer from
|
24
|
+
# the first text view; you could also create the buffer
|
25
|
+
# by itself Gtk::TextBuffer.new, then later create a view
|
26
|
+
# widget.
|
152
27
|
|
153
|
-
|
154
|
-
|
155
|
-
"right_margin" => 50)
|
28
|
+
view1 = Gtk::TextView.new
|
29
|
+
view2 = Gtk::TextView.new(view1.buffer)
|
156
30
|
|
157
|
-
|
158
|
-
|
31
|
+
sw = Gtk::ScrolledWindow.new
|
32
|
+
sw.set_policy(:automatic, :automatic)
|
33
|
+
vpaned.add1(sw)
|
34
|
+
sw.add(view1)
|
159
35
|
|
160
|
-
|
161
|
-
|
36
|
+
sw = Gtk::ScrolledWindow.new
|
37
|
+
sw.set_policy(:automatic, :automatic)
|
38
|
+
vpaned.add2(sw)
|
39
|
+
sw.add(view2)
|
162
40
|
|
163
|
-
|
164
|
-
|
41
|
+
create_tags(view1.buffer)
|
42
|
+
insert_text(view1.buffer)
|
165
43
|
|
166
|
-
|
167
|
-
|
168
|
-
"size" => 8 * Pango::SCALE) # 8 points
|
44
|
+
attach_widgets(view1)
|
45
|
+
attach_widgets(view2)
|
169
46
|
|
170
|
-
|
171
|
-
|
172
|
-
"size" => 8 * Pango::SCALE) # 8 points
|
47
|
+
vpaned.show_all
|
48
|
+
end
|
173
49
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
"right_margin" => 20)
|
50
|
+
def run
|
51
|
+
if !@window.visible?
|
52
|
+
@window.show_all
|
53
|
+
else
|
54
|
+
@window.destroy
|
180
55
|
end
|
56
|
+
@window
|
57
|
+
end
|
181
58
|
|
182
|
-
|
183
|
-
|
184
|
-
##
|
185
|
-
# Demo.find_file looks in the the current directory first,
|
186
|
-
# so you can run gtk-demo without installing GTK, then looks
|
187
|
-
# in the location where the file is installed.
|
188
|
-
#
|
189
|
-
|
190
|
-
filename = Demo.find_file("gtk-logo-rgb.gif")
|
191
|
-
pixbuf = Gdk::Pixbuf.new(filename) if filename
|
192
|
-
|
193
|
-
unless pixbuf
|
194
|
-
$stderr.print "Failed to load image file gtk-logo-rgb.gif\n"
|
195
|
-
exit 1
|
196
|
-
end
|
197
|
-
|
198
|
-
scaled = pixbuf.scale(32, 32, Gdk::Pixbuf::INTERP_BILINEAR)
|
199
|
-
pixbuf = scaled
|
200
|
-
|
201
|
-
##
|
202
|
-
# get start of buffer; each insertion will revalidate the
|
203
|
-
# iterator to point to just after the inserted text.
|
204
|
-
#
|
205
|
-
|
206
|
-
iter = buffer.get_iter_at(:offset => 0)
|
207
|
-
|
208
|
-
buffer.insert(iter, "The text widget can display text with all kinds of nifty attributes. It also supports multiple views of the same buffer; this demo is showing the same buffer in two places.\n\n")
|
209
|
-
|
210
|
-
buffer.insert(iter, "Font styles. ", 'heading')
|
211
|
-
|
212
|
-
buffer.insert(iter, "For example, you can have ")
|
213
|
-
buffer.insert(iter, "italic", "italic")
|
214
|
-
buffer.insert(iter, ", ")
|
215
|
-
buffer.insert(iter, "bold", "bold")
|
216
|
-
buffer.insert(iter, ", or ")
|
217
|
-
buffer.insert(iter, "monospace(typewriter)", "monospace")
|
218
|
-
buffer.insert(iter, ", or ")
|
219
|
-
buffer.insert(iter, "big", "big")
|
220
|
-
buffer.insert(iter, " text. ")
|
221
|
-
buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ")
|
222
|
-
buffer.insert(iter, "xx-small", "xx-small")
|
223
|
-
buffer.insert(iter, " or ")
|
224
|
-
buffer.insert(iter, "x-large", "x-large")
|
225
|
-
buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n")
|
226
|
-
|
227
|
-
buffer.insert(iter, "Colors. ", "heading")
|
228
|
-
|
229
|
-
buffer.insert(iter, "Colors such as ")
|
230
|
-
buffer.insert(iter, "a blue foreground", "blue_foreground")
|
231
|
-
buffer.insert(iter, " or ")
|
232
|
-
buffer.insert(iter, "a red background", "red_background")
|
233
|
-
buffer.insert(iter, " or even ")
|
234
|
-
buffer.insert(iter, "a stippled red background",
|
235
|
-
"red_background", "background_stipple")
|
236
|
-
|
237
|
-
buffer.insert(iter, " or ")
|
238
|
-
buffer.insert(iter, "a stippled blue foreground on solid red background",
|
239
|
-
"blue_foreground", "red_background", "foreground_stipple")
|
59
|
+
private
|
240
60
|
|
241
|
-
|
61
|
+
def create_tags(buffer)
|
62
|
+
# Create a bunch of tags. Note that it's also possible to
|
63
|
+
# create tags with Gtk::TextTag.new then add them to the
|
64
|
+
# tag table for the buffer, Gtk::TextBuffer.create_tag is
|
65
|
+
# just a convenience function. Also note that you don't have
|
66
|
+
# to give tags a name; pass NULL for the name to create an
|
67
|
+
# anonymous tag.
|
68
|
+
#
|
69
|
+
# In any real app, another useful optimization would be to create
|
70
|
+
# a Gtk::TextTagTable in advance, and reuse the same tag table for
|
71
|
+
# all the buffers with the same tag set, instead of creating
|
72
|
+
# new copies of the same tags for every buffer.
|
73
|
+
#
|
74
|
+
# Tags are assigned default priorities in order of addition to the
|
75
|
+
# tag table. That is, tags created later that affect the same text
|
76
|
+
# property affected by an earlier tag will override the earlier
|
77
|
+
# tag. You can modify tag priorities with
|
78
|
+
# Gtk::TextTag.priority=.
|
242
79
|
|
243
|
-
|
80
|
+
buffer.create_tag("heading",
|
81
|
+
"weight" => Pango::WEIGHT_BOLD,
|
82
|
+
"size" => 15 * Pango::SCALE)
|
244
83
|
|
245
|
-
|
246
|
-
|
247
|
-
buffer.insert(iter, "underline", "underline")
|
248
|
-
buffer.insert(iter, ", ")
|
249
|
-
buffer.insert(iter, "double underline", "double_underline")
|
250
|
-
buffer.insert(iter, ", ")
|
251
|
-
buffer.insert(iter, "superscript", "superscript")
|
252
|
-
buffer.insert(iter, ", and ")
|
253
|
-
buffer.insert(iter, "subscript", "subscript")
|
254
|
-
buffer.insert(iter, " are all supported.\n\n")
|
84
|
+
buffer.create_tag("italic",
|
85
|
+
"style" => Pango::STYLE_ITALIC)
|
255
86
|
|
256
|
-
|
87
|
+
buffer.create_tag("bold",
|
88
|
+
"weight" => Pango::WEIGHT_BOLD)
|
257
89
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
buffer.insert(iter, pixbuf)
|
262
|
-
buffer.insert(iter, " for example.\n\n")
|
90
|
+
buffer.create_tag("big",
|
91
|
+
# points times the PANGO_SCALE factor
|
92
|
+
"size" => 20 * Pango::SCALE)
|
263
93
|
|
264
|
-
|
94
|
+
buffer.create_tag("xx-small",
|
95
|
+
"scale" => Pango::AttrScale::XX_SMALL)
|
265
96
|
|
266
|
-
|
97
|
+
buffer.create_tag("x-large",
|
98
|
+
"scale" => Pango::AttrScale::X_LARGE)
|
267
99
|
|
268
|
-
|
269
|
-
"big_gap_before_line", "wide_margins")
|
270
|
-
buffer.insert(iter, "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n",
|
271
|
-
"big_gap_after_line", "wide_margins")
|
100
|
+
buffer.create_tag("monospace", "family" => "monospace")
|
272
101
|
|
273
|
-
|
274
|
-
"double_spaced_line", "wide_margins")
|
102
|
+
buffer.create_tag("blue_foreground", "foreground" => "blue")
|
275
103
|
|
276
|
-
|
104
|
+
buffer.create_tag("red_background", "background" => "red")
|
277
105
|
|
278
|
-
|
106
|
+
buffer.create_tag("big_gap_before_line",
|
107
|
+
"pixels_above_lines" => 30)
|
279
108
|
|
280
|
-
|
281
|
-
|
109
|
+
buffer.create_tag("big_gap_after_line",
|
110
|
+
"pixels_below_lines" => 30)
|
282
111
|
|
283
|
-
|
112
|
+
buffer.create_tag("double_spaced_line",
|
113
|
+
"pixels_inside_wrap" => 10)
|
284
114
|
|
285
|
-
|
115
|
+
buffer.create_tag("not_editable",
|
116
|
+
"editable" => false)
|
286
117
|
|
287
|
-
|
118
|
+
buffer.create_tag("word_wrap",
|
119
|
+
"wrap_mode" => :word)
|
288
120
|
|
289
|
-
|
121
|
+
buffer.create_tag("char_wrap",
|
122
|
+
"wrap_mode" => :char)
|
290
123
|
|
291
|
-
|
124
|
+
buffer.create_tag("no_wrap",
|
125
|
+
"wrap_mode" => :none)
|
292
126
|
|
293
|
-
|
127
|
+
buffer.create_tag("center",
|
128
|
+
"justification" => :center)
|
294
129
|
|
295
|
-
|
296
|
-
|
130
|
+
buffer.create_tag("right_justify",
|
131
|
+
"justification" => :right)
|
297
132
|
|
298
|
-
|
133
|
+
buffer.create_tag("wide_margins",
|
134
|
+
"left_margin" => 50,
|
135
|
+
"right_margin" => 50)
|
299
136
|
|
300
|
-
|
137
|
+
buffer.create_tag("strikethrough",
|
138
|
+
"strikethrough" => true)
|
301
139
|
|
302
|
-
|
140
|
+
buffer.create_tag("underline",
|
141
|
+
"underline" => Pango::UNDERLINE_SINGLE)
|
303
142
|
|
304
|
-
|
305
|
-
|
143
|
+
buffer.create_tag("double_underline",
|
144
|
+
"underline" => Pango::UNDERLINE_DOUBLE)
|
306
145
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
anchor = buffer.create_child_anchor(iter)
|
311
|
-
buffer.insert(iter, " and a scale: ")
|
312
|
-
anchor = buffer.create_child_anchor(iter)
|
313
|
-
buffer.insert(iter, " and an animation: ")
|
314
|
-
anchor = buffer.create_child_anchor(iter)
|
315
|
-
buffer.insert(iter, " finally a text entry: ")
|
316
|
-
anchor = buffer.create_child_anchor(iter)
|
317
|
-
buffer.insert(iter, ".\n")
|
146
|
+
buffer.create_tag("superscript",
|
147
|
+
"rise" => 10 * Pango::SCALE, # 10 pixels
|
148
|
+
"size" => 8 * Pango::SCALE) # 8 points
|
318
149
|
|
319
|
-
|
150
|
+
buffer.create_tag("subscript",
|
151
|
+
"rise" => -10 * Pango::SCALE, # 10 pixels
|
152
|
+
"size" => 8 * Pango::SCALE) # 8 points
|
320
153
|
|
321
|
-
|
154
|
+
buffer.create_tag("rtl_quote",
|
155
|
+
"wrap_mode" => :word,
|
156
|
+
"direction" => Gtk::TextDirection::RTL,
|
157
|
+
"indent" => 30,
|
158
|
+
"left_margin" => 20,
|
159
|
+
"right_margin" => 20)
|
160
|
+
end
|
322
161
|
|
323
|
-
|
324
|
-
|
325
|
-
|
162
|
+
def insert_text(buffer)
|
163
|
+
icon_theme = Gtk::IconTheme.default
|
164
|
+
pixbuf = icon_theme.load_icon("gtk3-demo", 32, :generic_fallback)
|
165
|
+
|
166
|
+
# get start of buffer; each insertion will revalidate the
|
167
|
+
# iterator to point to just after the inserted text.
|
168
|
+
|
169
|
+
iter = buffer.get_iter_at(:offset => 0)
|
170
|
+
buffer.insert(iter, <<TEXT)
|
171
|
+
The text widget can display text with all kinds of nifty attributes. It \
|
172
|
+
also supports multiple views of the same buffer; this demo is showing the \
|
173
|
+
same buffer in two places.
|
174
|
+
TEXT
|
175
|
+
buffer.insert(iter, "Font styles. ", :tags => ["heading"])
|
176
|
+
buffer.insert(iter, "For example, you can have ")
|
177
|
+
buffer.insert(iter, "italic", :tags => ["italic"])
|
178
|
+
buffer.insert(iter, ", ")
|
179
|
+
buffer.insert(iter, "bold", :tags => ["bold"])
|
180
|
+
buffer.insert(iter, ", or ")
|
181
|
+
buffer.insert(iter, "monospace(typewriter)", :tags => ["monospace"])
|
182
|
+
buffer.insert(iter, ", or ")
|
183
|
+
buffer.insert(iter, "big", :tags => ["big"])
|
184
|
+
buffer.insert(iter, " text. ")
|
185
|
+
buffer.insert(iter, "It's best not to hardcode specific text sizes; you can\
|
186
|
+
use relative sizes as with CSS, such as ")
|
187
|
+
buffer.insert(iter, "xx-small", :tags => ["xx-small"])
|
188
|
+
buffer.insert(iter, " or ")
|
189
|
+
buffer.insert(iter, "x-large", :tags => ["x-large"])
|
190
|
+
buffer.insert(iter, " to ensure that your program properly adapts if the \
|
191
|
+
user changes the default font size.\n\n")
|
192
|
+
|
193
|
+
buffer.insert(iter, "Colors. ", :tags => ["heading"])
|
194
|
+
|
195
|
+
buffer.insert(iter, "Colors such as ")
|
196
|
+
buffer.insert(iter, "a blue foreground", :tags => ["blue_foreground"])
|
197
|
+
buffer.insert(iter, " or ")
|
198
|
+
buffer.insert(iter, "a red background", :tags => ["red_background"])
|
199
|
+
buffer.insert(iter, " or even ")
|
200
|
+
buffer.insert(iter, "a blue foreground on red background",
|
201
|
+
:tags => %w(blue_foreground red_background))
|
202
|
+
|
203
|
+
buffer.insert(iter, "(select that to read it) can be used.\n\n")
|
204
|
+
|
205
|
+
buffer.insert(iter, "Underline, strikethrough, and rise. ",
|
206
|
+
:tags => ["heading"])
|
207
|
+
|
208
|
+
buffer.insert(iter, "Strikethrough", :tags => ["strikethrough"])
|
209
|
+
buffer.insert(iter, ", ")
|
210
|
+
buffer.insert(iter, "underline", :tags => ["underline"])
|
211
|
+
buffer.insert(iter, ", ")
|
212
|
+
buffer.insert(iter, "double underline", :tags => ["double_underline"])
|
213
|
+
buffer.insert(iter, ", ")
|
214
|
+
buffer.insert(iter, "superscript", :tags => ["superscript"])
|
215
|
+
buffer.insert(iter, ", and ")
|
216
|
+
buffer.insert(iter, "subscript", :tags => ["subscript"])
|
217
|
+
buffer.insert(iter, " are all supported.\n\n")
|
218
|
+
|
219
|
+
buffer.insert(iter, "Images. ", :tags => ["heading"])
|
220
|
+
|
221
|
+
buffer.insert(iter, "The buffer can have images in it: ")
|
222
|
+
buffer.insert(iter, pixbuf)
|
223
|
+
buffer.insert(iter, pixbuf)
|
224
|
+
buffer.insert(iter, pixbuf)
|
225
|
+
buffer.insert(iter, " for example.\n\n")
|
226
|
+
|
227
|
+
buffer.insert(iter, "Spacing. ", :tags => ["heading"])
|
228
|
+
|
229
|
+
buffer.insert(iter,
|
230
|
+
"You can adjust the amount of space before each line.\n")
|
231
|
+
|
232
|
+
buffer.insert(iter, "This line has a whole lot of space before it.\n",
|
233
|
+
:tags => %w(big_gap_before_line wide_margins))
|
234
|
+
buffer.insert(iter, "You can also adjust the amount of space after each \
|
235
|
+
line; this line has a whole lot of space after it.\n",
|
236
|
+
:tags => %w(big_gap_after_line wide_margins))
|
237
|
+
text = "You can also adjust the amount of space between wrapped lines; \
|
238
|
+
this line has extra space between each wrapped line in the same paragraph. To \
|
239
|
+
show off wrapping, some filler text: the quick brown fox jumped over the lazy \
|
240
|
+
dog. Blah blah blah blah blah blah blah blah blah.\n"
|
241
|
+
buffer.insert(iter, text,
|
242
|
+
:tags => %w(double_spaced_line wide_margins))
|
243
|
+
|
244
|
+
buffer.insert(iter,
|
245
|
+
"Also note that those lines have extra-wide margins.\n\n")
|
246
|
+
|
247
|
+
buffer.insert(iter, "Editability. ", :tags => ["heading"])
|
248
|
+
|
249
|
+
buffer.insert(iter, "This line is 'locked down' and can't be edited by the \
|
250
|
+
user - just try it! You can't delete this line.\n\n",
|
251
|
+
:tags => ["not_editable"])
|
252
|
+
|
253
|
+
buffer.insert(iter, "Wrapping. ", :tags => ["heading"])
|
254
|
+
|
255
|
+
buffer.insert(iter, "This line(and most of the others in this buffer) is \
|
256
|
+
word-wrapped, using the proper Unicode algorithm. Word wrap should work in all\
|
257
|
+
scripts and languages that GTK+ supports. Let's make this a long paragraph to\
|
258
|
+
demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah\
|
259
|
+
blah blah blah blah blah blah\n\n")
|
260
|
+
|
261
|
+
buffer.insert(iter, "This line has character-based wrapping, and can wrap \
|
262
|
+
between any two character glyphs. Let's make this a long paragraph to \
|
263
|
+
demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah \
|
264
|
+
blah blah blah blah blah blah\n\n", :tags => ["char_wrap"])
|
265
|
+
|
266
|
+
buffer.insert(iter, "This line has all wrapping turned off, so it makes \
|
267
|
+
the horizontal scrollbar appear.\n\n\n", :tags => ["no_wrap"])
|
268
|
+
|
269
|
+
buffer.insert(iter, "Justification. ", :tags => ["heading"])
|
270
|
+
|
271
|
+
buffer.insert(iter, "\nThis line has center justification.\n",
|
272
|
+
:tags => ["center"])
|
273
|
+
|
274
|
+
buffer.insert(iter, "This line has right justification.\n",
|
275
|
+
:tags => ["right_justify"])
|
276
|
+
|
277
|
+
buffer.insert(iter, "\nThis line has big wide margins. Text text text text\
|
278
|
+
text text text text text text text text text text text text text text text \
|
279
|
+
text text text text text text text text text text text text text text text \
|
280
|
+
text text.\n", :tags => ["wide_margins"])
|
281
|
+
|
282
|
+
buffer.insert(iter, "Internationalization. ", :tags => ["heading"])
|
283
|
+
|
284
|
+
buffer.insert(iter, "You can put all sorts of Unicode text in the buffer.\
|
285
|
+
\n\nGerman(Deutsch Süd) Grüß Gott\nGreek(Ελληνικά) Γειά σας\nHebrew \
|
286
|
+
שלום\nJapanese(日本語)\n\nThe widget properly handles bidirectional text, word\
|
287
|
+
wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so \
|
288
|
+
on using the Pango internationalization framework.\n")
|
289
|
+
|
290
|
+
buffer.insert(iter,
|
291
|
+
"Here's a word-wrapped quote in a right-to-left language:\n")
|
292
|
+
buffer.insert(iter, "\331\210\331\202\330\257 \330\250\330\257\330\243 \
|
293
|
+
\330\253\331\204\330\247\330\253 \331\205\331\206 \330\243\331\203\330\253\330\
|
294
|
+
\261 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \330\252\
|
295
|
+
\331\202\330\257\331\205\330\247 \331\201\331\212 \330\264\330\250\331\203\330\
|
296
|
+
\251 \330\247\331\203\330\263\331\212\331\210\331\206 \330\250\330\261\330\247\
|
297
|
+
\331\205\330\254\331\207\330\247 \331\203\331\205\331\206\330\270\331\205\330\
|
298
|
+
\247\330\252 \331\204\330\247 \330\252\330\263\330\271\331\211 \331\204\331\
|
299
|
+
\204\330\261\330\250\330\255\330\214 \330\253\331\205 \330\252\330\255\331\210\
|
300
|
+
\331\204\330\252 \331\201\331\212 \330\247\331\204\330\263\331\206\331\210\330\
|
301
|
+
\247\330\252 \330\247\331\204\330\256\331\205\330\263 \330\247\331\204\331\205\
|
302
|
+
\330\247\330\266\331\212\330\251 \330\245\331\204\331\211 \331\205\330\244\330\
|
303
|
+
\263\330\263\330\247\330\252 \331\205\330\247\331\204\331\212\330\251 \331\205\
|
304
|
+
\331\206\330\270\331\205\330\251\330\214 \331\210\330\250\330\247\330\252\330\
|
305
|
+
\252 \330\254\330\262\330\241\330\247 \331\205\331\206 \330\247\331\204\331\
|
306
|
+
\206\330\270\330\247\331\205 \330\247\331\204\331\205\330\247\331\204\331\212 \
|
307
|
+
\331\201\331\212 \330\250\331\204\330\257\330\247\331\206\331\207\330\247\330\
|
308
|
+
\214 \331\210\331\204\331\203\331\206\331\207\330\247 \330\252\330\252\330\256\
|
309
|
+
\330\265\330\265 \331\201\331\212 \330\256\330\257\331\205\330\251 \331\202\
|
310
|
+
\330\267\330\247\330\271 \330\247\331\204\331\205\330\264\330\261\331\210\330\
|
311
|
+
\271\330\247\330\252 \330\247\331\204\330\265\330\272\331\212\330\261\330\251.\
|
312
|
+
\331\210\330\243\330\255\330\257 \330\243\331\203\330\253\330\261 \331\207\330\
|
313
|
+
\260\331\207 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \
|
314
|
+
\331\206\330\254\330\247\330\255\330\247 \331\207\331\210 \302\273\330\250\330\
|
315
|
+
\247\331\206\331\203\331\210\330\263\331\210\331\204\302\253 \331\201\331\212 \
|
316
|
+
\330\250\331\210\331\204\331\212\331\201\331\212\330\247.\n\n" ,
|
317
|
+
:tags => ["rtl_quote"])
|
318
|
+
|
319
|
+
buffer.insert(iter, "You can put widgets in the buffer: Here's a button: ")
|
320
|
+
buffer.create_child_anchor(iter)
|
321
|
+
buffer.insert(iter, " and a menu: ")
|
322
|
+
buffer.create_child_anchor(iter)
|
323
|
+
buffer.insert(iter, " and a scale: ")
|
324
|
+
buffer.create_child_anchor(iter)
|
325
|
+
buffer.insert(iter, " and an animation: ")
|
326
|
+
buffer.create_child_anchor(iter)
|
327
|
+
buffer.insert(iter, " finally a text entry: ")
|
328
|
+
buffer.create_child_anchor(iter)
|
329
|
+
buffer.insert(iter, ".\n")
|
330
|
+
|
331
|
+
buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the \
|
332
|
+
Gtk::TextBuffer features; it leaves out, for example: invisible/hidden text \
|
333
|
+
(doesn't work in GTK 2, but planned), tab stops, application-drawn areas on \
|
334
|
+
the sides of the widget for displaying breakpoints and such...")
|
335
|
+
|
336
|
+
# Apply word_wrap tag to whole buffer
|
337
|
+
|
338
|
+
buf_start, buf_end = buffer.bounds
|
339
|
+
buffer.apply_tag("word_wrap", buf_start, buf_end)
|
340
|
+
end
|
326
341
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
end
|
331
|
-
return false
|
342
|
+
def find_anchor(iter)
|
343
|
+
while iter.forward_char
|
344
|
+
return true if iter.child_anchor
|
332
345
|
end
|
346
|
+
false
|
347
|
+
end
|
333
348
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
view = Gtk::TextView.new(buffer)
|
360
|
-
|
361
|
-
recursive_attach_view(0, view, anchor)
|
362
|
-
|
363
|
-
@@nest_window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
|
364
|
-
sw = Gtk::ScrolledWindow.new(nil, nil)
|
365
|
-
sw.set_policy(:automatic,
|
366
|
-
:automatic)
|
367
|
-
|
368
|
-
@@nest_window.add(sw)
|
369
|
-
sw.add(view)
|
370
|
-
|
371
|
-
@@nest_window.set_default_size(300, 400)
|
372
|
-
@@nest_window.show_all
|
373
|
-
}
|
374
|
-
elsif i == 1
|
375
|
-
menu = Gtk::Menu.new
|
376
|
-
widget = Gtk::OptionMenu.new
|
377
|
-
|
378
|
-
menu_item = Gtk::MenuItem.new("Option 1")
|
379
|
-
menu.append(menu_item)
|
380
|
-
menu_item = Gtk::MenuItem.new("Option 2")
|
381
|
-
menu.append(menu_item)
|
382
|
-
menu_item = Gtk::MenuItem.new("Option 3")
|
383
|
-
menu.append(menu_item)
|
384
|
-
|
385
|
-
widget.menu = menu
|
386
|
-
|
387
|
-
elsif i == 2
|
388
|
-
widget = Gtk::HScale.new
|
389
|
-
widget.set_range(0, 100)
|
390
|
-
widget.set_size_request(70, -1)
|
391
|
-
|
392
|
-
elsif i == 3
|
393
|
-
filename = Demo.find_file("floppybuddy.gif")
|
394
|
-
widget = Gtk::Image.new(filename)
|
395
|
-
|
396
|
-
elsif i == 4
|
397
|
-
widget = Gtk::Entry.new
|
398
|
-
|
399
|
-
else
|
400
|
-
#widget = nil; avoids a compiler warning
|
401
|
-
#g_assert_not_reached ;
|
402
|
-
end
|
403
|
-
|
404
|
-
text_view.add_child_at_anchor(widget,
|
405
|
-
anchor)
|
406
|
-
|
407
|
-
widget.show_all
|
408
|
-
i += 1
|
349
|
+
def attach_widgets(text_view)
|
350
|
+
buffer = text_view.buffer
|
351
|
+
iter = buffer.start_iter
|
352
|
+
i = 0
|
353
|
+
widget = nil
|
354
|
+
while find_anchor(iter)
|
355
|
+
anchor = iter.child_anchor
|
356
|
+
|
357
|
+
if i == 0
|
358
|
+
widget = Gtk::Button.new(:label => "Click Me")
|
359
|
+
widget.signal_connect("clicked") { easter_egg_callback }
|
360
|
+
elsif i == 1
|
361
|
+
widget = Gtk::ComboBoxText.new
|
362
|
+
widget.append_text("Option 1")
|
363
|
+
widget.append_text("Option 2")
|
364
|
+
widget.append_text("Option 3")
|
365
|
+
elsif i == 2
|
366
|
+
widget = Gtk::Scale.new(:horizontal, nil)
|
367
|
+
widget.set_range(0, 100)
|
368
|
+
widget.set_size_request(70, -1)
|
369
|
+
elsif i == 3
|
370
|
+
widget = Gtk::Image.new(:resource => "/textview/floppybuddy.gif")
|
371
|
+
elsif i == 4
|
372
|
+
widget = Gtk::Entry.new
|
409
373
|
end
|
374
|
+
text_view.add_child_at_anchor(widget, anchor)
|
375
|
+
widget.show_all
|
376
|
+
i += 1
|
410
377
|
end
|
378
|
+
end
|
411
379
|
|
380
|
+
def easter_egg_callback
|
381
|
+
buffer = Gtk::TextBuffer.new
|
382
|
+
iter = buffer.start_iter
|
383
|
+
buffer.insert(iter,
|
384
|
+
"This buffer is shared by a set of nested text views.\n \
|
385
|
+
Nested view:")
|
386
|
+
anchor = buffer.create_child_anchor(iter)
|
387
|
+
buffer.insert(iter,
|
388
|
+
"\nDon't do this in real applications, please.\n")
|
389
|
+
view = Gtk::TextView.new(buffer)
|
390
|
+
recursive_attach_view(0, view, anchor)
|
391
|
+
|
392
|
+
window = Gtk::Window.new
|
393
|
+
sw = Gtk::ScrolledWindow.new
|
394
|
+
sw.set_policy(:automatic, :automatic)
|
395
|
+
window.add(sw)
|
396
|
+
sw.add(view)
|
397
|
+
window.set_default_size(300, 400)
|
398
|
+
window.show_all
|
399
|
+
end
|
412
400
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
child_view = Gtk::TextView.new(view.buffer)
|
417
|
-
|
418
|
-
# Event box is to add a black border around each child view
|
419
|
-
event_box = Gtk::EventBox.new
|
420
|
-
color = Gdk::Color.parse("black")
|
421
|
-
event_box.modify_bg(Gtk::STATE_NORMAL, color)
|
422
|
-
|
423
|
-
align = Gtk::Alignment.new(0.5, 0.5, 1.0, 1.0)
|
424
|
-
align.set_border_width(1)
|
425
|
-
|
426
|
-
event_box.add(align)
|
427
|
-
align.add(child_view)
|
401
|
+
def recursive_attach_view(depth, view, anchor)
|
402
|
+
return if depth > 4
|
428
403
|
|
429
|
-
|
430
|
-
|
431
|
-
recursive_attach_view(depth + 1, child_view, anchor)
|
432
|
-
end
|
404
|
+
child_view = Gtk::TextView.new(view.buffer)
|
433
405
|
|
406
|
+
# Frame is to add a black border around each child view.
|
407
|
+
frame = Gtk::Frame.new
|
408
|
+
frame.add(child_view)
|
409
|
+
view.add_child_at_anchor(frame, anchor)
|
410
|
+
recursive_attach_view(depth + 1, child_view, anchor)
|
434
411
|
end
|
435
412
|
end
|
436
|
-
|