Skip to content

Commit c76c7a1

Browse files
committed
Make DBusProxy subclassable
1 parent 9969d4f commit c76c7a1

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

gio/src/subclass/dbus_interface.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Take a look at the license at the top of the repository in the LICENSE file.
2+
3+
#![deny(unsafe_op_in_unsafe_fn)]
4+
5+
use glib::{prelude::*, subclass::prelude::*};
6+
7+
use crate::DBusInterface;
8+
9+
pub trait DBusInterfaceImpl: ObjectImpl + ObjectSubclass<Type: IsA<DBusInterface>> {}
10+
11+
pub trait DBusInterfaceImplExt: DBusInterfaceImpl {}
12+
13+
impl<T: DBusInterfaceImpl> DBusInterfaceImplExt for T {}
14+
15+
unsafe impl<T: DBusInterfaceImpl> IsImplementable<T> for DBusInterface {
16+
fn interface_init(_iface: &mut glib::Interface<Self>) {}
17+
}

gio/src/subclass/dbus_proxy.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Take a look at the license at the top of the repository in the LICENSE file.
2+
3+
#![deny(unsafe_op_in_unsafe_fn)]
4+
5+
use glib::{prelude::*, subclass::prelude::*};
6+
7+
use crate::subclass::prelude::DBusInterfaceImpl;
8+
use crate::DBusProxy;
9+
10+
pub trait DBusProxyImpl:
11+
ObjectImpl + DBusInterfaceImpl + ObjectSubclass<Type: IsA<DBusProxy>>
12+
{
13+
}
14+
15+
pub trait DBusProxyImplExt: DBusProxyImpl {}
16+
17+
impl<T: DBusProxyImpl> DBusProxyImplExt for T {}
18+
19+
unsafe impl<T: DBusProxyImpl> IsSubclassable<T> for DBusProxy {
20+
fn class_init(class: &mut glib::Class<Self>) {
21+
Self::parent_class_init::<T>(class);
22+
}
23+
}

gio/src/subclass/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ mod action_group;
44
mod action_map;
55
mod application;
66
mod async_initable;
7+
mod dbus_interface;
8+
mod dbus_proxy;
79
mod file_enumerator;
810
mod file_monitor;
911
mod initable;
@@ -26,6 +28,8 @@ pub mod prelude {
2628
action_map::{ActionMapImpl, ActionMapImplExt},
2729
application::{ApplicationImpl, ApplicationImplExt},
2830
async_initable::{AsyncInitableImpl, AsyncInitableImplExt},
31+
dbus_interface::{DBusInterfaceImpl, DBusInterfaceImplExt},
32+
dbus_proxy::{DBusProxyImpl, DBusProxyImplExt},
2933
file_enumerator::{FileEnumeratorImpl, FileEnumeratorImplExt},
3034
file_monitor::{FileMonitorImpl, FileMonitorImplExt},
3135
initable::{InitableImpl, InitableImplExt},

0 commit comments

Comments
 (0)