diff --git a/meson.build b/meson.build index fbd60c5..cd49eba 100644 --- a/meson.build +++ b/meson.build @@ -12,7 +12,7 @@ vapi_dir = join_paths(meson.current_source_dir(), 'vapi') add_project_arguments(['--vapidir', vapi_dir], language: 'vala') dependencies = [ - dependency('gtk4'), + dependency('gtk4', version: '>=4.10'), dependency('gee-0.8'), dependency('granite-7'), dependency('threads'), diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 53dd395..8252062 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -284,26 +284,31 @@ public class Torrential.MainWindow : Gtk.ApplicationWindow { } private void on_open (SimpleAction action) { - var all_files_filter = new Gtk.FileFilter (); - all_files_filter.set_filter_name (_("All files")); + var all_files_filter = new Gtk.FileFilter () { + name = _("All files") + }; all_files_filter.add_pattern ("*"); - var torrent_files_filter = new Gtk.FileFilter (); - torrent_files_filter.set_filter_name (_("Torrent files")); + var torrent_files_filter = new Gtk.FileFilter () { + name = _("Torrent files") + }; torrent_files_filter.add_mime_type ("application/x-bittorrent"); - var filech = new Gtk.FileChooserNative (_("Open some torrents"), this, Gtk.FileChooserAction.OPEN, _("Open"), _("Cancel")); - filech.set_select_multiple (true); - filech.add_filter (torrent_files_filter); - filech.add_filter (all_files_filter); + var filters = new ListStore (typeof (Gtk.FileFilter)); + filters.append (all_files_filter); + filters.append (torrent_files_filter); - filech.show (); + var file_dialog = new Gtk.FileDialog () { + filters = filters, + title = _("Open some torrents") + }; - filech.response.connect ((response) => { - if (response == Gtk.ResponseType.ACCEPT) { - add_files (filech.get_files ()); - } - }); + try { + var file_listmodel = file_dialog.open_multiple (this, null); + add_files (file_listmodel); + } catch (Error e) { + critical (e.message); + } } private void on_open_magnet () {