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
@@ -16,7 +16,7 @@ Here is the most basic example that illustrate the principles of widget hierarch
16
16
  require "gtk3"
17
17
 
18
18
  window = Gtk::Window.new("First example")
19
- window.set_request_size(400, 400)
19
+ window.set_size_request(400, 400)
20
20
  window.set_border_width(10)
21
21
 
22
22
  button = Gtk::Button.new(:label => "Say hello")
@@ -157,7 +157,7 @@ app.signal_connect "activate" do |application|
157
157
  window.set_title("Window")
158
158
  window.set_border_width(10)
159
159
 
160
- # Here we construct the container that is going pack our buttons
160
+ # Here we construct the container that is going pack our buttons
161
161
  grid = Gtk::Grid.new
162
162
 
163
163
  # Pack the container in the window
@@ -281,7 +281,7 @@ Here is the "builder.ui" file that describes the interface:
281
281
  The usage of the `Gtk::Builder` is really easy, we just create an instance from the
282
282
  file "builder.ui" with `Gtk::Builder.new(:file => builder_file)`. Then you can access every widget or part of the interface thanks to its name: `window = builder.get_object("window")`. Note that `Gtk::Builder` can also be used to construct objects that are not widgets, such as tree models, adjustments, etc.
283
283
 
284
- The XML definition of the interface can be loaded from a file, a string or a path in a gresource binary. More informations related to this XML definition can be found [here](https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI). Those files are generally built with [glade](https://glade.gnome.org/).
284
+ The XML definition of the interface can be loaded from a file, a string or a path in a gresource binary. More informations related to this XML definition can be found [here](https://developer.gnome.org/gtk3/stable/GtkBuilder.html#BUILDER-UI). Those files are generally built with [glade](https://glade.gnome.org/).
285
285
 
286
286
 
287
287
  ## Building applications
@@ -296,7 +296,7 @@ require "gtk3"
296
296
  class ExampleAppWindow < Gtk::ApplicationWindow
297
297
 
298
298
  def open(file)
299
-
299
+
300
300
  end
301
301
  end
302
302
 
@@ -318,7 +318,7 @@ class ExampleApp < Gtk::Application
318
318
  end
319
319
 
320
320
  files.each { |file| win.open(file) }
321
-
321
+
322
322
  win.present
323
323
  end
324
324
  end
@@ -393,7 +393,7 @@ Here is the "window.ui" file that contains the template of the window:
393
393
  ```
394
394
  Unlike regular interface descriptions, in template XML descriptions, a`<template>` tag is expected as a direct child of the toplevel `<interface>` tag. Yhe `<template>` tag must specify the "*class*" attribute which must be the class name of the widget. Optionally, the "*parent*" attribute may be specified to indicate the direct parent class (superclass).
395
395
 
396
- More informations can be found in the part [building composite widgets from template XML](https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget.description) of the `Gtk::Widget` documentation.
396
+ More informations can be found in the part [building composite widgets from template XML](https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget.description) of the `Gtk::Widget` documentation.
397
397
 
398
398
  #### Link a template to a custom class widget.
399
399
 
@@ -411,7 +411,7 @@ class ExampleAppWindow < Gtk::ApplicationWindow
411
411
  end
412
412
 
413
413
  def open(file)
414
-
414
+
415
415
  end
416
416
  end
417
417
  ```
@@ -482,7 +482,7 @@ This new way to access the stack widget is used in the following code. We have p
482
482
  ```ruby
483
483
  class ExampleAppWindow < Gtk::ApplicationWindow
484
484
  def open(file)
485
-
485
+
486
486
  end
487
487
  end
488
488
 
@@ -500,7 +500,7 @@ class ExampleApp < Gtk::Application
500
500
  end
501
501
 
502
502
  files.each { |file| win.open(file) }
503
-
503
+
504
504
  win.present
505
505
  end
506
506
  end
@@ -526,14 +526,14 @@ def open(file)
526
526
  view.buffer.text = stream.read
527
527
  end
528
528
  ```
529
- Each file is opened and loaded in a `Gtk::TextView` with
529
+ Each file is opened and loaded in a `Gtk::TextView` with
530
530
 
531
531
  ```ruby
532
532
  stream = file.read
533
533
  view.buffer.text = stream.read
534
534
  ```
535
535
 
536
- We get the basename, of the file in argument, that will be used as title for each tab of the stack widget:
536
+ We get the basename, of the file in argument, that will be used as title for each tab of the stack widget:
537
537
 
538
538
  ```
539
539
  stack.add_titled(scrolled, basename, basename)
@@ -611,7 +611,7 @@ application.add_action(action)
611
611
 
612
612
  #### Add accelerators for action.
613
613
 
614
- An accelerator is just a keys combination that acts as a shortcut for an action.
614
+ An accelerator is just a keys combination that acts as a shortcut for an action.
615
615
 
616
616
  ```ruby
617
617
  quit_accels = ["<Ctrl>Q"]
@@ -655,7 +655,7 @@ We are going to use `Gio::Settings` to store our preferences. `Gio::Settings` re
655
655
  </schemalist>
656
656
  ```
657
657
 
658
- Before we can make use of this schema in our application, we need to compile it into the binary form that `Gio::Settings` expects.
658
+ Before we can make use of this schema in our application, we need to compile it into the binary form that `Gio::Settings` expects.
659
659
 
660
660
  ```ruby
661
661
  system("glib-compile-schemas", data_path)
@@ -670,12 +670,12 @@ Gio::SettingsSchemaSource.new(data_path,
670
670
  false)
671
671
 
672
672
  ```
673
- This is the corresponding method to the function [g_settings_schema_source_new_from_directory](https://developer.gnome.org/gio/stable/gio-GSettingsSchema-GSettingsSchemaSource.html#g-settings-schema-source-new-from-directory).
673
+ This is the corresponding method to the function [g_settings_schema_source_new_from_directory](https://developer.gnome.org/gio/stable/gio-GSettingsSchema-GSettingsSchemaSource.html#g-settings-schema-source-new-from-directory).
674
674
 
675
675
  As an alternative, our schema can just be loaded by using the `GSETTINGS_SCHEMA_DIR` environment variable.
676
676
 
677
677
  ```ruby
678
- ENV["GSETTINGS_SCHEMA_DIR"] = data_path
678
+ ENV["GSETTINGS_SCHEMA_DIR"] = data_path
679
679
  ```
680
680
  More informations on the use of gschemas can be found [here](https://developer.gnome.org/gio/stable/gio-GSettingsSchema-GSettingsSchemaSource.html)
681
681
 
@@ -842,11 +842,11 @@ def open(file)
842
842
  stream = file.read
843
843
  buffer = view.buffer
844
844
  buffer.text = stream.read
845
- tag = buffer.create_tag()
845
+ tag = buffer.create_tag()
846
846
  @settings.bind("font", tag, "font", Gio::SettingsBindFlags::DEFAULT)
847
847
  buffer.apply_tag(tag, buffer.start_iter, buffer.end_iter)
848
848
  end
849
- ```
849
+ ```
850
850
 
851
851
  ### Adding a search bar
852
852
  https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.10
@@ -1297,4 +1297,4 @@ Our application already uses a `Gtk::HeaderBar`, but so far it still gets a 'nor
1297
1297
  </interface>
1298
1298
  ```
1299
1299
 
1300
- A small extra bonus of using a header bar is that we get a fallback application menu for free.
1300
+ A small extra bonus of using a header bar is that we get a fallback application menu for free.
@@ -66,7 +66,7 @@ class TestGtkClipboard < Test::Unit::TestCase
66
66
  received_image = image
67
67
  loop.quit
68
68
  end
69
- image = Gdk::Pixbuf.new(fixture_path("gnome-logo-icon.png"))
69
+ image = GdkPixbuf::Pixbuf.new(:file => fixture_path("gnome-logo-icon.png"))
70
70
  @clipboard.image = image
71
71
  loop.run
72
72
 
@@ -27,7 +27,7 @@ class TestGtkComboBox < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  test ":model" do
30
- model = Gtk::ListStore.new(Gdk::Pixbuf, String)
30
+ model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String)
31
31
  combo_box = Gtk::ComboBox.new(:entry => true, :model => model)
32
32
  assert do
33
33
  combo_box.has_entry?
@@ -55,7 +55,7 @@ class TestGtkComboBox < Test::Unit::TestCase
55
55
  end
56
56
 
57
57
  test ":model" do
58
- model = Gtk::ListStore.new(Gdk::Pixbuf, String)
58
+ model = Gtk::ListStore.new(GdkPixbuf::Pixbuf, String)
59
59
  combo_box = Gtk::ComboBox.new(:model => model)
60
60
  assert do
61
61
  not combo_box.has_entry?
@@ -41,7 +41,7 @@ class TestGtkIconView < Test::Unit::TestCase
41
41
  class TestGetCellRect < self
42
42
  def setup
43
43
  only_gtk_version(3, 6, 0)
44
- model = Gtk::ListStore.new(String, Gdk::Pixbuf)
44
+ model = Gtk::ListStore.new(String, GdkPixbuf::Pixbuf)
45
45
  iter = model.append
46
46
  model.set_values(iter, ["label", nil])
47
47
  @path = iter.path
@@ -53,7 +53,7 @@ class TestGtkIconView < Test::Unit::TestCase
53
53
  end
54
54
 
55
55
  def test_not_found
56
- indices, _ = @path.indices
56
+ indices = @path.indices
57
57
  not_found_path = Gtk::TreePath.new
58
58
  not_found_path.append_index(indices.last + 1)
59
59
  assert_nil(@icon_view.get_cell_rect(not_found_path))
@@ -40,13 +40,13 @@ class TestGtkImage < Test::Unit::TestCase
40
40
  end
41
41
 
42
42
  test "resource" do
43
+ only_gtk_version(3, 18, 0)
43
44
  resource = Gio::Resource.load(fixture_path("image.gresource"))
44
45
  Gio::Resources.register(resource)
45
46
  begin
46
47
  resource_path = "/org/ruby/gnome/gnome-logo-icon.png"
47
48
  image = Gtk::Image.new(:resource => resource_path,
48
49
  :size => :dialog)
49
- omit("GTK+ 3.16 doesn't support getting resource path. See GitHub#461.")
50
50
  assert_equal(resource_path,
51
51
  image.resource)
52
52
  ensure
@@ -194,20 +194,26 @@ class TestGtkListStore < Test::Unit::TestCase
194
194
  test "iter" do
195
195
  GC.start
196
196
  n_iterators = count_objects(Gtk::TreeIter)
197
- 50.times do |i|
197
+ n_items = 50
198
+ n_iterators_created = 100
199
+ n_iterators_for_remove = 1
200
+
201
+ n_items.times do |i|
198
202
  iter = @store.append
199
203
  iter[ID] = i
200
204
  iter[NAME] = i.to_s
201
205
  end
202
- 100.times do
206
+ n_iterators_created.times do
203
207
  @store.iter_first
204
208
  end
205
209
  iter = @store.iter_first
206
210
  while @store.remove(iter); end
207
211
  assert_equal(0, @store.to_enum(:each).to_a.size)
212
+
208
213
  GC.start
209
214
  assert do
210
- count_objects(Gtk::TreeIter) <= n_iterators + 1
215
+ count_objects(Gtk::TreeIter) <
216
+ (n_iterators + n_items + n_iterators_created + n_iterators_for_remove)
211
217
  end
212
218
  end
213
219
 
@@ -0,0 +1,64 @@
1
+ # Copyright (C) 2016 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestGtkTextView < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ sub_test_case "instance methods" do
21
+ def setup
22
+ only_gtk_version(3, 14)
23
+ @text_buffer = Gtk::TextBuffer.new
24
+ @text_buffer.text = "Hello"
25
+ @text_view = Gtk::TextView.new(@text_buffer)
26
+ end
27
+
28
+ sub_test_case "#get_iter_at" do
29
+ test ":location" do
30
+ iter = @text_view.get_iter_at(:location => [0, 0])
31
+ assert_equal("H", iter.char)
32
+ end
33
+
34
+ test ":position" do
35
+ iter, trailing = @text_view.get_iter_at(:position => [0, 0])
36
+ assert_equal(["H", 0],
37
+ [iter.char, trailing])
38
+ end
39
+ end
40
+
41
+ sub_test_case "#get_iter_at_location" do
42
+ test "found" do
43
+ iter = @text_view.get_iter_at_location(0, 0)
44
+ assert_equal("H", iter.char)
45
+ end
46
+
47
+ test "not found" do
48
+ assert_nil(@text_view.get_iter_at_location(100, 0))
49
+ end
50
+ end
51
+
52
+ sub_test_case "#get_iter_at_position" do
53
+ test "found" do
54
+ iter, trailing = @text_view.get_iter_at_position(0, 0)
55
+ assert_equal(["H", 0],
56
+ [iter.char, trailing])
57
+ end
58
+
59
+ test "not found" do
60
+ assert_nil(@text_view.get_iter_at_position(100, 0))
61
+ end
62
+ end
63
+ end
64
+ end
@@ -30,9 +30,7 @@ class TestGtkTreePath < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def test_indices
33
- indices, depth = tree_path("2").indices
34
- assert_equal([[2], 1],
35
- [indices, depth])
33
+ assert_equal([2], tree_path("2").indices)
36
34
  end
37
35
 
38
36
  def test_down!
@@ -87,6 +87,67 @@ class TestGtkTreeView < Test::Unit::TestCase
87
87
  normalized_data)
