gtk3 3.3.9 → 3.4.4

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
  SHA256:
3
- metadata.gz: 04a0f7f2d95ea6a2b7666e001e53b2823203496e603beda15f2182d6272d2645
4
- data.tar.gz: 2b6a83c596071e51333d8d97b73ab754b378cc36891fd2285a26bd470f3c7f39
3
+ metadata.gz: 46f440c547ffc229c731a6d434a278203084202d005f7bf4a2db47ae54e7521d
4
+ data.tar.gz: 5d9fbab7ff4fffc9fe44362a70e794d4072ed9424d0d0e6bedc6c2e32337a986
5
5
  SHA512:
6
- metadata.gz: bb452074062e6f4cd5a46083daf95d414850849bb4f6361faf7dac7fbaf8cde65d3fec148560b765e5ce372577f3ffaf6775e74e789b547ed253c56f44f08b4f
7
- data.tar.gz: f35a6ad707e0936758adef67d6eaa03fbf0ab649f466bb73cb5bd1e8f29200b095407e5ab64ea0d9abb149ff5ad46511f80405fc819ebeba98619136a6ac23c7
6
+ metadata.gz: a3ffd7c7828d9ce4b4b819158014c87c12e5274dc4446f94521b33ea3c32a5aac9fa4c74916cde4bb3ebafca16bba9ba9cdc5d3b8f77872b9b06f415cf61abfe
7
+ data.tar.gz: e90825bf6764ff792c210b62a097b7b4808e1bf6e82a56e2fe1464d2db10f83b6ea0325c0181e64141c4def1061d0ad489726697f2ac5afd200371a5b26c4e89
data/README.md CHANGED
@@ -6,7 +6,7 @@ Ruby/GTK3 is a Ruby binding of GTK+ 3.
6
6
 
7
7
  * Ruby/GLib2, Ruby/ATK, Ruby/Pango, Ruby/GdkPixbuf2, Ruby/GIO2,
8
8
  Ruby/GDK3, Ruby/GObjectIntrospection and Ruby/GTK3 in
