gtk3 3.2.5 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,12 @@
8
8
  =end
9
9
  class BuilderDemo
10
10
  def initialize(_main_window)
11
- @builder = Gtk::Builder.new(:resource => "/builder/demo.ui")
11
+ if Gtk::Version.or_later?(3, 20)
12
+ ui_path = "/builder/demo.ui"
13
+ else
14
+ ui_path = "/builder/demo-3.18.ui"
15
+ end
16
+ @builder = Gtk::Builder.new(:resource => ui_path)
12
17
  @builder.connect_signals {}
13
18
 
14
19
  @window = @builder["window1"]
@@ -89,7 +89,6 @@ class ButtonBoxDemo
89
89
 
90
90
  def create_bbox(horizontal, title, spacing, layout)
91
91
  frame = Gtk::Frame.new(title)
92
- bbox = nil
93
92
 
94
93
  orientation = horizontal ? :horizontal : :vertical
95
94
  bbox = Gtk::ButtonBox.new(orientation)
@@ -0,0 +1,304 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!--*- mode: xml -*-->
3
+ <interface>
4
+ <object class="GtkListStore" id="liststore1">
5
+ <columns>
6
+ <column type="gchararray"/>
7
+ <column type="gchararray"/>
8
+ <column type="gint"/>
9
+ <column type="gchararray"/>
10
+ </columns>
11
+ <data>
12
+ <row>
13
+ <col id="0" translatable="yes">John</col>
14
+ <col id="1" translatable="yes">Doe</col>
15
+ <col id="2">25</col>
16
+ <col id="3" translatable="yes">This is the John Doe row</col>
17
+ </row>
18
+ <row>
19
+ <col id="0" translatable="yes">Mary</col>
20
+ <col id="1" translatable="yes">Unknown</col>
21
+ <col id="2">50</col>
22
+ <col id="3" translatable="yes">This is the Mary Unknown row</col>
23
+ </row>
24
+ </data>
25
+ </object>
26
+ <object class="GtkAboutDialog" id="aboutdialog1">
27
+ <property name="program-name" translatable="yes">Builder demo</property>
28
+ <property name="logo-icon-name" translatable="yes">gtk3-demo</property>
29
+ <accessibility>
30
+ <relation target="window1" type="subwindow-of"/>
31
+ </accessibility>
32
+ </object>
33
+ <object class="GtkWindow" id="window1">
34
+ <property name="default_height">250</property>
35
+ <property name="default_width">440</property>
36
+ <property name="title" translatable="yes">Builder</property>
37
+ <child>
38
+ <object class="GtkBox" id="vbox1">
39
+ <property name="visible">1</property>
40
+ <property name="orientation">vertical</property>
41
+ <child>
42
+ <object class="GtkMenuBar" id="menubar1">
43
+ <property name="visible">1</property>
44
+ <child internal-child="accessible">
45
+ <object class="AtkObject" id="a11y-menubar">
46
+ <property name="AtkObject::accessible-name">The menubar</property>
47
+ </object>
48
+ </child>
49
+ <child>
50
+ <object class="GtkMenuItem">
51
+ <property name="visible">1</property>
52
+ <property name="label" translatable="yes">_File</property>
53
+ <property name="use-underline">1</property>
54
+ <child type="submenu">
55
+ <object class="GtkMenu">
56
+ <child>
57
+ <object class="GtkMenuItem" id="new_item">
58
+ <property name="visible">1</property>
59
+ <property name="label" translatable="yes">_New</property>
60
+ <property name="use-underline">1</property>
61
+ </object>
62
+ </child>
63
+ <child>
64
+ <object class="GtkMenuItem" id="open_item">
65
+ <property name="visible">1</property>
66
+ <property name="label" translatable="yes">_Open</property>
67
+ <property name="use-underline">1</property>
68
+ </object>
69
+ </child>
70
+ <child>
71
+ <object class="GtkMenuItem" id="save_item">
72
+ <property name="visible">1</property>
73
+ <property name="label" translatable="yes">_Save</property>
74
+ <property name="use-underline">1</property>
75
+ </object>
76
+ </child>
77
+ <child>
78
+ <object class="GtkMenuItem" id="save_as_item">
79
+ <property name="visible">1</property>
80
+ <property name="label" translatable="yes">Save _As</property>
81
+ <property name="use-underline">1</property>
82
+ <accelerator key="s" modifiers="shift-mask" signal="activate"/>
83
+ </object>
84
+ </child>
85
+ <child>
86
+ <object class="GtkSeparatorMenuItem">
87
+ <property name="visible">1</property>
88
+ </object>
89
+ </child>
90
+ <child>
91
+ <object class="GtkMenuItem" id="quit_item">
92
+ <property name="visible">1</property>
93
+ <property name="label" translatable="yes">_Quit</property>
94
+ <property name="use-underline">1</property>
95
+ <property name="action-name">win.quit</property>
96
+ </object>
97
+ </child>
98
+ </object>
99
+ </child>
100
+ </object>
101
+ </child>
102
+ <child>
103
+ <object class="GtkMenuItem">
104
+ <property name="visible">1</property>
105
+ <property name="label" translatable="yes">_Edit</property>
106
+ <property name="use-underline">1</property>
107
+ <child type="submenu">
108
+ <object class="GtkMenu">
109
+ <child>
110
+ <object class="GtkMenuItem" id="copy_item">
111
+ <property name="visible">1</property>
112
+ <property name="label" translatable="yes">_Copy</property>
113
+ <property name="use-underline">1</property>
114
+ </object>
115
+ </child>
116
+ <child>
117
+ <object class="GtkMenuItem" id="cut_item">
118
+ <property name="visible">1</property>
119
+ <property name="label" translatable="yes">_Cut</property>
120
+ <property name="use-underline">1</property>
121
+ </object>
122
+ </child>
123
+ <child>
124
+ <object class="GtkMenuItem" id="paste_item">
125
+ <property name="visible">1</property>
126
+ <property name="label" translatable="yes">_Paste</property>
127
+ <property name="use-underline">1</property>
128
+ </object>
129
+ </child>
130
+ </object>
131
+ </child>
132
+ </object>
133
+ </child>
134
+ <child>
135
+ <object class="GtkMenuItem">
136
+ <property name="visible">1</property>
137
+ <property name="label" translatable="yes">_Help</property>
138
+ <property name="use-underline">1</property>
139
+ <child type="submenu">
140
+ <object class="GtkMenu">
141
+ <child>
142
+ <object class="GtkMenuItem" id="help_item">
143
+ <property name="visible">1</property>
144
+ <property name="label" translatable="yes">_Help</property>
145
+ <property name="use-underline">1</property>
146
+ <property name="action-name">win.help</property>
147
+ </object>
148
+ </child>
149
+ <child>
150
+ <object class="GtkMenuItem" id="about_item">
151
+ <property name="visible">1</property>
152
+ <property name="label" translatable="yes">_About</property>
153
+ <property name="use-underline">1</property>
154
+ <property name="action-name">win.about</property>
155
+ </object>
156
+ </child>
157
+ </object>
158
+ </child>
159
+ </object>
160
+ </child>
161
+ </object>
162
+ <packing>
163
+ <property name="expand">0</property>
164
+ </packing>
165
+ </child>
166
+ <child>
167
+ <object class="GtkToolbar" id="toolbar1">
168
+ <property name="visible">1</property>
169
+ <child internal-child="accessible">
170
+ <object class="AtkObject" id="a11y-toolbar">
171
+ <property name="AtkObject::accessible-name">The toolbar</property>
172
+ </object>
173
+ </child>
174
+ <child>
175
+ <object class="GtkToolButton">
176
+ <property name="visible">1</property>
177
+ <property name="label" translatable="yes">New</property>
178
+ <property name="tooltip-text" translatable="yes">Create a new file</property>
179
+ <property name="icon-name">document-new</property>
180
+ </object>
181
+ </child>
182
+ <child>
183
+ <object class="GtkToolButton">
184
+ <property name="visible">1</property>
185
+ <property name="label" translatable="yes">Open</property>
186
+ <property name="tooltip-text" translatable="yes">Open a file</property>
187
+ <property name="icon-name">document-open</property>
188
+ </object>
189
+ </child>
190
+ <child>
191
+ <object class="GtkToolButton">
192
+ <property name="visible">1</property>
193
+ <property name="label" translatable="yes">Save</property>
194
+ <property name="tooltip-text" translatable="yes">Save a file</property>
195
+ <property name="icon-name">document-save</property>
196
+ <property name="is-important">1</property>
197
+ </object>
198
+ </child>
199
+ <child>
200
+ <object class="GtkSeparatorToolItem">
201
+ <property name="visible">1</property>
202
+ </object>
203
+ </child>
204
+ <child>
205
+ <object class="GtkToolButton">
206
+ <property name="visible">1</property>
207
+ <property name="label" translatable="yes">Copy</property>
208
+ <property name="tooltip-text" translatable="yes">Copy selected object into the clipboard</property>
209
+ <property name="icon-name">edit-copy</property>
210
+ </object>
211
+ </child>
212
+ <child>
213
+ <object class="GtkToolButton">
214
+ <property name="visible">1</property>
215
+ <property name="label" translatable="yes">Cut</property>
216
+ <property name="tooltip-text" translatable="yes">Cut selected object into the clipboard</property>
217
+ <property name="icon-name">edit-cut</property>
218
+ </object>
219
+ </child>
220
+ <child>
221
+ <object class="GtkToolButton">
222
+ <property name="visible">1</property>
223
+ <property name="label" translatable="yes">Paste</property>
224
+ <property name="tooltip-text" translatable="yes">Paste object from the clipboard</property>
225
+ <property name="icon-name">edit-paste</property>
226
+ </object>
227
+ </child>
228
+ </object>
229
+ <packing>
230
+ <property name="expand">0</property>
231
+ <property name="position">1</property>
232
+ </packing>
233
+ </child>
234
+ <child>
235
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
236
+ <property name="shadow_type">in</property>
237
+ <property name="visible">1</property>
238
+ <child>
239
+ <object class="GtkTreeView" id="treeview1">
240
+ <property name="visible">1</property>
241
+ <property name="model">liststore1</property>
242
+ <property name="tooltip-column">3</property>
243
+ <child internal-child="accessible">
244
+ <object class="AtkObject" id="a11y-treeview">
245
+ <property name="AtkObject::accessible-name">Name list</property>
246
+ <property name="AtkObject::accessible-description">
247
+ A list of person with name, surname and age columns
248
+ </property>
249
+ </object>
250
+ </child>
251
+ <child>
252
+ <object class="GtkTreeViewColumn" id="column1">
253
+ <property name="title">Name</property>
254
+ <child>
255
+ <object class="GtkCellRendererText" id="renderer1"/>
256
+ <attributes>
257
+ <attribute name="text">0</attribute>
258
+ </attributes>
259
+ </child>
260
+ </object>
261
+ </child>
262
+ <child>
263
+ <object class="GtkTreeViewColumn" id="column2">
264
+ <property name="title">Surname</property>
265
+ <child>
266
+ <object class="GtkCellRendererText" id="renderer2"/>
267
+ <attributes>
268
+ <attribute name="text">1</attribute>
269
+ </attributes>
270
+ </child>
271
+ </object>
272
+ </child>
273
+ <child>
274
+ <object class="GtkTreeViewColumn" id="column3">
275
+ <property name="title">Age</property>
276
+ <child>
277
+ <object class="GtkCellRendererText" id="renderer3"/>
278
+ <attributes>
279
+ <attribute name="text">2</attribute>
280
+ </attributes>
281
+ </child>
282
+ </object>
283
+ </child>
284
+ </object>
285
+ </child>
286
+ </object>
287
+ <packing>
288
+ <property name="position">2</property>
289
+ <property name="expand">1</property>
290
+ </packing>
291
+ </child>
292
+ <child>
293
+ <object class="GtkStatusbar" id="statusbar1">
294
+ <property name="visible">1</property>
295
+ </object>
296
+ <packing>
297
+ <property name="position">3</property>
298
+ <property name="expand">0</property>
299
+ </packing>
300
+ </child>
301
+ </object>
302
+ </child>
303
+ </object>
304
+ </interface>
@@ -11,6 +11,7 @@
11
11
  </gresource>-->
