gtk3 3.1.6 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 896364a10f88da275d77be15db8f54a5c416661d
4
- data.tar.gz: 7bcbac84c450e6e57c4e61e23e3cef003c3420b9
3
+ metadata.gz: 46d25e3ef4f8f4f867e7c4c302a40aeaf98751c3
4
+ data.tar.gz: cfa9b630510b66a3fb79a23ce87c373a979d82a6
5
5
  SHA512:
6
- metadata.gz: 53fa4aa53b1cb1cbc8855edeb89432e607d0045b33a3676e96a5d5ca96b87015fe041eb4dde1075bf95006d05e26721598abd0877f30564bccdf4a617fa9540b
7
- data.tar.gz: 9e55a0e3a519703e60844491e449bfebb636cd99861e19b0aba9f0bd3ba586f930a28c099995ff7ed99512b1a1ea3428ab3b2175faed2c9abf73f3faa46851fc
6
+ metadata.gz: 33e0431bf941c84715b89161754c72bab2e0b6ad623eb06ee00f887b551799977e1d6422374b370ec44c88d20b18c6a9a931247edb70709f3c46c1a2c145e5d8
7
+ data.tar.gz: bc25f8ff6ccd9b26652e39e0aa11c33a7a7001934828cd72f07954fa5c974ab2d4a6393127977f5a5dc8ebb753fb72502dcda37d6c1a73a220d7a6a70e305012
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
19
19
  package.windows.dependencies = []
20
20
  package.cross_compiling do |spec|
21
21
  if /mingw|mswin/ =~ spec.platform.to_s
22
- spec.add_runtime_dependency("rsvg2", ">= #{package.version}")
22
+ spec.add_runtime_dependency("rsvg2", "= #{package.version}")
23
23
  end
24
24
  end
25
25
  end
@@ -63,7 +63,7 @@ module Gtk
63
63
  Gio.init if Gio.respond_to?(:init)
64
64
  Gdk.init if Gdk.respond_to?(:init)
65
65
  loader = Loader.new(self, argv)
66
- loader.load("Gtk")
66
+ loader.load
67
67
  end
68
68
  end
69
69
  end
@@ -34,5 +34,14 @@ module Gtk
34
34
  raise ArgumentError, "#{message}: #{options.inspect}"
35
35
  end
36
36
  end
37
+
38
+ alias_method :load_from_data_raw, :load_from_data
39
+ def load_from_data(data)
40
+ if data.is_a?(GLib::Bytes)
41
+ load_from_data_raw(data.to_s)
42
+ else
43
+ load_from_data_raw(data)
44
+ end
45
+ end
37
46
  end
38
47
  end
@@ -21,6 +21,11 @@ module Gtk
21
21
  @init_arguments = init_arguments
22
22
  end
23
23
 
24
+ def load
25
+ self.version = "3.0"
26
+ super("Gtk")
27
+ end
28
+
24
29
  private
25
30
  def pre_load(repository, namespace)
26
31
  call_init_function(repository, namespace)
@@ -127,6 +132,7 @@ module Gtk
127
132
  require "gtk3/target-entry"
128
133
  require "gtk3/text-buffer"
129
134
  require "gtk3/text-iter"
135
+ require "gtk3/text-tag"
130
136
  require "gtk3/text-tag-table"
131
137
  require "gtk3/text-view"
132
138
  require "gtk3/toggle-action"
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2014-2017 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -21,9 +21,8 @@ module Gtk
21
21
  succeeded = tag_table.add(tag)
22
22
  return nil unless succeeded
23
23
 
24
- properties.each do |property|
25
- key, value = property
26
- tag.set_property(key, value)
24
+ properties.each do |name, value|
25
+ tag.__send__("#{name}=", value)
27
26
  end
28
27
 
29
28
  tag
@@ -134,6 +133,8 @@ module Gtk
134
133
  insert_pixbuf_raw(iter, target)
135
134
  when TextChildAnchor
136
135
  insert_text_child_anchor_raw(iter, target)
