Skip to content

Commit 424c2dc

Browse files
committed
Add derived_properties macro
1 parent 09167fe commit 424c2dc

File tree

15 files changed

+28
-193
lines changed

15 files changed

+28
-193
lines changed

book/listings/g_object_properties/3/custom_button/imp.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,8 @@ impl ObjectSubclass for CustomButton {
2525

2626
// ANCHOR: object_impl
2727
// Trait shared by all GObjects
28+
#[glib::derived_properties]
2829
impl ObjectImpl for CustomButton {
29-
fn properties() -> &'static [ParamSpec] {
30-
Self::derived_properties()
31-
}
32-
33-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
34-
self.derived_set_property(id, value, pspec)
35-
}
36-
37-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
38-
self.derived_property(id, pspec)
39-
}
40-
4130
fn constructed(&self) {
4231
self.parent_constructed();
4332

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl ObjectSubclass for CustomButton {
2525

2626
// ANCHOR: object_impl
2727
// Trait shared by all GObjects
28+
#[glib::derived_properties]
2829
impl ObjectImpl for CustomButton {
2930
fn signals() -> &'static [Signal] {
3031
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
@@ -36,18 +37,6 @@ impl ObjectImpl for CustomButton {
3637
}
3738
// ANCHOR_END: object_impl
3839

39-
fn properties() -> &'static [ParamSpec] {
40-
Self::derived_properties()
41-
}
42-
43-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
44-
self.derived_set_property(id, value, pspec)
45-
}
46-
47-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
48-
self.derived_property(id, pspec)
49-
}
50-
5140
fn constructed(&self) {
5241
self.parent_constructed();
5342

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ impl ObjectSubclass for IntegerObject {
2424

2525
// ANCHOR: object_impl
2626
// Trait shared by all GObjects
27-
impl ObjectImpl for IntegerObject {
28-
fn properties() -> &'static [ParamSpec] {
29-
Self::derived_properties()
30-
}
31-
32-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
33-
self.derived_set_property(id, value, pspec)
34-
}
35-
36-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
37-
self.derived_property(id, pspec)
38-
}
39-
}
27+
#[glib::derived_properties]
28+
impl ObjectImpl for IntegerObject {}
4029
// ANCHOR_END: object_impl

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ impl ObjectSubclass for IntegerObject {
2222

2323
// ANCHOR: object_impl
2424
// Trait shared by all GObjects
25-
impl ObjectImpl for IntegerObject {
26-
fn properties() -> &'static [ParamSpec] {
27-
Self::derived_properties()
28-
}
29-
30-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
31-
self.derived_set_property(id, value, pspec)
32-
}
33-
34-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
35-
self.derived_property(id, pspec)
36-
}
37-
}
25+
#[glib::derived_properties]
26+
impl ObjectImpl for IntegerObject {}
3827
// ANCHOR_END: object_impl

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ impl ObjectSubclass for IntegerObject {
2222

2323
// ANCHOR: object_impl
2424
// Trait shared by all GObjects
25-
impl ObjectImpl for IntegerObject {
26-
fn properties() -> &'static [ParamSpec] {
27-
Self::derived_properties()
28-
}
29-
30-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
31-
self.derived_set_property(id, value, pspec)
32-
}
33-
34-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
35-
self.derived_property(id, pspec)
36-
}
37-
}
25+
#[glib::derived_properties]
26+
impl ObjectImpl for IntegerObject {}
3827
// ANCHOR_END: object_impl

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ impl ObjectSubclass for IntegerObject {
2222

2323
// ANCHOR: object_impl
2424
// Trait shared by all GObjects
25-
impl ObjectImpl for IntegerObject {
26-
fn properties() -> &'static [ParamSpec] {
27-
Self::derived_properties()
28-
}
29-
30-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
31-
self.derived_set_property(id, value, pspec)
32-
}
33-
34-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
35-
self.derived_property(id, pspec)
36-
}
37-
}
25+
#[glib::derived_properties]
26+
impl ObjectImpl for IntegerObject {}
3827
// ANCHOR_END: object_impl

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ impl ObjectSubclass for TaskObject {
2525
}
2626

2727
// Trait shared by all GObjects
28-
impl ObjectImpl for TaskObject {
29-
fn properties() -> &'static [ParamSpec] {
30-
Self::derived_properties()
31-
}
32-
33-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
34-
self.derived_set_property(id, value, pspec)
35-
}
36-
37-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
38-
self.derived_property(id, pspec)
39-
}
40-
}
28+
#[glib::derived_properties]
29+
impl ObjectImpl for TaskObject {}
4130
// ANCHOR_END: struct_and_subclass

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,5 @@ impl ObjectSubclass for TaskObject {
2424
}
2525

2626
// Trait shared by all GObjects
27-
impl ObjectImpl for TaskObject {
28-
fn properties() -> &'static [ParamSpec] {
29-
Self::derived_properties()
30-
}
31-
32-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
33-
self.derived_set_property(id, value, pspec)
34-
}
35-
36-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
37-
self.derived_property(id, pspec)
38-
}
39-
}
27+
#[glib::derived_properties]
28+
impl ObjectImpl for TaskObject {}

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,5 @@ impl ObjectSubclass for TaskObject {
2424
}
2525

2626
// Trait shared by all GObjects
27-
impl ObjectImpl for TaskObject {
28-
fn properties() -> &'static [ParamSpec] {
29-
Self::derived_properties()
30-
}
31-
32-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
33-
self.derived_set_property(id, value, pspec)
34-
}
35-
36-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
37-
self.derived_property(id, pspec)
38-
}
39-
}
27+
#[glib::derived_properties]
28+
impl ObjectImpl for TaskObject {}

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,5 @@ impl ObjectSubclass for TaskObject {
2424
}
2525

2626
// Trait shared by all GObjects
27-
impl ObjectImpl for TaskObject {
28-
fn properties() -> &'static [ParamSpec] {
29-
Self::derived_properties()
30-
}
31-
32-
fn set_property(&self, id: usize, value: &Value, pspec: &ParamSpec) {
33-
self.derived_set_property(id, value, pspec)
34-
}
35-
36-
fn property(&self, id: usize, pspec: &ParamSpec) -> Value {
37-
self.derived_property(id, pspec)
38-
}
39-
}
27+
#[glib::derived_properties]
28+
impl ObjectImpl for TaskObject {}

0 commit comments

Comments
 (0)