@@ -1097,14 +1097,64 @@ impl ParamSpecString {
10971097 ) )
10981098 }
10991099 }
1100+
1101+ pub fn builder < ' a > ( name : & ' a str ) -> ParamSpecStringBuilder < ' a > {
1102+ ParamSpecStringBuilder :: new ( name)
1103+ }
11001104}
11011105
1102- define_builder ! (
1103- ParamSpecString ,
1104- ParamSpecStringBuilder {
1105- default_value: Option <& ' a str > = None ,
1106+ #[ must_use]
1107+ pub struct ParamSpecStringBuilder < ' a > {
1108+ name : & ' a str ,
1109+ nick : Option < & ' a str > ,
1110+ blurb : Option < & ' a str > ,
1111+ flags : crate :: ParamFlags ,
1112+ default_value : Option < & ' a str > ,
1113+ }
1114+
1115+ impl < ' a > ParamSpecStringBuilder < ' a > {
1116+ fn new ( name : & ' a str ) -> Self {
1117+ Self {
1118+ name,
1119+ nick : None ,
1120+ blurb : None ,
1121+ flags : crate :: ParamFlags :: default ( ) ,
1122+ default_value : None ,
1123+ }
11061124 }
1107- ) ;
1125+
1126+ #[ doc = "Default: None`" ]
1127+ pub fn default_value ( mut self , value : impl Into < Option < & ' a str > > ) -> Self {
1128+ self . default_value = value. into ( ) ;
1129+ self
1130+ }
1131+
1132+ #[ must_use]
1133+ pub fn build ( self ) -> ParamSpec {
1134+ ParamSpecString :: new (
1135+ self . name ,
1136+ self . nick ,
1137+ self . blurb ,
1138+ self . default_value ,
1139+ self . flags ,
1140+ )
1141+ }
1142+ }
1143+
1144+ impl < ' a > crate :: prelude:: ParamSpecBuilderExt < ' a > for ParamSpecStringBuilder < ' a > {
1145+ fn set_nick ( & mut self , nick : Option < & ' a str > ) {
1146+ self . nick = nick;
1147+ }
1148+ fn set_blurb ( & mut self , blurb : Option < & ' a str > ) {
1149+ self . blurb = blurb;
1150+ }
1151+ fn set_flags ( & mut self , flags : crate :: ParamFlags ) {
1152+ self . flags = flags;
1153+ }
1154+ fn current_flags ( & self ) -> crate :: ParamFlags {
1155+ self . flags
1156+ }
1157+ }
11081158
11091159define_param_spec ! ( ParamSpecParam , gobject_ffi:: GParamSpecParam , 15 ) ;
11101160
@@ -1283,14 +1333,64 @@ impl ParamSpecValueArray {
12831333 ( * ptr) . fixed_n_elements
12841334 }
12851335 }
1336+
1337+ pub fn builder ( name : & str ) -> ParamSpecValueArrayBuilder {
1338+ ParamSpecValueArrayBuilder :: new ( name)
1339+ }
12861340}
12871341
1288- define_builder ! (
1289- ParamSpecValueArray ,
1290- ParamSpecValueArrayBuilder {
1291- element_spec: Option <& ' a ParamSpec > = None ,
1342+ #[ must_use]
1343+ pub struct ParamSpecValueArrayBuilder < ' a > {
1344+ name : & ' a str ,
1345+ nick : Option < & ' a str > ,
1346+ blurb : Option < & ' a str > ,
1347+ flags : crate :: ParamFlags ,
1348+ element_spec : Option < & ' a ParamSpec > ,
1349+ }
1350+
1351+ impl < ' a > ParamSpecValueArrayBuilder < ' a > {
1352+ fn new ( name : & ' a str ) -> Self {
1353+ Self {
1354+ name,
1355+ nick : None ,
1356+ blurb : None ,
1357+ flags : crate :: ParamFlags :: default ( ) ,
1358+ element_spec : None ,
1359+ }
1360+ }
1361+
1362+ #[ doc = "Default: None`" ]
1363+ pub fn element_spec ( mut self , value : impl Into < Option < & ' a ParamSpec > > ) -> Self {
1364+ self . element_spec = value. into ( ) ;
1365+ self
12921366 }
1293- ) ;
1367+
1368+ #[ must_use]
1369+ pub fn build ( self ) -> ParamSpec {
1370+ ParamSpecValueArray :: new (
1371+ self . name ,
1372+ self . nick ,
1373+ self . blurb ,
1374+ self . element_spec ,
1375+ self . flags ,
1376+ )
1377+ }
1378+ }
1379+
1380+ impl < ' a > crate :: prelude:: ParamSpecBuilderExt < ' a > for ParamSpecValueArrayBuilder < ' a > {
1381+ fn set_nick ( & mut self , nick : Option < & ' a str > ) {
1382+ self . nick = nick;
1383+ }
1384+ fn set_blurb ( & mut self , blurb : Option < & ' a str > ) {
1385+ self . blurb = blurb;
1386+ }
1387+ fn set_flags ( & mut self , flags : crate :: ParamFlags ) {
1388+ self . flags = flags;
1389+ }
1390+ fn current_flags ( & self ) -> crate :: ParamFlags {
1391+ self . flags
1392+ }
1393+ }
12941394
12951395define_param_spec ! ( ParamSpecObject , gobject_ffi:: GParamSpecObject , 19 ) ;
12961396
@@ -1546,16 +1646,67 @@ impl ParamSpecVariant {
15461646 }
15471647 }
15481648 }
1649+
1650+ pub fn builder < ' a > ( name : & ' a str , type_ : & ' a crate :: VariantTy ) -> ParamSpecVariantBuilder < ' a > {
1651+ ParamSpecVariantBuilder :: new ( name, type_)
1652+ }
15491653}
15501654
1551- define_builder ! (
1552- ParamSpecVariant ,
1553- ParamSpecVariantBuilder {
1554- type_: & ' a crate :: VariantTy ,
1555- default_value: Option <& ' a crate :: Variant > = None ,
1655+ #[ must_use]
1656+ pub struct ParamSpecVariantBuilder < ' a > {
1657+ name : & ' a str ,
1658+ nick : Option < & ' a str > ,
1659+ blurb : Option < & ' a str > ,
1660+ flags : crate :: ParamFlags ,
1661+ type_ : & ' a crate :: VariantTy ,
1662+ default_value : Option < & ' a crate :: Variant > ,
1663+ }
1664+
1665+ impl < ' a > ParamSpecVariantBuilder < ' a > {
1666+ fn new ( name : & ' a str , type_ : & ' a crate :: VariantTy ) -> Self {
1667+ Self {
1668+ name,
1669+ nick : None ,
1670+ blurb : None ,
1671+ flags : crate :: ParamFlags :: default ( ) ,
1672+ type_,
1673+ default_value : None ,
1674+ }
15561675 }
1557- requires ( type_: & ' a crate :: VariantTy , )
1558- ) ;
1676+
1677+ #[ doc = "Default: None`" ]
1678+ pub fn default_value ( mut self , value : impl Into < Option < & ' a crate :: Variant > > ) -> Self {
1679+ self . default_value = value. into ( ) ;
1680+ self
1681+ }
1682+
1683+ #[ must_use]
1684+ pub fn build ( self ) -> ParamSpec {
1685+ ParamSpecVariant :: new (
1686+ self . name ,
1687+ self . nick ,
1688+ self . blurb ,
1689+ self . type_ ,
1690+ self . default_value ,
1691+ self . flags ,
1692+ )
1693+ }
1694+ }
1695+
1696+ impl < ' a > crate :: prelude:: ParamSpecBuilderExt < ' a > for ParamSpecVariantBuilder < ' a > {
1697+ fn set_nick ( & mut self , nick : Option < & ' a str > ) {
1698+ self . nick = nick;
1699+ }
1700+ fn set_blurb ( & mut self , blurb : Option < & ' a str > ) {
1701+ self . blurb = blurb;
1702+ }
1703+ fn set_flags ( & mut self , flags : crate :: ParamFlags ) {
1704+ self . flags = flags;
1705+ }
1706+ fn current_flags ( & self ) -> crate :: ParamFlags {
1707+ self . flags
1708+ }
1709+ }
15591710
15601711#[ cfg( test) ]
15611712mod tests {
0 commit comments