136
+ when GLib::Bytes
137
+ insert_raw(iter, target, target.size)
137
138
  else
138
139
  insert_raw(iter, target, target.bytesize)
139
140
  end
@@ -150,6 +151,19 @@ module Gtk
150
151
  self
151
152
  end
152
153
 
154
+ if method_defined?(:insert_markup)
155
+ alias_method :insert_markup_raw, :insert_markup
156
+ def insert_markup(iter, markup, n_bytes=nil)
157
+ case markup
158
+ when GLib::Bytes
159
+ n_bytes ||= markup.size
160
+ else
161
+ n_bytes ||= markup.bytesize
162
+ end
163
+ insert_markup_raw(iter, markup, n_bytes)
164
+ end
165
+ end
166
+
153
167
  alias_method :insert_at_cursor_raw, :insert_at_cursor
154
168
  def insert_at_cursor(text, options={})
155
169
  interactive = options[:interactive]
@@ -165,7 +179,12 @@ module Gtk
165
179
 
166
180
  alias_method :set_text_raw, :set_text
167
181
  def set_text(text)
168
- set_text_raw(text, text.bytesize)
182
+ if text.is_a?(GLib::Bytes)
183
+ text, text_size = text.to_s, text.size
184
+ else
185
+ text_size = text.bytesize
186
+ end
187
+ set_text_raw(text, text_size)
169
188
  end
170
189
  remove_method :text=
171
190
  alias_method :text=, :set_text
@@ -197,12 +216,22 @@ module Gtk
197
216
  private
198
217
  alias_method :insert_interactive_raw, :insert_interactive
199
218
  def insert_interactive(iter, text, default_ediatable)
200
- insert_interactive_raw(iter, text, text.bytesize, default_ediatable)
219
+ if text.is_a?(GLib::Bytes)
220
+ text, text_size = text.to_s, text.size
221
+ else
222
+ text_size = text.bytesize
223
+ end
224
+ insert_interactive_raw(iter, text, text_size, default_ediatable)
201
225
  end
202
226
 
203
227
  alias_method :insert_interactive_at_cursor_raw, :insert_interactive_at_cursor
204
228
  def insert_interactive_at_cursor(text, default_ediatable)
205
- insert_interactive_at_cursor_raw(text, text.bytesize, default_ediatable)
229
+ if text.is_a?(GLib::Bytes)
230
+ text, text_size = text.to_s, text.size
231
+ else
232
+ text_size = text.bytesize
233
+ end
234
+ insert_interactive_at_cursor_raw(text, text_size, default_ediatable)
206
235
  end
207
236
  end
208
237
  end
@@ -0,0 +1,41 @@
1
+ # Copyright (C) 2017 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
+ module Gtk
18
+ class TextTag
19
+ alias_method :set_weight_raw, :set_weight
20
+ def set_weight(weight)
21
+ case weight
22
+ when Symbol, String
23
+ weight = Pango::Weight.new(weight).to_i
24
+ end
25
+ set_weight_raw(weight)
26
+ end
27
+ undef_method :weight=
28
+ alias_method :weight=, :set_weight
29
+
30
+ alias_method :set_scale_raw, :set_scale
31
+ def set_scale(scale)
32
+ case scale
33
+ when Symbol, String
34
+ scale = Pango::Scale.const_get(scale.to_s.upcase)
35
+ end
36
+ set_scale_raw(scale)
37
+ end
38
+ undef_method :scale=
39
+ alias_method :scale=, :set_scale
40
+ end
41
+ end
@@ -31,7 +31,7 @@ class ClipboardDemo
31
31
  text = "\"Paste\" will paste the text from the clipboard to the entry"
32
32
  generate_entry(text, "_Paste") do |entry|
33
33
  clipboard = entry.get_clipboard(Gdk::Selection::CLIPBOARD)
34
- clipboard.request_text { |_clip, entry_text| entry.text = entry_text }
34
+ clipboard.request_text { |_clip, entry_text| entry.text = entry_text || "" }
35
35
  end
36
36
 
37
37
  text = "Images can be transferred via the clipboard, too"
