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

Commit a935b11

Browse files
committed
Add ObjectSubclass::Interfaces associated type for listing all interfaces the subclass should implement
1 parent 496efa5 commit a935b11

File tree

13 files changed

+123
-43
lines changed

13 files changed

+123
-43
lines changed

examples/src/bin/basic_subclass.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mod imp_win {
4040
const NAME: &'static str = "SimpleWindow";
4141
type Type = super::SimpleWindow;
4242
type ParentType = gtk::ApplicationWindow;
43+
type Interfaces = ();
4344
type Instance = subclass::simple::InstanceStruct<Self>;
4445
type Class = subclass::simple::ClassStruct<Self>;
4546

@@ -128,6 +129,7 @@ mod imp_app {
128129
const NAME: &'static str = "SimpleApplication";
129130
type Type = super::SimpleApplication;
130131
type ParentType = gtk::Application;
132+
type Interfaces = ();
131133
type Instance = subclass::simple::InstanceStruct<Self>;
132134
type Class = subclass::simple::ClassStruct<Self>;
133135

examples/src/bin/composite_template.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod imp {
2929
const NAME: &'static str = "ExApplicationWindow";
3030
type Type = super::ExApplicationWindow;
3131
type ParentType = gtk::ApplicationWindow;
32+
type Interfaces = ();
3233
type Instance = subclass::simple::InstanceStruct<Self>;
3334
type Class = subclass::simple::ClassStruct<Self>;
3435

examples/src/bin/gio_task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ mod imp {
2727
const NAME: &'static str = "FileSize";
2828
type ParentType = glib::Object;
2929
type Instance = subclass::simple::InstanceStruct<Self>;
30+
type Interfaces = ();
3031
type Class = subclass::simple::ClassStruct<Self>;
3132
type Type = super::FileSize;
3233
glib::object_subclass!();

examples/src/bin/listbox_model.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@ mod model {
3434
const NAME: &'static str = "Model";
3535
type Type = super::Model;
3636
type ParentType = glib::Object;
37+
type Interfaces = (gio::ListModel,);
3738
type Instance = subclass::simple::InstanceStruct<Self>;
3839
type Class = subclass::simple::ClassStruct<Self>;
3940

4041
glib::object_subclass!();
4142

42-
// Called right before class_init and allows a GObject to specify
43-
// which interfaces it implement, in this case gio::ListModel
44-
fn type_init(type_: &mut subclass::InitializingType<Self>) {
45-
type_.add_interface::<gio::ListModel>();
46-
}
47-
4843
// Called once at the very beginning of instantiation
4944
fn new() -> Self {
5045
Self(RefCell::new(Vec::new()))
@@ -311,6 +306,7 @@ mod row_data {
311306
const NAME: &'static str = "RowData";
312307
type Type = super::RowData;
313308
type ParentType = glib::Object;
309+
type Interfaces = ();
314310
type Instance = subclass::simple::InstanceStruct<Self>;
315311
type Class = subclass::simple::ClassStruct<Self>;
316312

gio/src/read_input_stream.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mod imp {
2525
const NAME: &'static str = "ReadInputStream";
2626
type Type = super::ReadInputStream;
2727
type ParentType = InputStream;
28+
type Interfaces = (crate::Seekable,);
2829
type Instance = subclass::simple::InstanceStruct<Self>;
2930
type Class = subclass::simple::ClassStruct<Self>;
3031

@@ -35,10 +36,6 @@ mod imp {
3536
read: RefCell::new(None),
3637
}
3738
}
38-
39-
fn type_init(type_: &mut subclass::InitializingType<Self>) {
40-
type_.add_interface::<crate::Seekable>();
41-
}
4239
}
4340

4441
impl ObjectImpl for ReadInputStream {}

gio/src/subclass/application.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ mod tests {
493493
const NAME: &'static str = "SimpleApplication";
494494
type Type = super::SimpleApplication;
495495
type ParentType = Application;
496+
type Interfaces = ();
496497
type Instance = subclass::simple::InstanceStruct<Self>;
497498
type Class = subclass::simple::ClassStruct<Self>;
498499

gio/src/subclass/input_stream.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ mod tests {
269269
const NAME: &'static str = "SimpleInputStream";
270270
type Type = super::SimpleInputStream;
271271
type ParentType = InputStream;
272+
type Interfaces = (crate::Seekable,);
272273
type Instance = subclass::simple::InstanceStruct<Self>;
273274
type Class = subclass::simple::ClassStruct<Self>;
274275

@@ -279,10 +280,6 @@ mod tests {
279280
pos: RefCell::new(0),
280281
}
281282
}
282-
283-
fn type_init(type_: &mut subclass::InitializingType<Self>) {
284-
type_.add_interface::<crate::Seekable>();
285-
}
286283
}
287284

288285
impl ObjectImpl for SimpleInputStream {}

gio/src/subclass/output_stream.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ mod tests {
331331
const NAME: &'static str = "SimpleOutputStream";
332332
type Type = super::SimpleOutputStream;
333333
type ParentType = OutputStream;
334+
type Interfaces = ();
334335
type Instance = subclass::simple::InstanceStruct<Self>;
335336
type Class = subclass::simple::ClassStruct<Self>;
336337

gio/src/task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ mod test {
129129
const NAME: &'static str = "MySimpleObjectPrivate";
130130
type ParentType = glib::Object;
131131
type Instance = subclass::simple::InstanceStruct<Self>;
132+
type Interfaces = ();
132133
type Class = subclass::simple::ClassStruct<Self>;
133134
type Type = MySimpleObject;
134135
glib::object_subclass!();

gio/src/write_output_stream.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ mod imp {
2727
const NAME: &'static str = "WriteOutputStream";
2828
type Type = super::WriteOutputStream;
2929
type ParentType = OutputStream;
30+
type Interfaces = (crate::Seekable,);
3031
type Instance = subclass::simple::InstanceStruct<Self>;
3132
type Class = subclass::simple::ClassStruct<Self>;
3233

@@ -37,10 +38,6 @@ mod imp {
3738
write: RefCell::new(None),
3839
}
3940
}
40-
41-
fn type_init(type_: &mut subclass::InitializingType<Self>) {
42-
type_.add_interface::<crate::Seekable>();
43-
}
4441
}
4542

4643
impl ObjectImpl for WriteOutputStream {}

0 commit comments

Comments
 (0)