88
88
  end
89
89
 
90
+ sub_test_case "#expand_row" do
91
+ setup do
92
+ @parent = @store.append(nil)
93
+ @parent[0] = "parent"
94
+ @child = @store.append(@parent)
95
+ @child[0] = "child"
96
+ @grand_child = @store.append(@child)
97
+ @grand_child[0] = "grand child"
98
+ end
99
+
100
+ test "default" do
101
+ @view.expand_row(@parent.path)
102
+ assert do
103
+ @view.row_expanded?(@parent.path)
104
+ end
105
+ assert do
106
+ @view.row_expanded?(@child.path)
107
+ end
108
+ end
109
+
110
+ test "true" do
111
+ @view.expand_row(@parent.path, true)
112
+ assert do
113
+ @view.row_expanded?(@parent.path)
114
+ end
115
+ assert do
116
+ @view.row_expanded?(@child.path)
117
+ end
118
+ end
119
+
120
+ test "false" do
121
+ @view.expand_row(@parent.path, false)
122
+ assert do
123
+ @view.row_expanded?(@parent.path)
124
+ end
125
+ assert do
126
+ not @view.row_expanded?(@child.path)
127
+ end
128
+ end
129
+
130
+ test ":open_all => true" do
131
+ @view.expand_row(@parent.path, :open_all => true)
132
+ assert do
133
+ @view.row_expanded?(@parent.path)
134
+ end
135
+ assert do
136
+ @view.row_expanded?(@child.path)
137
+ end
138
+ end
139
+
140
+ test ":open_all => false" do
141
+ @view.expand_row(@parent.path, :open_all => false)
142
+ assert do
143
+ @view.row_expanded?(@parent.path)
144
+ end
145
+ assert do
146
+ not @view.row_expanded?(@child.path)
147
+ end
148
+ end
149
+ end
150
+
90
151
  test "#row_expanded?" do