@@ -107,7 +107,7 @@ class ClipboardDemo
107
107
  ebox.drag_source_set(Gdk::ModifierType::BUTTON1_MASK, [], :copy)
108
108
  ebox.drag_source_add_image_targets
109
109
  ebox.signal_connect "drag-begin" do |_widget, context|
110
- pixbuf = get_image_pixbuf(image1)
110
+ pixbuf = get_image_pixbuf(image)
111
111
  context.set_icon_pixbuf(pixbuf, -2, -2)
112
112
  end
113
113
 
@@ -14,7 +14,7 @@ class CssBasicsDemo
14
14
  @window.transient_for = main_window
15
15
  @window.set_default_size(400, 300)
16
16
 
17
- @default_css = Gio::Resources.lookup_data("/css_basics/css_basics.css", 0)
17
+ @default_css = Gio::Resources.lookup_data("/css_basics/css_basics.css", 0).to_s
18
18
  initialize_text_buffer
19
19
 
20
20
  container = Gtk::ScrolledWindow.new
@@ -50,8 +50,8 @@ class CssBasicsDemo
50
50
 
51
51
  def initialize_text_buffer
52
52
  @text = Gtk::TextBuffer.new
53
- @text.create_tag("warning", "underline" => Pango::UNDERLINE_SINGLE)
54
- @text.create_tag("error", "underline" => Pango::UNDERLINE_ERROR)
53
+ @text.create_tag("warning", "underline" => :single)
54
+ @text.create_tag("error", "underline" => :error)
55
55
  @text.text = @default_css
56
56
  text_buffer_signal_connect_changed
57
57
  end
@@ -92,8 +92,8 @@ class CssMultiplebgsDemo
92
92
 
93
93
  def initialize_text_buffer
94
94
  @text = Gtk::TextBuffer.new
95
- @text.create_tag("warning", "underline" => Pango::UNDERLINE_SINGLE)
96
- @text.create_tag("error", "underline" => Pango::UNDERLINE_ERROR)
95
+ @text.create_tag("warning", "underline" => :single)
96
+ @text.create_tag("error", "underline" => :error)
97
97
  @text.text = @default_css
98
98
  text_buffer_signal_connect_changed
99
99
  end
@@ -14,7 +14,7 @@ class CssPixbufsDemo
14
14
  @window.transient_for = main_window
15
15
  @window.set_default_size(400, 300)
16
16
 
17
- @default_css = Gio::Resources.lookup_data("/css_pixbufs/gtk.css", 0)
17
+ @default_css = Gio::Resources.lookup_data("/css_pixbufs/gtk.css", 0).to_s
18
18
 
19
19
  initialize_text_buffer
20
20
  initialize_provider
@@ -56,8 +56,8 @@ class CssPixbufsDemo
56
56
 
57
57
  def initialize_text_buffer
58
58
  @text = Gtk::TextBuffer.new
59
- @text.create_tag("warning", "underline" => Pango::UNDERLINE_SINGLE)
60
- @text.create_tag("error", "underline" => Pango::UNDERLINE_ERROR)
59
+ @text.create_tag("warning", "underline" => :single)
60
+ @text.create_tag("error", "underline" => :error)
61
61
  @text.text = @default_css
62
62
  text_buffer_signal_connect_changed
63
63
  end
@@ -155,7 +155,7 @@ class GlareaDemo
155
155
  # Load the shaders sources
156
156
  shader = glCreateShader(type)
157
157
 
158
- glShaderSource(shader, 1, [source].pack("p"), [source.bytesize].pack("I"))
158
+ glShaderSource(shader, 1, [source.pointer].pack("j"), [source.size].pack("I"))
159
159
  # Compile the vertex shader
160
160
  glCompileShader(shader)
161
161
  # Check the vertex shader compilation
@@ -11,6 +11,8 @@
11
11
  =end
12
12
  class HypertextDemo
13
13
  def initialize(main_window)
14
+ @hovering = false
15
+
14
16
  initialize_window(main_window)
