Skip to content

Commit 65a06b0

Browse files
authored
Merge pull request #914 from sdroege/regen
Regenerate with latest gir and mark suboptimal `Object` constructors as deprecated
2 parents bb0879e + 44f6737 commit 65a06b0

36 files changed

+361
-405
lines changed

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 @ d7bdac6deb40)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 2d5d67805483)
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 @ d7bdac6deb40)
1+
Generated by gir (https://github.com/gtk-rs/gir @ 2d5d67805483)
22
from gir-files (https://github.com/gtk-rs/gir-files @ 040da0b3a013)

gio/src/async_initable.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ impl AsyncInitable {
1616
#[allow(clippy::new_ret_no_self)]
1717
#[doc(alias = "g_async_initable_new_async")]
1818
#[track_caller]
19+
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default() instead"]
20+
#[allow(deprecated)]
1921
pub fn new<
2022
O: IsClass + IsA<Object> + IsA<AsyncInitable>,
2123
Q: FnOnce(Result<O, glib::Error>) + 'static,
@@ -41,6 +43,8 @@ impl AsyncInitable {
4143
/// `AsyncInitable::init` failed.
4244
#[doc(alias = "g_async_initable_new_async")]
4345
#[track_caller]
46+
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead"]
47+
#[allow(deprecated)]
4448
pub fn new_future<O: IsClass + IsA<Object> + IsA<AsyncInitable>>(
4549
properties: &[(&str, &dyn ToValue)],
4650
io_priority: glib::Priority,
@@ -58,6 +62,7 @@ impl AsyncInitable {
5862
/// `AsyncInitable::init` failed.
5963
#[doc(alias = "g_async_initable_new_async")]
6064
#[track_caller]
65+
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_with_type() instead"]
6166
pub fn with_type<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
6267
type_: Type,
6368
properties: &[(&str, &dyn ToValue)],
@@ -93,6 +98,7 @@ impl AsyncInitable {
9398
/// `AsyncInitable::init` failed.
9499
#[doc(alias = "g_async_initable_new_async")]
95100
#[track_caller]
101+
#[deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead"]
96102
pub fn with_type_future(
97103
type_: Type,
98104
properties: &[(&str, &dyn ToValue)],
@@ -230,6 +236,7 @@ impl AsyncInitable {
230236
/// `AsyncInitable::init` failed.
231237
#[doc(alias = "g_async_initable_new_async")]
232238
#[track_caller]
239+
#[deprecated = "Use AsyncInitable::with_mut_values() instead"]
233240
pub fn with_values<Q: FnOnce(Result<Object, glib::Error>) + 'static>(
234241
type_: Type,
235242
properties: &[(&str, glib::Value)],
@@ -265,6 +272,7 @@ impl AsyncInitable {
265272
/// `AsyncInitable::init` failed.
266273
#[doc(alias = "g_async_initable_new_async")]
267274
#[track_caller]
275+
#[deprecated = "Use AsyncInitable::with_mut_values_future() instead"]
268276
pub fn with_values_future(
269277
type_: Type,
270278
properties: &[(&str, glib::Value)],

gio/src/auto/application.rs

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Application {
4040
///
4141
/// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects.
4242
pub fn builder() -> ApplicationBuilder {
43-
ApplicationBuilder::default()
43+
ApplicationBuilder::new()
4444
}
4545

4646
#[doc(alias = "g_application_get_default")]
@@ -62,77 +62,69 @@ impl Application {
6262

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

69-
#[derive(Clone, Default)]
7069
// rustdoc-stripper-ignore-next
7170
/// A [builder-pattern] type to construct [`Application`] objects.
7271
///
7372
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
7473
#[must_use = "The builder must be built to be used"]
7574
pub struct ApplicationBuilder {
76-
action_group: Option<ActionGroup>,
77-
application_id: Option<String>,
78-
flags: Option<ApplicationFlags>,
79-
inactivity_timeout: Option<u32>,
80-
resource_base_path: Option<String>,
75+
builder: glib::object::ObjectBuilder<'static, Application>,
8176
}
8277

8378
impl ApplicationBuilder {
84-
// rustdoc-stripper-ignore-next
85-
/// Create a new [`ApplicationBuilder`].
86-
pub fn new() -> Self {
87-
Self::default()
79+
fn new() -> Self {
80+
Self {
81+
builder: glib::object::Object::builder(),
82+
}
8883
}
8984

90-
// rustdoc-stripper-ignore-next
91-
/// Build the [`Application`].
92-
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
93-
pub fn build(self) -> Application {
94-
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
95-
if let Some(ref action_group) = self.action_group {
96-
properties.push(("action-group", action_group));
97-
}
98-
if let Some(ref application_id) = self.application_id {
99-
properties.push(("application-id", application_id));
100-
}
101-
if let Some(ref flags) = self.flags {
102-
properties.push(("flags", flags));
103-
}
104-
if let Some(ref inactivity_timeout) = self.inactivity_timeout {
105-
properties.push(("inactivity-timeout", inactivity_timeout));
85+
pub fn action_group(self, action_group: &impl IsA<ActionGroup>) -> Self {
86+
Self {
87+
builder: self
88+
.builder
89+
.property("action-group", action_group.clone().upcast()),
10690
}
107-
if let Some(ref resource_base_path) = self.resource_base_path {
108-
properties.push(("resource-base-path", resource_base_path));
109-
}
110-
glib::Object::new::<Application>(&properties)
11191
}
11292

113-
pub fn action_group(mut self, action_group: &impl IsA<ActionGroup>) -> Self {
114-
self.action_group = Some(action_group.clone().upcast());
115-
self
93+
pub fn application_id(self, application_id: impl Into<glib::GString>) -> Self {
94+
Self {
95+
builder: self
96+
.builder
97+
.property("application-id", application_id.into()),
98+
}
11699
}
117100

118-
pub fn application_id(mut self, application_id: &str) -> Self {
119-
self.application_id = Some(application_id.to_string());
120-
self
101+
pub fn flags(self, flags: ApplicationFlags) -> Self {
102+
Self {
103+
builder: self.builder.property("flags", flags),
104+
}
121105
}
122106

123-
pub fn flags(mut self, flags: ApplicationFlags) -> Self {
124-
self.flags = Some(flags);
125-
self
107+
pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self {
108+
Self {
109+
builder: self
110+
.builder
111+
.property("inactivity-timeout", inactivity_timeout),
112+
}
126113
}
127114

128-
pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self {
129-
self.inactivity_timeout = Some(inactivity_timeout);
130-
self
115+
pub fn resource_base_path(self, resource_base_path: impl Into<glib::GString>) -> Self {
116+
Self {
117+
builder: self
118+
.builder
119+
.property("resource-base-path", resource_base_path.into()),
120+
}
131121
}
132122

133-
pub fn resource_base_path(mut self, resource_base_path: &str) -> Self {
134-
self.resource_base_path = Some(resource_base_path.to_string());
135-
self
123+
// rustdoc-stripper-ignore-next
124+
/// Build the [`Application`].
125+
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
126+
pub fn build(self) -> Application {
127+
self.builder.build()
136128
}
137129
}
138130

gio/src/auto/buffered_input_stream.rs

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,65 +48,59 @@ impl BufferedInputStream {
4848
///
4949
/// This method returns an instance of [`BufferedInputStreamBuilder`](crate::builders::BufferedInputStreamBuilder) which can be used to create [`BufferedInputStream`] objects.
5050
pub fn builder() -> BufferedInputStreamBuilder {
51-
BufferedInputStreamBuilder::default()
51+
BufferedInputStreamBuilder::new()
5252
}
5353
}
5454

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

61-
#[derive(Clone, Default)]
6261
// rustdoc-stripper-ignore-next
6362
/// A [builder-pattern] type to construct [`BufferedInputStream`] objects.
6463
///
6564
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
6665
#[must_use = "The builder must be built to be used"]
6766
pub struct BufferedInputStreamBuilder {
68-
buffer_size: Option<u32>,
69-
base_stream: Option<InputStream>,
70-
close_base_stream: Option<bool>,
67+
builder: glib::object::ObjectBuilder<'static, BufferedInputStream>,
7168
}
7269

7370
impl BufferedInputStreamBuilder {
74-
// rustdoc-stripper-ignore-next
75-
/// Create a new [`BufferedInputStreamBuilder`].
76-
pub fn new() -> Self {
77-
Self::default()
71+
fn new() -> Self {
72+
Self {
73+
builder: glib::object::Object::builder(),
74+
}
7875
}
7976

80-
// rustdoc-stripper-ignore-next
81-
/// Build the [`BufferedInputStream`].
82-
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
83-
pub fn build(self) -> BufferedInputStream {
84-
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
85-
if let Some(ref buffer_size) = self.buffer_size {
86-
properties.push(("buffer-size", buffer_size));
87-
}
88-
if let Some(ref base_stream) = self.base_stream {
89-
properties.push(("base-stream", base_stream));
77+
pub fn buffer_size(self, buffer_size: u32) -> Self {
78+
Self {
79+
builder: self.builder.property("buffer-size", buffer_size),
9080
}
91-
if let Some(ref close_base_stream) = self.close_base_stream {
92-
properties.push(("close-base-stream", close_base_stream));
93-
}
94-
glib::Object::new::<BufferedInputStream>(&properties)
9581
}
9682

97-
pub fn buffer_size(mut self, buffer_size: u32) -> Self {
98-
self.buffer_size = Some(buffer_size);
99-
self
83+
pub fn base_stream(self, base_stream: &impl IsA<InputStream>) -> Self {
84+
Self {
85+
builder: self
86+
.builder
87+
.property("base-stream", base_stream.clone().upcast()),
88+
}
10089
}
10190

102-
pub fn base_stream(mut self, base_stream: &impl IsA<InputStream>) -> Self {
103-
self.base_stream = Some(base_stream.clone().upcast());
104-
self
91+
pub fn close_base_stream(self, close_base_stream: bool) -> Self {
92+
Self {
93+
builder: self
94+
.builder
95+
.property("close-base-stream", close_base_stream),
96+
}
10597
}
10698

107-
pub fn close_base_stream(mut self, close_base_stream: bool) -> Self {
108-
self.close_base_stream = Some(close_base_stream);
109-
self
99+
// rustdoc-stripper-ignore-next
100+
/// Build the [`BufferedInputStream`].
101+
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
102+
pub fn build(self) -> BufferedInputStream {
103+
self.builder.build()
110104
}
111105
}
112106

gio/src/auto/buffered_output_stream.rs

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,74 +48,65 @@ impl BufferedOutputStream {
4848
///
4949
/// This method returns an instance of [`BufferedOutputStreamBuilder`](crate::builders::BufferedOutputStreamBuilder) which can be used to create [`BufferedOutputStream`] objects.
5050
pub fn builder() -> BufferedOutputStreamBuilder {
51-
BufferedOutputStreamBuilder::default()
51+
BufferedOutputStreamBuilder::new()
5252
}
5353
}
5454

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

61-
#[derive(Clone, Default)]
6261
// rustdoc-stripper-ignore-next
6362
/// A [builder-pattern] type to construct [`BufferedOutputStream`] objects.
6463
///
6564
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
6665
#[must_use = "The builder must be built to be used"]
6766
pub struct BufferedOutputStreamBuilder {
68-
auto_grow: Option<bool>,
69-
buffer_size: Option<u32>,
70-
base_stream: Option<OutputStream>,
71-
close_base_stream: Option<bool>,
67+
builder: glib::object::ObjectBuilder<'static, BufferedOutputStream>,
7268
}
7369

7470
impl BufferedOutputStreamBuilder {
75-
// rustdoc-stripper-ignore-next
76-
/// Create a new [`BufferedOutputStreamBuilder`].
77-
pub fn new() -> Self {
78-
Self::default()
71+
fn new() -> Self {
72+
Self {
73+
builder: glib::object::Object::builder(),
74+
}
7975
}
8076

81-
// rustdoc-stripper-ignore-next
82-
/// Build the [`BufferedOutputStream`].
83-
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
84-
pub fn build(self) -> BufferedOutputStream {
85-
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
86-
if let Some(ref auto_grow) = self.auto_grow {
87-
properties.push(("auto-grow", auto_grow));
88-
}
89-
if let Some(ref buffer_size) = self.buffer_size {
90-
properties.push(("buffer-size", buffer_size));
91-
}
92-
if let Some(ref base_stream) = self.base_stream {
93-
properties.push(("base-stream", base_stream));
77+
pub fn auto_grow(self, auto_grow: bool) -> Self {
78+
Self {
79+
builder: self.builder.property("auto-grow", auto_grow),
9480
}
95-
if let Some(ref close_base_stream) = self.close_base_stream {
96-
properties.push(("close-base-stream", close_base_stream));
97-
}
98-
glib::Object::new::<BufferedOutputStream>(&properties)
9981
}
10082

101-
pub fn auto_grow(mut self, auto_grow: bool) -> Self {
102-
self.auto_grow = Some(auto_grow);
103-
self
83+
pub fn buffer_size(self, buffer_size: u32) -> Self {
84+
Self {
85+
builder: self.builder.property("buffer-size", buffer_size),
86+
}
10487
}
10588

106-
pub fn buffer_size(mut self, buffer_size: u32) -> Self {
107-
self.buffer_size = Some(buffer_size);
108-
self
89+
pub fn base_stream(self, base_stream: &impl IsA<OutputStream>) -> Self {
90+
Self {
91+
builder: self
92+
.builder
93+
.property("base-stream", base_stream.clone().upcast()),
94+
}
10995
}
11096

111-
pub fn base_stream(mut self, base_stream: &impl IsA<OutputStream>) -> Self {
112-
self.base_stream = Some(base_stream.clone().upcast());
113-
self
97+
pub fn close_base_stream(self, close_base_stream: bool) -> Self {
98+
Self {
99+
builder: self
100+
.builder
101+
.property("close-base-stream", close_base_stream),
102+
}
114103
}
115104

116-
pub fn close_base_stream(mut self, close_base_stream: bool) -> Self {
117-
self.close_base_stream = Some(close_base_stream);
118-
self
105+
// rustdoc-stripper-ignore-next
106+
/// Build the [`BufferedOutputStream`].
107+
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
108+
pub fn build(self) -> BufferedOutputStream {
109+
self.builder.build()
119110
}
120111
}
121112

0 commit comments

Comments
 (0)