gir_ffi-gtk 0.8.0 → 0.8.1
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.
- checksums.yaml +4 -4
- data/Changelog.md +20 -8
- data/examples/04_webkit.rb +7 -5
- data/examples/07_simple_gtk_application.rb +30 -0
- data/examples/08_webkit_headless.rb +21 -0
- data/examples/09_webkit2_headless.rb +24 -0
- data/lib/gir_ffi-gtk/base.rb +4 -4
- data/lib/gir_ffi-gtk/menu.rb +3 -1
- data/lib/gir_ffi-gtk/message_dialog.rb +2 -2
- data/lib/gir_ffi-gtk/radio_action.rb +14 -0
- data/lib/gir_ffi-gtk/radio_button.rb +10 -10
- data/lib/gir_ffi-gtk/tree_path.rb +2 -2
- data/lib/gir_ffi-gtk2.rb +1 -0
- data/tasks/test.rake +3 -3
- data/test/gir_ffi-gtk/radio_action_test.rb +27 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9db12a11ec0be6f650fa77d62a76e2f987b2e99a
|
4
|
+
data.tar.gz: d3a2f90bb11881d3b4f0fe12beda7e1791e2ad55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 215691511a0bb591c5342ad9842d637b29f06f1112e4b29ead2033833bc64ed430e19de97c7283a0fbbe9558d55a4d4d84308d7c4d4056c525c93ef0b8a3d6de
|
7
|
+
data.tar.gz: 0e695e5a0d1a17f29d58d97a1ed4a7a4258d4f5243014f848bc029467d0bc525f26a0ee43766f752bd80f8431e91e5014d2e4ee1b78e1aec44c76e4213bfa574
|
data/Changelog.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
|
1
|
+
# Change Log
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file. See the
|
3
4
|
Git log for all changes.
|
4
5
|
|
5
|
-
|
6
|
+
## 0.8.1 / 2015-12-02
|
7
|
+
|
8
|
+
* Add override for Gtk::RadioAction#set_group
|
9
|
+
* Add Gtk::Application example (thanks, cedlemo)
|
10
|
+
* Add and update WebKit examples
|
11
|
+
|
12
|
+
## 0.8.0 / 2015-09-20
|
13
|
+
|
14
|
+
* Update dependency on GirFFI
|
15
|
+
* Update constructor overrides to match GirFFI's new constructor structure
|
16
|
+
|
17
|
+
## 0.7.2 / 2014-09-22
|
6
18
|
|
7
19
|
* Require at least Ruby 1.9.3
|
8
20
|
* Add overrides for Gtk::TreePath
|
@@ -11,31 +23,31 @@ Git log for all changes.
|
|
11
23
|
* Update dependencies
|
12
24
|
* Update examples
|
13
25
|
|
14
|
-
|
26
|
+
## 0.7.1 / 2014-03-25
|
15
27
|
|
16
28
|
* Fix Gtk::Builder#connect_signals_full by updating dependency on GirFFI
|
17
29
|
* Only override Gtk::Menu#popup if needed
|
18
30
|
* Test both Gtk+ 2 and 3
|
19
31
|
* Provide constructors for Gtk::RadioButton if needed
|
20
32
|
|
21
|
-
|
33
|
+
## 0.7.0 / 2014-01-11
|
22
34
|
|
23
35
|
* Update dependency on GirFFI
|
24
36
|
|
25
|
-
|
37
|
+
## 0.6.0 / 2013-06-09
|
26
38
|
|
27
39
|
* Update dependency on GirFFI
|
28
40
|
|
29
|
-
|
41
|
+
## 0.5.0 / 2013-01-19
|
30
42
|
|
31
43
|
* Update dependency on GirFFI
|
32
44
|
|
33
|
-
|
45
|
+
## 0.4.1 / 2012-09-22
|
34
46
|
|
35
47
|
* New TreeView example (thanks, Kasper Johansen)
|
36
48
|
* Implement Gtk::Menu#popup
|
37
49
|
* Update dependency on GirFFI so interfaces can wrap pointers
|
38
50
|
|
39
|
-
|
51
|
+
## 0.4.0 / 2012-08-24
|
40
52
|
|
41
53
|
* Initial release
|
data/examples/04_webkit.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Based on http://www.idle-hacking.com/2010/02/webkit-ruby-and-gtk/
|
3
|
+
# Based on https://web.archive.org/web/20110228141616/http://www.idle-hacking.com/2010/02/webkit-ruby-and-gtk/
|
4
|
+
#
|
5
|
+
|
4
6
|
require 'gir_ffi-gtk3'
|
5
7
|
|
6
|
-
GirFFI.setup :
|
8
|
+
GirFFI.setup :WebKit2, '4.0'
|
7
9
|
|
8
10
|
Gtk.init
|
9
11
|
|
10
12
|
win = Gtk::Window.new :toplevel
|
11
|
-
wv =
|
13
|
+
wv = WebKit2::WebView.new
|
12
14
|
win.add(wv)
|
13
15
|
win.show_all
|
14
|
-
wv.
|
15
|
-
win.signal_connect(
|
16
|
+
wv.load_uri('http://www.google.com/')
|
17
|
+
win.signal_connect('destroy') { Gtk.main_quit }
|
16
18
|
Gtk.main
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'gir_ffi-gtk3'
|
4
|
+
|
5
|
+
myapp = Gtk::Application.new('org.gtk.example', :handles_command_line)
|
6
|
+
|
7
|
+
myapp.signal_connect 'command-line' do |app, _command_line|
|
8
|
+
app.activate
|
9
|
+
0
|
10
|
+
end
|
11
|
+
|
12
|
+
myapp.signal_connect 'activate' do |app|
|
13
|
+
win = Gtk::ApplicationWindow.new(app)
|
14
|
+
win.set_title('Gtk Application example')
|
15
|
+
win.set_default_size(200, 200)
|
16
|
+
|
17
|
+
button_box = Gtk::ButtonBox.new(:horizontal)
|
18
|
+
win.add(button_box)
|
19
|
+
|
20
|
+
button = Gtk::Button.new_with_label('Hello world')
|
21
|
+
button.signal_connect 'clicked' do
|
22
|
+
puts 'Hello World'
|
23
|
+
app.quit
|
24
|
+
end
|
25
|
+
|
26
|
+
button_box.add(button)
|
27
|
+
win.show_all
|
28
|
+
end
|
29
|
+
|
30
|
+
exit(myapp.run([$PROGRAM_NAME] + ARGV))
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'gir_ffi-gtk3'
|
2
|
+
|
3
|
+
GirFFI.setup :WebKit, '3.0'
|
4
|
+
|
5
|
+
Gtk.init
|
6
|
+
|
7
|
+
win = Gtk::OffscreenWindow.new
|
8
|
+
web_view = WebKit::WebView.new
|
9
|
+
win.add(web_view)
|
10
|
+
|
11
|
+
web_view.signal_connect "load-finished" do
|
12
|
+
pixbuf = win.get_pixbuf
|
13
|
+
pixbuf.savev("google.png", "png", nil, nil)
|
14
|
+
puts web_view.get_title
|
15
|
+
Gtk.main_quit
|
16
|
+
end
|
17
|
+
|
18
|
+
web_view.load_uri('http://www.google.com/')
|
19
|
+
win.show_all
|
20
|
+
|
21
|
+
Gtk.main
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'gir_ffi-gtk3'
|
2
|
+
|
3
|
+
GirFFI.setup :WebKit2, '4.0'
|
4
|
+
|
5
|
+
Gtk.init
|
6
|
+
|
7
|
+
win = Gtk::OffscreenWindow.new
|
8
|
+
web_view = WebKit2::WebView.new
|
9
|
+
win.add(web_view)
|
10
|
+
|
11
|
+
web_view.signal_connect "load-changed" do |_, event, _|
|
12
|
+
case event
|
13
|
+
when :finished
|
14
|
+
pixbuf = win.get_pixbuf
|
15
|
+
pixbuf.savev("google.png", "png", nil, nil)
|
16
|
+
puts web_view.get_title
|
17
|
+
Gtk.main_quit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
web_view.load_uri('http://www.google.com/')
|
22
|
+
win.show_all
|
23
|
+
|
24
|
+
Gtk.main
|
data/lib/gir_ffi-gtk/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module GirFFIGtk
|
2
2
|
# Override init to automatically use ARGV as its argument.
|
3
3
|
module AutoArgv
|
4
|
-
def self.included
|
4
|
+
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
6
|
class << base
|
7
7
|
alias_method :init_without_auto_argv, :init
|
@@ -22,7 +22,7 @@ module GirFFIGtk
|
|
22
22
|
# Override main to start an idle thread to allow Ruby threads to run during
|
23
23
|
# the main loop.
|
24
24
|
module ThreadEnabler
|
25
|
-
def self.included
|
25
|
+
def self.included(base)
|
26
26
|
base.extend ClassMethods
|
27
27
|
class << base
|
28
28
|
alias_method :main_without_thread_enabler, :main
|
@@ -47,8 +47,8 @@ end
|
|
47
47
|
|
48
48
|
# Overrides for Gtk module functions
|
49
49
|
module Gtk
|
50
|
-
setup_method
|
51
|
-
setup_method
|
50
|
+
setup_method 'init'
|
51
|
+
setup_method 'main'
|
52
52
|
|
53
53
|
include GirFFIGtk::AutoArgv
|
54
54
|
include GirFFIGtk::ThreadEnabler
|
data/lib/gir_ffi-gtk/menu.rb
CHANGED
@@ -3,7 +3,9 @@ module Gtk
|
|
3
3
|
# Overrides for GtkMenu
|
4
4
|
class Menu
|
5
5
|
unless method_defined? :popup
|
6
|
-
|
6
|
+
# Smells of :reek:LongParameterList: due to the defined GtkMenu interface.
|
7
|
+
# rubocop:disable Metrics/ParameterLists
|
8
|
+
def popup(parent_menu_shell, parent_menu_item, func, data, button, activate_time)
|
7
9
|
popup_for_device(nil,
|
8
10
|
parent_menu_shell, parent_menu_item, func, data,
|
9
11
|
nil,
|
@@ -13,13 +13,13 @@ module Gtk
|
|
13
13
|
|
14
14
|
# Overrides for GtkMessageDialog
|
15
15
|
class MessageDialog
|
16
|
-
def self.new
|
16
|
+
def self.new(*args)
|
17
17
|
obj = allocate
|
18
18
|
obj.send :initialize, *args
|
19
19
|
obj
|
20
20
|
end
|
21
21
|
|
22
|
-
def initialize
|
22
|
+
def initialize(parent, flags, type, buttons, message)
|
23
23
|
ptr = Gtk::Lib.gtk_message_dialog_new(parent, flags, type, buttons,
|
24
24
|
'%s',
|
25
25
|
:string, message)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gtk.load_class :RadioAction
|
2
|
+
module Gtk
|
3
|
+
# Add non-introspected functions to Gtk::Lib
|
4
|
+
module Lib
|
5
|
+
attach_function :gtk_radio_action_set_group, [:pointer, :pointer], :void
|
6
|
+
end
|
7
|
+
|
8
|
+
# Overrides for GtkRadioAction
|
9
|
+
class RadioAction
|
10
|
+
def set_group(group)
|
11
|
+
Gtk::Lib.gtk_radio_action_set_group self, group
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -8,28 +8,28 @@ module Gtk
|
|
8
8
|
|
9
9
|
# Overrides for GtkRadioButton
|
10
10
|
class RadioButton
|
11
|
-
def self.new
|
11
|
+
def self.new(*args)
|
12
12
|
obj = allocate
|
13
13
|
obj.send :initialize, *args
|
14
14
|
obj
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.new_from_widget
|
17
|
+
def self.new_from_widget(*args)
|
18
18
|
obj = allocate
|
19
19
|
obj.send :initialize_from_widget, *args
|
20
20
|
obj
|
21
21
|
end
|
22
22
|
|
23
|
-
def initialize
|
24
|
-
|
25
|
-
|
26
|
-
store_pointer(
|
23
|
+
def initialize(group)
|
24
|
+
list = GLib::SList.from(Gtk::RadioButton, group)
|
25
|
+
ptr = Gtk::Lib.gtk_radio_button_new(list)
|
26
|
+
store_pointer(ptr)
|
27
27
|
end
|
28
28
|
|
29
|
-
def initialize_from_widget
|
30
|
-
|
31
|
-
|
32
|
-
store_pointer(
|
29
|
+
def initialize_from_widget(radio_group_member)
|
30
|
+
widget = Gtk::RadioButton.from(radio_group_member)
|
31
|
+
ptr = Gtk::Lib.gtk_radio_button_new_from_widget(widget)
|
32
|
+
store_pointer(ptr)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -10,13 +10,13 @@ module Gtk
|
|
10
10
|
# Overrides for GtkTreePath
|
11
11
|
class TreePath
|
12
12
|
if Gtk::MAJOR_VERSION == 2 || Gtk::MAJOR_VERSION == 3 && Gtk::MINOR_VERSION < 12
|
13
|
-
def self.new_from_indices
|
13
|
+
def self.new_from_indices(*args)
|
14
14
|
obj = allocate
|
15
15
|
obj.send :initialize_from_indices, *args
|
16
16
|
obj
|
17
17
|
end
|
18
18
|
|
19
|
-
def initialize_from_indices
|
19
|
+
def initialize_from_indices(indices)
|
20
20
|
args = indices.flat_map { |index| [:int, index] }
|
21
21
|
ptr = Gtk::Lib.gtk_tree_path_new_from_indices(*args, :int, -1)
|
22
22
|
store_pointer ptr
|
data/lib/gir_ffi-gtk2.rb
CHANGED
data/tasks/test.rake
CHANGED
@@ -4,15 +4,15 @@ namespace :test do
|
|
4
4
|
Rake::TestTask.new(:gtk3) do |t|
|
5
5
|
t.libs = ['lib']
|
6
6
|
t.test_files = FileList['test/**/*_test.rb']
|
7
|
-
t.ruby_opts += [
|
7
|
+
t.ruby_opts += ['-w', '-Itest']
|
8
8
|
end
|
9
9
|
|
10
10
|
Rake::TestTask.new(:gtk2) do |t|
|
11
11
|
t.libs = ['lib']
|
12
12
|
t.test_files = FileList['test/**/*_test.rb']
|
13
|
-
t.ruby_opts += [
|
13
|
+
t.ruby_opts += ['-rgir_ffi-gtk2', '-w', '-Itest']
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
desc 'Run unit tests'
|
18
|
-
task :
|
18
|
+
task test: ['test:gtk3', 'test:gtk2']
|
@@ -0,0 +1,27 @@
|
|
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', 'other-tooltip', nil, 2
|
23
|
+
other_action.set_group grp
|
24
|
+
pass
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi-gtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gir_ffi
|
@@ -83,9 +83,13 @@ files:
|
|
83
83
|
- examples/04_webkit.rb
|
84
84
|
- examples/05_notification.rb
|
85
85
|
- examples/06_treeview.rb
|
86
|
+
- examples/07_simple_gtk_application.rb
|
87
|
+
- examples/08_webkit_headless.rb
|
88
|
+
- examples/09_webkit2_headless.rb
|
86
89
|
- lib/gir_ffi-gtk/base.rb
|
87
90
|
- lib/gir_ffi-gtk/menu.rb
|
88
91
|
- lib/gir_ffi-gtk/message_dialog.rb
|
92
|
+
- lib/gir_ffi-gtk/radio_action.rb
|
89
93
|
- lib/gir_ffi-gtk/radio_button.rb
|
90
94
|
- lib/gir_ffi-gtk/tree_path.rb
|
91
95
|
- lib/gir_ffi-gtk2.rb
|
@@ -95,6 +99,7 @@ files:
|
|
95
99
|
- test/gir_ffi-gtk/generated_gtk_test.rb
|
96
100
|
- test/gir_ffi-gtk/menu_test.rb
|
97
101
|
- test/gir_ffi-gtk/message_dialog_test.rb
|
102
|
+
- test/gir_ffi-gtk/radio_action_test.rb
|
98
103
|
- test/gir_ffi-gtk/radio_button_test.rb
|
99
104
|
- test/gir_ffi-gtk/tree_path_test.rb
|
100
105
|
- test/test_helper.rb
|
@@ -127,6 +132,7 @@ test_files:
|
|
127
132
|
- test/gir_ffi-gtk/generated_gtk_test.rb
|
128
133
|
- test/gir_ffi-gtk/menu_test.rb
|
129
134
|
- test/gir_ffi-gtk/message_dialog_test.rb
|
135
|
+
- test/gir_ffi-gtk/radio_action_test.rb
|
130
136
|
- test/gir_ffi-gtk/radio_button_test.rb
|
131
137
|
- test/gir_ffi-gtk/tree_path_test.rb
|
132
138
|
- test/test_helper.rb
|