From 4afcc97a088821ba763f95ba9d4c61819eeca920 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 11 Jul 2024 15:43:18 -0300 Subject: [PATCH 1/3] Bump GI-Crystal version. --- shard.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shard.yml b/shard.yml index 81141e395..7fce1d47f 100644 --- a/shard.yml +++ b/shard.yml @@ -7,11 +7,11 @@ authors: dependencies: gi-crystal: github: hugopl/gi-crystal - version: ">= 0.22.2" + version: ">= 0.23.0" pango: github: hugopl/pango.cr version: ">= 0.2.0" -crystal: ">= 1.4.1" +crystal: ">= 1.6.0" license: MIT From 6bbbd4c7aaad3f317b8e029e810d6d4adb335cc6 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 11 Jul 2024 15:40:38 -0300 Subject: [PATCH 2/3] Remove some deprecated classes in examples. --- examples/alert_dialog.cr | 18 +++++++++++++++ examples/file_chooser_dialog.cr | 20 ----------------- examples/file_dialog.cr | 19 ++++++++++++++++ examples/message_dialog.cr | 39 --------------------------------- 4 files changed, 37 insertions(+), 59 deletions(-) create mode 100644 examples/alert_dialog.cr delete mode 100644 examples/file_chooser_dialog.cr create mode 100644 examples/file_dialog.cr delete mode 100644 examples/message_dialog.cr diff --git a/examples/alert_dialog.cr b/examples/alert_dialog.cr new file mode 100644 index 000000000..0b9031f92 --- /dev/null +++ b/examples/alert_dialog.cr @@ -0,0 +1,18 @@ +require "../src/gtk4" + +def activate(app : Gtk::Application) + options = {"Yes", "Maybe"} + alert_dialog = Gtk::AlertDialog.new(message: "Message", buttons: options) + alert_dialog.choose(nil, nil) do |obj, result| + idx = alert_dialog.choose_finish(result) + puts "You choose: #{options[idx]}" + ensure + app.quit + end + app.hold +end + +app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None) +app.activate_signal.connect(->activate(Gtk::Application)) +exit(app.run) + diff --git a/examples/file_chooser_dialog.cr b/examples/file_chooser_dialog.cr deleted file mode 100644 index e87a15bd1..000000000 --- a/examples/file_chooser_dialog.cr +++ /dev/null @@ -1,20 +0,0 @@ -require "../src/gtk4" - -def activate(app : Gtk::Application) - dialog = Gtk::FileChooserDialog.new(application: app, title: "Choose a file", action: :open) - dialog.add_button("Cancel", Gtk::ResponseType::Cancel.value) - dialog.add_button("Open", Gtk::ResponseType::Accept.value) - - dialog.response_signal.connect do |response| - case Gtk::ResponseType.from_value(response) - when .cancel? then puts "Cancelled." - when .accept? then puts "You choose: #{dialog.file.try(&.path)}" - end - dialog.destroy - end - dialog.present -end - -app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None) -app.activate_signal.connect(->activate(Gtk::Application)) -exit(app.run) diff --git a/examples/file_dialog.cr b/examples/file_dialog.cr new file mode 100644 index 000000000..aaad5a9bf --- /dev/null +++ b/examples/file_dialog.cr @@ -0,0 +1,19 @@ +require "../src/gtk4" + +def activate(app : Gtk::Application) + dialog = Gtk::FileDialog.new + dialog.open(nil, nil) do |obj, result| + file = dialog.open_finish(result) + puts "You choose: #{file.path}" if file + rescue e + STDERR.puts("#{e.class.name} raised: #{e.message}") + ensure + app.quit + end + app.hold # Since there's no windows open, we must tell the application to not quit +end + +app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None) +app.activate_signal.connect(->activate(Gtk::Application)) +exit(app.run) + diff --git a/examples/message_dialog.cr b/examples/message_dialog.cr deleted file mode 100644 index f0ee8ccea..000000000 --- a/examples/message_dialog.cr +++ /dev/null @@ -1,39 +0,0 @@ -require "../src/gtk4" - -def activate(app : Gtk::Application) - window = Gtk::ApplicationWindow.new(app) - window.set_default_size(200, 200) - window.title = "Message Box" - label = Gtk::Label.new - window.child = label - - Gtk::MessageDialog.yes_no(transient_for: window, message_type: :info, title: "Title", text: "😎️") do |response| - response = Gtk::ResponseType.from_value(response) - label.text = response.inspect - next if response.no? - - Gtk::MessageDialog.ok_cancel(transient_for: window, message_type: :info, title: "Title", text: "😁️") do |response| - response = Gtk::ResponseType.from_value(response) - label.text = response.inspect - next if response.cancel? - - Gtk::MessageDialog.ok(transient_for: window, message_type: :info, title: "Title", text: "🤓️") do |response| - label.text = Gtk::ResponseType.from_value(response).inspect - - Gtk::MessageDialog.close(transient_for: window, message_type: :info, title: "Title", text: "😵‍💫️") do |response| - label.text = Gtk::ResponseType.from_value(response).inspect - - Gtk::MessageDialog.cancel(transient_for: window, message_type: :info, title: "Title", text: "😅️") do |response| - label.text = Gtk::ResponseType.from_value(response).inspect - end - end - end - end - end - - window.present -end - -app = Gtk::Application.new("hello.example.com", Gio::ApplicationFlags::None) -app.activate_signal.connect(->activate(Gtk::Application)) -exit(app.run) From 9e288b7c38c605b1380b1b73b5c054ec4edaad93 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 11 Jul 2024 15:49:21 -0300 Subject: [PATCH 3/3] Release v0.17.0. --- CHANGELOG.md | 8 ++++++++ shard.yml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac7d7f8bb..6c90e01c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.17.0] - 2024-07-11 +### Added +- Functions receiving `Gio::AsyncResultCallback` not works, unless the `_finish` functions isn't too complex, see `examples/file_dialog.cr`. + +### Changed +- Using GI-Crystal v0.23.x, See [GI-Crystal changelog](https://github.com/hugopl/gi-crystal/blob/master/CHANGELOG.md) for more info. +- Minimal crystal compiler version bumper to 1.6.0. + ## [0.16.1] - 2024-03-24 ### Fixed - Workaround to fix compilation with GTK 4.14. This remove Gtk::PathPoint#get_curvature diff --git a/shard.yml b/shard.yml index 7fce1d47f..8b5d91aff 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: gtk4 -version: 0.16.1 +version: 0.17.0 authors: - Hugo Parente Lima