15
17
  initialize_cursors(main_window)
16
18
  initialize_view
@@ -106,7 +108,7 @@ class HypertextDemo
106
108
 
107
109
  def generate_page_1
108
110
  iter = @buffer.get_iter_at(:offset => 0)
109
- @buffer.insert(iter, "Some text to show that simple")
111
+ @buffer.insert(iter, "Some text to show that simple ")
110
112
  insert_link(iter, "hyper text", 3)
111
113
  @buffer.insert(iter, " can easily be realized with ")
112
114
  insert_link(iter, "tags", 2)
@@ -129,7 +131,7 @@ EOF
129
131
  def generate_page_3
130
132
  iter = @buffer.get_iter_at(:offset => 0)
131
133
  tag = @buffer.create_tag(nil,
132
- "weight" => Pango::FontDescription::WEIGHT_BOLD)
134
+ "weight" => :bold)
133
135
  @buffer.insert(iter, "hypertext:\n", :tags => [tag])
134
136
  @buffer.insert(iter, <<-EOF)
135
137
  machine-readable text that is not sequential but is organized
@@ -141,7 +143,7 @@ EOF
141
143
  def insert_link(iter, text, page)
142
144
  tag = @buffer.create_tag(nil,
143
145
  "foreground" => "blue",
144
- "underline" => Pango::AttrUnderline::SINGLE)
146
+ "underline" => :single)
145
147
  tag.page = page
146
148
  @buffer.insert(iter, text, :tags => [tag])
147
149
  end
@@ -25,7 +25,7 @@ class ImagesDemo
25
25
  @window.title = "Images"
26
26
  @window.signal_connect "destroy" do
27
27
  GLib::Source.remove(@load_timeout) if @load_timeout
28
- @pixbuf_loader.close
28
+ @pixbuf_loader.close if @pixbuf_loader
29
29
  end
30
30
 
31
31
  @vbox = Gtk::Box.new(:vertical, 8)
@@ -86,7 +86,7 @@ class ImagesDemo
86
86
  # The timeout simply simulates a slow data source by inserting
87
87
  # pauses in the reading process.
88
88
  image_stream = nil
89
- pixbuf_loader = nil
89
+ @pixbuf_loader = nil
90
90
  @load_timeout = GLib::Timeout.add(150) do
91
91
  if image_stream
92
92
  begin
@@ -108,14 +108,15 @@ class ImagesDemo
108
108
  end
109
109
 
110
110
  begin
111
- pixbuf_loader.close
111
+ @pixbuf_loader.close
112
112
  rescue => error
113
113
  show_dialog_on_error("Failed to load image: #{error.message}")
114
114
  end
115
+ @pixbuf_loader = nil
115
116
  GLib::Source::REMOVE
116
117
  else
117
118
  begin
118
- pixbuf_loader.write(buf)
119
+ @pixbuf_loader.write(buf)
119
120
  rescue => error
120
121
  show_dialog_on_error("Failed to load image: #{error.message}")
121
122
  end
@@ -127,15 +128,15 @@ class ImagesDemo
127
128
  rescue => error
128
129
  show_dialog_on_error(error.message)
129
130
  end
130
- pixbuf_loader.close if pixbuf_loader
131
- pixbuf_loader = GdkPixbuf::PixbufLoader.new
132
- pixbuf_loader.signal_connect "area-prepared" do |loader|
131
+ @pixbuf_loader.close if @pixbuf_loader
132
+ @pixbuf_loader = GdkPixbuf::PixbufLoader.new
133
+ @pixbuf_loader.signal_connect "area-prepared" do |loader|
133
134
  pixbuf = loader.pixbuf
134
135
  pixbuf.fill(0xaaaaaaff)
135
136
  image.from_pixbuf = pixbuf
136
137
  end
137
138
 
138
- pixbuf_loader.signal_connect "area-updated" do
139
+ @pixbuf_loader.signal_connect "area-updated" do
139
140
  # progressive_updated_callback
140
141
  # We know the pixbuf inside the GtkImage has changed, but the image
