gir_ffi 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/README.rdoc +5 -27
- data/lib/gir_ffi/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/type_builder_test.rb +0 -2
- metadata +1 -13
- data/examples/01_empty_window.rb +0 -12
- data/examples/02_hello_world.rb +0 -28
- data/examples/03_upgraded_hello_world.rb +0 -42
- data/examples/04_webkit.rb +0 -15
- data/examples/05_notification.rb +0 -34
- data/lib/ffi-gtk/base.rb +0 -17
- data/lib/ffi-gtk2.rb +0 -5
- data/lib/ffi-gtk3.rb +0 -5
- data/test/ffi-gtk/gtk_test.rb +0 -36
- data/test/integration/generated_gtk_test.rb +0 -94
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -13,10 +13,10 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
|
|
13
13
|
== Features/Notes
|
14
14
|
|
15
15
|
* Create bindings to any GObject-based library.
|
16
|
-
* Supports both Gtk+ 2 and Gtk+ 3.
|
17
16
|
* Bindings generated at runtime.
|
18
17
|
* Provides overridden bindings for selected methods.
|
19
|
-
*
|
18
|
+
* Install 'gir_ffi-gtk' and require 'gir_ffi-gtk2' or 'gir_ffi-gtk3' to
|
19
|
+
load overrides for Gtk2 or Gtk3.
|
20
20
|
|
21
21
|
== Install
|
22
22
|
|
@@ -24,8 +24,6 @@ Ruby bindings for GNOME using the GObject Introspection Repository.
|
|
24
24
|
|
25
25
|
== Synopsis
|
26
26
|
|
27
|
-
Basic usage:
|
28
|
-
|
29
27
|
require 'gir_ffi'
|
30
28
|
|
31
29
|
GirFFI.setup :TheNamespace
|
@@ -35,26 +33,6 @@ Basic usage:
|
|
35
33
|
obj = TheNamespace::SomeClass.new
|
36
34
|
obj.some_method with, some, args
|
37
35
|
|
38
|
-
Gtk2:
|
39
|
-
|
40
|
-
require 'ffi-gtk2'
|
41
|
-
Gtk.init
|
42
|
-
win = Gtk::Window.new :toplevel
|
43
|
-
win.show
|
44
|
-
GObject.signal_connect(win, "destroy") { Gtk.main_quit }
|
45
|
-
Gtk.main
|
46
|
-
|
47
|
-
Gtk3:
|
48
|
-
|
49
|
-
require 'ffi-gtk3'
|
50
|
-
Gtk.init
|
51
|
-
win = Gtk::Window.new :toplevel
|
52
|
-
win.show
|
53
|
-
GObject.signal_connect(win, "destroy") { Gtk.main_quit }
|
54
|
-
Gtk.main
|
55
|
-
|
56
|
-
See the `examples/` directory for more, well, examples.
|
57
|
-
|
58
36
|
== Requirements
|
59
37
|
|
60
38
|
* Ruby-FFI of course
|
@@ -66,9 +44,9 @@ available under the name ending in plain `.so`. If GirFFI complains that it
|
|
66
44
|
cannot find the library, try installing development packages for those
|
67
45
|
libraries.
|
68
46
|
|
69
|
-
On Debian and Ubuntu,
|
70
|
-
`
|
71
|
-
`
|
47
|
+
On Debian and Ubuntu, installing `libgirepository1.0-dev` and
|
48
|
+
`gobject-introspection` (at least version 0.10) should be enough to get `rake
|
49
|
+
test` working.
|
72
50
|
|
73
51
|
== Hacking and contributing
|
74
52
|
|
data/lib/gir_ffi/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/type_builder_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -102,10 +102,8 @@ extra_rdoc_files:
|
|
102
102
|
- README.rdoc
|
103
103
|
- TODO.rdoc
|
104
104
|
files:
|
105
|
-
- lib/ffi-gtk2.rb
|
106
105
|
- lib/ffi-gobject_introspection.rb
|
107
106
|
- lib/gir_ffi.rb
|
108
|
-
- lib/ffi-gtk/base.rb
|
109
107
|
- lib/gir_ffi/lib_c.rb
|
110
108
|
- lib/gir_ffi/builder/function.rb
|
111
109
|
- lib/gir_ffi/builder/type/constant.rb
|
@@ -195,7 +193,6 @@ files:
|
|
195
193
|
- lib/ffi-gobject_introspection/i_registered_type_info.rb
|
196
194
|
- lib/ffi-gobject_introspection/g_error.rb
|
197
195
|
- lib/ffi-gobject.rb
|
198
|
-
- lib/ffi-gtk3.rb
|
199
196
|
- test/test_helper.rb
|
200
197
|
- test/unit/user_defined_registered_type_info_test.rb
|
201
198
|
- test/unit/unintrospectable_type_builder_test.rb
|
@@ -230,13 +227,11 @@ files:
|
|
230
227
|
- test/lib/autogen.sh
|
231
228
|
- test/builder_test.rb
|
232
229
|
- test/gir_ffi_test_helper.rb
|
233
|
-
- test/ffi-gtk/gtk_test.rb
|
234
230
|
- test/integration/derived_classes_test.rb
|
235
231
|
- test/integration/generated_regress_test.rb
|
236
232
|
- test/integration/method_lookup_test.rb
|
237
233
|
- test/integration/generated_gimarshallingtests_test.rb
|
238
234
|
- test/integration/generated_gio_test.rb
|
239
|
-
- test/integration/generated_gtk_test.rb
|
240
235
|
- test/integration/pretty_print_test.rb
|
241
236
|
- test/integration/generated_pango_test.rb
|
242
237
|
- test/integration/generated_gobject_test.rb
|
@@ -270,12 +265,7 @@ files:
|
|
270
265
|
- examples/leak_test.rb
|
271
266
|
- examples/demo_ffi_safe_inherited_layout.rb
|
272
267
|
- examples/demo_ffi_inherited_layout.rb
|
273
|
-
- examples/04_webkit.rb
|
274
|
-
- examples/01_empty_window.rb
|
275
|
-
- examples/03_upgraded_hello_world.rb
|
276
268
|
- examples/print_class.rb
|
277
|
-
- examples/02_hello_world.rb
|
278
|
-
- examples/05_notification.rb
|
279
269
|
- README.rdoc
|
280
270
|
- DESIGN.rdoc
|
281
271
|
- TODO.rdoc
|
@@ -330,14 +320,12 @@ test_files:
|
|
330
320
|
- test/ffi-gobject_introspection/i_object_info_test.rb
|
331
321
|
- test/ffi-gobject_introspection/i_repository_test.rb
|
332
322
|
- test/ffi-gobject_introspection/lib_test.rb
|
333
|
-
- test/ffi-gtk/gtk_test.rb
|
334
323
|
- test/gir_ffi_test_helper.rb
|
335
324
|
- test/girffi_test.rb
|
336
325
|
- test/integration/derived_classes_test.rb
|
337
326
|
- test/integration/generated_gimarshallingtests_test.rb
|
338
327
|
- test/integration/generated_gio_test.rb
|
339
328
|
- test/integration/generated_gobject_test.rb
|
340
|
-
- test/integration/generated_gtk_test.rb
|
341
329
|
- test/integration/generated_pango_test.rb
|
342
330
|
- test/integration/generated_regress_test.rb
|
343
331
|
- test/integration/method_lookup_test.rb
|
data/examples/01_empty_window.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Based on the empty window Gtk+ tutorial example at
|
3
|
-
# http://library.gnome.org/devel/gtk-tutorial/2.90/c39.html
|
4
|
-
#
|
5
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'ffi-gtk3'
|
7
|
-
|
8
|
-
Gtk.init
|
9
|
-
win = Gtk::Window.new :toplevel
|
10
|
-
win.show
|
11
|
-
GObject.signal_connect(win, "destroy") { Gtk.main_quit }
|
12
|
-
Gtk.main
|
data/examples/02_hello_world.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Based on the 'Hello world' Gtk+ tutorial example at
|
3
|
-
# http://library.gnome.org/devel/gtk-tutorial/2.90/c39.html#SEC-HELLOWORLD
|
4
|
-
#
|
5
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'ffi-gtk3'
|
7
|
-
|
8
|
-
Gtk.init
|
9
|
-
|
10
|
-
win = Gtk::Window.new(:toplevel)
|
11
|
-
GObject.signal_connect win, "delete-event" do
|
12
|
-
puts "delete event occured"
|
13
|
-
true
|
14
|
-
end
|
15
|
-
|
16
|
-
GObject.signal_connect(win, "destroy") { Gtk.main_quit }
|
17
|
-
# FIXME: #border_width= should work
|
18
|
-
win.set_border_width 10
|
19
|
-
|
20
|
-
but = Gtk::Button.new_with_label("Hello World")
|
21
|
-
GObject.signal_connect(but, "clicked") { win.destroy }
|
22
|
-
|
23
|
-
win.add but
|
24
|
-
|
25
|
-
but.show
|
26
|
-
win.show
|
27
|
-
|
28
|
-
Gtk.main
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Based on the 'Upgraded Hello world' Gtk+ tutorial example at
|
3
|
-
# http://library.gnome.org/devel/gtk-tutorial/2.90/x344.html
|
4
|
-
#
|
5
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
6
|
-
require 'ffi-gtk3'
|
7
|
-
|
8
|
-
callback = lambda { |widget, data|
|
9
|
-
puts "Hello again - #{data} was pressed"
|
10
|
-
}
|
11
|
-
|
12
|
-
Gtk.init
|
13
|
-
|
14
|
-
win = Gtk::Window.new(:toplevel)
|
15
|
-
win.title= "Hello Buttons!"
|
16
|
-
|
17
|
-
GObject.signal_connect win, "delete-event" do
|
18
|
-
Gtk.main_quit
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
# FIXME: #border_width= should work
|
23
|
-
win.set_border_width 10
|
24
|
-
|
25
|
-
box = Gtk::HBox.new(false, 0)
|
26
|
-
win.add box
|
27
|
-
|
28
|
-
button = Gtk::Button.new_with_label("Button 1")
|
29
|
-
GObject.signal_connect button, "clicked", "button 1", &callback
|
30
|
-
box.pack_start button, true, true, 0
|
31
|
-
button.show
|
32
|
-
|
33
|
-
button = Gtk::Button.new_with_label("Button 2")
|
34
|
-
GObject.signal_connect button, "clicked", "button 2", &callback
|
35
|
-
box.pack_start button, true, true, 0
|
36
|
-
button.show
|
37
|
-
|
38
|
-
box.show
|
39
|
-
win.show
|
40
|
-
|
41
|
-
Gtk.main
|
42
|
-
|
data/examples/04_webkit.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Based on http://www.idle-hacking.com/2010/02/webkit-ruby-and-gtk/
|
2
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
-
require 'ffi-gtk3'
|
4
|
-
|
5
|
-
GirFFI.setup :WebKit, '3.0'
|
6
|
-
|
7
|
-
Gtk.init
|
8
|
-
|
9
|
-
win = Gtk::Window.new :toplevel
|
10
|
-
wv = WebKit::WebView.new
|
11
|
-
win.add(wv)
|
12
|
-
win.show_all
|
13
|
-
wv.open('http://www.google.com/')
|
14
|
-
GObject.signal_connect(win, "destroy") { Gtk.main_quit }
|
15
|
-
Gtk.main
|
data/examples/05_notification.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Simple notification example.
|
3
|
-
#
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
-
require 'ffi-gtk3'
|
6
|
-
|
7
|
-
GirFFI.setup :Notify
|
8
|
-
|
9
|
-
# Both Gtk and Notify need to be init'ed.
|
10
|
-
Gtk.init
|
11
|
-
Notify.init "notification test"
|
12
|
-
|
13
|
-
# Basic set up of the notification.
|
14
|
-
nf = Notify::Notification.new "Hello!", "Hi there.", "gtk-dialog-info"
|
15
|
-
nf.timeout = 3000
|
16
|
-
nf.urgency = :critical
|
17
|
-
|
18
|
-
# Show a button 'Test' in the notification, with a callback function.
|
19
|
-
nf.add_action "test", "Test", Proc.new { |obj, action, user_data|
|
20
|
-
puts "Action #{action} clicked."
|
21
|
-
}, nil, nil
|
22
|
-
|
23
|
-
# In this case, we want the program to end once the notification is gone,
|
24
|
-
# but not before.
|
25
|
-
GObject.signal_connect(nf, "closed") {
|
26
|
-
puts "Notification closed."
|
27
|
-
Gtk.main_quit
|
28
|
-
}
|
29
|
-
|
30
|
-
# Show the notification.
|
31
|
-
nf.show
|
32
|
-
|
33
|
-
# Start a main loop to wait for the notification to be closed.
|
34
|
-
Gtk.main
|
data/lib/ffi-gtk/base.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Gtk
|
2
|
-
_setup_method "init"
|
3
|
-
|
4
|
-
def self.init_with_auto_argv
|
5
|
-
my_args = init_without_auto_argv [$0, *ARGV]
|
6
|
-
my_args.shift
|
7
|
-
ARGV.replace my_args
|
8
|
-
end
|
9
|
-
class << self
|
10
|
-
alias init_without_auto_argv init
|
11
|
-
alias init init_with_auto_argv
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Gtk.class_eval do
|
16
|
-
end
|
17
|
-
|
data/lib/ffi-gtk2.rb
DELETED
data/lib/ffi-gtk3.rb
DELETED
data/test/ffi-gtk/gtk_test.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
require 'ffi-gtk3'
|
4
|
-
|
5
|
-
describe Gtk do
|
6
|
-
describe "::init" do
|
7
|
-
before do
|
8
|
-
save_module :Gtk
|
9
|
-
::Object.const_set :Gtk, Module.new
|
10
|
-
Gtk.class_eval do
|
11
|
-
def self.init arr
|
12
|
-
["baz", "qux", "zonk"]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
stub(Gtk)._setup_method { }
|
16
|
-
|
17
|
-
load 'ffi-gtk/base.rb'
|
18
|
-
end
|
19
|
-
|
20
|
-
it "does not take any arguments" do
|
21
|
-
assert_raises(ArgumentError) { Gtk.init 1, ["foo"] }
|
22
|
-
assert_raises(ArgumentError) { Gtk.init ["foo"] }
|
23
|
-
assert_nothing_raised { Gtk.init }
|
24
|
-
end
|
25
|
-
|
26
|
-
it "replaces ARGV with the tail of the result of the original init function" do
|
27
|
-
ARGV.replace ["foo", "bar"]
|
28
|
-
Gtk.init
|
29
|
-
assert_equal ["qux", "zonk"], ARGV.to_a
|
30
|
-
end
|
31
|
-
|
32
|
-
after do
|
33
|
-
restore_module :Gtk
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
# Since the tests will call Gtk+ functions, Gtk+ must be initialized.
|
4
|
-
require 'ffi-gtk3'
|
5
|
-
Gtk.init
|
6
|
-
|
7
|
-
# Tests generated methods and functions in the Gtk namespace.
|
8
|
-
class GeneratedGtkTest < MiniTest::Spec
|
9
|
-
context "In the generated Gtk module" do
|
10
|
-
context "a Gtk::Builder instance" do
|
11
|
-
setup do
|
12
|
-
@builder = Gtk::Builder.new
|
13
|
-
@spec = '
|
14
|
-
<interface>
|
15
|
-
<object class="GtkButton" id="foo">
|
16
|
-
<signal handler="on_button_clicked" name="clicked"/>
|
17
|
-
</object>
|
18
|
-
</interface>
|
19
|
-
'
|
20
|
-
end
|
21
|
-
|
22
|
-
should "load spec" do
|
23
|
-
assert_nothing_raised { @builder.add_from_string @spec, @spec.length }
|
24
|
-
end
|
25
|
-
|
26
|
-
context "its #get_object method" do
|
27
|
-
should "return objects of the proper class" do
|
28
|
-
@builder.add_from_string @spec, @spec.length
|
29
|
-
o = @builder.get_object "foo"
|
30
|
-
assert_instance_of Gtk::Button, o
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "its #connect_signals_full method" do
|
35
|
-
setup do
|
36
|
-
@builder.add_from_string @spec, @spec.length
|
37
|
-
end
|
38
|
-
should "pass arguments correctly" do
|
39
|
-
aa = nil
|
40
|
-
@builder.connect_signals_full Proc.new {|*args| aa = args}, nil
|
41
|
-
b, o, sn, hn, co, f, ud = aa
|
42
|
-
assert_instance_of Gtk::Builder, b
|
43
|
-
assert_equal b.to_ptr, @builder.to_ptr
|
44
|
-
assert_instance_of Gtk::Button, o
|
45
|
-
assert_equal "clicked", sn
|
46
|
-
assert_equal "on_button_clicked", hn
|
47
|
-
assert_equal nil, co
|
48
|
-
assert_equal 0, f
|
49
|
-
assert_equal nil, ud
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "a Gtk::Window instance" do
|
55
|
-
setup do
|
56
|
-
@w = Gtk::Window.new :toplevel
|
57
|
-
end
|
58
|
-
|
59
|
-
should "start with a refcount of 2 (one for us, one for GTK+)" do
|
60
|
-
assert_equal 2, ref_count(@w)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "Gtk::RadioButton" do
|
65
|
-
context ".new" do
|
66
|
-
should "work when called with nil" do
|
67
|
-
assert_nothing_raised {
|
68
|
-
Gtk::RadioButton.new nil
|
69
|
-
}
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "#get_group" do
|
74
|
-
should "return a GLib::SList object" do
|
75
|
-
btn = Gtk::RadioButton.new nil
|
76
|
-
grp = btn.get_group
|
77
|
-
assert_instance_of GLib::SList, grp
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context ".new" do
|
82
|
-
should "work when called with the result of #get_group" do
|
83
|
-
assert_nothing_raised {
|
84
|
-
btn = Gtk::RadioButton.new nil
|
85
|
-
grp = btn.get_group
|
86
|
-
Gtk::RadioButton.new grp
|
87
|
-
}
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|