gtk3 3.0.8-x86-mingw32 → 3.0.9-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/rb-gtk3.c +17 -0
  3. data/lib/2.2/gtk3.so +0 -0
  4. data/lib/2.3/gtk3.so +0 -0
  5. data/lib/gtk3/container.rb +0 -7
  6. data/lib/gtk3/deprecated.rb +3 -3
  7. data/lib/gtk3/image.rb +7 -7
  8. data/lib/gtk3/loader.rb +11 -5
  9. data/lib/gtk3/text-buffer.rb +33 -12
  10. data/lib/gtk3/text-view.rb +53 -0
  11. data/lib/gtk3/tree-model.rb +5 -0
  12. data/lib/gtk3/tree-view.rb +25 -0
  13. data/lib/gtk3/widget.rb +0 -5
  14. data/sample/gtk-demo/TODO +10 -6
  15. data/sample/gtk-demo/application.ui +93 -70
  16. data/sample/gtk-demo/appmenu.ui +19 -0
  17. data/sample/gtk-demo/assistant.rb +1 -0
  18. data/sample/gtk-demo/css_accordion.css +8 -8
  19. data/sample/gtk-demo/css_accordion.rb +2 -2
  20. data/sample/gtk-demo/css_basics.css +1 -1
  21. data/sample/gtk-demo/css_basics.rb +2 -2
  22. data/sample/gtk-demo/css_multiplebgs.rb +2 -2
  23. data/sample/gtk-demo/css_pixbufs.css +2 -2
  24. data/sample/gtk-demo/css_pixbufs.rb +2 -2
  25. data/sample/gtk-demo/css_shadows.css +5 -5
  26. data/sample/gtk-demo/css_shadows.rb +2 -2
  27. data/sample/gtk-demo/cssview.css +5 -5
  28. data/sample/gtk-demo/data/16x16/gtk3-demo-symbolic.symbolic.png +0 -0
  29. data/sample/gtk-demo/data/16x16/gtk3-demo.png +0 -0
  30. data/sample/gtk-demo/data/22x22/gtk3-demo-symbolic.symbolic.png +0 -0
  31. data/sample/gtk-demo/data/22x22/gtk3-demo.png +0 -0
  32. data/sample/gtk-demo/data/24x24/gtk3-demo-symbolic.symbolic.png +0 -0
  33. data/sample/gtk-demo/data/24x24/gtk3-demo.png +0 -0
  34. data/sample/gtk-demo/data/256x256/gtk3-demo-symbolic.symbolic.png +0 -0
  35. data/sample/gtk-demo/data/256x256/gtk3-demo.png +0 -0
  36. data/sample/gtk-demo/data/32x32/gtk3-demo-symbolic.symbolic.png +0 -0
  37. data/sample/gtk-demo/data/32x32/gtk3-demo.png +0 -0
  38. data/sample/gtk-demo/data/48x48/gtk3-demo-symbolic.symbolic.png +0 -0
  39. data/sample/gtk-demo/data/48x48/gtk3-demo.png +0 -0
  40. data/sample/gtk-demo/data/512x512/gtk3-demo-symbolic.symbolic.png +0 -0
  41. data/sample/gtk-demo/data/512x512/gtk3-demo.png +0 -0
  42. data/sample/gtk-demo/data/source.svg +2886 -0
  43. data/sample/gtk-demo/data/symbolic-source.svg +29 -0
  44. data/sample/gtk-demo/demo.gresource.xml +16 -5
  45. data/sample/gtk-demo/demo.ui +1 -0
  46. data/sample/gtk-demo/font_features.rb +1 -1
  47. data/sample/gtk-demo/main.rb +2 -2
  48. data/sample/gtk-demo/main.ui +18 -36
  49. data/sample/gtk-demo/markup.rb +53 -8
  50. data/sample/gtk-demo/markup.txt +2 -2
  51. data/sample/gtk-demo/org.gtk.Demo.gschema.xml +9 -0
  52. data/sample/gtk-demo/pixbufs.rb +105 -145
  53. data/sample/gtk-demo/reset.css +1 -58
  54. data/sample/gtk-demo/rotated_text.rb +119 -55
  55. data/sample/gtk-demo/shortcuts-boxes.ui +167 -0
  56. data/sample/gtk-demo/shortcuts-builder.ui +547 -0
  57. data/sample/gtk-demo/shortcuts-clocks.ui +166 -0
  58. data/sample/gtk-demo/shortcuts-gedit.ui +172 -0
  59. data/sample/gtk-demo/shortcuts.ui +65 -0
  60. data/sample/gtk-demo/stack.ui +5 -5
  61. data/sample/gtk-demo/textscroll.rb +106 -0
  62. data/sample/gtk-demo/theming.ui +58 -22
  63. data/sample/gtk-demo/theming_style_classes.rb +5 -4
  64. data/sample/gtk-demo/transparent.rb +143 -0
  65. data/sample/misc/aboutdialog.rb +1 -1
  66. data/sample/misc/bindings.rb +36 -15
  67. data/sample/misc/combobox.rb +1 -1
  68. data/sample/misc/dnd.rb +3 -3
  69. data/sample/misc/icons-theme-viewer.rb +1 -1
  70. data/sample/misc/iconview.rb +2 -2
  71. data/sample/misc/textbuffer-serialize.rb +18 -14
  72. data/sample/misc/to-drawable.rb +2 -2
  73. data/sample/misc/tooltips.rb +1 -0
  74. data/sample/misc/treeview.rb +1 -1
  75. data/sample/tutorial/README.md +18 -18
  76. data/test/test-gtk-clipboard.rb +1 -1
  77. data/test/test-gtk-combo-box.rb +2 -2
  78. data/test/test-gtk-icon-view.rb +2 -2
  79. data/test/test-gtk-image.rb +1 -1
  80. data/test/test-gtk-list-store.rb +9 -3
  81. data/test/test-gtk-text-view.rb +64 -0
  82. data/test/test-gtk-tree-path.rb +1 -3
  83. data/test/test-gtk-tree-view.rb +97 -0
  84. data/test/test-gtk-window.rb +2 -2
  85. data/test/test-pango-context.rb +56 -0
  86. metadata +46 -19