9
- [Ruby-GNOME2](https://ruby-gnome2.osdn.jp/)
9
+ [Ruby-GNOME](https://ruby-gnome2.osdn.jp/)
10
10
  * [rcairo](https://github.com/rcairo/rcairo)
11
11
  * [GTK+](http://www.gtk.org/) 3.4.2 or later
12
12
 
@@ -23,7 +23,7 @@ Ruby/GTK3 is a Ruby binding of GTK+ 3.
23
23
 
24
24
  ## License
25
25
 
26
- Copyright (c) 2002-2018 Ruby-GNOME2 Project Team
26
+ Copyright (c) 2002-2020 Ruby-GNOME Project Team
27
27
 
28
28
  This program is free software. You can distribute/modify this program
29
29
  under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
data/lib/gtk3/dialog.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2016 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2020 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
@@ -56,21 +56,20 @@ module Gtk
56
56
 
57
57
  alias_method :add_button_raw, :add_button
58
58
  def add_button(text, response_id)
59
- case response_id
60
- when Symbol
61
- response_id = ResponseType.new(response_id)
62
- end
63
- add_button_raw(text, response_id)
59
+ add_button_raw(text, ResponseType.resolve(response_id))
64
60
  end
65
61
 
66
62
  alias_method :get_widget_for_response_raw, :get_widget_for_response
67
63
  def get_widget_for_response(response_id)
68
- case response_id
69
- when Symbol
70
- response_id = ResponseType.new(response_id)
71
- end
72
- get_widget_for_response_raw(response_id)
64
+ get_widget_for_response_raw(ResponseType.resolve(response_id))
65
+ end
66
+
67
+ alias_method :set_default_response_raw, :set_default_response
68
+ def set_default_response(response_id)
69
+ set_default_response_raw(ResponseType.resolve(response_id))
73
70
  end
71
+ alias_method :default_response_raw=, :default_response=
72
+ alias_method :default_response=, :set_default_response
74
73
 
75
74
  if method_defined?(:use_header_bar)
76
75
  alias_method :use_header_bar_raw, :use_header_bar
data/lib/gtk3/loader.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2019 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2014-2020 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
@@ -114,6 +114,7 @@ module Gtk
114
114
  require "gtk3/radio-action"
115
115
  require "gtk3/radio-button"
116
116
  require "gtk3/recent-chooser-dialog"
117
+ require "gtk3/response-type"
117
118
  require "gtk3/scale-button"
118
119
  require "gtk3/scrolled-window"
119
120
  require "gtk3/search-bar"
@@ -0,0 +1,30 @@
1
+ # Copyright (C) 2020 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 ResponseType
19
+ class << self
20
+ def resolve(id)
21
+ case id
22
+ when Symbol
23
+ new(id)
24
+ else
25
+ id
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/gtk3/widget.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2018 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2020 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
@@ -82,6 +82,24 @@ module Gtk
82
82
  alias_method :events_raw=, :events=
83
83
  alias_method :events=, :set_events
84
84
 
85
+ alias_method :set_size_request_raw, :set_size_request
86
+ def set_size_request(*args)
87
+ case args.size
88
+ when 1
89
+ options = args[0]
90
+ raise ArgumentError, ":width is missing" unless options.key?(:width)
91
+ width = options[:width]
92
+ raise ArgumentError, ":height is missing" unless options.key?(:height)
93
+ height = options[:height]
94
+ when 2
95
+ width, height = args
96
+ else
97
+ message = "wrong number of arguments (given #{args.size}, expected 1..2)"
98
+ raise ArgumentError, message
99
+ end
100
+ set_size_request_raw(width, height)
101
+ end
102
+
85
103
  alias_method :drag_source_set_raw, :drag_source_set
86
104
  def drag_source_set(flags, targets, actions)
87
105
  targets = ensure_drag_targets(targets)
@@ -97,6 +115,9 @@ module Gtk
97
115
  alias_method :style_get_property_raw, :style_get_property
98
116
  def style_get_property(name)
99
117
  property = self.class.find_style_property(name)
118
+ if property.nil?
119
+ raise ArgumentError, "unknown style: #{name.inspect}"
120
+ end
100
121
  value = GLib::Value.new(property.value_type)
101
122
  style_get_property_raw(name, value)
102
123
  value.value
@@ -1,7 +1,12 @@
1
- gtk-demo for Ruby/GTK
1
+ # gtk-demo for Ruby/GTK
2
2
 
3
3
  To run, do
4
4
 
5
5
  ruby main.rb
6
6
 
7
7
  in this directory.
8
+
9
+ NOTE: `glib-compile-resources` program must be in the PATH.
10
+ On Windows, try the following command.
11
+
12
+ ridk exec ruby main.rb
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  aboutdialog.rb - Ruby/GTK sample script.
4
4
 
5
- Copyright (c) 2005-2018 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2005-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -17,15 +17,15 @@ a = Gtk::AboutDialog.new
17
17
  a.artists = ["Artist 1 <no1@foo.bar.com>", "Artist 2 <no2@foo.bar.com>"]
18
18
  a.authors = ["Author 1 <no1@foo.bar.com>", "Author 2 <no2@foo.bar.com>"]
19
19
  a.comments = "This is a sample script for Gtk::AboutDialog"
20
- a.copyright = "Copyright (C) 2005 Ruby-GNOME2 Project"
20
+ a.copyright = "Copyright (C) 2020 Ruby-GNOME Project"
21
21
  a.documenters = ["Documenter 1 <no1@foo.bar.com>", "Documenter 2 <no2@foo.bar.com>"]
22
- a.license = "This program is licenced under the same licence as Ruby-GNOME2."
22
+ a.license = "This program is licenced under the same licence as Ruby-GNOME."
23
23
  a.logo = GdkPixbuf::Pixbuf.new(:file => File.join(__dir__, "gnome-logo-icon.png"))
24
24
  a.program_name = "Gtk::AboutDialog sample"
25
25
  a.translator_credits = "Translator 1\nTranslator 2\n"
26
26
  a.version = "1.0.0"
27
27
  a.website = "https://ruby-gnome2.osdn.jp"
28
- a.website_label = "Ruby-GNOME2 Project Website"
28
+ a.website_label = "Ruby-GNOME Project Website"
29
29
 
30
30
  a.signal_connect("activate-link") do |_widget, uri|
31
31
  p _widget.class
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  aboutdialog2.rb - Ruby/GTK sample script.
4
4
 
5
- Copyright (c) 2005-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2005-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
  require "gtk3"
9
9
 
@@ -12,19 +12,24 @@ unless Gtk::Version.or_later?(3, 4, 2)
12
12
  exit
13
13
  end
14
14
 
15
- Gtk::AboutDialog.show(nil,
16
- "artists" => ["Artist 1 <no1@foo.bar.com>", "Artist 2 <no2@foo.bar.com>"],
17
- "authors" => ["Author 1 <no1@foo.bar.com>", "Author 2 <no2@foo.bar.com>"],
18
- "comments" => "This is a sample script for Gtk::AboutDialog",
19
- "copyright" => "Copyright (C) 2005 Ruby-GNOME2 Project",
20
- "documenters" => ["Documenter 1 <no1@foo.bar.com>", "Documenter 2 <no2@foo.bar.com>"],
21
- "license" => "This program is licenced under the same licence as Ruby-GNOME2.",
22
- "logo_icon_name" => "gtk-home",
23
- "program_name" => "Gtk::AboutDialog sample",
24
- "translator_credits" => "Translator 1 <no1@foo.bar.com>\nTranslator 2 <no2@foo.bar.com>\n",
25
- "version" => "1.0.0",
26
- "website" => "https://ruby-gnome2.osdn.jp",
27
- "website_label" => "Ruby-GNOME2 Project Website"
28
- )
15
+ about_dialog = Gtk::AboutDialog.show(
16
+ nil,
17
+ "artists" => ["Artist 1 <no1@foo.bar.com>", "Artist 2 <no2@foo.bar.com>"],
18
+ "authors" => ["Author 1 <no1@foo.bar.com>", "Author 2 <no2@foo.bar.com>"],
19
+ "comments" => "This is a sample script for Gtk::AboutDialog",
20
+ "copyright" => "Copyright (C) 2005-2020 Ruby-GNOME Project",
21
+ "documenters" => ["Documenter 1 <no1@foo.bar.com>", "Documenter 2 <no2@foo.bar.com>"],
22
+ "license" => "This program is licenced under the same licence as Ruby-GNOME.",
23
+ "logo_icon_name" => "gtk-home",
24
+ "program_name" => "Gtk::AboutDialog sample",
25
+ "translator_credits" => "Translator 1 <no1@foo.bar.com>\nTranslator 2 <no2@foo.bar.com>\n",
26
+ "version" => "1.0.0",
27
+ "website" => "https://ruby-gnome2.osdn.jp",
28
+ "website_label" => "Ruby-GNOME Project Website"
29
+ )
30
+
31
+ about_dialog.signal_connect('delete_event') do
32
+ Gtk.main_quit
33
+ end
29
34
 
30
35
  Gtk.main
@@ -5,8 +5,10 @@
5
5
  Copyright (c) 2015 Ruby-GNOME2 Project Team
6
6
  This program is licenced under the same licence as Ruby-GNOME2.
7
7
  =end
8
+
8
9
  require "gtk3"
9
- ui_file = "#{File.expand_path(File.dirname(__FILE__))}/builder.ui"
10
+
11
+ ui_file = File.expand_path("builder.ui", __dir__)
10
12
  builder = Gtk::Builder.new
11
13
  builder.add_from_file(ui_file)
12
14
 
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  button2.rb - Ruby/GTK2 sample script.
4
4
 
5
- Copyright (c) 2002-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2002-2020 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -12,7 +12,7 @@ window = Gtk::Window.new("Gtk::Button sample")
12
12
 
13
13
  button1 = Gtk::Button.new(:mnemonic => "_HELLO")
14
14
  button2 = Gtk::Button.new(:label => "_HELLO")
15
- button3 = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
15
+ button3 = Gtk::Button.new(:stock_id => Gtk::Stock::QUIT)
16
16
 
17
17
  button3.signal_connect("clicked"){ Gtk.main_quit }
18
18
 
@@ -22,7 +22,7 @@ box.add(button2)
22
22
  box.add(button3)
23
23
 
24
24
  window.add(box)
25
- window.set_default_size(100,100)
25
+ window.set_default_size(100, 100)
26
26
  window.show_all
27
27
 
28
28
  Gtk.main
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  cairo_cursor.rb Ruby/GTK3 script
3
3
  Adapted from https://developer.gnome.org/gtk3/stable/ch25s02.html#id-1.6.3.4.5
4
- Copyright (c) 2015 Ruby-GNOME2 Project Team
5
- This program is licenced under the same licence as Ruby-GNOME2.
4
+ Copyright (c) 2015-2020 Ruby-GNOME Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME.
6
6
  =end
7
7
 
8
8
  require "gtk3"
@@ -20,7 +20,7 @@ cr.arc(3, 3, 3, 0, 2 * Math::PI)
20
20
  cr.fill
21
21
  cr.destroy
22
22
 
23
- pixbuf = surface.to_pixbuf(0, 0, 6, 6)
23
+ pixbuf = surface.to_pixbuf(src_x: 0, src_y: 0, width: 6, heihgt: 6)
24
24
  cursor = Gdk::Cursor.new(pixbuf, 0, 0)
25
25
 
26
26
  # generate the underlaying GDK resource associated with the window widget.
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  calendar.rb - Gtk::Calendar sample script.
3
3
 
4
- Copyright (c) 2002-2018 Ruby-GNOME2 Project Team
5
- This program is licenced under the same licence as Ruby-GNOME2.
4
+ Copyright (c) 2002-2020 Ruby-GNOME Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME.
6
6
  =end
7
7
 
8
8
  require "gtk3"
@@ -21,11 +21,7 @@ date = Time.new
21
21
  cal.select_month(date.month, date.year)
22
22
  cal.select_day(date.day)
23
23
  cal.mark_day(date.day)
24
- #cal.clear_marks
25
-
26
- #
27
- # Gtk::CalendarDisplayOptions::WEEK_START_MONDAY does not exist anymore
28
- #
24
+ # cal.clear_marks
29
25
 
30
26
  cal.set_display_options(Gtk::CalendarDisplayOptions::SHOW_HEADING |
31
27
  Gtk::CalendarDisplayOptions::SHOW_DAY_NAMES |
@@ -2,8 +2,8 @@
2
2
  cursor.rb - Gdk::Cursor sample script.
3
3
 
4
4
  Copyright (C) 2001-2006 Masao Mutoh
5
- Copyright (c) 2002-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2002-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -15,20 +15,20 @@ window.realize
15
15
  button = Gtk::Button.new(:label => "Click!")
16
16
  button.use_underline = false
17
17
 
18
- cursors = Gdk::CursorType.values - [Gdk::CursorType::CURSOR_IS_PIXMAP]
19
- cursors -= [Gdk::CursorType::LAST_CURSOR]
18
+ cursors = Gdk::CursorType.values -
19
+ [Gdk::CursorType::CURSOR_IS_PIXMAP] -
20
+ [Gdk::CursorType::LAST_CURSOR]
21
+ cursors = cursors.cycle
20
22
 
21
- cnt = 0
22
23
  button.signal_connect('clicked') do
23
- cursor = cursors[cnt]
24
- p cursor.inspect
24
+ cursor = cursors.next
25
+ p cursor
25
26
  button.set_label(cursor.inspect)
26
27
  window.window.set_cursor(Gdk::Cursor.new(cursor))
27
- cnt += 1
28
- cnt = 0 if cnt == cursors.size
29
28
  end
29
+
30
30
  window.add(button)
31
- window.set_default_size(400,100)
31
+ window.set_default_size(400, 100)
32
32
  window.show_all
33
33
 
34
34
  Gtk.main
@@ -2,8 +2,8 @@
2
2
  dndtreeview.rb - Drag and Drop sample script.
3
3
 
4
4
  Copyright (C) 2003-2015 Masao Mutoh
5
- Copyright (c) 2003-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2003-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -27,8 +27,8 @@ class TestWindow < Gtk::Window
27
27
  model = Gtk::ListStore.new(String, String)
28
28
  view = Gtk::TreeView.new(model)
29
29
  renderer = Gtk::CellRendererText.new
30
- col1 = Gtk::TreeViewColumn.new("Data", renderer, { :text => 0 })
31
- col2 = Gtk::TreeViewColumn.new("Data", renderer, { :text => 1 })
30
+ col1 = Gtk::TreeViewColumn.new("English", renderer, { :text => 0 })
31
+ col2 = Gtk::TreeViewColumn.new("Japanese", renderer, { :text => 1 })
32
32
  view.append_column(col1)
33
33
  view.append_column(col2)
34
34
 
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  drawing.rb - Ruby/GTK version of gtk+/examples/drawing.c.
3
3
  https://git.gnome.org/browse/gtk+/tree/examples/drawing.c?h=gtk-3-16
4
- Copyright (c) 2015 Ruby-GNOME2 Project Team
5
- This program is licenced under the same licence as Ruby-GNOME2.
4
+ Copyright (c) 2015-2020 Ruby-GNOME Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME.
6
6
  =end
7
7
 
8
8
  require "gtk3"
@@ -24,7 +24,7 @@ def draw_brush(widget, surface, x, y)
24
24
  widget.queue_draw_area(x - 3, y - 3, 6, 6)
25
25
  end
26
26
 
27
- myapp = Gtk::Application.new "org.gtk.example", :flags_none
27
+ myapp = Gtk::Application.new "org.gtk.example", :flags_none
28
28
 
29
29
  myapp.signal_connect "activate" do |app|
30
30
  win = Gtk::ApplicationWindow.new app
@@ -69,7 +69,7 @@ myapp.signal_connect "activate" do |app|
69
69
  drawing_area.signal_connect "motion-notify-event" do |da, ev|
70
70
  return false unless surface
71
71
 
72
- if ((ev.state & Gdk::EventMask::BUTTON_PRESS_MASK.to_i) != 0)
72
+ if (ev.state & Gdk::EventMask::BUTTON_PRESS_MASK.to_i) != 0
73
73
  draw_brush(da, surface, ev.x, ev.y)
74
74
  end
75
75
  end
@@ -77,9 +77,10 @@ myapp.signal_connect "activate" do |app|
77
77
  drawing_area.signal_connect "button-press-event" do |da, ev|
78
78
  return false unless surface
79
79
 
80
- if (ev.button == Gdk::BUTTON_PRIMARY)
80
+ case ev.button
81
+ when Gdk::BUTTON_PRIMARY
81
82
  draw_brush(da, surface, ev.x, ev.y)
82
- elsif (ev.button == Gdk::BUTTON_SECONDARY)
83
+ when Gdk::BUTTON_SECONDARY
83
84
  clear_surface(surface)
84
85
  da.queue_draw
85
86
  end
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  eventbox.rb - Ruby/GTK sample script.
3
3
 
4
- Copyright (c) 2015 Ruby-GNOME2 Project Team
5
- This program is licenced under the same licence as Ruby-GNOME2.
4
+ Copyright (c) 2015-2020 Ruby-GNOME Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME.
6
6
  =end
7
7
 
8
8
  # https://developer.gnome.org/gtk3/unstable/GtkEventBox.html
@@ -31,7 +31,9 @@ cr.set_source_rgb(0, 0, 1)
31
31
  cr.rectangle(*r3)
32
32
  cr.fill
33
33
 
34
- image = Gtk::Image.new(:pixbuf => surface.to_pixbuf(0, 0, 265, 95))
34
+ image = Gtk::Image.new(
35
+ pixbuf: surface.to_pixbuf(src_x: 0, src_y: 0, width: 265, height: 95)
36
+ )
35
37
 
36
38
  event_box = Gtk::EventBox.new
37
39
 
@@ -40,11 +42,11 @@ event_box.add(image)
40
42
  event_box.signal_connect "button-press-event" do |_widget, event|
41
43
  if event.y >= 10 && event.y <= 85
42
44
  if event.x >= 10 && event.x <= 85
43
- puts "red x = #{event.x} y = #{event.y}"
45
+ puts "red x = #{event.x} \t y = #{event.y}"
44
46
  elsif event.x >= 95 && event.x <= 180
45
- puts "green x = #{event.x} y = #{event.y}"
47
+ puts "green x = #{event.x} \t y = #{event.y}"
46
48
  elsif event.x >= 190 && event.x <= 255
47
- puts "blue x = #{event.x} y = #{event.y}"
49
+ puts "blue x = #{event.x} \t y = #{event.y}"
48
50
  end
49
51
  end
50
52
  end
@@ -2,16 +2,16 @@
2
2
  =begin
3
3
  filechooser.rb - Ruby/GTK2 sample script.
4
4
 
5
- Copyright (c) 2004-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2004-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
10
10
 
11
- dialog = Gtk::FileChooserDialog.new(:title => "Gtk::FileChooser sample",
12
- :action => Gtk::FileChooserAction::OPEN,
13
- :buttons => [[Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT],
14
- [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL]])
11
+ dialog = Gtk::FileChooserDialog.new(:title => "Gtk::FileChooser sample",
12
+ :action => :open,
13
+ :buttons => [[Gtk::Stock::OPEN, :accept],
14
+ [Gtk::Stock::CANCEL, :cancel]])
15
15
 
16
16
  extra_button = Gtk::Button.new(:label => "Extra button")
17
17
  extra_button.signal_connect("clicked") do
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Copyright (c) 2014 Gian Mario Tagliaretti
4
- # Copyright (c) 2015-2018 Ruby-GNOME2 Project Team
4
+ # Copyright (c) 2015-2020 Ruby-GNOME Project Team
5
5
  #
6
6
  # Permission is granted to copy, distribute and/or modify this document
7
7
  # under the terms of the GNU Free Documentation License, Version 1.3
@@ -44,7 +44,7 @@ class FlowBoxWindow < Gtk::Window
44
44
  set_titlebar(header)
45
45
 
46
46
  scrolled = Gtk::ScrolledWindow.new
47
- scrolled.set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC)
47
+ scrolled.set_policy(:never, :automatic)
48
48
 
49
49
  flowbox = Gtk::FlowBox.new
50
50
  flowbox.valign = :start
@@ -73,7 +73,7 @@ class FlowBoxWindow < Gtk::Window
73
73
  area.signal_connect("draw") do |_, context|
74
74
  context.set_source_rgba(color)
75
75
  context.paint
76
- end
76
+ end
77
77
 
78
78
  button.add(area)
79
79
  end
data/sample/misc/image.rb CHANGED
@@ -2,42 +2,28 @@
2
2
  =begin
3
3
  image.rb - Ruby/GTK sample script.
4
4
 
5
- Copyright (c) 2002-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2002-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
10
10
 
11
11
  window = Gtk::Window.new("Image")
12
- window.signal_connect("destroy") do
13
- Gtk.main_quit
14
- end
15
- window.border_width = 0
16
-
17
- box1 = Gtk::Box.new(:vertical, 10)
18
- box1.border_width = 10
12
+ window.signal_connect("destroy") { Gtk.main_quit }
13
+ window.border_width = 10
19
14
 
20
15
  button = Gtk::Button.new
21
- box1.add(button)
22
16
 
23
- label = Gtk::Label.new("Gtk::Image\ntest")
17
+ label = Gtk::Label.new("Gtk::Image")
24
18
  image = Gtk::Image.new(:file => "test.xpm")
25
19
 
26
- box2 = Gtk::Box.new(:horizontal, 5)
27
- box2.add(image)
28
- box2.add(label)
29
-
30
- button.add(box2)
31
-
32
- box1.add(Gtk::Separator.new(:horizontal))
20
+ box = Gtk::Box.new(:horizontal, 5)
21
+ box.add(image)
22
+ box.add(label)
33
23
 
34
- button = Gtk::Button.new(:label => "close")
35
- button.signal_connect("clicked") do
36
- Gtk.main_quit
37
- end
38
- box1.add(button)
24
+ button.add(box)
39
25
 
40
- window.add(box1)
26
+ window.add(button)
41
27
  window.show_all
42
28
 
43
29
  Gtk.main
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  linkbutton.rb - Gtk::LinkButton sample.
4
4
 
5
- Copyright (c) 2006-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2006-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -22,7 +22,7 @@ vbox.pack_start(button1)
22
22
 
23
23
  # URI with a label
24
24
  button2 = Gtk::LinkButton.new("https://ruby-gnome2.osdn.jp/",
25
- "Ruby-GNOME2 Website")
25
+ "Ruby-GNOME Website")
26
26
  button2.signal_connect("clicked") do
27
27
  puts button2.uri
28
28
  end
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  misc_button.rb - Ruby/GTK sample script.
4
4
 
5
- Copyright (c) 2004-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2004-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -25,8 +25,7 @@ end
25
25
  box.add(fontbutton)
26
26
 
27
27
  # Gtk::FileChooserButton
28
- filebutton = Gtk::FileChooserButton.new("Gtk::FileChooserButton",
29
- Gtk::FileChooserAction::OPEN)
28
+ filebutton = Gtk::FileChooserButton.new("Gtk::FileChooserButton", :open)
30
29
  filebutton.filename = GLib.home_dir
31
30
  filebutton.signal_connect("current-folder-changed") do |w, e|
32
31
  p filebutton.filename
@@ -2,15 +2,15 @@
2
2
  =begin
3
3
  recentchooserdialog.rb - Ruby/GTK sample script.
4
4
 
5
- Copyright (c) 2006-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2006-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
10
10
 
11
11
  dialog = Gtk::RecentChooserDialog.new(:title => "Recent Chooser Dialog Sample",
12
- :buttons => [["_Cancel", Gtk::ResponseType::CANCEL],
13
- ["_Accept", Gtk::ResponseType::ACCEPT]])
12
+ :buttons => [["_Cancel", :cancel],
13
+ ["_Accept", :accept]])
14
14
 
15
15
  dialog.signal_connect("response") do |_widget, response|
16
16
  case response
@@ -40,7 +40,7 @@ dialog.signal_connect("response") do |_widget, response|
40
40
  puts info.exist?
41
41
  end
42
42
  else
43
- p "Close"
43
+ puts "Close"
44
44
  dialog.destroy
45
45
  Gtk.main_quit
46
46
  end
@@ -2,8 +2,8 @@
2
2
  =begin
3
3
  scalebutton.rb - Very simple Gtk::ScaleButton example.
4
4
 
5
- Copyright (c) 2007-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2007-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -12,8 +12,8 @@ window = Gtk::Window.new
12
12
  window.set_size_request(300, 300)
13
13
  scale = Gtk::ScaleButton.new
14
14
  scale.set_value(30)
15
- scale.set_valign(Gtk::Align::END)
16
- scale.set_halign(Gtk::Align::END)
15
+ scale.set_valign(:end)
16
+ scale.set_halign(:end)
17
17
  box = Gtk::Box.new(:vertical)
18
18
  box.add(scale)
19
19
  box.vexpand = true
data/sample/misc/stock.rb CHANGED
@@ -2,8 +2,8 @@
2
2
  stock.rb - Gtk::Stock sample script.
3
3
 
4
4
  Copyright (C) 2001-2006 Masao Mutoh
5
- Copyright (c) 2001-2015 Ruby-GNOME2 Project Team
6
- This program is licenced under the same licence as Ruby-GNOME2.
5
+ Copyright (c) 2001-2020 Ruby-GNOME Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME.
7
7
  =end
8
8
 
9
9
  require "gtk3"
@@ -11,26 +11,22 @@ require "gtk3"
11
11
  window = Gtk::Window.new("Gtk::Stock sample")
12
12
  window.signal_connect("destroy") { Gtk.main_quit }
13
13
 
14
- stocks = Gtk::Stock.constants.sort
14
+ stocks = Gtk::Stock.constants.sort.cycle
15
15
 
16
16
  image = Gtk::Image.new(:stock => Gtk::Stock::OK, :size => :dialog)
17
17
  label = Gtk::Label.new("Gtk::Stock::OK")
18
18
  button = Gtk::Button.new(:label => "Click!")
19
- cnt = 0
19
+
20
20
  button.signal_connect("clicked") do
21
- stock_name = "Gtk::Stock::#{stocks[cnt]}"
21
+ stock = stocks.next
22
+ stock_name = "Gtk::Stock::#{stock}"
22
23
  label.set_text(stock_name)
23
24
  image.set_stock(eval(stock_name))
24
- if cnt < stocks.size - 1
25
- cnt += 1
26
- else
27
- cnt = 0
28
- end
29
25
  end
30
26
 
31
27
  box = Gtk::Box.new(:vertical, 0)
32
- box.add(image)
33
- box.add(label)
28
+ box.add(image, :expand => true)
29
+ box.add(label, :expand => true)
34
30
  box.add(button)
35
31
  window.add(box)
36
32
  window.set_default_size(200, 200)
@@ -391,7 +391,7 @@ Here is the "window.ui" file that contains the template of the window:
391
391
  </template>
392
392
  </interface>
393
393
  ```
394
- Unlike regular interface descriptions, in template XML descriptions, a`<template>` tag is expected as a direct child of the toplevel `<interface>` tag. Yhe `<template>` tag must specify the "*class*" attribute which must be the class name of the widget. Optionally, the "*parent*" attribute may be specified to indicate the direct parent class (superclass).
394
+ Unlike regular interface descriptions, in template XML descriptions, a`<template>` tag is expected as a direct child of the toplevel `<interface>` tag. The `<template>` tag must specify the "*class*" attribute which must be the class name of the widget. Optionally, the "*parent*" attribute may be specified to indicate the direct parent class (superclass).
395
395
 
396
396
  More informations can be found in the part [building composite widgets from template XML](https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget.description) of the `Gtk::Widget` documentation.
397
397
 
@@ -17,6 +17,9 @@
17
17
  require "tempfile"
18
18
  require "fileutils"
19
19
 
20
+ require "gtk3"
21
+ Gtk.init
22
+
20
23
  module GtkTestUtils
21
24
  private
22
25
  def only_gtk_version(major, minor, micro=nil)
@@ -52,6 +55,7 @@ module GtkTestUtils
52
55
  end
53
56
 
54
57
  def fixture_path(*components)
55
- File.join(File.dirname(__FILE__), "fixture", *components)
58
+ File.expand_path(File.join(*components),
59
+ ENV["GTK3_FIXTURE_DIR"] || File.join("test", "fixture"))
56
60
  end
57
61
  end
data/test/run-test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright (C) 2013-2017 Ruby-GNOME2 Project Team
3
+ # Copyright (C) 2013-2021 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
@@ -16,51 +16,20 @@
16
16
  # License along with this library; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
- ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..")
20
- ruby_gnome2_base = File.expand_path(ruby_gnome2_base)
21
-
22
- glib_base = File.join(ruby_gnome2_base, "glib2")
23
- gobject_introspection_base = File.join(ruby_gnome2_base, "gobject-introspection")
24
- atk_base = File.join(ruby_gnome2_base, "atk")
25
- cairo_gobject_base = File.join(ruby_gnome2_base, "cairo-gobject")
26
- pango_base = File.join(ruby_gnome2_base, "pango")
27
- gdk_pixbuf_base = File.join(ruby_gnome2_base, "gdk_pixbuf2")
28
- gio2_base = File.join(ruby_gnome2_base, "gio2")
29
- gdk3_base = File.join(ruby_gnome2_base, "gdk3")
30
- gtk3_base = File.join(ruby_gnome2_base, "gtk3")
31
-
32
- [
33
- [glib_base, "glib2"],
34
- [gobject_introspection_base, "gobject-introspection"],
35
- [atk_base, "atk"],
36
- [cairo_gobject_base, "cairo-gobject"],
37
- [pango_base, "pango"],
38
- [gdk_pixbuf_base, "gdk_pixbuf2"],
39
- [gio2_base, "gio2"],
40
- [gdk3_base, "gdk3"],
41
- [gtk3_base, "gtk3"]
42
- ].each do |target, module_name|
43
- if File.exist?(File.join(target, "Makefile"))
44
- if system("which make > /dev/null")
45
- `make -C #{target.dump} > /dev/null` or exit(false)
46
- end
47
- $LOAD_PATH.unshift(File.join(target, "ext", module_name))
48
- end
49
- $LOAD_PATH.unshift(File.join(target, "lib"))
19
+ require_relative "../../glib2/test/run-test"
20
+
21
+ run_test(__dir__,
22
+ [
23
+ "glib2",
24
+ "gobject-introspection",
25
+ "atk",
26
+ "cairo-gobject",
27
+ "gdk_pixbuf2",
28
+ "gio2",
29
+ "pango",
30
+ "gdk3",
31
+ "gtk3",
32
+ ]) do |context|
33
+ ENV["GTK3_FIXTURE_DIR"] = context[:build_fixture_dir]
34
+ require_relative "gtk-test-utils"
50
35
  end
51
-
52
- Dir.chdir(File.join(gtk3_base, "test", "fixture")) do
53
- system("rake") or exit(false)
54
- end
55
-
56
- $LOAD_PATH.unshift(File.join(glib_base, "test"))
57
- require 'glib-test-init'
58
-
59
- $LOAD_PATH.unshift(File.join(gtk3_base, "test"))
60
- require 'gtk-test-utils'
61
-
62
- require 'gtk3'
63
-
64
- Gtk.init
65
-
66
- exit Test::Unit::AutoRunner.run(true, File.join(gtk3_base, "test"))
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2018 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2019 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
@@ -46,11 +46,9 @@ class TestGtkToggleAction < Test::Unit::TestCase
46
46
 
47
47
  sub_test_case("#active=") do
48
48
  def test_nil
49
- if (GObjectIntrospection::BUILD_VERSION <=> [1, 42, 0]) < 0
50
- omit("require GObjectIntrospection 1.42.0 or later.")
51
- end
52
- assert_raise(ArgumentError) do
53
- @action.active = nil
49
+ @action.active = nil
50
+ assert do
51
+ not @action.active?
54
52
  end
55
53
  end
56
54
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2008-2016 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2008-2020 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
@@ -130,10 +130,56 @@ class TestGtkWidget < Test::Unit::TestCase
130
130
  end
131
131
  end
132
132
 
133
- test "#style_get_property" do
134
- entry = Gtk::Entry.new
135
- assert do
136
- entry.style_get_property("focus-padding").is_a?(Integer)
133
+ sub_test_case "#set_size_request" do
134
+ test("{width:, height:}") do
135
+ entry = Gtk::Entry.new
136
+ entry.set_size_request(width: 50, height: 100)
137
+ assert_equal([50, 100], entry.size_request)
138
+ end
139
+
140
+ test("{width:}") do
141
+ entry = Gtk::Entry.new
142
+ assert_raise(ArgumentError.new(":height is missing")) do
143
+ entry.set_size_request(width: 50)
144
+ end
145
+ end
146
+
147
+ test("{height:}") do
148
+ entry = Gtk::Entry.new
149
+ assert_raise(ArgumentError.new(":width is missing")) do
150
+ entry.set_size_request(height: 100)
151
+ end
152
+ end
153
+
154
+ test("(width, height)") do
155
+ entry = Gtk::Entry.new
156
+ entry.set_size_request(50, 100)
157
+ assert_equal([50, 100], entry.size_request)
158
+ end
159
+
160
+ test("nothing") do
161
+ entry = Gtk::Entry.new
162
+ assert_raise(ArgumentError.new("wrong number of arguments " +
163
+ "(given 0, expected 1..2)")) do
164
+ entry.set_size_request
165
+ end
166
+ end
167
+ end
168
+
169
+ sub_test_case "#style_get_property" do
170
+ test("existent") do
171
+ entry = Gtk::Entry.new
172
+ assert do
173
+ entry.style_get_property("focus-padding").is_a?(Integer)
174
+ end
175
+ end
176
+
177
+ test("nonexistent") do
178
+ entry = Gtk::Entry.new
179
+ name = "nonexistent"
180
+ assert_raise(ArgumentError.new("unknown style: #{name.inspect}")) do
181
+ entry.style_get_property(name)
182
+ end
137
183
  end
138
184
  end
139
185
 
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.3.9
4
+ version: 3.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gio2
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.9
19
+ version: 3.4.4
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.3.9
26
+ version: 3.4.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: atk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.3.9
33
+ version: 3.4.4
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.3.9
40
+ version: 3.4.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pango
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 3.3.9
47
+ version: 3.4.4
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.3.9
54
+ version: 3.4.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gdk_pixbuf2
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 3.3.9
61
+ version: 3.4.4
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.3.9
68
+ version: 3.4.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gdk3
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 3.3.9
75
+ version: 3.4.4
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.3.9
82
+ version: 3.4.4
83
83
  description: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
84
84
  email: ruby-gnome2-devel-en@lists.sourceforge.net
85
85
  executables: []
@@ -147,6 +147,7 @@ files:
147
147
  - lib/gtk3/radio-action.rb
148
148
  - lib/gtk3/radio-button.rb
149
149
  - lib/gtk3/recent-chooser-dialog.rb
150
+ - lib/gtk3/response-type.rb
150
151
  - lib/gtk3/scale-button.rb
151
152
  - lib/gtk3/scrolled-window.rb
152
153
  - lib/gtk3/search-bar.rb
@@ -537,7 +538,6 @@ files:
537
538
  - sample/tutorial/exampleapp9/window.ui
538
539
  - test/fixture/Rakefile
539
540
  - test/fixture/gnome-logo-icon.png
540
- - test/fixture/image.gresource
541
541
  - test/fixture/image.gresource.xml
542
542
  - test/fixture/simple_window.gresource.xml
543
543
  - test/fixture/simple_window.ui
@@ -654,8 +654,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
654
654
  - !ruby/object:Gem::Version
655
655
  version: '0'
656
656
  requirements: []
657
- rubyforge_project:
658
- rubygems_version: 2.7.6.2
657
+ rubygems_version: 3.3.0.dev
659
658
  signing_key:
660
659
  specification_version: 4
661
660
  summary: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
Binary file