@@ -6,8 +6,6 @@ module Collision
66 resource: " /dev/geopjr/Collision/ui/application.ui" ,
77 children: {
88 " welcomeBtn" ,
9- " mainFileChooserNative" ,
10- " compareBtnFileChooserNative" ,
119 " mainStack" ,
1210 " fileInfo" ,
1311 " headerbarStack" ,
@@ -35,8 +33,6 @@ module Collision
3533 @compareBtnLabel : Gtk ::Label
3634 @compareBtnStack : Gtk ::Stack
3735 @openFileBtn : Gtk ::Button
38- @mainFileChooserNative : Gtk ::FileChooserNative
39- @compareBtnFileChooserNative : Gtk ::FileChooserNative
4036 @mainStack : Gtk ::Stack
4137 @fileInfo : Adw ::StatusPage
4238 @switcher_bar : Adw ::ViewSwitcherBar
@@ -82,7 +78,23 @@ module Collision
8278 end
8379
8480 def on_open_btn_clicked
85- @mainFileChooserNative .show
81+ Gtk ::FileDialog .new(
82+ title: Gettext .gettext(" Choose a File" ),
83+ modal: true
84+ ).open_multiple(self , nil ) do |obj , result |
85+ next if (files = obj.as(Gtk ::FileDialog ).open_multiple_finish(result)).nil?
86+
87+ gio_files = [] of Gio ::File
88+ files.n_items.times do |i |
89+ gio_files << Gio ::File .cast(files.item(i).not_nil!)
90+ end
91+
92+ loading
93+ self .file = gio_files.shift
94+ open_files(Adw ::Application .cast(self .application.not_nil!), gio_files) unless gio_files.empty? || self .application.nil?
95+ rescue ex
96+ Collision ::LOGGER .debug { ex }
97+ end
8698 end
8799
88100 def on_drop (file : Gio ::File )
@@ -227,49 +239,29 @@ module Collision
227239 @compareBtnStack = Gtk ::Stack .cast(template_child(" compareBtnStack" ))
228240 @progressbar = Gtk ::ProgressBar .cast(template_child(" progressbar" ))
229241
230- @mainFileChooserNative = Gtk ::FileChooserNative .cast(template_child(" mainFileChooserNative" ))
231- @compareBtnFileChooserNative = Gtk ::FileChooserNative .cast(template_child(" compareBtnFileChooserNative" ))
232- @mainFileChooserNative .transient_for = self
233- @compareBtnFileChooserNative .transient_for = self
234-
235242 @verifyTextView .buffer.notify_signal[" text" ].connect do
236243 Collision ::LOGGER .debug { " Verify tool notify event" }
237244
238245 handle_input_change(@verifyTextView .buffer.text)
239246 end
240247
241- @mainFileChooserNative .response_signal.connect do |response |
242- next unless response == -3
243-
244- gio_files = [] of Gio ::File
245- files = @mainFileChooserNative .files
246- files.n_items.times do |i |
247- gio_files << Gio ::File .cast(files.item(i).not_nil!)
248- end
249-
250- loading
251- self .file = gio_files.shift
252- open_files(Adw ::Application .cast(self .application.not_nil!), gio_files) unless gio_files.empty? || self .application.nil?
253- rescue ex
254- Collision ::LOGGER .debug { ex }
255- end
256-
257- @compareBtnFileChooserNative .response_signal.connect do |response |
258- next unless response == -3
259-
260- self .comparefile = @compareBtnFileChooserNative .file.not_nil!
261- rescue ex
262- Collision ::LOGGER .debug { ex }
263- end
264-
265248 @welcomeBtn .clicked_signal.connect(- > on_open_btn_clicked)
266249 @openFileBtn .clicked_signal.connect(- > on_open_btn_clicked)
267250
268251 @mainStack .add_controller(Collision ::DragNDrop .new(- > on_drop(Gio ::File )).controller)
269252 @compareBtn .add_controller(Collision ::DragNDrop .new(- > comparefile= (Gio ::File )).controller)
270253
271254 @compareBtn .clicked_signal.connect do
272- @compareBtnFileChooserNative .show
255+ Gtk ::FileDialog .new(
256+ title: Gettext .gettext(" Choose a File" ),
257+ modal: true
258+ ).open(self , nil ) do |obj , result |
259+ next if (file = obj.as(Gtk ::FileDialog ).open_finish(result)).nil?
260+
261+ self .comparefile = file
262+ rescue ex
263+ Collision ::LOGGER .debug { ex }
264+ end
273265 end
274266 end
275267 end
0 commit comments