141
142
  # itself doesn't know this; so give it a hint by setting the pixbuf
@@ -34,7 +34,7 @@ class ListboxDemo
34
34
  vbox.show_all
35
35
 
36
36
  data = Gio::Resources.lookup_data("/listbox/messages.txt", 0)
37
- data.each_line do |line|
37
+ data.to_s.each_line do |line|
38
38
  message = Message.new(line)
39
39
  row = GtkMessageRow.new(message)
40
40
  row.show
@@ -118,7 +118,7 @@ def append_children(model, source, parent = nil)
118
118
  iter = model.append(parent)
119
119
  iter[TITLE_COLUMN] = title
120
120
  iter[FILENAME_COLUMN] = filename
121
- iter[STYLE_COLUMN] = Pango::FontDescription::STYLE_NORMAL
121
+ iter[STYLE_COLUMN] = Pango::Style::NORMAL
122
122
 
123
123
  append_children(model, children, iter) if children
124
124
  end
@@ -181,7 +181,7 @@ def run_demo_from_file(filename, window)
181
181
  demo = klass.new(window)
182
182
  demo_window = demo.run
183
183
 
184
- if demo_window && demo_window.is_a?(Gtk::Window)
184
+ if demo_window.is_a?(Gtk::Window)
185
185
  demo_window.set_transient_for(window)
186
186
  demo_window.modal = true
187
187
  end
@@ -247,7 +247,7 @@ class Demo < Gtk::Application
247
247
  "foreground" => "ForestGreen")
248
248
  @source_buffer.create_tag("string",
249
249
  "foreground" => "RosyBrown",
250
- "weight" => Pango::FontDescription::WEIGHT_BOLD)
250
+ "weight" => Pango::Weight::BOLD)
251
251
  @source_buffer.create_tag("reserved",
252
252
  "foreground" => "purple")
253
253
  end
@@ -314,7 +314,14 @@ class Demo < Gtk::Application
314
314
  selection = @treeview.selection
315
315
  iter = selection.selected
316
316
  filename = iter[1]
317
- run_demo_from_file(filename, windows.first) if filename
317
+ if filename
318
+ begin
319
+ run_demo_from_file(filename, windows.first)
320
+ rescue => error
321
+ puts("failed to run demo: #{filename}")
322
+ report_error(error)
323
+ end
324
+ end
318
325
  end
319
326
  window.add_action(action)
320
327
 
@@ -356,20 +363,30 @@ class Demo < Gtk::Application
356
363
  @treeview.signal_connect "row-activated" do |_tree_view, path, _column|
357
364
  iter = model.get_iter(path)
358
365
  filename = iter[1]
359
- iter[2] = Pango::FontDescription::STYLE_ITALIC
360
- demo = run_demo_from_file(filename, windows.first)
361
- demo.signal_connect "destroy" do
362
- iter[2] = Pango::FontDescription::STYLE_NORMAL
366
+ begin
367
+ demo = run_demo_from_file(filename, windows.first)
368
+ rescue => error
369
+ puts("failed to run demo: #{filename}")
370
+ report_error(error)
371
+ else
372
+ if demo
373
+ iter[2] = Pango::Style::ITALIC
374
+ demo.signal_connect "destroy" do
375
+ iter[2] = Pango::Style::NORMAL
376
+ end
377
+ end
363
378
  end
364
379
  end
365
380
 
366
381
  treeview_selection = @builder["treeview-selection"]
367
382
  treeview_selection.signal_connect "changed" do |selection, _model|
368
383
  iter = selection.selected
369
- filename = iter[1]
370
- title = iter[0]
371
- load_file(filename) if filename
372
- headerbar.set_title(title)
384
+ if iter
385
+ filename = iter[1]
386
+ title = iter[0]
387
+ load_file(filename) if filename
388
+ headerbar.set_title(title)
389
+ end
373
390
  end
374
391
 
375
392
  window.show_all
@@ -66,7 +66,7 @@ class MarkupDemo
66
66
  buffer = @view.buffer
