gtk4 4.2.9 → 4.3.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/README.md +8 -6
- data/ext/gtk4/rb-gtk4-widget.c +18 -5
- data/gtk4.gemspec +1 -0
- data/lib/gtk4/deprecated.rb +6 -3
- data/lib/gtk4/image.rb +11 -2
- data/lib/gtk4/loader.rb +4 -2
- data/lib/gtk4/popover.rb +29 -0
- data/lib/gtk4/snapshot.rb +31 -0
- data/lib/gtk4.rb +1 -0
- data/sample/examples/file_dialog_demo.rb +40 -0
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594341a672fef1c67eeef1f1d3354d653159776f38bf91be8ca02d80f66b79d0
|
4
|
+
data.tar.gz: 76ffb0a798252613e79235cd66dbd0578bfa4912fac3412aa9e6c1e42ba5ce3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 015e9f5e73f4275dca4c56f89350f72aba1f800e1ac711aad961262449f2c6428764afee9907f4d3acef1335df7708052f760e42517d13287a1c29700248fbcc
|
7
|
+
data.tar.gz: 75485b2b4317c06d01151f439b764fbfd2659a236d604f1671c5a425cec4595067f7a3b74d75660c4a7991af1907bf215290a3e139bf4503bfa5cbc57a0f324b
|
data/README.md
CHANGED
@@ -4,15 +4,17 @@ Ruby/GTK4 is a Ruby binding of GTK 4.
|
|
4
4
|
|
5
5
|
## Requirements
|
6
6
|
|
7
|
-
* Ruby/GLib2, Ruby/
|
8
|
-
Ruby/GDK4, Ruby/
|
7
|
+
* Ruby/GLib2, Ruby/GObjectIntrospection, Ruby/ATK, Ruby/Pango, Ruby/GdkPixbuf2,
|
8
|
+
Ruby/GIO2, Ruby/GDK4, Ruby/Graphene and Ruby/GSK4 in
|
9
9
|
[Ruby-GNOME2](https://ruby-gnome.github.io/)
|
10
10
|
* [rcairo](https://github.com/rcairo/rcairo)
|
11
11
|
* [GTK](https://www.gtk.org/)
|
12
12
|
|
13
13
|
## Install
|
14
14
|
|
15
|
-
|
15
|
+
```bash
|
16
|
+
gem install gtk4
|
17
|
+
```
|
16
18
|
|
17
19
|
## Tutorials, examples:
|
18
20
|
|
@@ -20,12 +22,12 @@ Ruby/GTK4 is a Ruby binding of GTK 4.
|
|
20
22
|
|
21
23
|
## License
|
22
24
|
|
23
|
-
Copyright (C) 2002-
|
25
|
+
Copyright (C) 2002-2025 Ruby-GNOME Project Team
|
24
26
|
|
25
27
|
This program is free software. You can distribute/modify this program
|
26
|
-
under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
|
28
|
+
under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
|
29
|
+
or later.
|
27
30
|
|
28
31
|
## Project Websites
|
29
32
|
|
30
|
-
* https://github.com/ruby-gnome/ruby-gnome
|
31
33
|
* https://ruby-gnome.github.io/
|
data/ext/gtk4/rb-gtk4-widget.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2015-
|
3
|
+
* Copyright (C) 2015-2025 Ruby-GNOME Project Team
|
4
4
|
*
|
5
5
|
* This library is free software; you can redistribute it and/or
|
6
6
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -23,10 +23,23 @@
|
|
23
23
|
static void
|
24
24
|
rb_gtk4_widget_mark(gpointer object)
|
25
25
|
{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
{
|
27
|
+
GtkWidget *child = gtk_widget_get_first_child(object);
|
28
|
+
while (child) {
|
29
|
+
rbgobj_gc_mark_instance(child);
|
30
|
+
child = gtk_widget_get_next_sibling(child);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
{
|
35
|
+
GListModel *controllers = gtk_widget_observe_controllers(object);
|
36
|
+
guint n = g_list_model_get_n_items(controllers);
|
37
|
+
for (guint i = 0; i < n; i++) {
|
38
|
+
GObject *controller = g_list_model_get_object(controllers, i);
|
39
|
+
rbgobj_gc_mark_instance(controller);
|
40
|
+
g_object_unref(controller);
|
41
|
+
}
|
42
|
+
g_object_unref(controllers);
|
30
43
|
}
|
31
44
|
}
|
32
45
|
|
data/gtk4.gemspec
CHANGED
data/lib/gtk4/deprecated.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011-
|
1
|
+
# Copyright (C) 2011-2025 Ruby-GNOME 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
|
@@ -619,7 +619,8 @@ module Gtk
|
|
619
619
|
define_deprecated_method :set, warn: message
|
620
620
|
define_deprecated_method_by_hash_args :initialize,
|
621
621
|
'image',
|
622
|
-
'icon_name: nil, icon: nil, file: nil, pixbuf: nil'
|
622
|
+
'icon_name: nil, icon: nil, file: nil, pixbuf: nil, resource: nil, ' +
|
623
|
+
'paintable: nil' do
|
623
624
|
|_self, image|
|
624
625
|
case image
|
625
626
|
when String
|
@@ -631,9 +632,11 @@ module Gtk
|
|
631
632
|
when Symbol
|
632
633
|
[{icon_name: image}]
|
633
634
|
when GdkPixbuf::Pixbuf
|
634
|
-
[{:
|
635
|
+
[{pixbuf: image}]
|
635
636
|
when Gio::Icon
|
636
637
|
[{icon: image}]
|
638
|
+
when Gdk::Paintable
|
639
|
+
[{paintable: paintable}]
|
637
640
|
else
|
638
641
|
message =
|
639
642
|
"Image must be String, Symbol, GdkPixbuf::Pixbuf or " +
|
data/lib/gtk4/image.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2025 Ruby-GNOME 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
|
@@ -20,7 +20,7 @@ module Gtk
|
|
20
20
|
# Creates a Gtk::Image. The source of the image depends on the options
|
21
21
|
# given.
|
22
22
|
#
|
23
|
-
# @param Hash{Symbol => String, Gio::Icon, GdkPixbuf::Pixbuf}
|
23
|
+
# @param Hash{Symbol => String, Gio::Icon, GdkPixbuf::Pixbuf, Gdk::Paintable}
|
24
24
|
#
|
25
25
|
# @example Create an empty image.
|
26
26
|
# image = Gtk::Image.new
|
@@ -49,12 +49,19 @@ module Gtk
|
|
49
49
|
# Gio::Resources.register(resource)
|
50
50
|
# resource_path = "/path/to/image.png"
|
51
51
|
# image = Gtk::Image.new(resource: resource_path)
|
52
|
+
#
|
53
|
+
# @example Create an image from a paintable
|
54
|
+
# Gio::File.open(path: "my.png") do |file|
|
55
|
+
# texture = Gdk::Texture.new(file)
|
56
|
+
# image = Gtk::Image.new(paintable: texture)
|
57
|
+
# end
|
52
58
|
def initialize(options={})
|
53
59
|
icon_name = options[:icon_name] || nil
|
54
60
|
icon = options[:icon] || options[:gicon] || nil
|
55
61
|
file = options[:file] || nil
|
56
62
|
pixbuf = options[:pixbuf] || nil
|
57
63
|
resource = options[:resource] || nil
|
64
|
+
paintable = options[:paintable] || nil
|
58
65
|
|
59
66
|
if icon_name
|
60
67
|
initialize_new_from_icon_name(icon_name)
|
@@ -66,6 +73,8 @@ module Gtk
|
|
66
73
|
initialize_new_from_pixbuf(pixbuf)
|
67
74
|
elsif resource
|
68
75
|
initialize_new_from_resource(resource)
|
76
|
+
elsif paintable
|
77
|
+
initialize_new_from_paintable(paintable)
|
69
78
|
else
|
70
79
|
initialize_raw
|
71
80
|
end
|
data/lib/gtk4/loader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2025 Ruby-GNOME 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
|
@@ -104,12 +104,14 @@ module Gtk
|
|
104
104
|
require_relative "list-store"
|
105
105
|
require_relative "message-dialog"
|
106
106
|
require_relative "paned"
|
107
|
+
require_relative "popover"
|
107
108
|
require_relative "response-type"
|
108
109
|
require_relative "scale-button"
|
109
110
|
require_relative "scrolled-window"
|
110
111
|
require_relative "search-bar"
|
111
|
-
require_relative "spin-button"
|
112
112
|
require_relative "show-uri"
|
113
|
+
require_relative "snapshot"
|
114
|
+
require_relative "spin-button"
|
113
115
|
require_relative "stack"
|
114
116
|
require_relative "style-context"
|
115
117
|
require_relative "text-buffer"
|
data/lib/gtk4/popover.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (C) 2025 Ruby-GNOME 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 Popover
|
19
|
+
alias_method :pointing_to_raw, :pointing_to
|
20
|
+
def pointing_to
|
21
|
+
have, rectangle = pointing_to_raw
|
22
|
+
if have
|
23
|
+
rectangle
|
24
|
+
else
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright (C) 2025 Ruby-GNOME 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 Snapshot
|
19
|
+
alias_method :save_raw, :save
|
20
|
+
def save
|
21
|
+
save_raw
|
22
|
+
if block_given?
|
23
|
+
begin
|
24
|
+
yield
|
25
|
+
ensure
|
26
|
+
restore
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/gtk4.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (C) 2024 Ruby-GNOME 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
|
+
require "gtk4"
|
18
|
+
|
19
|
+
def on_activate(app)
|
20
|
+
win = Gtk::ApplicationWindow.new(app)
|
21
|
+
dialog = Gtk::FileDialog.new
|
22
|
+
dialog.modal = true
|
23
|
+
dialog.initial_file = Gio::File.open(path: File.expand_path(__FILE__))
|
24
|
+
dialog.initial_folder = Gio::File.open(path: Dir.pwd)
|
25
|
+
dialog.save do |_dialog, result|
|
26
|
+
begin
|
27
|
+
file = dialog.save_finish(result)
|
28
|
+
puts("file.path: #{file.path}")
|
29
|
+
rescue Gtk::DialogError::Dismissed
|
30
|
+
puts("Dismissed")
|
31
|
+
end
|
32
|
+
win.destroy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
app = Gtk::Application.new("io.github.ruby-gnome.gtk4.example.FileDialog")
|
37
|
+
app.signal_connect("activate") do
|
38
|
+
on_activate(app)
|
39
|
+
end
|
40
|
+
app.run
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME Project Team
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: atk
|
@@ -15,28 +15,42 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - '='
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 4.
|
18
|
+
version: 4.3.1
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - '='
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 4.
|
25
|
+
version: 4.3.1
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: gdk4
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
30
|
- - '='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 4.
|
32
|
+
version: 4.3.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - '='
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 4.
|
39
|
+
version: 4.3.1
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: gsk4
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 4.3.1
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 4.3.1
|
40
54
|
description: Ruby/GTK4 is a Ruby binding of GTK 4.x. It allows Ruby programmers to
|
41
55
|
use the GTK graphics toolkit to make graphical user interfaces for their Ruby scripts.
|
42
56
|
Many of the programs you use like file explorers, browsers, graphics programs etc.
|
@@ -98,12 +112,14 @@ files:
|
|
98
112
|
- lib/gtk4/loader.rb
|
99
113
|
- lib/gtk4/message-dialog.rb
|
100
114
|
- lib/gtk4/paned.rb
|
115
|
+
- lib/gtk4/popover.rb
|
101
116
|
- lib/gtk4/response-type.rb
|
102
117
|
- lib/gtk4/ruby-builder-scope.rb
|
103
118
|
- lib/gtk4/scale-button.rb
|
104
119
|
- lib/gtk4/scrolled-window.rb
|
105
120
|
- lib/gtk4/search-bar.rb
|
106
121
|
- lib/gtk4/show-uri.rb
|
122
|
+
- lib/gtk4/snapshot.rb
|
107
123
|
- lib/gtk4/spin-button.rb
|
108
124
|
- lib/gtk4/stack.rb
|
109
125
|
- lib/gtk4/style-context.rb
|
@@ -175,6 +191,7 @@ files:
|
|
175
191
|
- sample/examples/builder.rb
|
176
192
|
- sample/examples/builder.ui
|
177
193
|
- sample/examples/drawing.rb
|
194
|
+
- sample/examples/file_dialog_demo.rb
|
178
195
|
- sample/examples/grid_packing.rb
|
179
196
|
- sample/examples/hello_world.rb
|
180
197
|
- sample/examples/menubar.rb
|
@@ -203,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
220
|
- !ruby/object:Gem::Version
|
204
221
|
version: '0'
|
205
222
|
requirements: []
|
206
|
-
rubygems_version: 3.6.
|
223
|
+
rubygems_version: 3.6.9
|
207
224
|
specification_version: 4
|
208
225
|
summary: Ruby/GTK4 is a Ruby binding of GTK+-4.x.
|
209
226
|
test_files: []
|