@@ -0,0 +1,166 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <!-- interface-requires gtk+ 3.17 -->
4
+
5
+ <object class="GtkShortcutsWindow" id="shortcuts-clocks">
6
+ <property name="modal">1</property>
7
+ <child>
8
+ <object class="GtkShortcutsSection">
9
+ <property name="visible">1</property>
10
+ <property name="section-name">shortcuts</property>
11
+ <property name="max-height">10</property>
12
+ <child>
13
+ <object class="GtkShortcutsGroup">
14
+ <property name="visible">1</property>
15
+ <property name="title" translatable="yes">General</property>
16
+ <child>
17
+ <object class="GtkShortcutsShortcut">
18
+ <property name="visible">1</property>
19
+ <property name="accelerator">&lt;ctrl&gt;Page_Down</property>
20
+ <property name="title" translatable="yes">Go to the next section</property>
21
+ </object>
22
+ </child>
23
+ <child>
24
+ <object class="GtkShortcutsShortcut">
25
+ <property name="visible">1</property>
26
+ <property name="accelerator">&lt;ctrl&gt;Page_Up</property>
27
+ <property name="title" translatable="yes">Go to the previous section</property>
28
+ </object>
29
+ </child>
30
+ <child>
31
+ <object class="GtkShortcutsShortcut">
32
+ <property name="visible">1</property>
33
+ <property name="accelerator">&lt;alt&gt;Q</property>
34
+ <property name="title" translatable="yes">Quit</property>
35
+ </object>
36
+ </child>
37
+ <child>
38
+ <object class="GtkShortcutsShortcut">
39
+ <property name="visible">1</property>
40
+ <property name="accelerator">&lt;alt&gt;Right</property>
41
+ <property name="direction">ltr</property>
42
+ <property name="title" translatable="yes">Forward</property>
43
+ </object>
44
+ </child>
45
+ <child>
46
+ <object class="GtkShortcutsShortcut">
47
+ <property name="visible">1</property>
48
+ <property name="accelerator">&lt;ctrl&gt;Left</property>
49
+ <property name="direction">ltr</property>
50
+ <property name="title" translatable="yes">Back</property>
51
+ </object>
52
+ </child>
53
+ <child>
54
+ <object class="GtkShortcutsShortcut">
55
+ <property name="visible">1</property>
56
+ <property name="accelerator">&lt;alt&gt;Left</property>
57
+ <property name="direction">rtl</property>
58
+ <property name="title" translatable="yes">Forward</property>
59
+ </object>
60
+ </child>
61
+ <child>
62
+ <object class="GtkShortcutsShortcut">
63
+ <property name="visible">1</property>
64
+ <property name="accelerator">&lt;ctrl&gt;Right</property>
65
+ <property name="direction">rtl</property>
66
+ <property name="title" translatable="yes">Back</property>
67
+ </object>
68
+ </child>
69
+ </object>
70
+ </child>
71
+ <child>
72
+ <object class="GtkShortcutsGroup">
73
+ <property name="visible">1</property>
74
+ <property name="view">world</property>
75
+ <property name="title" translatable="yes">World Clocks</property>
76
+ <child>
77
+ <object class="GtkShortcutsShortcut">
78
+ <property name="visible">1</property>
79
+ <property name="accelerator">&lt;ctrl&gt;N</property>
80
+ <property name="title" translatable="yes">Add a world clock</property>
81
+ </object>
82
+ </child>
83
+ <child>
84
+ <object class="GtkShortcutsShortcut">
85
+ <property name="visible">1</property>
86
+ <property name="accelerator">&lt;ctrl&gt;S</property>
87
+ <property name="title" translatable="yes">Select world clocks</property>
88
+ </object>
89
+ </child>
90
+ </object>
91
+ </child>
92
+ <child>
93
+ <object class="GtkShortcutsGroup">
94
+ <property name="visible">1</property>
95
+ <property name="view">alarm</property>
96
+ <property name="title" translatable="yes">Alarm</property>
97
+ <child>
98
+ <object class="GtkShortcutsShortcut">
99
+ <property name="visible">1</property>
100
+ <property name="accelerator">&lt;ctrl&gt;N</property>
101
+ <property name="title" translatable="yes">Add an alarm</property>
102
+ </object>
103
+ </child>
104
+ <child>
105
+ <object class="GtkShortcutsShortcut">
106
+ <property name="visible">1</property>
107
+ <property name="accelerator">&lt;ctrl&gt;S</property>
108
+ <property name="title" translatable="yes">Select alarms</property>
109
+ </object>
110
+ </child>
111
+ </object>
112
+ </child>
113
+ <child>
114
+ <object class="GtkShortcutsGroup">
115
+ <property name="visible">1</property>
116
+ <property name="view">stopwatch</property>
117
+ <property name="title" translatable="yes">Stopwatch</property>
118
+ <child>
119
+ <object class="GtkShortcutsShortcut">
120
+ <property name="visible">1</property>
121
+ <property name="accelerator">Return space</property>
122
+ <property name="title" translatable="yes">Start / Stop / Continue</property>
123
+ </object>
124
+ </child>
125
+ <child>
126
+ <object class="GtkShortcutsShortcut">
127
+ <property name="visible">1</property>
128
+ <property name="accelerator">L</property>
129
+ <property name="title" translatable="yes">Lap</property>
130
+ </object>
131
+ </child>
132
+ <child>
133
+ <object class="GtkShortcutsShortcut">
134
+ <property name="visible">1</property>
135
+ <property name="accelerator">Delete</property>
136
+ <property name="title" translatable="yes">Reset</property>
137
+ </object>
138
+ </child>
139
+ </object>
140
+ </child>
141
+ <child>
142
+ <object class="GtkShortcutsGroup">
143
+ <property name="visible">1</property>
144
+ <property name="view">timer</property>
145
+ <property name="title" translatable="yes">Timer</property>
146
+ <child>
147
+ <object class="GtkShortcutsShortcut">
148
+ <property name="visible">1</property>
149
+ <property name="accelerator">Return space</property>
150
+ <property name="title" translatable="yes">Start / Stop / Pause</property>
151
+ </object>
152
+ </child>
153
+ <child>
154
+ <object class="GtkShortcutsShortcut">
155
+ <property name="visible">1</property>
156
+ <property name="accelerator">Delete</property>
157
+ <property name="title" translatable="yes">Reset</property>
158
+ </object>
159
+ </child>
160
+ </object>
161
+ </child>
162
+ </object>
163
+ </child>
164
+ </object>
165
+
166
+ </interface>
@@ -0,0 +1,172 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <!-- interface-requires gtk+ 3.17 -->
4
+
5
+ <object class="GtkShortcutsWindow" id="shortcuts-gedit">
6
+ <property name="modal">1</property>
7
+ <child>
8
+ <object class="GtkShortcutsSection">
9
+ <property name="visible">1</property>
10
+ <property name="section-name">shortcuts</property>
11
+ <property name="max-height">12</property>
12
+ <child>
13
+ <object class="GtkShortcutsGroup">
14
+ <property name="visible">1</property>
15
+ <property name="title" translatable="yes">Touchpad gestures</property>
16
+ <child>
17
+ <object class="GtkShortcutsShortcut">
18
+ <property name="visible">1</property>
19
+ <property name="shortcut-type">gesture-two-finger-swipe-right</property>
20
+ <property name="title" translatable="yes">Switch to the next document</property>
21
+ </object>
22
+ </child>
23
+ <child>
24
+ <object class="GtkShortcutsShortcut">
25
+ <property name="visible">1</property>
26
+ <property name="shortcut-type">gesture-two-finger-swipe-left</property>
27
+ <property name="title" translatable="yes">Switch to the previous document</property>
28
+ </object>
29
+ </child>
30
+ </object>
31
+ </child>
32
+ <child>
33
+ <object class="GtkShortcutsGroup">
34
+ <property name="visible">1</property>
35
+ <property name="title" translatable="yes">Documents</property>
36
+ <child>
37
+ <object class="GtkShortcutsShortcut">
38
+ <property name="visible">1</property>
39
+ <property name="accelerator">&lt;ctrl&gt;N</property>
40
+ <property name="title" translatable="yes">Create new document</property>
41
+ </object>
42
+ </child>
43
+ <child>
44
+ <object class="GtkShortcutsShortcut">
45
+ <property name="visible">1</property>
46
+ <property name="accelerator">&lt;ctrl&gt;O</property>
47
+ <property name="title" translatable="yes">Open a document</property>
48
+ </object>
49
+ </child>
50
+ <child>
51
+ <object class="GtkShortcutsShortcut">
52
+ <property name="visible">1</property>
53
+ <property name="accelerator">&lt;ctrl&gt;S</property>
54
+ <property name="title" translatable="yes">Save the document</property>
55
+ </object>
56
+ </child>
57
+ <child>
58
+ <object class="GtkShortcutsShortcut">
59
+ <property name="visible">1</property>
60
+ <property name="accelerator">&lt;ctrl&gt;W</property>
61
+ <property name="title" translatable="yes">Close the document</property>
62
+ </object>
63
+ </child>
64
+ <child>
65
+ <object class="GtkShortcutsShortcut">
66
+ <property name="visible">1</property>
67
+ <property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Down</property>
68
+ <property name="title" translatable="yes">Switch to the next document</property>
69
+ </object>
70
+ </child>
71
+ <child>
72
+ <object class="GtkShortcutsShortcut">
73
+ <property name="visible">1</property>
74
+ <property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Up</property>
75
+ <property name="title" translatable="yes">Switch to the previous document</property>
76
+ </object>
77
+ </child>
78
+ </object>
79
+ </child>
80
+ <child>
81
+ <object class="GtkShortcutsGroup">
82
+ <property name="visible">1</property>
83
+ <property name="title" translatable="yes">Find and Replace</property>
84
+ <child>
85
+ <object class="GtkShortcutsShortcut">
86
+ <property name="visible">1</property>
87
+ <property name="accelerator">&lt;ctrl&gt;F</property>
88
+ <property name="title" translatable="yes">Find</property>
89
+ </object>
90
+ </child>
91
+ <child>
92
+ <object class="GtkShortcutsShortcut">
93
+ <property name="visible">1</property>
94
+ <property name="accelerator">&lt;ctrl&gt;G</property>
95
+ <property name="title" translatable="yes">Find the next match</property>
96
+ </object>
97
+ </child>
98
+ <child>
99
+ <object class="GtkShortcutsShortcut">
100
+ <property name="visible">1</property>
101
+ <property name="accelerator">&lt;ctrl&gt;&lt;Shift&gt;G</property>
102
+ <property name="title" translatable="yes">Find the previous match</property>
103
+ </object>
104
+ </child>
105
+ <child>
106
+ <object class="GtkShortcutsShortcut">
107
+ <property name="visible">1</property>
108
+ <property name="accelerator">&lt;ctrl&gt;H</property>
109
+ <property name="title" translatable="yes">Find and Replace</property>
110
+ </object>
111
+ </child>
112
+ <child>
113
+ <object class="GtkShortcutsShortcut">
114
+ <property name="visible">1</property>
115
+ <property name="accelerator">&lt;ctrl&gt;&lt;Shift&gt;K</property>
116
+ <property name="title" translatable="yes">Clear highlight</property>
117
+ </object>
118
+ </child>
119
+ <child>
120
+ <object class="GtkShortcutsShortcut">
121
+ <property name="visible">1</property>
122
+ <property name="accelerator">&lt;ctrl&gt;I</property>
123
+ <property name="title" translatable="yes">Go to line</property>
124
+ </object>
125
+ </child>
126
+ </object>
127
+ </child>
128
+ <child>
129
+ <object class="GtkShortcutsGroup">
130
+ <property name="visible">1</property>
131
+ <property name="title" translatable="yes">Tools</property>
132
+ <child>
133
+ <object class="GtkShortcutsShortcut">
134
+ <property name="visible">1</property>
135
+ <property name="accelerator">&lt;shift&gt;F7</property>
136
+ <property name="title" translatable="yes">Check spelling</property>
137
+ </object>
138
+ </child>
139
+ </object>
140
+ </child>
141
+ <child>
142
+ <object class="GtkShortcutsGroup">
143
+ <property name="visible">1</property>
144
+ <property name="title" translatable="yes">Miscellaneous</property>
145
+ <child>
146
+ <object class="GtkShortcutsShortcut">
147
+ <property name="visible">1</property>
148
+ <property name="accelerator">F11</property>
149
+ <property name="title" translatable="yes">Fullscreen on / off</property>
150
+ </object>
151
+ </child>
152
+ <child>
153
+ <object class="GtkShortcutsShortcut">
154
+ <property name="visible">1</property>
155
+ <property name="accelerator">&lt;ctrl&gt;P</property>
156
+ <property name="title" translatable="yes">Print the document</property>
157
+ </object>
158
+ </child>
159
+ <child>
160
+ <object class="GtkShortcutsShortcut">
161
+ <property name="visible">1</property>
162
+ <property name="accelerator">Insert</property>
163
+ <property name="title" translatable="yes">Toggle insert / overwrite</property>
164
+ </object>
165
+ </child>
166
+ </object>
167
+ </child>
168
+ </object>
169
+ </child>
170
+ </object>
171
+
172
+ </interface>
@@ -0,0 +1,65 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <interface>
3
+ <!-- interface-requires gtk+ 3.17 -->
4
+
5
+ <object class="GtkWindow" id="window1">
6
+ <property name="title" translatable="yes">Shortcuts</property>
7
+ <child>
8
+ <object class="GtkBox">
9
+ <property name="visible">1</property>
10
+ <property name="orientation">vertical</property>
11
+ <property name="margin">50</property>
12
+ <property name="spacing">10</property>
13
+ <child>
14
+ <object class="GtkButton">
15
+ <property name="visible">1</property>
16
+ <property name="label">Builder</property>
17
+ <signal name="clicked" handler="builder_shortcuts" swapped="1" object="window1"/>
18
+ </object>
19
+ </child>
20
+ <child>
21
+ <object class="GtkButton">
22
+ <property name="visible">1</property>
23
+ <property name="label">GEdit</property>
24
+ <signal name="clicked" handler="gedit_shortcuts" swapped="1" object="window1"/>
25
+ </object>
26
+ </child>
27
+ <child>
28
+ <object class="GtkButton">
29
+ <property name="visible">1</property>
30
+ <property name="label">Clocks - All</property>
31
+ <signal name="clicked" handler="clocks_shortcuts" swapped="1" object="window1"/>
32
+ </object>
33
+ </child>
34
+ <child>
35
+ <object class="GtkButton">
36
+ <property name="visible">1</property>
37
+ <property name="label">Clocks - Stopwatch</property>
38
+ <signal name="clicked" handler="clocks_shortcuts_stopwatch" swapped="1" object="window1"/>
39
+ </object>
40
+ </child>
41
+ <child>
42
+ <object class="GtkButton">
43
+ <property name="visible">1</property>
44
+ <property name="label">Boxes</property>
45
+ <signal name="clicked" handler="boxes_shortcuts" swapped="1" object="window1"/>
46
+ </object>
47
+ </child>
48
+ <child>
49
+ <object class="GtkButton">
50
+ <property name="visible">1</property>
51
+ <property name="label">Boxes - Wizard</property>
52
+ <signal name="clicked" handler="boxes_shortcuts_wizard" swapped="1" object="window1"/>
53
+ </object>
54
+ </child>
55
+ <child>
56
+ <object class="GtkButton">
57
+ <property name="visible">1</property>
58
+ <property name="label">Boxes - Display</property>
59
+ <signal name="clicked" handler="boxes_shortcuts_display" swapped="1" object="window1"/>
60
+ </object>
61
+ </child>
62
+ </object>
63
+ </child>
64
+ </object>
65
+ </interface>
@@ -4,10 +4,10 @@
4
4
  <object class="GtkWindow" id="window1">