67
67
  start_iter, start_end = buffer.bounds
68
68
  buffer.delete(start_iter, start_end)
69
- buffer.insert_markup(buffer.start_iter, markup, -1)
69
+ buffer.insert_markup(buffer.start_iter, markup)
70
70
  @stack.visible_child_name = "formatted"
71
71
  end
72
72
  end
@@ -96,7 +96,7 @@ class MarkupDemo
96
96
  markup = Gio::Resources.lookup_data("/markup/markup.txt", 0)
97
97
 
98
98
  buffer = @view.buffer
99
- buffer.insert_markup(buffer.start_iter, markup, -1)
99
+ buffer.insert_markup(buffer.start_iter, markup)
100
100
 
101
101
  buffer = @view2.buffer
102
102
  buffer.insert(buffer.start_iter, markup)
@@ -16,8 +16,6 @@ class StackDemo
16
16
  builder.connect_signals {}
17
17
  @window = builder["window1"]
18
18
  @window.screen = main_window.screen
19
-
20
- @window.signal_connect("destroy") { window.destroyed(window) }
21
19
  end
22
20
 
23
21
  def run
@@ -78,24 +78,24 @@ class TextviewDemo
78
78
  # Gtk::TextTag.priority=.
79
79
 
80
80
  buffer.create_tag("heading",
81
- "weight" => Pango::WEIGHT_BOLD,
81
+ "weight" => :bold,
82
82
  "size" => 15 * Pango::SCALE)
83
83
 
84
84
  buffer.create_tag("italic",
85
- "style" => Pango::STYLE_ITALIC)
85
+ "style" => :italic)
86
86
 
87
87
  buffer.create_tag("bold",
88
- "weight" => Pango::WEIGHT_BOLD)
88
+ "weight" => :bold)
89
89
 
90
90
  buffer.create_tag("big",
91
91
  # points times the PANGO_SCALE factor
92
92
  "size" => 20 * Pango::SCALE)
93
93
 
94
94
  buffer.create_tag("xx-small",
95
- "scale" => Pango::AttrScale::XX_SMALL)
95
+ "scale" => :xx_small)
96
96
 
97
97
  buffer.create_tag("x-large",
98
- "scale" => Pango::AttrScale::X_LARGE)
98
+ "scale" => :x_large)
99
99
 
100
100
  buffer.create_tag("monospace", "family" => "monospace")
101
101
 
@@ -138,10 +138,10 @@ class TextviewDemo
138
138
  "strikethrough" => true)
139
139
 
140
140
  buffer.create_tag("underline",
141
- "underline" => Pango::UNDERLINE_SINGLE)
141
+ "underline" => :single)
142
142
 
143
143
  buffer.create_tag("double_underline",
144
- "underline" => Pango::UNDERLINE_DOUBLE)
144
+ "underline" => :double)
145
145
 
