@@ -3,13 +3,16 @@ import GObject from "gi://GObject";
3
3
import Gdk from "gi://Gdk?version=4.0" ;
4
4
import Gtk from "gi://Gtk?version=4.0" ;
5
5
6
- const list = workbench . builder . get_object ( "list" ) ;
7
- const drop_target = Gtk . DropTarget . new ( Gtk . ListBoxRow , Gdk . DragAction . MOVE ) ;
6
+ const list = workbench . builder . get_object < Gtk . ListBox > ( "list" ) ;
7
+ const drop_target = Gtk . DropTarget . new ( Gtk . ListBoxRow . $gtype , Gdk . DragAction . MOVE ) ;
8
8
9
9
list . add_controller ( drop_target ) ;
10
10
11
11
// Iterate over ListBox children
12
- for ( const row of list ) {
12
+ // @ts -expect-error Gtk.ListBox is iterable
13
+ // See: https://github.com/gjsify/ts-for-gir/issues/193
14
+ for ( const object of list ) {
15
+ const row = object as Adw . ActionRow ;
13
16
let drag_x ;
14
17
let drag_y ;
15
18
@@ -28,7 +31,7 @@ for (const row of list) {
28
31
drag_y = y ;
29
32
30
33
const value = new GObject . Value ( ) ;
31
- value . init ( Gtk . ListBoxRow ) ;
34
+ value . init ( Gtk . ListBoxRow . $gtype ) ;
32
35
value . set_object ( row ) ;
33
36
34
37
return Gdk . ContentProvider . new_for_value ( value ) ;
@@ -68,7 +71,7 @@ for (const row of list) {
68
71
}
69
72
70
73
// Drop Handling
71
- drop_target . connect ( "drop" , ( _drop , value , _x , y ) => {
74
+ drop_target . connect ( "drop" , ( _drop , value : Gtk . Widget , _x , y ) => {
72
75
const target_row = list . get_row_at_y ( y ) ;
73
76
const target_index = target_row . get_index ( ) ;
74
77
0 commit comments