@@ -7,6 +7,16 @@ use glib::{prelude::*, translate::*, Object};
77use crate :: { prelude:: * , ListModel , ListStore } ;
88
99impl ListStore {
10+ #[ doc( alias = "g_list_store_new" ) ]
11+ pub fn new < T : StaticType > ( ) -> Self {
12+ Self :: with_type ( T :: static_type ( ) )
13+ }
14+
15+ #[ doc( alias = "g_list_store_new" ) ]
16+ pub fn with_type ( type_ : glib:: types:: Type ) -> Self {
17+ unsafe { from_glib_full ( ffi:: g_list_store_new ( type_. into_glib ( ) ) ) }
18+ }
19+
1020 #[ doc( alias = "g_list_store_insert_sorted" ) ]
1121 pub fn insert_sorted < P : IsA < glib:: Object > , F : FnMut ( & Object , & Object ) -> Ordering > (
1222 & self ,
@@ -119,7 +129,7 @@ impl ListStore {
119129
120130impl < P : IsA < glib:: Object > > std:: iter:: FromIterator < P > for ListStore {
121131 fn from_iter < I : IntoIterator < Item = P > > ( iter : I ) -> Self {
122- let store = Self :: new ( P :: static_type ( ) ) ;
132+ let store = Self :: new :: < P > ( ) ;
123133 for item in iter. into_iter ( ) {
124134 store. append ( & item)
125135 }
@@ -165,35 +175,35 @@ mod tests {
165175
166176 #[ test]
167177 fn splice ( ) {
168- let item0 = ListStore :: new ( ListStore :: static_type ( ) ) ;
169- let item1 = ListStore :: new ( ListStore :: static_type ( ) ) ;
170- let list = ListStore :: new ( ListStore :: static_type ( ) ) ;
178+ let item0 = ListStore :: new :: < ListStore > ( ) ;
179+ let item1 = ListStore :: new :: < ListStore > ( ) ;
180+ let list = ListStore :: new :: < ListStore > ( ) ;
171181 list. splice ( 0 , 0 , & [ item0. clone ( ) , item1. clone ( ) ] ) ;
172182 assert_eq ! ( list. item( 0 ) , Some ( item0. upcast( ) ) ) ;
173183 assert_eq ! ( list. item( 1 ) , Some ( item1. upcast( ) ) ) ;
174184 }
175185
176186 #[ test]
177187 fn extend ( ) {
178- let item0 = ListStore :: new ( ListStore :: static_type ( ) ) ;
179- let item1 = ListStore :: new ( ListStore :: static_type ( ) ) ;
180- let mut list = ListStore :: new ( ListStore :: static_type ( ) ) ;
188+ let item0 = ListStore :: new :: < ListStore > ( ) ;
189+ let item1 = ListStore :: new :: < ListStore > ( ) ;
190+ let mut list = ListStore :: new :: < ListStore > ( ) ;
181191 list. extend ( [ & item0, & item1] ) ;
182192 assert_eq ! ( list. item( 0 ) . as_ref( ) , Some ( item0. upcast_ref( ) ) ) ;
183193 assert_eq ! ( list. item( 1 ) . as_ref( ) , Some ( item1. upcast_ref( ) ) ) ;
184194 list. extend ( [ item0. clone ( ) , item1. clone ( ) ] ) ;
185195 assert_eq ! ( list. item( 2 ) . as_ref( ) , Some ( item0. upcast_ref( ) ) ) ;
186196 assert_eq ! ( list. item( 3 ) . as_ref( ) , Some ( item1. upcast_ref( ) ) ) ;
187197
188- let list_from_slice = ListStore :: new ( ListStore :: static_type ( ) ) ;
198+ let list_from_slice = ListStore :: new :: < ListStore > ( ) ;
189199 list_from_slice. extend_from_slice ( & [ item0, item1. clone ( ) ] ) ;
190200 assert_eq ! ( list_from_slice. item( 1 ) . as_ref( ) , Some ( item1. upcast_ref( ) ) ) ;
191201 }
192202
193203 #[ test]
194204 fn from_iterator ( ) {
195- let item0 = ListStore :: new ( ListStore :: static_type ( ) ) ;
196- let item1 = ListStore :: new ( ListStore :: static_type ( ) ) ;
205+ let item0 = ListStore :: new :: < ListStore > ( ) ;
206+ let item1 = ListStore :: new :: < ListStore > ( ) ;
197207 let v = vec ! [ item0. clone( ) , item1. clone( ) ] ;
198208 let list = ListStore :: from_iter ( v) ;
199209 assert_eq ! ( list. item( 0 ) . as_ref( ) , Some ( item0. upcast_ref( ) ) ) ;
@@ -204,9 +214,9 @@ mod tests {
204214 #[ cfg( feature = "v2_74" ) ]
205215 #[ test]
206216 fn find ( ) {
207- let item0 = ListStore :: new ( ListStore :: static_type ( ) ) ;
208- let item1 = ListStore :: new ( ListStore :: static_type ( ) ) ;
209- let list = ListStore :: new ( ListStore :: static_type ( ) ) ;
217+ let item0 = ListStore :: new :: < ListStore > ( ) ;
218+ let item1 = ListStore :: new :: < ListStore > ( ) ;
219+ let list = ListStore :: new :: < ListStore > ( ) ;
210220 list. append ( & item0) ;
211221 list. append ( & item1) ;
212222
0 commit comments