gir_ffi-gtk 0.14.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +17 -0
- data/lib/gir_ffi-gtk/base.rb +3 -3
- data/lib/gir_ffi-gtk/container.rb +1 -1
- data/lib/gir_ffi-gtk/file_chooser_dialog.rb +4 -0
- data/lib/gir_ffi-gtk/gtk2/menu.rb +26 -0
- data/lib/gir_ffi-gtk/message_dialog.rb +1 -1
- data/lib/gir_ffi-gtk/tree_path.rb +1 -1
- data/lib/gir_ffi-gtk/version.rb +5 -0
- data/lib/gir_ffi-gtk2.rb +22 -21
- data/lib/gir_ffi-gtk3.rb +18 -18
- metadata +94 -74
- data/Rakefile +0 -8
- data/examples/01_empty_window.rb +0 -12
- data/examples/02_hello_world.rb +0 -27
- data/examples/03_upgraded_hello_world.rb +0 -40
- data/examples/04_webkit.rb +0 -18
- data/examples/05_notification.rb +0 -33
- data/examples/06_treeview.rb +0 -51
- data/examples/07_simple_gtk_application.rb +0 -30
- data/examples/08_webkit_headless.rb +0 -21
- data/examples/09_webkit2_headless.rb +0 -24
- data/examples/10_completion_provider.rb +0 -62
- data/lib/gir_ffi-gtk/menu.rb +0 -19
- data/tasks/test.rake +0 -30
- data/test/callback_exceptions_test.rb +0 -58
- data/test/gir_ffi-gtk/action_test.rb +0 -17
- data/test/gir_ffi-gtk/base_test.rb +0 -47
- data/test/gir_ffi-gtk/builder_test.rb +0 -70
- data/test/gir_ffi-gtk/button_test.rb +0 -19
- data/test/gir_ffi-gtk/container_test.rb +0 -33
- data/test/gir_ffi-gtk/dialog_test.rb +0 -13
- data/test/gir_ffi-gtk/file_chooser_dialog_test.rb +0 -18
- data/test/gir_ffi-gtk/generated_gtk_test.rb +0 -58
- data/test/gir_ffi-gtk/image_test.rb +0 -43
- data/test/gir_ffi-gtk/list_store_test.rb +0 -38
- data/test/gir_ffi-gtk/menu_test.rb +0 -20
- data/test/gir_ffi-gtk/message_dialog_test.rb +0 -15
- data/test/gir_ffi-gtk/radio_action_test.rb +0 -28
- data/test/gir_ffi-gtk/radio_button_test.rb +0 -37
- data/test/gir_ffi-gtk/target_entry_test.rb +0 -19
- data/test/gir_ffi-gtk/tree_path_test.rb +0 -17
- data/test/gir_ffi-gtk/tree_store_test.rb +0 -38
- data/test/gir_ffi-gtk/tree_view_column_test.rb +0 -51
- data/test/gir_ffi-gtk/widget_test.rb +0 -103
- data/test/test_helper.rb +0 -36
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::MessageDialog do
|
4
|
-
describe '.new' do
|
5
|
-
it 'creates a Gtk::MessageDialog with the right text' do
|
6
|
-
dialog = Gtk::MessageDialog.new nil, :modal, :info, :close, 'Foo'
|
7
|
-
dialog.text.must_equal 'Foo'
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'handles all % characters in the message as literals' do
|
11
|
-
dialog = Gtk::MessageDialog.new nil, :modal, :info, :close, 'Foo %'
|
12
|
-
dialog.text.must_equal 'Foo %'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::RadioAction do
|
4
|
-
describe '#get_group' do
|
5
|
-
it 'returns a GLib::SList object' do
|
6
|
-
action = Gtk::RadioAction.new 'name', 'label', 'tooltip', nil, 1
|
7
|
-
grp = action.get_group
|
8
|
-
grp.must_be_instance_of GLib::SList
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#set_group' do
|
13
|
-
let(:action) { Gtk::RadioAction.new 'name', 'label', 'tooltip', nil, 1 }
|
14
|
-
|
15
|
-
it 'accepts nil' do
|
16
|
-
action.set_group nil
|
17
|
-
pass
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'accepts a GLib::SList object' do
|
21
|
-
grp = action.get_group
|
22
|
-
other_action = Gtk::RadioAction.new('other-name', 'other-label',
|
23
|
-
'other-tooltip', nil, 2)
|
24
|
-
other_action.set_group grp
|
25
|
-
pass
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::RadioButton do
|
4
|
-
describe '.new_from_widget' do
|
5
|
-
it 'works when called with nil' do
|
6
|
-
result = Gtk::RadioButton.new_from_widget(nil)
|
7
|
-
result.must_be_instance_of Gtk::RadioButton
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'works when called with another radio button' do
|
11
|
-
btn = Gtk::RadioButton.new_from_widget nil
|
12
|
-
result = Gtk::RadioButton.new_from_widget btn
|
13
|
-
result.must_be_instance_of Gtk::RadioButton
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#get_group' do
|
18
|
-
it 'returns a GLib::SList object' do
|
19
|
-
btn = Gtk::RadioButton.new_from_widget nil
|
20
|
-
grp = btn.get_group
|
21
|
-
assert_instance_of GLib::SList, grp
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '.new' do
|
26
|
-
it 'works when called with nil' do
|
27
|
-
result = Gtk::RadioButton.new nil
|
28
|
-
result.must_be_instance_of Gtk::RadioButton
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'works when called with the result of #get_group' do
|
32
|
-
btn = Gtk::RadioButton.new_from_widget nil
|
33
|
-
result = Gtk::RadioButton.new btn.get_group
|
34
|
-
result.must_be_instance_of Gtk::RadioButton
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::TargetEntry do
|
4
|
-
describe '.new' do
|
5
|
-
it 'takes and uses three arguments' do
|
6
|
-
entry = Gtk::TargetEntry.new('foo', 3, 42)
|
7
|
-
entry.target.must_equal 'foo'
|
8
|
-
entry.flags.must_equal 3
|
9
|
-
entry.info.must_equal 42
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'allows symbol values for the second argument' do
|
13
|
-
entry = Gtk::TargetEntry.new('foo', :same_app, 42)
|
14
|
-
entry.target.must_equal 'foo'
|
15
|
-
entry.flags.must_equal 1
|
16
|
-
entry.info.must_equal 42
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::TreePath do
|
4
|
-
describe '#get_indices' do
|
5
|
-
it "returns an enumerable of the TreePath's indices" do
|
6
|
-
tree_path = Gtk::TreePath.new_from_string '1:2:3'
|
7
|
-
tree_path.get_indices.to_a.must_equal [1, 2, 3]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.new_from_indices' do
|
12
|
-
it 'creates a Gtk::TreePath with the right indices' do
|
13
|
-
tree_path = Gtk::TreePath.new_from_indices [1, 2, 3]
|
14
|
-
tree_path.get_indices.to_a.must_equal [1, 2, 3]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::TreeStore do
|
4
|
-
describe '.new' do
|
5
|
-
it 'takes an array of column types' do
|
6
|
-
store = Gtk::TreeStore.new([GObject::TYPE_STRING, GObject::TYPE_INT])
|
7
|
-
store.must_be_instance_of Gtk::TreeStore
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#insert_with_values' do
|
12
|
-
it 'inserts a row with the given values' do
|
13
|
-
store = Gtk::TreeStore.new([GObject::TYPE_STRING, GObject::TYPE_INT])
|
14
|
-
row = store.insert_with_values(nil, 0, [0, 1], ['foo', 42])
|
15
|
-
store.get_value(row, 0).must_equal 'foo'
|
16
|
-
store.get_value(row, 1).must_equal 42
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#set' do
|
21
|
-
it 'updates a row with the given values' do
|
22
|
-
store = Gtk::TreeStore.new([GObject::TYPE_STRING, GObject::TYPE_INT])
|
23
|
-
row = store.insert_with_values(nil, 0, [0, 1], ['foo', 42])
|
24
|
-
store.set(row, [1, 0], [3, 'bar'])
|
25
|
-
store.get_value(row, 0).must_equal 'bar'
|
26
|
-
store.get_value(row, 1).must_equal 3
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#set_value' do
|
31
|
-
it 'allows setting a value to nil' do
|
32
|
-
store = Gtk::TreeStore.new([GObject::TYPE_STRING, GObject::TYPE_INT])
|
33
|
-
row = store.insert_with_values(nil, 0, [0, 1], ['foo', 42])
|
34
|
-
store.set_value(row, 0, nil)
|
35
|
-
store.get_value(row, 0).must_be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::TreeViewColumn do
|
4
|
-
describe '.new_with_attributes' do
|
5
|
-
let(:renderer) { Gtk::CellRendererText.new }
|
6
|
-
let(:column) do
|
7
|
-
Gtk::TreeViewColumn.new_with_attributes('foo-title',
|
8
|
-
renderer,
|
9
|
-
text: 1)
|
10
|
-
end
|
11
|
-
let(:list_store) { Gtk::ListStore.new([GObject::TYPE_INT, GObject::TYPE_STRING]) }
|
12
|
-
|
13
|
-
it "sets the column's title" do
|
14
|
-
column.title.must_equal 'foo-title'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'packs the renderer into the column' do
|
18
|
-
column.get_cells.to_a.must_equal [renderer]
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'adds the attribute mapping for the renderer' do
|
22
|
-
row = list_store.append
|
23
|
-
list_store.set_value(row, 1, 'foo-value')
|
24
|
-
column.cell_set_cell_data(list_store, row, false, false)
|
25
|
-
renderer.text.must_equal 'foo-value'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'allows not specifying any attributes' do
|
29
|
-
col = Gtk::TreeViewColumn.new_with_attributes('foo-title', renderer)
|
30
|
-
col.must_be_instance_of Gtk::TreeViewColumn
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#set_attributes' do
|
35
|
-
let(:renderer) { Gtk::CellRendererText.new }
|
36
|
-
let(:column) { Gtk::TreeViewColumn.new }
|
37
|
-
let(:list_store) { Gtk::ListStore.new([GObject::TYPE_INT, GObject::TYPE_STRING]) }
|
38
|
-
|
39
|
-
before do
|
40
|
-
column.pack_start(renderer, false)
|
41
|
-
column.set_attributes(renderer, text: 1)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'adds the attribute mapping for the renderer' do
|
45
|
-
row = list_store.append
|
46
|
-
list_store.set_value(row, 1, 'foo-value')
|
47
|
-
column.cell_set_cell_data(list_store, row, false, false)
|
48
|
-
renderer.text.must_equal 'foo-value'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Gtk::Widget do
|
4
|
-
describe '#add_events' do
|
5
|
-
let(:widget) { Gtk::EventBox.new }
|
6
|
-
let(:expected_native) do
|
7
|
-
Gdk::EventMask.to_int(focus_change_mask: true,
|
8
|
-
button_press_mask: true)
|
9
|
-
end
|
10
|
-
|
11
|
-
before do
|
12
|
-
ev_int = Gdk::EventMask.to_int :focus_change_mask
|
13
|
-
widget.set_events ev_int
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'works when called with a bitmask hash' do
|
17
|
-
widget.add_events button_press_mask: true
|
18
|
-
ev = widget.get_events
|
19
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'works when called with a symbol' do
|
23
|
-
widget.add_events :button_press_mask
|
24
|
-
ev = widget.get_events
|
25
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'works when called with an int' do
|
29
|
-
ev_int = Gdk::EventMask.to_int :button_press_mask
|
30
|
-
widget.add_events ev_int
|
31
|
-
ev = widget.get_events
|
32
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#get_events' do
|
37
|
-
let(:widget) { Gtk::EventBox.new }
|
38
|
-
|
39
|
-
it 'returns a bitmap hash' do
|
40
|
-
widget.set_events focus_change_mask: true
|
41
|
-
ev = widget.get_events
|
42
|
-
ev.must_equal focus_change_mask: true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#set_events' do
|
47
|
-
let(:widget) { Gtk::EventBox.new }
|
48
|
-
let(:expected_native) { Gdk::EventMask.to_int(focus_change_mask: true) }
|
49
|
-
|
50
|
-
it 'works when called with a bitmask hash' do
|
51
|
-
widget.set_events focus_change_mask: true
|
52
|
-
ev = widget.get_events
|
53
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'works when called with a symbol' do
|
57
|
-
widget.set_events :focus_change_mask
|
58
|
-
ev = widget.get_events
|
59
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'works when called with an int' do
|
63
|
-
ev_int = Gdk::EventMask.to_int :focus_change_mask
|
64
|
-
widget.set_events ev_int
|
65
|
-
ev = widget.get_events
|
66
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#events' do
|
71
|
-
let(:widget) { Gtk::EventBox.new }
|
72
|
-
|
73
|
-
it 'returns a bitmap hash' do
|
74
|
-
widget.set_events focus_change_mask: true
|
75
|
-
ev = widget.events
|
76
|
-
ev.must_equal focus_change_mask: true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#events=' do
|
81
|
-
let(:widget) { Gtk::EventBox.new }
|
82
|
-
let(:expected_native) { Gdk::EventMask.to_int(focus_change_mask: true) }
|
83
|
-
|
84
|
-
it 'works when called with a bitmask hash' do
|
85
|
-
widget.events = { focus_change_mask: true }
|
86
|
-
ev = widget.get_events
|
87
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'works when called with a symbol' do
|
91
|
-
widget.events = :focus_change_mask
|
92
|
-
ev = widget.get_events
|
93
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'works when called with an int' do
|
97
|
-
ev_int = Gdk::EventMask.to_int :focus_change_mask
|
98
|
-
widget.events = ev_int
|
99
|
-
ev = widget.get_events
|
100
|
-
Gdk::EventMask.to_int(ev).must_equal expected_native
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'rubygems' if RUBY_PLATFORM == 'java'
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'simplecov'
|
5
|
-
SimpleCov.start do
|
6
|
-
add_filter '/test/'
|
7
|
-
end
|
8
|
-
rescue LoadError
|
9
|
-
nil # SimpleCov not available
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'minitest/autorun'
|
13
|
-
require 'rr'
|
14
|
-
|
15
|
-
Thread.abort_on_exception = true
|
16
|
-
|
17
|
-
if ENV['GTK_VERSION'] == '2'
|
18
|
-
require 'gir_ffi-gtk2'
|
19
|
-
else
|
20
|
-
require 'gir_ffi-gtk3'
|
21
|
-
end
|
22
|
-
|
23
|
-
module BaseTestExtensions
|
24
|
-
def assert_nothing_raised
|
25
|
-
yield
|
26
|
-
assert true
|
27
|
-
end
|
28
|
-
|
29
|
-
def ref_count(object)
|
30
|
-
GObject::Object::Struct.new(object.to_ptr)[:ref_count]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
Minitest::Test.send :include, BaseTestExtensions
|
35
|
-
|
36
|
-
Gtk.init
|