gtk3 3.0.5-x64-mingw32 → 3.0.6-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gtk3/rb-gtk3-cell-layout.c +42 -0
- data/ext/gtk3/rb-gtk3-private.h +3 -0
- data/ext/gtk3/rb-gtk3-tree-model.c +77 -0
- data/ext/gtk3/rb-gtk3-tree-view.c +42 -0
- data/ext/gtk3/rb-gtk3.c +33 -0
- data/lib/2.0/gtk3.so +0 -0
- data/lib/2.1/gtk3.so +0 -0
- data/lib/2.2/gtk3.so +0 -0
- data/lib/gtk3/builder.rb +54 -11
- data/lib/gtk3/container.rb +13 -0
- data/lib/gtk3/deprecated.rb +4 -4
- data/lib/gtk3/loader.rb +2 -0
- data/lib/gtk3/show-uri.rb +34 -0
- data/lib/gtk3/stock-item.rb +36 -0
- data/lib/gtk3/tree-iter.rb +3 -1
- data/sample/gtk-demo/TODO +1 -1
- data/sample/gtk-demo/alias_cursor.png +0 -0
- data/sample/gtk-demo/all_scroll_cursor.png +0 -0
- data/sample/gtk-demo/application.ui +11 -18
- data/sample/gtk-demo/brick.png +0 -0
- data/sample/gtk-demo/brick2.png +0 -0
- data/sample/gtk-demo/cell_cursor.png +0 -0
- data/sample/gtk-demo/col_resize_cursor.png +0 -0
- data/sample/gtk-demo/copy_cursor.png +0 -0
- data/sample/gtk-demo/crosshair_cursor.png +0 -0
- data/sample/gtk-demo/css_accordion.css +1 -2
- data/sample/gtk-demo/css_basics.css +1 -1
- data/sample/gtk-demo/css_multiplebgs.css +136 -0
- data/sample/gtk-demo/css_pixbufs.css +76 -0
- data/sample/gtk-demo/css_shadows.css +44 -0
- data/sample/gtk-demo/cssview.css +41 -0
- data/sample/gtk-demo/decor1.png +0 -0
- data/sample/gtk-demo/decor2.png +0 -0
- data/sample/gtk-demo/default_cursor.png +0 -0
- data/sample/gtk-demo/demo.gresource.xml +216 -0
- data/sample/gtk-demo/demo.ui +285 -241
- data/sample/gtk-demo/e_resize_cursor.png +0 -0
- data/sample/gtk-demo/ew_resize_cursor.png +0 -0
- data/sample/gtk-demo/filtermodel.ui +195 -0
- data/sample/gtk-demo/font-features.ui +966 -0
- data/sample/gtk-demo/glarea-fragment.glsl +9 -0
- data/sample/gtk-demo/glarea-vertex.glsl +8 -0
- data/sample/gtk-demo/grab_cursor.png +0 -0
- data/sample/gtk-demo/grabbing_cursor.png +0 -0
- data/sample/gtk-demo/hand_cursor.png +0 -0
- data/sample/gtk-demo/help_cursor.png +0 -0
- data/sample/gtk-demo/listbox.ui +332 -0
- data/sample/gtk-demo/main.rb +132 -313
- data/sample/gtk-demo/main.ui +190 -0
- data/sample/gtk-demo/markup.txt +16 -0
- data/sample/gtk-demo/menus.ui +1 -1
- data/sample/gtk-demo/messages.txt +388 -0
- data/sample/gtk-demo/modelbutton.ui +162 -0
- data/sample/gtk-demo/move_cursor.png +0 -0
- data/sample/gtk-demo/n_resize_cursor.png +0 -0
- data/sample/gtk-demo/ne_resize_cursor.png +0 -0
- data/sample/gtk-demo/nesw_resize_cursor.png +0 -0
- data/sample/gtk-demo/no_drop_cursor.png +0 -0
- data/sample/gtk-demo/none_cursor.png +0 -0
- data/sample/gtk-demo/not_allowed_cursor.png +0 -0
- data/sample/gtk-demo/ns_resize_cursor.png +0 -0
- data/sample/gtk-demo/nw_resize_cursor.png +0 -0
- data/sample/gtk-demo/nwse_resize_cursor.png +0 -0
- data/sample/gtk-demo/org.gtk.Demo.gschema.xml +17 -0
- data/sample/gtk-demo/pointer_cursor.png +0 -0
- data/sample/gtk-demo/popover.ui +94 -0
- data/sample/gtk-demo/progress_cursor.png +0 -0
- data/sample/gtk-demo/reset.css +0 -1
- data/sample/gtk-demo/revealer.ui +177 -0
- data/sample/gtk-demo/row_resize_cursor.png +0 -0
- data/sample/gtk-demo/s_resize_cursor.png +0 -0
- data/sample/gtk-demo/scale.ui +117 -0
- data/sample/gtk-demo/se_resize_cursor.png +0 -0
- data/sample/gtk-demo/spinbutton.ui +194 -0
- data/sample/gtk-demo/stack.ui +72 -0
- data/sample/gtk-demo/sw_resize_cursor.png +0 -0
- data/sample/gtk-demo/text_cursor.png +0 -0
- data/sample/gtk-demo/theming.ui +102 -147
- data/sample/gtk-demo/vertical_text_cursor.png +0 -0
- data/sample/gtk-demo/w_resize_cursor.png +0 -0
- data/sample/gtk-demo/wait_cursor.png +0 -0
- data/sample/gtk-demo/zoom_in_cursor.png +0 -0
- data/sample/gtk-demo/zoom_out_cursor.png +0 -0
- data/sample/tutorial/README.md +415 -0
- data/test/run-test.rb +1 -1
- data/test/test-gtk-builder.rb +108 -30
- data/test/test-gtk-cell-layout.rb +6 -0
- metadata +82 -18
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,332 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface domain="gtk30">
|
3
|
+
<!-- interface-requires gtk+ 3.10 -->
|
4
|
+
<!-- interface-requires gtkdemo 3.10 -->
|
5
|
+
<object class="GtkMenu" id="menu1">
|
6
|
+
<property name="visible">1</property>
|
7
|
+
<child>
|
8
|
+
<object class="GtkMenuItem" id="menuitem1">
|
9
|
+
<property name="visible">1</property>
|
10
|
+
<property name="label" translatable="yes">Email message</property>
|
11
|
+
<property name="use_underline">1</property>
|
12
|
+
</object>
|
13
|
+
</child>
|
14
|
+
<child>
|
15
|
+
<object class="GtkMenuItem" id="menuitem2">
|
16
|
+
<property name="visible">1</property>
|
17
|
+
<property name="label" translatable="yes">Embed message</property>
|
18
|
+
<property name="use_underline">1</property>
|
19
|
+
</object>
|
20
|
+
</child>
|
21
|
+
</object>
|
22
|
+
<template class="GtkMessageRow" parent="GtkListBoxRow">
|
23
|
+
<child>
|
24
|
+
<object class="GtkGrid" id="grid1">
|
25
|
+
<property name="visible">1</property>
|
26
|
+
<property name="hexpand">1</property>
|
27
|
+
<child>
|
28
|
+
<object class="GtkImage" id="avatar_image">
|
29
|
+
<property name="width_request">32</property>
|
30
|
+
<property name="height_request">32</property>
|
31
|
+
<property name="visible">1</property>
|
32
|
+
<property name="halign">center</property>
|
33
|
+
<property name="valign">start</property>
|
34
|
+
<property name="margin_top">8</property>
|
35
|
+
<property name="margin_bottom">8</property>
|
36
|
+
<property name="margin_start">8</property>
|
37
|
+
<property name="margin_end">8</property>
|
38
|
+
<property name="icon-name">image-missing</property>
|
39
|
+
</object>
|
40
|
+
<packing>
|
41
|
+
<property name="left_attach">0</property>
|
42
|
+
<property name="top_attach">0</property>
|
43
|
+
<property name="height">5</property>
|
44
|
+
</packing>
|
45
|
+
</child>
|
46
|
+
<child>
|
47
|
+
<object class="GtkBox" id="box1">
|
48
|
+
<property name="visible">1</property>
|
49
|
+
<property name="hexpand">1</property>
|
50
|
+
<property name="baseline_position">top</property>
|
51
|
+
<child>
|
52
|
+
<object class="GtkButton" id="button2">
|
53
|
+
<property name="visible">1</property>
|
54
|
+
<property name="can_focus">1</property>
|
55
|
+
<property name="receives_default">1</property>
|
56
|
+
<property name="valign">baseline</property>
|
57
|
+
<property name="relief">none</property>
|
58
|
+
<child>
|
59
|
+
<object class="GtkLabel" id="source_name">
|
60
|
+
<property name="visible">1</property>
|
61
|
+
<property name="valign">baseline</property>
|
62
|
+
<property name="label" translatable="0">Username</property>
|
63
|
+
<attributes>
|
64
|
+
<attribute name="weight" value="bold"/>
|
65
|
+
</attributes>
|
66
|
+
</object>
|
67
|
+
</child>
|
68
|
+
</object>
|
69
|
+
</child>
|
70
|
+
<child>
|
71
|
+
<object class="GtkLabel" id="source_nick">
|
72
|
+
<property name="visible">1</property>
|
73
|
+
<property name="valign">baseline</property>
|
74
|
+
<property name="label" translatable="0">@nick</property>
|
75
|
+
<style>
|
76
|
+
<class name="dim-label"/>
|
77
|
+
</style>
|
78
|
+
</object>
|
79
|
+
<packing>
|
80
|
+
<property name="position">1</property>
|
81
|
+
</packing>
|
82
|
+
</child>
|
83
|
+
<child>
|
84
|
+
<object class="GtkLabel" id="short_time_label">
|
85
|
+
<property name="visible">1</property>
|
86
|
+
<property name="valign">baseline</property>
|
87
|
+
<property name="label" translatable="yes">38m</property>
|
88
|
+
<style>
|
89
|
+
<class name="dim-label"/>
|
90
|
+
</style>
|
91
|
+
</object>
|
92
|
+
<packing>
|
93
|
+
<property name="fill">0</property>
|
94
|
+
<property name="pack_type">end</property>
|
95
|
+
<property name="position">2</property>
|
96
|
+
</packing>
|
97
|
+
</child>
|
98
|
+
</object>
|
99
|
+
<packing>
|
100
|
+
<property name="left_attach">1</property>
|
101
|
+
<property name="top_attach">0</property>
|
102
|
+
</packing>
|
103
|
+
</child>
|
104
|
+
<child>
|
105
|
+
<object class="GtkLabel" id="content_label">
|
106
|
+
<property name="visible">1</property>
|
107
|
+
<property name="halign">start</property>
|
108
|
+
<property name="valign">start</property>
|
109
|
+
<property name="xalign">0</property>
|
110
|
+
<property name="yalign">0</property>
|
111
|
+
<property name="label" translatable="0">Message</property>
|
112
|
+
<property name="wrap">1</property>
|
113
|
+
</object>
|
114
|
+
<packing>
|
115
|
+
<property name="left_attach">1</property>
|
116
|
+
<property name="top_attach">1</property>
|
117
|
+
</packing>
|
118
|
+
</child>
|
119
|
+
<child>
|
120
|
+
<object class="GtkBox" id="resent_box">
|
121
|
+
<child>
|
122
|
+
<object class="GtkImage" id="image2">
|
123
|
+
<property name="visible">1</property>
|
124
|
+
<property name="icon_name">media-playlist-repeat</property>
|
125
|
+
</object>
|
126
|
+
</child>
|
127
|
+
<child>
|
128
|
+
<object class="GtkLabel" id="label4">
|
129
|
+
<property name="visible">1</property>
|
130
|
+
<property name="label" translatable="yes">Resent by</property>
|
131
|
+
</object>
|
132
|
+
<packing>
|
133
|
+
<property name="position">1</property>
|
134
|
+
</packing>
|
135
|
+
</child>
|
136
|
+
<child>
|
137
|
+
<object class="GtkLinkButton" id="resent_by_button">
|
138
|
+
<property name="label" translatable="0">reshareer</property>
|
139
|
+
<property name="visible">1</property>
|
140
|
+
<property name="can_focus">1</property>
|
141
|
+
<property name="receives_default">1</property>
|
142
|
+
<property name="relief">none</property>
|
143
|
+
<property name="uri">http://www.gtk.org</property>
|
144
|
+
</object>
|
145
|
+
<packing>
|
146
|
+
<property name="position">2</property>
|
147
|
+
</packing>
|
148
|
+
</child>
|
149
|
+
</object>
|
150
|
+
<packing>
|
151
|
+
<property name="left_attach">1</property>
|
152
|
+
<property name="top_attach">2</property>
|
153
|
+
</packing>
|
154
|
+
</child>
|
155
|
+
<child>
|
156
|
+
<object class="GtkBox" id="box3">
|
157
|
+
<property name="visible">1</property>
|
158
|
+
<property name="spacing">6</property>
|
159
|
+
<child>
|
160
|
+
<object class="GtkButton" id="expand_button">
|
161
|
+
<property name="label" translatable="yes">Expand</property>
|
162
|
+
<property name="visible">1</property>
|
163
|
+
<property name="can_focus">1</property>
|
164
|
+
<property name="receives_default">1</property>
|
165
|
+
<property name="relief">none</property>
|
166
|
+
<signal name="clicked" handler="expand_clicked" swapped="yes"/>
|
167
|
+
</object>
|
168
|
+
</child>
|
169
|
+
<child>
|
170
|
+
<object class="GtkBox" id="extra_buttons_box">
|
171
|
+
<property name="spacing">6</property>
|
172
|
+
<child>
|
173
|
+
<object class="GtkButton" id="reply-button">
|
174
|
+
<property name="label" translatable="yes">Reply</property>
|
175
|
+
<property name="visible">1</property>
|
176
|
+
<property name="can_focus">1</property>
|
177
|
+
<property name="receives_default">1</property>
|
178
|
+
<property name="relief">none</property>
|
179
|
+
</object>
|
180
|
+
</child>
|
181
|
+
<child>
|
182
|
+
<object class="GtkButton" id="reshare-button">
|
183
|
+
<property name="label" translatable="yes">Reshare</property>
|
184
|
+
<property name="visible">1</property>
|
185
|
+
<property name="can_focus">1</property>
|
186
|
+
<property name="receives_default">1</property>
|
187
|
+
<property name="relief">none</property>
|
188
|
+
<signal name="clicked" handler="reshare_clicked" swapped="yes"/>
|
189
|
+
</object>
|
190
|
+
<packing>
|
191
|
+
<property name="position">1</property>
|
192
|
+
</packing>
|
193
|
+
</child>
|
194
|
+
<child>
|
195
|
+
<object class="GtkButton" id="favorite-buttton">
|
196
|
+
<property name="label" translatable="yes">Favorite</property>
|
197
|
+
<property name="visible">1</property>
|
198
|
+
<property name="can_focus">1</property>
|
199
|
+
<property name="receives_default">1</property>
|
200
|
+
<property name="relief">none</property>
|
201
|
+
<signal name="clicked" handler="favorite_clicked" swapped="yes"/>
|
202
|
+
</object>
|
203
|
+
<packing>
|
204
|
+
<property name="position">2</property>
|
205
|
+
</packing>
|
206
|
+
</child>
|
207
|
+
<child>
|
208
|
+
<object class="GtkMenuButton" id="more-button">
|
209
|
+
<property name="visible">1</property>
|
210
|
+
<property name="can_focus">1</property>
|
211
|
+
<property name="receives_default">1</property>
|
212
|
+
<property name="relief">none</property>
|
213
|
+
<property name="popup">menu1</property>
|
214
|
+
<child>
|
215
|
+
<object class="GtkLabel" id="label7">
|
216
|
+
<property name="visible">1</property>
|
217
|
+
<property name="label" translatable="yes">More...</property>
|
218
|
+
</object>
|
219
|
+
</child>
|
220
|
+
</object>
|
221
|
+
<packing>
|
222
|
+
<property name="position">3</property>
|
223
|
+
</packing>
|
224
|
+
</child>
|
225
|
+
</object>
|
226
|
+
<packing>
|
227
|
+
<property name="position">1</property>
|
228
|
+
</packing>
|
229
|
+
</child>
|
230
|
+
</object>
|
231
|
+
<packing>
|
232
|
+
<property name="left_attach">1</property>
|
233
|
+
<property name="top_attach">3</property>
|
234
|
+
</packing>
|
235
|
+
</child>
|
236
|
+
<child>
|
237
|
+
<object class="GtkRevealer" id="details_revealer">
|
238
|
+
<property name="visible">1</property>
|
239
|
+
<child>
|
240
|
+
<object class="GtkBox" id="box5">
|
241
|
+
<property name="visible">1</property>
|
242
|
+
<property name="orientation">vertical</property>
|
243
|
+
<child>
|
244
|
+
<object class="GtkBox" id="box7">
|
245
|
+
<property name="visible">1</property>
|
246
|
+
<property name="margin_top">2</property>
|
247
|
+
<property name="margin_bottom">2</property>
|
248
|
+
<property name="spacing">8</property>
|
249
|
+
<child>
|
250
|
+
<object class="GtkFrame" id="frame1">
|
251
|
+
<property name="visible">1</property>
|
252
|
+
<property name="shadow_type">none</property>
|
253
|
+
<child>
|
254
|
+
<object class="GtkLabel" id="n_reshares_label">
|
255
|
+
<property name="visible">1</property>
|
256
|
+
<property name="label" translatable="0"><b>2</b>
|
257
|
+
Reshares</property>
|
258
|
+
<property name="use_markup">1</property>
|
259
|
+
</object>
|
260
|
+
</child>
|
261
|
+
<child type="label_item">
|
262
|
+
</child>
|
263
|
+
</object>
|
264
|
+
</child>
|
265
|
+
<child>
|
266
|
+
<object class="GtkFrame" id="frame2">
|
267
|
+
<property name="visible">1</property>
|
268
|
+
<property name="shadow_type">none</property>
|
269
|
+
<child>
|
270
|
+
<object class="GtkLabel" id="n_favorites_label">
|
271
|
+
<property name="visible">1</property>
|
272
|
+
<property name="label" translatable="0"><b>2</b>
|
273
|
+
FAVORITES</property>
|
274
|
+
<property name="use_markup">1</property>
|
275
|
+
</object>
|
276
|
+
</child>
|
277
|
+
<child type="label_item">
|
278
|
+
</child>
|
279
|
+
</object>
|
280
|
+
<packing>
|
281
|
+
<property name="position">1</property>
|
282
|
+
</packing>
|
283
|
+
</child>
|
284
|
+
</object>
|
285
|
+
<packing>
|
286
|
+
<property name="position">1</property>
|
287
|
+
</packing>
|
288
|
+
</child>
|
289
|
+
<child>
|
290
|
+
<object class="GtkBox" id="box6">
|
291
|
+
<property name="visible">1</property>
|
292
|
+
<child>
|
293
|
+
<object class="GtkLabel" id="detailed_time_label">
|
294
|
+
<property name="visible">1</property>
|
295
|
+
<property name="label" translatable="0">4:25 AM - 14 Jun 13 </property>
|
296
|
+
<style>
|
297
|
+
<class name="dim-label"/>
|
298
|
+
</style>
|
299
|
+
</object>
|
300
|
+
</child>
|
301
|
+
<child>
|
302
|
+
<object class="GtkButton" id="button5">
|
303
|
+
<property name="label" translatable="yes">Details</property>
|
304
|
+
<property name="visible">1</property>
|
305
|
+
<property name="can_focus">1</property>
|
306
|
+
<property name="receives_default">1</property>
|
307
|
+
<property name="relief">none</property>
|
308
|
+
<style>
|
309
|
+
<class name="dim-label"/>
|
310
|
+
</style>
|
311
|
+
</object>
|
312
|
+
<packing>
|
313
|
+
<property name="position">1</property>
|
314
|
+
</packing>
|
315
|
+
</child>
|
316
|
+
</object>
|
317
|
+
<packing>
|
318
|
+
<property name="position">2</property>
|
319
|
+
</packing>
|
320
|
+
</child>
|
321
|
+
</object>
|
322
|
+
</child>
|
323
|
+
</object>
|
324
|
+
<packing>
|
325
|
+
<property name="left_attach">1</property>
|
326
|
+
<property name="top_attach">4</property>
|
327
|
+
</packing>
|
328
|
+
</child>
|
329
|
+
</object>
|
330
|
+
</child>
|
331
|
+
</template>
|
332
|
+
</interface>
|
data/sample/gtk-demo/main.rb
CHANGED
@@ -1,358 +1,177 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright (C) 2006-2015 Ruby-GNOME2 Project Team
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
8
18
|
|
9
19
|
require "gtk3"
|
20
|
+
require "optparse"
|
21
|
+
require "fileutils"
|
10
22
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class Main < Gtk::Window
|
15
|
-
TITLE_COLUMN, FILENAME_COLUMN, CLASS_COLUMN, ITALIC_COLUMN = 0, 1, 2, 3
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
super()
|
19
|
-
|
20
|
-
@current_file = nil
|
23
|
+
current_path = File.expand_path(File.dirname(__FILE__))
|
24
|
+
gresource_bin = "#{current_path}/demo.gresource"
|
25
|
+
gresource_xml = "#{current_path}/demo.gresource.xml"
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
signal_connect("destroy") { Gtk.main_quit }
|
27
|
-
|
28
|
-
signal_connect("key_press_event") do |_widget, event|
|
29
|
-
if event.state.control_mask? && event.keyval == Gdk::Keyval::KEY_q
|
30
|
-
destroy
|
31
|
-
true
|
32
|
-
else
|
33
|
-
false
|
34
|
-
end
|
35
|
-
end
|
27
|
+
system("glib-compile-resources",
|
28
|
+
"--target", gresource_bin,
|
29
|
+
"--sourcedir", current_path,
|
30
|
+
gresource_xml)
|
36
31
|
|
37
|
-
|
38
|
-
add(hbox)
|
39
|
-
|
40
|
-
tree = create_tree
|
41
|
-
scrolled_window = Gtk::ScrolledWindow.new
|
42
|
-
scrolled_window.set_policy :never, :automatic
|
43
|
-
scrolled_window.add(tree)
|
44
|
-
hbox.pack_start(scrolled_window, :expand => false, :fill => false, :padding => 0)
|
45
|
-
|
46
|
-
notebook = Gtk::Notebook.new
|
47
|
-
hbox.pack_start(notebook, :expand => true, :fill => true, :padding => 0)
|
48
|
-
|
49
|
-
notebook.append_page(create_text(@info_buffer, false),
|
50
|
-
Gtk::Label.new("_Info", :use_underline => true))
|
51
|
-
|
52
|
-
notebook.append_page(create_text(@source_buffer, true),
|
53
|
-
Gtk::Label.new("_Source", :use_underline => true))
|
54
|
-
|
55
|
-
@info_buffer.create_tag("title",
|
56
|
-
"font" => "Sans 18")
|
57
|
-
|
58
|
-
@source_buffer.create_tag("comment",
|
59
|
-
"foreground" => "red")
|
60
|
-
@source_buffer.create_tag("const",
|
61
|
-
"foreground" => "ForestGreen")
|
62
|
-
@source_buffer.create_tag("string",
|
63
|
-
"foreground" => "RosyBrown",
|
64
|
-
"weight" => Pango::FontDescription::WEIGHT_BOLD
|
65
|
-
)
|
66
|
-
@source_buffer.create_tag("reserved",
|
67
|
-
"foreground" => "purple")
|
68
|
-
end
|
69
|
-
|
70
|
-
def script_info(path)
|
71
|
-
title = nil
|
72
|
-
klass = nil
|
73
|
-
depend = nil
|
74
|
-
|
75
|
-
file = File.open(path)
|
76
|
-
file.each do |ln|
|
77
|
-
if !title && ln =~ /^=\s+(.*)$/
|
78
|
-
title = Regexp.last_match(1)
|
79
|
-
if title =~ /^(.*)\((.+?)\)$/
|
80
|
-
title = Regexp.last_match(1)
|
81
|
-
depend = Regexp.last_match(2)
|
82
|
-
end
|
83
|
-
elsif !klass && ln =~ /\s*class\s+([A-Z][A-Za-z0-9_]*)/
|
84
|
-
klass = Regexp.last_match(1)
|
85
|
-
end
|
86
|
-
|
87
|
-
break if title && klass
|
88
|
-
end
|
89
|
-
|
90
|
-
raise "File not found: #{path}." unless klass
|
91
|
-
|
92
|
-
return title, klass.intern, depend
|
93
|
-
end
|
32
|
+
gschema_bin = "#{current_path}/gschemas.compiled"
|
94
33
|
|
95
|
-
|
96
|
-
# Target scripts
|
97
|
-
scripts = Dir.glob(File.join(File.dirname(__FILE__), "*.rb"))
|
34
|
+
system("glib-compile-schemas", current_path)
|
98
35
|
|
99
|
-
|
100
|
-
|
101
|
-
|
36
|
+
at_exit do
|
37
|
+
FileUtils.rm_f([gresource_bin, gschema_bin])
|
38
|
+
end
|
102
39
|
|
103
|
-
|
104
|
-
|
105
|
-
title, klass, depend = script_info(script)
|
40
|
+
resource = Gio::Resource.load(gresource_bin)
|
41
|
+
Gio::Resources.register(resource)
|
106
42
|
|
107
|
-
|
43
|
+
ENV["GSETTINGS_SCHEMA_DIR"] = current_path
|
108
44
|
|
109
|
-
if title =~ %r{^(.+?)/(.+)$}
|
110
|
-
parent = Regexp.last_match(1)
|
111
|
-
child = Regexp.last_match(2)
|
112
45
|
|
113
|
-
unless children[parent]
|
114
|
-
children[parent] = []
|
115
|
-
index += [[parent, nil, nil, []]]
|
116
|
-
end
|
117
46
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
47
|
+
class Demo < Gtk::Application
|
48
|
+
def initialize
|
49
|
+
super("org.gtk.Demo", [:non_unique, :handles_command_line])
|
123
50
|
|
124
|
-
|
125
|
-
|
126
|
-
children[parent].sort! do |a, b|
|
127
|
-
a[0] <=> b[0]
|
128
|
-
end
|
129
|
-
end
|
51
|
+
@options = {}
|
52
|
+
@exit_status = 0
|
130
53
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
54
|
+
signal_connect "startup" do |application|
|
55
|
+
puts "startup"
|
56
|
+
@builder = Gtk::Builder.new(:resource => "/ui/main.ui")
|
57
|
+
appmenu = @builder["appmenu"]
|
58
|
+
application.set_app_menu(appmenu)
|
59
|
+
end
|
136
60
|
|
137
|
-
|
138
|
-
|
61
|
+
signal_connect "activate" do |application|
|
62
|
+
puts "activate"
|
63
|
+
begin
|
64
|
+
run_application
|
65
|
+
rescue => error
|
66
|
+
report_error(error)
|
67
|
+
@exit_status = 1
|
139
68
|
end
|
140
|
-
|
141
|
-
index
|
142
69
|
end
|
143
70
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
"text" => TITLE_COLUMN,
|
160
|
-
"style_set" => ITALIC_COLUMN
|
161
|
-
)
|
162
|
-
|
163
|
-
tree_view.append_column(column)
|
164
|
-
|
165
|
-
selection.signal_connect("changed") do |changed_selection|
|
166
|
-
iter = changed_selection.selected
|
167
|
-
load_file(iter.get_value(FILENAME_COLUMN)) if iter
|
168
|
-
end
|
169
|
-
tree_view.signal_connect("row_activated") do |_tree_view, path, _column|
|
170
|
-
row_activated_cb(_tree_view.model, path)
|
71
|
+
signal_connect "command-line" do |application, command_line|
|
72
|
+
puts "cmd"
|
73
|
+
begin
|
74
|
+
parse_command_line(command_line.arguments)
|
75
|
+
rescue SystemExit => error
|
76
|
+
error.status
|
77
|
+
rescue OptionParser::InvalidOption => error
|
78
|
+
puts error.message
|
79
|
+
1
|
80
|
+
rescue => error
|
81
|
+
report_error(error)
|
82
|
+
1
|
83
|
+
else
|
84
|
+
activate
|
85
|
+
@exit_status
|
171
86
|
end
|
87
|
+
end
|
88
|
+
end
|
172
89
|
|
173
|
-
|
174
|
-
|
90
|
+
private
|
91
|
+
def parse_command_line(arguments)
|
92
|
+
parser = OptionParser.new
|
93
|
+
parser.on("-r", "--run EXAMPLE", "Run an example") do |example|
|
94
|
+
@options[:name] = example
|
95
|
+
end
|
96
|
+
parser.on("-a", "--autoquit", "Quit after a delay") do
|
97
|
+
@options[:autoquit] = true
|
98
|
+
end
|
99
|
+
parser.on("-l", "--list", "List examples") do
|
100
|
+
@options[:list] = true
|
175
101
|
end
|
102
|
+
parser.parse(arguments)
|
103
|
+
end
|
176
104
|
|
177
|
-
|
178
|
-
|
179
|
-
|
105
|
+
def report_error(error)
|
106
|
+
puts "#{error.class}: #{error.message}"
|
107
|
+
puts error.backtrace
|
108
|
+
end
|
180
109
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
110
|
+
def run_application
|
111
|
+
if @options[:list]
|
112
|
+
puts "list"
|
113
|
+
# list_demos
|
114
|
+
quit
|
115
|
+
end
|
185
116
|
|
186
|
-
|
187
|
-
|
117
|
+
if @options[:name]
|
118
|
+
puts "name"
|
119
|
+
# lookup_for_corresponding_demo
|
120
|
+
# load_demo
|
188
121
|
end
|
189
122
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
lib = iter.get_value(FILENAME_COLUMN)
|
195
|
-
if lib
|
196
|
-
require_relative(File.basename(lib))
|
197
|
-
|
198
|
-
klass = Demo.const_get(iter.get_value(CLASS_COLUMN))
|
199
|
-
window = klass.new
|
200
|
-
window.signal_connect("destroy") do
|
201
|
-
iter.set_value(ITALIC_COLUMN, false)
|
202
|
-
end
|
203
|
-
window.show_all
|
204
|
-
@window = window
|
123
|
+
if @options[:autoquit]
|
124
|
+
puts "autoquit"
|
125
|
+
GLib::Timeout.add(1) do
|
126
|
+
#implement auto_quit
|
205
127
|
end
|
206
128
|
end
|
207
129
|
|
208
|
-
|
209
|
-
|
210
|
-
scrolled_window.set_policy(:automatic,
|
211
|
-
:automatic)
|
212
|
-
scrolled_window.set_shadow_type(:in)
|
213
|
-
|
214
|
-
text_view = Gtk::TextView.new
|
130
|
+
window = @builder["window"]
|
131
|
+
add_window(window)
|
215
132
|
|
216
|
-
|
217
|
-
|
218
|
-
|
133
|
+
action = Gio::SimpleAction.new("run")
|
134
|
+
action.signal_connect "activate" do |_action, _parameter|
|
135
|
+
# activate_run
|
136
|
+
end
|
137
|
+
add_action(action)
|
219
138
|
|
220
|
-
|
139
|
+
notebook = @builder["notebook"]
|
140
|
+
info_textwiew = @builder["info-textview"]
|
141
|
+
source_textview = @builder["source-textview"]
|
142
|
+
headerbar = @builder["headerbar"]
|
143
|
+
treeview = @builder["treeview"]
|
144
|
+
model = treeview.model
|
221
145
|
|
222
|
-
|
223
|
-
|
224
|
-
text_view.override_font(font_desc)
|
146
|
+
sw = @builder["source-scrolledwindow"]
|
147
|
+
scrollbar = sw.vscrollbar
|
225
148
|
|
226
|
-
|
227
|
-
else
|
228
|
-
text_view.set_wrap_mode(:word)
|
229
|
-
text_view.set_pixels_above_lines(2)
|
230
|
-
text_view.set_pixels_below_lines(2)
|
231
|
-
end
|
149
|
+
menu = Gtk::Menu.new
|
232
150
|
|
233
|
-
|
151
|
+
item = Gtk::MenuItem.new("Start")
|
152
|
+
menu.append(item)
|
153
|
+
item.signal_connect "activate" do
|
154
|
+
adj = scrollbar.adjustement
|
155
|
+
adj.value = adj.get_lower
|
234
156
|
end
|
235
157
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
tokenizer.tokenize(str, start_iter.offset) do |tag, start, last|
|
242
|
-
@source_buffer.apply_tag(tag.to_s,
|
243
|
-
@source_buffer.get_iter_at(:offset => start),
|
244
|
-
@source_buffer.get_iter_at(:offset => last))
|
245
|
-
end
|
158
|
+
item = Gtk::MenuItem.new("End")
|
159
|
+
menu.append(item)
|
160
|
+
item.signal_connect "activate" do
|
161
|
+
adj = scrollbar.adjustement
|
162
|
+
adj.value = adj.get_upper - adj.get_page_size
|
246
163
|
end
|
247
164
|
|
248
|
-
|
249
|
-
return if filename == @current_file
|
250
|
-
|
251
|
-
@info_buffer.delete(*@info_buffer.bounds)
|
252
|
-
|
253
|
-
@source_buffer.delete(*@source_buffer.bounds)
|
254
|
-
|
255
|
-
file = begin
|
256
|
-
File.open(filename)
|
257
|
-
rescue
|
258
|
-
$stderr.puts "Cannot open: #{$ERROR_INFO}" if $DEBUG
|
259
|
-
return
|
260
|
-
end
|
261
|
-
start = @info_buffer.get_iter_at(:offset => 0)
|
262
|
-
state = :before_header
|
263
|
-
|
264
|
-
file.each do |line|
|
265
|
-
case state
|
266
|
-
when :before_header
|
267
|
-
state = :in_header if line =~ /^=begin$/
|
268
|
-
when :in_header
|
269
|
-
if line =~ /^=end$/
|
270
|
-
state = :body
|
271
|
-
start = @source_buffer.get_iter_at(:offset => 0)
|
272
|
-
elsif line =~ /^=\s+(.*)$/
|
273
|
-
title = Regexp.last_match(1)
|
274
|
-
title.gsub!(/\s*\(.*\)$/, "") # Delete depend field
|
275
|
-
|
276
|
-
last = start
|
277
|
-
|
278
|
-
@info_buffer.insert(last, title)
|
279
|
-
start = last.clone
|
280
|
-
|
281
|
-
start.backward_chars(title.length)
|
282
|
-
@info_buffer.apply_tag("title", start, last)
|
283
|
-
|
284
|
-
start = last
|
285
|
-
else
|
286
|
-
@info_buffer.insert(start, line)
|
287
|
-
end
|
288
|
-
when :body # Reading program body
|
289
|
-
@source_buffer.insert(start, line)
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
fontify
|
165
|
+
menu.show_all
|
294
166
|
|
295
|
-
|
167
|
+
scrollbar.signal_connect "popup-menu" do
|
168
|
+
menu.popup(nil, nil, Gtk.current_event_time)
|
296
169
|
end
|
297
|
-
end
|
298
170
|
|
299
|
-
|
300
|
-
RESERVED_WORDS = %w(begin end module class def if then else while unless do case when require yield)
|
301
|
-
RESERVED_WORDS_PATTERN = Regexp.compile(/(^|\s+)(#{RESERVED_WORDS.collect { |pat| Regexp.quote(pat) }.join("|")})(\s+|$)/)
|
302
|
-
|
303
|
-
def tokenize(str, index = 0)
|
304
|
-
until str.empty?
|
305
|
-
tag = nil
|
306
|
-
|
307
|
-
case str
|
308
|
-
when /".+?"/, /".+?"/
|
309
|
-
tag = :string
|
310
|
-
when /#.*$/
|
311
|
-
tag = :comment
|
312
|
-
when RESERVED_WORDS_PATTERN
|
313
|
-
tag = :reserved
|
314
|
-
when /[A-Z][A-Za-z0-9_]+/
|
315
|
-
tag = :const
|
316
|
-
end
|
317
|
-
|
318
|
-
if tag
|
319
|
-
tokenize($LAST_MATCH_INFO.pre_match, index) do |*args|
|
320
|
-
yield(*args)
|
321
|
-
end
|
322
|
-
yield(tag, index + $LAST_MATCH_INFO.begin(0), index + $LAST_MATCH_INFO.end(0))
|
323
|
-
index += (str.length - $LAST_MATCH_INFO.post_match.length)
|
324
|
-
str = $LAST_MATCH_INFO.post_match
|
325
|
-
else
|
326
|
-
index += str.length
|
327
|
-
str = ""
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
171
|
+
window.show_all
|
331
172
|
end
|
332
173
|
end
|
333
174
|
|
334
|
-
|
335
|
-
if target
|
336
|
-
Demo::INDEX.each do |_title, filename, klass_symbol, _children|
|
337
|
-
if target == filename || target == klass_symbol.id2name
|
338
|
-
require filename
|
339
|
-
|
340
|
-
window = Demo.const_get(klass_symbol).new
|
341
|
-
window.show_all
|
342
|
-
|
343
|
-
class << window
|
344
|
-
def quit
|
345
|
-
Gtk.main_quit
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
break
|
350
|
-
end
|
351
|
-
end
|
352
|
-
else
|
353
|
-
main = Demo::Main.new
|
354
|
-
main.set_default_size(600, 400)
|
355
|
-
main.show_all
|
356
|
-
end
|
175
|
+
demo = Demo.new
|
357
176
|
|
358
|
-
|
177
|
+
exit(demo.run([$PROGRAM_NAME] + ARGV))
|