5
5
  <property name="title" translatable="yes">Stack</property>
6
6
  <child>
7
- <object class="GtkGrid" id="grid1">
7
+ <object class="GtkGrid">
8
8
  <property name="visible">1</property>
9
9
  <child>
10
- <object class="GtkStackSwitcher" id="switcher">
10
+ <object class="GtkStackSwitcher">
11
11
  <property name="visible">1</property>
12
12
  <property name="stack">stack</property>
13
13
  <property name="halign">center</property>
@@ -23,7 +23,7 @@
23
23
  <property name="can_focus">1</property>
24
24
  <property name="transition-type">crossfade</property>
25
25
  <child>
26
- <object class="GtkImage" id="image1">
26
+ <object class="GtkImage">
27
27
  <property name="visible">1</property>
28
28
  <property name="margin-top">20</property>
29
29
  <property name="margin-bottom">20</property>
@@ -35,7 +35,7 @@
35
35
  </packing>
36
36
  </child>
37
37
  <child>
38
- <object class="GtkCheckButton" id="checkbutton1">
38
+ <object class="GtkCheckButton">
39
39
  <property name="label" translatable="yes">Page 2</property>
40
40
  <property name="visible">1</property>
41
41
  <property name="can_focus">1</property>
@@ -49,7 +49,7 @@
49
49
  </packing>
