Skip to content

Commit 29e9ee0

Browse files
authored
Merge pull request #931 from sdroege/object-new
glib: Rename `Object::new_default()` to `Object::new()` and remove de…
2 parents 22a91c1 + 608459f commit 29e9ee0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+101
-450
lines changed

examples/gio_task/file_size/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ unsafe impl Sync for FileSize {}
1313

1414
impl FileSize {
1515
pub fn new() -> Self {
16-
glib::Object::new_default()
16+
glib::Object::new()
1717
}
1818

1919
pub fn retrieved_size(&self) -> Option<i64> {

gdk-pixbuf/src/auto/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ 0f6ef0cecfc6)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 047f55810b96)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 040da0b3a013)

gdk-pixbuf/sys/versions.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Generated by gir (https://github.com/gtk-rs/gir @ 0f6ef0cecfc6)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 047f55810b96)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 040da0b3a013)

gio/src/async_initable.rs

Lines changed: 10 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -9,160 +9,38 @@ use crate::{prelude::*, AsyncInitable, Cancellable};
99

1010
impl AsyncInitable {
1111
// rustdoc-stripper-ignore-next
12-
/// Create a new instance of an async initable object with the given properties.
12+
/// Create a new instance of an async initable object with the default property values.
1313
///
1414
/// Similar to [`Object::new`] but can fail because the object initialization in
1515
/// `AsyncInitable::init` failed.
16-
#[allow(clippy::new_ret_no_self)]
1716
#[doc(alias = "g_async_initable_new_async")]
1817
#[track_caller]
19-
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default() instead"]
20-
#[allow(deprecated)]
18+
#[allow(clippy::new_ret_no_self)]
2119
pub fn new<
2220
O: IsClass + IsA<Object> + IsA<AsyncInitable>,
2321
Q: FnOnce(Result<O, glib::Error>) + 'static,
2422
>(
25-
properties: &[(&str, &dyn ToValue)],
2623
io_priority: glib::Priority,
2724
cancellable: Option<&impl IsA<Cancellable>>,
2825
callback: Q,
2926
) {
30-
Self::with_type(
31-
O::static_type(),
32-
properties,
33-
io_priority,
34-
cancellable,
35-
move |res| callback(res.map(|o| unsafe { o.unsafe_cast() })),
36-
)
37-
}
38-
39-
// rustdoc-stripper-ignore-next
40-
/// Create a new instance of an async initable object with the given properties as future.
41-
///
42-
/// Similar to [`Object::new`] but can fail because the object initialization in
43-
/// `AsyncInitable::init` failed.
44-
#[doc(alias = "g_async_initable_new_async")]
45-
#[track_caller]
46-
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead"]
47-
#[allow(deprecated)]
48-
pub fn new_future<O: IsClass + IsA<Object> + IsA<AsyncInitable>>(
49-
properties: &[(&str, &dyn ToValue)],
50-
io_priority: glib::Priority,
51-
) -> Pin<Box_<dyn std::future::Future<Output = Result<O, glib::Error>> + 'static>> {
52-
Box::pin(
53-
Self::with_type_future(O::static_type(), properties, io_priority)
54-
.map_ok(|o| unsafe { o.unsafe_cast() }),
55-
)
56-
}
57-
58-
// rustdoc-stripper-ignore-next
59-
/// Create a new instance of an async initable object of the given type with the given properties.
60-
///
61-
/// Similar to [`Object::with_type`] but can fail because the object initialization in
62-
/// `AsyncInitable::init` failed.
63-
#[doc(alias = "g_async_initable_new_async")]
64-
#[track_caller]
65-
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_with_type() instead"]
66-
pub fn with_type<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
67-
type_: Type,
68-
properties: &[(&str, &dyn ToValue)],
69-
io_priority: glib::Priority,
70-
cancellable: Option<&impl IsA<Cancellable>>,
71-
callback: Q,
72-
) {
73-
if !type_.is_a(AsyncInitable::static_type()) {
74-
panic!("Type '{type_}' is not async initable");
75-
}
76-
77-
let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
78-
for (name, value) in properties {
79-
property_values.push((*name, value.to_value()));
80-
}
81-
82-
unsafe {
83-
let obj = Object::new_internal(type_, &mut property_values);
84-
obj.unsafe_cast_ref::<Self>().init_async(
85-
io_priority,
86-
cancellable,
87-
glib::clone!(@strong obj => move |res| {
88-
callback(res.map(|_| obj));
89-
}),
90-
)
91-
};
92-
}
93-
94-
// rustdoc-stripper-ignore-next
95-
/// Create a new instance of an async initable object of the given type with the given properties as future.
96-
///
97-
/// Similar to [`Object::with_type`] but can fail because the object initialization in
98-
/// `AsyncInitable::init` failed.
99-
#[doc(alias = "g_async_initable_new_async")]
100-
#[track_caller]
101-
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead"]
102-
pub fn with_type_future(
103-
type_: Type,
104-
properties: &[(&str, &dyn ToValue)],
105-
io_priority: glib::Priority,
106-
) -> Pin<Box_<dyn std::future::Future<Output = Result<Object, glib::Error>> + 'static>> {
107-
if !type_.is_a(AsyncInitable::static_type()) {
108-
panic!("Type '{type_}' is not async initable");
109-
}
110-
111-
let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
112-
for (name, value) in properties {
113-
property_values.push((*name, value.to_value()));
114-
}
115-
116-
unsafe {
117-
// FIXME: object construction should ideally happen as part of the future
118-
let obj = Object::new_internal(type_, &mut property_values);
119-
Box_::pin(crate::GioFuture::new(
120-
&obj,
121-
move |obj, cancellable, send| {
122-
obj.unsafe_cast_ref::<Self>().init_async(
123-
io_priority,
124-
Some(cancellable),
125-
glib::clone!(@strong obj => move |res| {
126-
send.resolve(res.map(|_| obj));
127-
}),
128-
);
129-
},
130-
))
131-
}
132-
}
133-
134-
// rustdoc-stripper-ignore-next
135-
/// Create a new instance of an async initable object with the default property values.
136-
///
137-
/// Similar to [`Object::new_default`] but can fail because the object initialization in
138-
/// `AsyncInitable::init` failed.
139-
#[doc(alias = "g_async_initable_new_async")]
140-
#[track_caller]
141-
pub fn new_default<
142-
O: IsClass + IsA<Object> + IsA<AsyncInitable>,
143-
Q: FnOnce(Result<O, glib::Error>) + 'static,
144-
>(
145-
io_priority: glib::Priority,
146-
cancellable: Option<&impl IsA<Cancellable>>,
147-
callback: Q,
148-
) {
149-
Self::new_default_with_type(O::static_type(), io_priority, cancellable, move |res| {
27+
Self::with_type(O::static_type(), io_priority, cancellable, move |res| {
15028
callback(res.map(|o| unsafe { o.unsafe_cast() }))
15129
})
15230
}
15331

15432
// rustdoc-stripper-ignore-next
15533
/// Create a new instance of an async initable object with the default property values as future.
15634
///
157-
/// Similar to [`Object::new_default`] but can fail because the object initialization in
35+
/// Similar to [`Object::new`] but can fail because the object initialization in
15836
/// `AsyncInitable::init` failed.
15937
#[doc(alias = "g_async_initable_new_async")]
16038
#[track_caller]
161-
pub fn new_default_future<O: IsClass + IsA<Object> + IsA<AsyncInitable>>(
39+
pub fn new_future<O: IsClass + IsA<Object> + IsA<AsyncInitable>>(
16240
io_priority: glib::Priority,
16341
) -> Pin<Box_<dyn std::future::Future<Output = Result<O, glib::Error>> + 'static>> {
16442
Box::pin(
165-
Self::new_default_with_type_future(O::static_type(), io_priority)
43+
Self::with_type_future(O::static_type(), io_priority)
16644
.map_ok(|o| unsafe { o.unsafe_cast() }),
16745
)
16846
}
@@ -171,11 +49,11 @@ impl AsyncInitable {
17149
/// Create a new instance of an async initable object of the given type with the default
17250
/// property values.
17351
///
174-
/// Similar to [`Object::new_default_with_type`] but can fail because the object initialization in
52+
/// Similar to [`Object::with_type`] but can fail because the object initialization in
17553
/// `AsyncInitable::init` failed.
17654
#[doc(alias = "g_async_initable_new_async")]
17755
#[track_caller]
178-
pub fn new_default_with_type<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
56+
pub fn with_type<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
17957
type_: Type,
18058
io_priority: glib::Priority,
18159
cancellable: Option<&impl IsA<Cancellable>>,
@@ -200,11 +78,11 @@ impl AsyncInitable {
20078
// rustdoc-stripper-ignore-next
20179
/// Create a new instance of an async initable object of the given type with the default property values as future.
20280
///
203-
/// Similar to [`Object::new_default_with_type`] but can fail because the object initialization in
81+
/// Similar to [`Object::with_type`] but can fail because the object initialization in
20482
/// `AsyncInitable::init` failed.
20583
#[doc(alias = "g_async_initable_new_async")]
20684
#[track_caller]
207-
pub fn new_default_with_type_future(
85+
pub fn with_type_future(
20886
type_: Type,
20987
io_priority: glib::Priority,
21088
) -> Pin<Box_<dyn std::future::Future<Output = Result<Object, glib::Error>> + 'static>> {
@@ -229,82 +107,6 @@ impl AsyncInitable {
229107
}
230108
}
231109

232-
// rustdoc-stripper-ignore-next
233-
/// Create a new instance of an async initable object of the given type with the given properties.
234-
///
235-
/// Similar to [`Object::with_values`] but can fail because the object initialization in
236-
/// `AsyncInitable::init` failed.
237-
#[doc(alias = "g_async_initable_new_async")]
238-
#[track_caller]
239-
#[deprecated = "Use AsyncInitable::with_mut_values() instead"]
240-
pub fn with_values<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
241-
type_: Type,
242-
properties: &[(&str, glib::Value)],
243-
io_priority: glib::Priority,
244-
cancellable: Option<&impl IsA<Cancellable>>,
245-
callback: Q,
246-
) {
247-
if !type_.is_a(AsyncInitable::static_type()) {
248-
panic!("Type '{type_}' is not async initable");
249-
}
250-
251-
let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
252-
for (name, value) in properties {
253-
property_values.push((*name, value.clone()));
254-
}
255-
256-
unsafe {
257-
let obj = Object::new_internal(type_, &mut property_values);
258-
obj.unsafe_cast_ref::<Self>().init_async(
259-
io_priority,
260-
cancellable,
261-
glib::clone!(@strong obj => move |res| {
262-
callback(res.map(|_| obj));
263-
}),
264-
)
265-
};
266-
}
267-
268-
// rustdoc-stripper-ignore-next
269-
/// Create a new instance of an async initable object of the given type with the given properties as a future.
270-
///
271-
/// Similar to [`Object::with_values`] but can fail because the object initialization in
272-
/// `AsyncInitable::init` failed.
273-
#[doc(alias = "g_async_initable_new_async")]
274-
#[track_caller]
275-
#[deprecated = "Use AsyncInitable::with_mut_values_future() instead"]
276-
pub fn with_values_future(
277-
type_: Type,
278-
properties: &[(&str, glib::Value)],
279-
io_priority: glib::Priority,
280-
) -> Pin<Box_<dyn std::future::Future<Output = Result<Object, glib::Error>> + 'static>> {
281-
if !type_.is_a(AsyncInitable::static_type()) {
282-
panic!("Type '{type_}' is not async initable");
283-
}
284-
285-
let mut property_values = smallvec::SmallVec::<[_; 16]>::with_capacity(properties.len());
286-
for (name, value) in properties {
287-
property_values.push((*name, value.clone()));
288-
}
289-
290-
unsafe {
291-
// FIXME: object construction should ideally happen as part of the future
292-
let obj = Object::new_internal(type_, &mut property_values);
293-
Box_::pin(crate::GioFuture::new(
294-
&obj,
295-
move |obj, cancellable, send| {
296-
obj.unsafe_cast_ref::<Self>().init_async(
297-
io_priority,
298-
Some(cancellable),
299-
glib::clone!(@strong obj => move |res| {
300-
send.resolve(res.map(|_| obj));
301-
}),
302-
);
303-
},
304-
))
305-
}
306-
}
307-
308110
// rustdoc-stripper-ignore-next
309111
/// Create a new instance of an async initable object of the given type with the given properties as mutable values.
310112
///

gio/src/auto/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Application {
6262

6363
impl Default for Application {
6464
fn default() -> Self {
65-
glib::object::Object::new_default::<Self>()
65+
glib::object::Object::new::<Self>()
6666
}
6767
}
6868

gio/src/auto/buffered_input_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl BufferedInputStream {
5454

5555
impl Default for BufferedInputStream {
5656
fn default() -> Self {
57-
glib::object::Object::new_default::<Self>()
57+
glib::object::Object::new::<Self>()
5858
}
5959
}
6060

gio/src/auto/buffered_output_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl BufferedOutputStream {
5454

5555
impl Default for BufferedOutputStream {
5656
fn default() -> Self {
57-
glib::object::Object::new_default::<Self>()
57+
glib::object::Object::new::<Self>()
5858
}
5959
}
6060

gio/src/auto/charset_converter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl CharsetConverter {
107107

108108
impl Default for CharsetConverter {
109109
fn default() -> Self {
110-
glib::object::Object::new_default::<Self>()
110+
glib::object::Object::new::<Self>()
111111
}
112112
}
113113

gio/src/auto/converter_input_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ConverterInputStream {
4343

4444
impl Default for ConverterInputStream {
4545
fn default() -> Self {
46-
glib::object::Object::new_default::<Self>()
46+
glib::object::Object::new::<Self>()
4747
}
4848
}
4949

gio/src/auto/converter_output_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl ConverterOutputStream {
4343

4444
impl Default for ConverterOutputStream {
4545
fn default() -> Self {
46-
glib::object::Object::new_default::<Self>()
46+
glib::object::Object::new::<Self>()
4747
}
4848
}
4949

0 commit comments

Comments
 (0)