91
152
  parent = @store.append(nil)
92
153
  parent[0] = "Hello"
@@ -129,4 +190,40 @@ class TestGtkTreeView < Test::Unit::TestCase
129
190
  end
130
191
  end
131
192
  end
193
+
194
+ sub_test_case "signal" do
195
+ def setup
196
+ @store = Gtk::TreeStore.new(String)
197
+ @view = Gtk::TreeView.new(@store)
198
+
199
+ root = @store.append(nil)
200
+ root[0] = "root"
201
+ child = @store.append(root)
202
+ child[0] = "child"
203
+ grand_child = @store.append(child)
204
+ grand_child[0] = "grand child"
205
+ end
206
+
207
+ test "row-collapsed" do
208
+ @view.expand_all
209
+
210
+ values = []
211
+ @view.signal_connect("row-collapsed") do |_, iter, path|
212
+ values << iter[0]
213
+ end
214
+ @view.collapse_row(Gtk::TreePath.new("0:0"))
215
+ assert_equal(["child"], values)
216
+ end
217
+
218
+ test "row-expanded" do
219
+ @view.collapse_all
220
+
221
+ values = []
222
+ @view.signal_connect("row-expanded") do |_, iter, path|
223
+ values << iter[0]
224
+ end
225
+ @view.expand_row(Gtk::TreePath.new("0"))
226
+ assert_equal(["root", "child"], values)
227
+ end
228
+ end
132
229
  end