12
12
  <gresource prefix="/builder">
13
13
  <file>demo.ui</file>
14
+ <file>demo-3.18.ui</file>
14
15
  </gresource>
15
16
  <gresource prefix="/css_accordion">
16
17
  <file>css_accordion.css</file>
@@ -208,6 +209,7 @@
208
209
  </gresource>
209
210
  <gresource prefix="/popover">
210
211
  <file>popover.ui</file>
212
+ <file>popover-3.18.ui</file>
211
213
  </gresource>
212
214
  <gresource prefix="/glarea">
213
215
  <file>glarea-gl.fs.glsl</file>
@@ -15,7 +15,7 @@
15
15
  =end
16
16
  class EditableCellsDemo
17
17
  Item = Struct.new("Item", :number, :product, :yummy)
18
- COL_ITEM_NUM, COL_ITEM_PROD, COL_ITEM_YUMMY = *(0..3).to_a
18
+ COL_ITEM_NUM, COL_ITEM_PROD, COL_ITEM_YUMMY = 0, 1, 2
19
19
  COL_NUM_TEXT = 0
20
20
 
21
21
  def initialize(main_window)
@@ -27,21 +27,8 @@ class HypertextDemo
27
27
  false
28
28
  end
29
29
 
30
- # Links can also be activated by clicking or tapping.
31
30
  @view.signal_connect "event-after" do |widget, event|
