@@ -6,8 +6,6 @@ module Collision
6
6
resource: " /dev/geopjr/Collision/ui/application.ui" ,
7
7
children: {
8
8
" welcomeBtn" ,
9
- " mainFileChooserNative" ,
10
- " compareBtnFileChooserNative" ,
11
9
" mainStack" ,
12
10
" fileInfo" ,
13
11
" headerbarStack" ,
@@ -35,8 +33,6 @@ module Collision
35
33
@compareBtnLabel : Gtk ::Label
36
34
@compareBtnStack : Gtk ::Stack
37
35
@openFileBtn : Gtk ::Button
38
- @mainFileChooserNative : Gtk ::FileChooserNative
39
- @compareBtnFileChooserNative : Gtk ::FileChooserNative
40
36
@mainStack : Gtk ::Stack
41
37
@fileInfo : Adw ::StatusPage
42
38
@switcher_bar : Adw ::ViewSwitcherBar
@@ -82,7 +78,23 @@ module Collision
82
78
end
83
79
84
80
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
86
98
end
87
99
88
100
def on_drop (file : Gio ::File )
@@ -227,49 +239,29 @@ module Collision
227
239
@compareBtnStack = Gtk ::Stack .cast(template_child(" compareBtnStack" ))
228
240
@progressbar = Gtk ::ProgressBar .cast(template_child(" progressbar" ))
229
241
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
-
235
242
@verifyTextView .buffer.notify_signal[" text" ].connect do
236
243
Collision ::LOGGER .debug { " Verify tool notify event" }
237
244
238
245
handle_input_change(@verifyTextView .buffer.text)
239
246
end
240
247
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
-
265
248
@welcomeBtn .clicked_signal.connect(- > on_open_btn_clicked)
266
249
@openFileBtn .clicked_signal.connect(- > on_open_btn_clicked)
267
250
268
251
@mainStack .add_controller(Collision ::DragNDrop .new(- > on_drop(Gio ::File )).controller)
269
252
@compareBtn .add_controller(Collision ::DragNDrop .new(- > comparefile= (Gio ::File )).controller)
270
253
271
254
@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
273
265
end
274
266
end
275
267
end
0 commit comments