@@ -26,8 +26,8 @@ class TestGtkWindow < Test::Unit::TestCase
26
26
  @window.icon = fixture_path("gnome-logo-icon.png")
27
27
  end
28
28
 
29
- test "Gdk::Pixbuf" do
30
- icon = Gdk::Pixbuf.new(fixture_path("gnome-logo-icon.png"))
29
+ test "GdkPixbuf::Pixbuf" do
30
+ icon = GdkPixbuf::Pixbuf.new(:file => fixture_path("gnome-logo-icon.png"))
31
31
  @window.icon = icon
32
32
  end
33
33
  end
@@ -0,0 +1,56 @@
1
+ # Copyright (C) 2016 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestPangoContext < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ def test_set_shape_renderer
21
+ text = "this is a test"
22
+ label = Gtk::Label.new(text)
23
+ layout = label.layout
24
+
25
+ last_block_arguments = nil
26
+ layout.context.set_shape_renderer do |cr, attr, do_path|
27
+ last_block_arguments = [cr.class, attr.class, do_path]
28
+ end
29
+
30
+ metrics = layout.context.get_metrics(layout.font_description)
31
+ ascent = metrics.ascent
32
+ logical_rect = Pango::Rectangle.new(0, -ascent, ascent, ascent)
33
+ ink_rect = logical_rect.dup
34
+ attrs = Pango::AttrList.new
35
+ attr = Pango::AttrShape.new(ink_rect, logical_rect, "a")
36
+ attr.start_index = text[0, text.index("a")].bytesize
37
+ attr.end_index = attr.start_index + "a".bytesize
38
+ attrs.insert(attr)
39
+ label.attributes = attrs
40
+
41
+ window = Gtk::Window.new
42
+ window.signal_connect("destroy") do
43
+ Gtk.main_quit
44
+ end
45
+ window.add(label)
46
+ GLib::Timeout.add(1000) do
47
+ window.destroy
48
+ GLib::Source::REMOVE
49
+ end
50
+ window.show_all
51
+ Gtk.main
52
+
53
+ assert_equal([Cairo::Context, Pango::AttrShape, false],
54
+ last_block_arguments)
55
+ end
56
+ end