32
- if event.is_a?(Gdk::EventButton) && event.button == 1
33
- buffer = widget.buffer
34
-
35
- # we shouldn't follow a link if the user has selected something
36
- range = buffer.selection_bounds
37
- return false if range && range[0].offset != range[1].offset
38
-
39
- x, y = widget.window_to_buffer_coords(:widget, event.x, event.y)
40
- iter = widget.get_iter_at_location(x, y)
41
- follow_if_link(iter) if iter
42
- else
43
- false
44
- end
31
+ event_after(event)
45
32
  end
46
33
 
47
34
  @view.signal_connect "motion-notify-event" do |widget, event|
@@ -125,7 +112,7 @@ tags don't have to affect appearance. They can instead affect the
125
112
  behavior of mouse and key presses, "lock" a range of text so the
126
113
  user can't edit it, or countless other things.\n
127
114
  EOF
128
- insert_link(iter, "Goback", 1)
115
+ insert_link(iter, "Go back", 1)
129
116
  end
130
117
 
131
118
  def generate_page_3
@@ -148,6 +135,28 @@ EOF
148
135
  @buffer.insert(iter, text, :tags => [tag])
149
136
  end
150
137
 
138
+ # Links can also be activated by clicking or tapping.
139
+ def event_after(event)
140
+ case event.type
141
+ when Gdk::EventType::BUTTON_RELEASE
142
+ return false unless event.button == Gdk::BUTTON_PRIMARY
143
+ when Gdk::EventType::TOUCH_END
144
+ else
145
+ return false
146
+ end
147
+
148
+ buffer = @view.buffer
149
+
150
+ # we shouldn't follow a link if the user has selected something
151
+ range = buffer.selection_bounds
152
+ return false if range && range[0].offset != range[1].offset
153
+
154
+ x, y = @view.window_to_buffer_coords(:widget, event.x, event.y)
155
+ iter = @view.get_iter_at_location(x, y)
156
+ follow_if_link(iter) if iter
157
+ true
158
+ end
159
+
151
160
  # Looks at all tags covering the position of iter in the text view,