146
146
  buffer.create_tag("superscript",
147
147
  "rise" => 10 * Pango::SCALE, # 10 pixels
@@ -153,7 +153,7 @@ class TextviewDemo
153
153
 
154
154
  buffer.create_tag("rtl_quote",
155
155
  "wrap_mode" => :word,
156
- "direction" => Gtk::TextDirection::RTL,
156
+ "direction" => :rtl,
157
157
  "indent" => 30,
158
158
  "left_margin" => 20,
159
159
  "right_margin" => 20)
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,12 @@ class TestGtkTextBuffer < Test::Unit::TestCase
30
30
  assert_equal("Hello Ruby World!", @text_buffer.text)
31
31
  end
32
32
 
33
+ test "GLib::Bytes" do
34
+ iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
35
+ @text_buffer.insert(iter, GLib::Bytes.new("Ruby "))
36
+ assert_equal("Hello Ruby World!", @text_buffer.text)
37
+ end
38
+
33
39
  test ":interactive" do
34
40
  iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
35
41
  @text_buffer.insert(iter, "Ruby ", :interactive => true)
@@ -53,6 +59,30 @@ class TestGtkTextBuffer < Test::Unit::TestCase
53
59
  end
54
60
  end
55
61
 
62
+ sub_test_case "#insert_markup" do
63
+ setup do
64
+ only_gtk_version(3, 16)
65
+ end
66
+
67
+ test "String" do
68
+ iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
69
+ @text_buffer.insert_markup(iter, "<b>Ruby</b> ")
70
+ assert_equal("Hello Ruby World!", @text_buffer.text)
71
+ end
72
+
73
+ test "GLib::Bytes" do
74
+ iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
75
+ @text_buffer.insert_markup(iter, GLib::Bytes.new("<b>Ruby</b> "))
76
+ assert_equal("Hello Ruby World!", @text_buffer.text)
77
+ end
78
+
79
+ test "n_bytes" do
80
+ iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
81
+ @text_buffer.insert_markup(iter, "<b>Ruby</b> language", 12)
82
+ assert_equal("Hello Ruby World!", @text_buffer.text)
83
+ end
84
+ end
85
+
56
86
  sub_test_case "#insert_at_cursor" do
57
87
  test "no options" do
58
88
  iter = @text_buffer.get_iter_at(:offset => "Hello ".bytesize)
@@ -0,0 +1,49 @@
1
+ # Copyright (C) 2017 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 TestGtkTextTag < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ sub_test_case "instance methods" do
21
+ def setup
22
+ @tag = Gtk::TextTag.new
23
+ end
24
+
25
+ sub_test_case "#weight" do
26
+ test "Symbol" do
27
+ @tag.weight = :bold
28
+ assert_equal(Pango::Weight::BOLD, @tag.weight)
29
+ end
30
+
31
+ test "String" do
32
+ @tag.weight = "bold"
33
+ assert_equal(Pango::Weight::BOLD, @tag.weight)
34
+ end
35
+ end
36
+
37
+ sub_test_case "#scale" do
38
+ test "Symbol" do
39
+ @tag.scale = :x_small
40
+ assert_equal(Pango::Scale::X_SMALL, @tag.scale)
41
+ end
42
+
43
+ test "String" do
44
+ @tag.scale = "x_small"
45
+ assert_equal(Pango::Scale::X_SMALL, @tag.scale)
46
+ end
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.6
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-03 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glib2
@@ -16,98 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.6
19
+ version: 3.1.7
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.6
26
+ version: 3.1.7
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gio2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.1.6
33
+ version: 3.1.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.1.6
40
+ version: 3.1.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: atk
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 3.1.6
47
+ version: 3.1.7
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 3.1.6
54
+ version: 3.1.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pango
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.1.6
61
+ version: 3.1.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 3.1.6
68
+ version: 3.1.7
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gdk_pixbuf2
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 3.1.6
75
+ version: 3.1.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 3.1.6
82
+ version: 3.1.7
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: gdk3
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 3.1.6
89
+ version: 3.1.7
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 3.1.6
96
+ version: 3.1.7
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: gobject-introspection
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 3.1.6
103
+ version: 3.1.7
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 3.1.6
110
+ version: 3.1.7
111
111
  description: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
112
112
  email: ruby-gnome2-devel-en@lists.sourceforge.net
113
113
  executables: []
@@ -185,6 +185,7 @@ files:
185
185
  - lib/gtk3/text-buffer.rb
186
186
  - lib/gtk3/text-iter.rb
187
187
  - lib/gtk3/text-tag-table.rb
188
+ - lib/gtk3/text-tag.rb
188
189
  - lib/gtk3/text-view.rb
189
190
  - lib/gtk3/toggle-action.rb
190
191
  - lib/gtk3/toggle-button.rb
@@ -625,6 +626,7 @@ files:
625
626
  - test/test-gtk-target-entry.rb
626
627
  - test/test-gtk-text-buffer.rb
627
628
  - test/test-gtk-text-tag-table.rb
629
+ - test/test-gtk-text-tag.rb
628
630
  - test/test-gtk-text-view.rb
629
631
  - test/test-gtk-toggle-action.rb
630
632
  - test/test-gtk-toggle-button.rb