Skip to content

Commit 02b24e1

Browse files
committed
book: Use Object::builder() instead of Object::new()
1 parent e47eca4 commit 02b24e1

File tree

49 files changed

+81
-54
lines changed

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

+81
-54
lines changed

book/listings/actions/5/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ glib::wrapper! {
1717
impl Window {
1818
pub fn new(app: &Application) -> Self {
1919
// Create new window
20-
Object::new(&[("application", app)])
20+
Object::builder().property("application", app).build()
2121
}
2222

2323
fn setup_actions(&self) {

book/listings/actions/6/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ glib::wrapper! {
1616
impl Window {
1717
pub fn new(app: &Application) -> Self {
1818
// Create new window
19-
Object::new(&[("application", app)])
19+
Object::builder().property("application", app).build()
2020
}
2121

2222
// ANCHOR: setup_actions

book/listings/actions/7/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ glib::wrapper! {
1818
impl Window {
1919
pub fn new(app: &Application) -> Self {
2020
// Create new window
21-
Object::new(&[("application", app)])
21+
Object::builder().property("application", app).build()
2222
}
2323

2424
// ANCHOR: settings

book/listings/composite_templates/1/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/composite_templates/2/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ glib::wrapper! {
1414

1515
impl CustomButton {
1616
pub fn new() -> Self {
17-
Object::new(&[])
17+
Object::builder().build()
1818
}
1919
}
2020

book/listings/composite_templates/2/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/composite_templates/3/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/composite_templates/3/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/composite_templates/4/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/composite_templates/4/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/composite_templates/5/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/composite_templates/5/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/composite_templates/6/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/composite_templates/6/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/css/6/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/css/7/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/css/8/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/css/9/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ glib::wrapper! {
1313
impl Window {
1414
pub fn new(app: &Application) -> Self {
1515
// Create new window
16-
Object::new(&[("application", app)])
16+
Object::builder().property("application", app).build()
1717
}
1818
}

book/listings/g_object_properties/4/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/g_object_signals/2/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/g_object_subclassing/1/custom_button/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ glib::wrapper! {
1212

1313
impl CustomButton {
1414
pub fn new() -> Self {
15-
Object::new(&[])
15+
Object::builder().build()
1616
}
1717

1818
pub fn with_label(label: &str) -> Self {
19-
Object::new(&[("label", &label)])
19+
Object::builder().property("label", label).build()
2020
}
2121
}
2222
// ANCHOR_END: mod

book/listings/g_object_subclassing/2/custom_button/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111

1212
impl CustomButton {
1313
pub fn new() -> Self {
14-
Object::new(&[])
14+
Object::builder().build()
1515
}
1616
}
1717

book/listings/list_widgets/2/integer_object/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ glib::wrapper! {
1010

1111
impl IntegerObject {
1212
pub fn new(number: i32) -> Self {
13-
Object::new(&[("number", &number)])
13+
Object::builder().property("number", number).build()
1414
}
1515
}
1616
// ANCHOR_END: integer_object

book/listings/list_widgets/3/integer_object/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ glib::wrapper! {
1111
// ANCHOR: integer_object
1212
impl IntegerObject {
1313
pub fn new(number: i32) -> Self {
14-
Object::new(&[("number", &number)])
14+
Object::builder().property("number", number).build()
1515
}
1616

1717
pub fn increase_number(self) {

book/listings/list_widgets/4/integer_object/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ glib::wrapper! {
1010

1111
impl IntegerObject {
1212
pub fn new(number: i32) -> Self {
13-
Object::new(&[("number", &number)])
13+
Object::builder().property("number", number).build()
1414
}
1515

1616
pub fn increase_number(self) {

book/listings/list_widgets/5/integer_object/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ glib::wrapper! {
1010

1111
impl IntegerObject {
1212
pub fn new(number: i32) -> Self {
13-
Object::new(&[("number", &number)])
13+
Object::builder().property("number", number).build()
1414
}
1515

1616
pub fn increase_number(self) {

book/listings/saving_window_state/1/custom_window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ glib::wrapper! {
1919
impl Window {
2020
pub fn new(app: &Application) -> Self {
2121
// Create new window
22-
Object::new(&[("application", app)])
22+
Object::builder().property("application", app).build()
2323
}
2424

2525
fn setup_settings(&self) {

book/listings/todo/1/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ glib::wrapper! {
1010

1111
impl TaskObject {
1212
pub fn new(completed: bool, content: String) -> Self {
13-
Object::new(&[("completed", &completed), ("content", &content)])
13+
Object::builder()
14+
.property("completed", completed)
15+
.property("content", content)
16+
.build()
1417
}
1518
}
1619
// ANCHOR_END: glib_wrapper_and_new

book/listings/todo/1/task_row/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Default for TaskRow {
2424

2525
impl TaskRow {
2626
pub fn new() -> Self {
27-
Object::new(&[])
27+
Object::builder().build()
2828
}
2929

3030
// ANCHOR: bind

book/listings/todo/1/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ glib::wrapper! {
2020
impl Window {
2121
pub fn new(app: &Application) -> Self {
2222
// Create new window
23-
Object::new(&[("application", app)])
23+
Object::builder().property("application", app).build()
2424
}
2525

2626
// ANCHOR: tasks

book/listings/todo/2/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ glib::wrapper! {
1212
// ANCHOR: impl
1313
impl TaskObject {
1414
pub fn new(completed: bool, content: String) -> Self {
15-
Object::new(&[("completed", &completed), ("content", &content)])
15+
Object::builder()
16+
.property("completed", completed)
17+
.property("content", content)
18+
.build()
1619
}
1720

1821
pub fn is_completed(&self) -> bool {

book/listings/todo/2/task_row/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Default for TaskRow {
2222

2323
impl TaskRow {
2424
pub fn new() -> Self {
25-
Object::new(&[])
25+
Object::builder().build()
2626
}
2727

2828
pub fn bind(&self, task_object: &TaskObject) {

book/listings/todo/2/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ glib::wrapper! {
2626
impl Window {
2727
pub fn new(app: &Application) -> Self {
2828
// Create new window
29-
Object::new(&[("application", app)])
29+
Object::builder().property("application", app).build()
3030
}
3131

3232
// ANCHOR: settings

book/listings/todo/3/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ glib::wrapper! {
1111

1212
impl TaskObject {
1313
pub fn new(completed: bool, content: String) -> Self {
14-
Object::new(&[("completed", &completed), ("content", &content)])
14+
Object::builder()
15+
.property("completed", completed)
16+
.property("content", content)
17+
.build()
1518
}
1619

1720
pub fn is_completed(&self) -> bool {

book/listings/todo/3/task_row/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Default for TaskRow {
2222

2323
impl TaskRow {
2424
pub fn new() -> Self {
25-
Object::new(&[])
25+
Object::builder().build()
2626
}
2727

2828
pub fn bind(&self, task_object: &TaskObject) {

book/listings/todo/3/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ glib::wrapper! {
2626
impl Window {
2727
pub fn new(app: &Application) -> Self {
2828
// Create new window
29-
Object::new(&[("application", app)])
29+
Object::builder().property("application", app).build()
3030
}
3131

3232
fn setup_settings(&self) {

book/listings/todo/4/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ glib::wrapper! {
1111

1212
impl TaskObject {
1313
pub fn new(completed: bool, content: String) -> Self {
14-
Object::new(&[("completed", &completed), ("content", &content)])
14+
Object::builder()
15+
.property("completed", completed)
16+
.property("content", content)
17+
.build()
1518
}
1619

1720
pub fn is_completed(&self) -> bool {

book/listings/todo/4/task_row/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Default for TaskRow {
2222

2323
impl TaskRow {
2424
pub fn new() -> Self {
25-
Object::new(&[])
25+
Object::builder().build()
2626
}
2727

2828
pub fn bind(&self, task_object: &TaskObject) {

book/listings/todo/4/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ glib::wrapper! {
2626
impl Window {
2727
pub fn new(app: &Application) -> Self {
2828
// Create new window
29-
Object::new(&[("application", app)])
29+
Object::builder().property("application", app).build()
3030
}
3131

3232
fn setup_settings(&self) {

book/listings/todo/5/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ glib::wrapper! {
1111

1212
impl TaskObject {
1313
pub fn new(completed: bool, content: String) -> Self {
14-
Object::new(&[("completed", &completed), ("content", &content)])
14+
Object::builder()
15+
.property("completed", completed)
16+
.property("content", content)
17+
.build()
1518
}
1619

1720
pub fn is_completed(&self) -> bool {

book/listings/todo/5/task_row/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Default for TaskRow {
2222

2323
impl TaskRow {
2424
pub fn new() -> Self {
25-
Object::new(&[])
25+
Object::builder().build()
2626
}
2727

2828
pub fn bind(&self, task_object: &TaskObject) {

book/listings/todo/5/window/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Window {
2626
// ANCHOR: new
2727
pub fn new(app: &adw::Application) -> Self {
2828
// Create new window
29-
Object::new(&[("application", app)])
29+
Object::builder().property("application", app).build()
3030
}
3131
// ANCHOR_END: new
3232

book/listings/todo/6/task_object/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ glib::wrapper! {
1111

1212
impl TaskObject {
1313
pub fn new(completed: bool, content: String) -> Self {
14-
Object::new(&[("completed", &completed), ("content", &content)])
14+
Object::builder()
15+
.property("completed", completed)
16+
.property("content", content)
17+
.build()
1518
}
1619

1720
pub fn is_completed(&self) -> bool {

0 commit comments

Comments
 (0)