Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Commit f7f09f6

Browse files
committed
Use Object::new() without parameters or the builders
1 parent f2cea73 commit f7f09f6

File tree

7 files changed

+14
-25
lines changed

7 files changed

+14
-25
lines changed

examples/basic_subclass/simple_application/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ glib::wrapper! {
1111
impl SimpleApplication {
1212
#[allow(clippy::new_without_default)]
1313
pub fn new() -> Self {
14-
glib::Object::new(&[
15-
("application-id", &"org.gtk-rs.SimpleApplication"),
16-
("flags", &ApplicationFlags::empty()),
17-
])
14+
glib::Object::builder()
15+
.property("application-id", &"org.gtk-rs.SimpleApplication")
16+
.property("flags", &ApplicationFlags::empty())
17+
.build()
1818
}
1919
}

examples/basic_subclass/simple_window/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ glib::wrapper! {
1111

1212
impl SimpleWindow {
1313
pub fn new(app: &SimpleApplication) -> Self {
14-
glib::Object::new(&[("application", app)])
14+
glib::Object::builder().property("application", app).build()
1515
}
1616
}

examples/composite_template/example_application_window/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl ExampleApplicationWindow {
1313
pub fn new<P: glib::IsA<gtk::Application>>(app: &P) -> Self {
14-
glib::Object::new(&[("application", app)])
14+
glib::Object::builder().property("application", app).build()
1515
}
1616

1717
fn init_label(&self) {

examples/list_box_model/model/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ glib::wrapper! {
1515
impl Model {
1616
#[allow(clippy::new_without_default)]
1717
pub fn new() -> Model {
18-
glib::Object::new(&[])
18+
glib::Object::new()
1919
}
2020

2121
pub fn append(&self, obj: &RowData) {

examples/list_box_model/row_data/imp.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,8 @@ impl ObjectImpl for RowData {
2929
use once_cell::sync::Lazy;
3030
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
3131
vec![
32-
glib::ParamSpecString::new(
33-
"name",
34-
"Name",
35-
"Name",
36-
None, // Default value
37-
glib::ParamFlags::READWRITE,
38-
),
39-
glib::ParamSpecUInt::new(
40-
"count",
41-
"Count",
42-
"Count",
43-
0,
44-
100,
45-
0, // Allowed range and default value
46-
glib::ParamFlags::READWRITE,
47-
),
32+
glib::ParamSpecString::builder("name").build(),
33+
glib::ParamSpecUInt::builder("count").maximum(100).build(),
4834
]
4935
});
5036

examples/list_box_model/row_data/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ glib::wrapper! {
1818
// initial values for our two properties and then returns the new instance
1919
impl RowData {
2020
pub fn new(name: &str, count: u32) -> RowData {
21-
glib::Object::new(&[("name", &name), ("count", &count)])
21+
glib::Object::builder()
22+
.property("name", &name)
23+
.property("count", &count)
24+
.build()
2225
}
2326
}

gtk3-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use syn::{parse_macro_input, DeriveInput};
7575
///
7676
/// impl MyWidget {
7777
/// pub fn new() -> Self {
78-
/// glib::Object::new(&[])
78+
/// glib::Object::new()
7979
/// }
8080
/// }
8181
/// # fn main() {}

0 commit comments

Comments
 (0)