152
161
  # and if one of them is a link, follow it by showing the page identified
153
162
  # by the data attached to it.
@@ -57,18 +57,23 @@ class IconviewEditDemo
57
57
  @icon_view.set_cell_data_func(renderer) do |_layout, cell_renderer, model, iter|
58
58
  text = model.get_value(iter, COL_TEXT)
59
59
  if text
60
- color = Gdk::RGBA.parse(text)
61
- pixel = nil
60
+ begin
61
+ color = Gdk::RGBA.parse(text)
62
+ rescue ArgumentError
63
+ color = nil
64
+ end
62
65
  if color
63
66
  pixel = (color.red * 255).to_i << 24 |
64
67
  (color.green * 255).to_i << 16 |
65
68
  (color.blue * 255).to_i << 8 |
66
69
  (color.alpha * 255).to_i
70
+ else
71
+ pixel = 0
67
72
  end
68
73
  pixbuf = GdkPixbuf::Pixbuf.new(:colorspace => :rgb, :has_alpha => true,
69
74
  :bits_per_sample => 8,
70
75
  :width => 24, :height => 24)
71
- pixbuf.fill!(pixel) if pixel
76
+ pixbuf.fill!(pixel)
72
77
  cell_renderer.set_property("pixbuf", pixbuf)
73
78
  end
74
79
  end
@@ -108,7 +108,9 @@ class InfobarDemo
108
108
  :buttons => :ok,
109
109
  :message => "You clicked a button on an info bar")
110
110
  dialog.secondary_text = "Your response has id #{response_id}"
111
- dialog.signal_connect("response", &:destroy)
111
+ dialog.signal_connect("response") do
112
+ dialog.destroy
113
+ end
112
114
  dialog.show_all
113
115
  end
114
116
  end