50
50
  </child>
51
51
  <child>
52
- <object class="GtkSpinner" id="spinner1">
52
+ <object class="GtkSpinner">
53
53
  <property name="visible">1</property>
54
54
  <property name="halign">center</property>
55
55
  <property name="valign">center</property>
@@ -0,0 +1,106 @@
1
+ # Copyright (c) 2016 Ruby-GNOME2 Project Team
2
+ # This program is licenced under the same licence as Ruby-GNOME2.
3
+ #
4
+ =begin
5
+ = Text View/Automatic Scrolling
6
+
7
+ This example demonstrates how to use the gravity of
8
+ GtkTextMarks to keep a text view scrolled to the bottom
9
+ while appending text.
10
+ =end
11
+ module TextscrollDemo
12
+ def self.run_demo(main_window)
13
+ window = Gtk::Window.new(:toplevel)
14
+ window.screen = main_window.screen
15
+
16
+ window.set_default_size(600, 400)
17
+
18
+ hbox = Gtk::Box.new(:horizontal, 6)
19
+ hbox.homogeneous = true
20
+ window.add(hbox)
21
+
22
+ create_text_view(hbox, true)
23
+ create_text_view(hbox, false)
24
+
25
+ if !window.visible?
26
+ window.show_all
27
+ else
28
+ window.destroy
29
+ end
30
+ window
31
+ end
32
+
33
+ def self.create_text_view(hbox, to_end)
34
+ swindow = Gtk::ScrolledWindow.new
35
+ hbox.pack_start(swindow, :fill => true, :expand => true, :padding => 0)
36
+ textview = Gtk::TextView.new
37
+ swindow.add(textview)
38
+ timeout = setup_scroll(textview, to_end)
39
+ textview.signal_connect("destroy") { GLib::Source.remove(timeout) }
40
+ end
41
+
42
+ def self.setup_scroll(textview, to_end)
43
+ buffer = textview.buffer
44
+ end_iter = buffer.end_iter
45
+ count = 0
46
+ if to_end
47
+ # If we want to scroll to the end, including horizontal scrolling,
48
+ # then we just create a mark with right gravity at the end of the
49
+ # buffer. It will stay at the end unless explicitly moved with
50
+ # gtk_text_buffer_move_mark.
51
+ buffer.create_mark("end", end_iter, false)
52
+
53
+ # add scrolling timeout
54
+ return GLib::Timeout.add(50) do # scroll to end
55
+ count += 1
56
+ # Get "end" mark. It's located at the end of buffer because
57
+ # of right gravity
58
+ mark = buffer.get_mark("end")
59
+ mark_iter = buffer.get_iter_at(:mark => mark)
60
+ # and insert some text at its position, the iter will be
61
+ # revalidated after insertion to point to the end of inserted text
62
+ buffer.insert(mark_iter, "\n")
63
+ buffer.insert(mark_iter, " " * count)
64
+ buffer.insert(mark_iter, "Scroll to end scroll to end scroll" +
65
+ " to end scroll to end #{count}")
66
+ # Now scroll the end mark onscreen.
67
+ textview.scroll_mark_onscreen(mark)
68
+
69
+ # Emulate typewriter behavior, shift to the left if we
70
+ # are far enough to the right.
71
+ count = 0 if count > 150
72
+ GLib::Source::CONTINUE
73
+ end
74
+ else
75
+ # If we want to scroll to the bottom, but not scroll horizontally,
76
+ # then an end mark won't do the job. Just create a mark so we can
77
+ # use it with gtk_text_view_scroll_mark_onscreen, we'll position it
78
+ # explicitly when needed. Use left gravity so the mark stays where
79
+ # we put it after inserting new text.
80
+ buffer.create_mark("scroll", end_iter, true)
81
+ return GLib::Timeout.add(100) do # scroll to bottom
82
+ count += 1
83
+ # Get end iterator
84
+ end_iter = buffer.end_iter
85
+ # and insert some text at it, the iter will be revalidated
86
+ # after insertion to point to the end of inserted text
87
+ buffer.insert(end_iter, "\n")
88
+ buffer.insert(end_iter, " " * count)
89
+ buffer.insert(end_iter,"Scroll to bottom scroll to bottom scroll" +
90
+ " to bottom scroll to bottom #{count}")
91
+ # Move the iterator to the beginning of line, so we don't scroll
92
+ # in horizontal direction
93
+ end_iter.line_offset = 0
94
+ # and place the mark at iter. the mark will stay there after we
95
+ # insert some text at the end because it has left gravity.
96
+ mark = buffer.get_mark("scroll")
97
+ buffer.move_mark(mark, end_iter)
98
+ # Scroll the mark onscreen.
99
+ textview.scroll_mark_onscreen(mark)
100
+ # Shift text back if we got enough to the right.
101
+ count = 0 if count > 40
102
+ GLib::Source::CONTINUE
103
+ end
104
+ end
105
+ end
106
+ end