Skip to content

Commit

Permalink
Merge pull request #1587 from gtk-rs/bilelmoussaoui/gio-bindings
Browse files Browse the repository at this point in the history
Generate all the missing Gio bindings
  • Loading branch information
sdroege authored Dec 2, 2024
2 parents 8e2f4d0 + 059efb0 commit 94435b2
Show file tree
Hide file tree
Showing 17 changed files with 3,134 additions and 0 deletions.
37 changes: 37 additions & 0 deletions gio/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ generate = [
"Gio.DBusAuthObserver",
"Gio.DBusCallFlags",
"Gio.DBusCapabilityFlags",
"Gio.DBusError",
"Gio.DBusInterfaceGetPropertyFunc",
"Gio.DBusInterfaceMethodCallFunc",
"Gio.DBusInterfaceSetPropertyFunc",
Expand All @@ -45,16 +46,23 @@ generate = [
"Gio.DBusObject",
"Gio.DBusObjectManager",
"Gio.DBusObjectManagerClientFlags",
"Gio.DBusObjectManagerServer",
"Gio.DBusObjectProxy",
"Gio.DBusObjectSkeleton",
"Gio.DBusPropertyInfo",
"Gio.DBusPropertyInfoFlags",
"Gio.DBusSendMessageFlags",
"Gio.DBusServer",
"Gio.DBusServerFlags",
"Gio.DBusSignalFlags",
"Gio.DBusSignalInfo",
"Gio.DBusSubtreeFlags",
"Gio.DebugController",
"Gio.Drive",
"Gio.DriveStartFlags",
"Gio.DriveStartStopType",
"Gio.DtlsClientConnection",
"Gio.DtlsServerConnection",
"Gio.Emblem",
"Gio.EmblemedIcon",
"Gio.EmblemOrigin",
Expand All @@ -72,8 +80,10 @@ generate = [
"Gio.FilenameCompleter",
"Gio.FileOutputStream",
"Gio.FileQueryInfoFlags",
"Gio.FilesystemPreviewType",
"Gio.FileType",
"Gio.FilterInputStream",
"Gio.IOModuleScopeFlags",
"Gio.IOStreamSpliceFlags",
"Gio.LoadableIcon",
"Gio.MemoryMonitor",
Expand All @@ -85,6 +95,8 @@ generate = [
"Gio.MountOperation",
"Gio.MountOperationResult",
"Gio.MountUnmountFlags",
"Gio.NativeSocketAddress",
"Gio.NativeVolumeMonitor",
"Gio.NetworkConnectivity",
"Gio.NetworkMonitor",
"Gio.NetworkService",
Expand All @@ -96,11 +108,13 @@ generate = [
"Gio.PollableReturn",
"Gio.PropertyAction",
"Gio.Proxy",
"Gio.ProxyAddressEnumerator",
"Gio.ProxyResolver",
"Gio.RemoteActionGroup",
"Gio.ResolverError",
"Gio.ResolverNameLookupFlags",
"Gio.ResourceError",
"Gio.ResourceFlags",
"Gio.ResourceLookupFlags",
"Gio.Seekable",
"Gio.SettingsBackend",
Expand All @@ -124,10 +138,14 @@ generate = [
"Gio.SocketType",
"Gio.SrvTarget",
"Gio.TcpConnection",
"Gio.TcpWrapperConnection",
"Gio.TestDBus",
"Gio.TestDBusFlags",
"Gio.TlsAuthenticationMode",
"Gio.TlsBackend",
"Gio.TlsCertificate",
"Gio.TlsCertificateRequestFlags",
"Gio.TlsChannelBindingError",
"Gio.TlsClientConnection",
"Gio.TlsDatabase",
"Gio.TlsDatabaseLookupFlags",
Expand All @@ -146,6 +164,7 @@ generate = [
]

ignore = [
"Gio.ThreadedResolver", # Same as sys class, not sure if this needs to be exposed
]

manual = [
Expand All @@ -155,6 +174,7 @@ manual = [
"Gio.IOExtension",
"Gio.IOExtensionPoint",
"Gio.OutputMessage",
"Gio.SocketMsgFlags",
"Gio.Task",
"GLib.ByteArray",
"GLib.Bytes",
Expand Down Expand Up @@ -708,6 +728,13 @@ cfg_condition = "all(not(windows),not(target_os = \"macos\"))"
# has to use RawFd / SOCKET
manual = true

[[object]]
name = "Gio.DtlsConnection"
status = "generate"
[[object.function]]
name = "get_channel_binding_data"
ignore = true # needs manual implementation

[[object]]
name = "Gio.File"
status = "generate"
Expand Down Expand Up @@ -1480,6 +1507,11 @@ status = "generate"
name = "set_value"
ignore = true

[[object]]
name = "Gio.UnixConnection"
status = "generate"
cfg_condition = "unix"

[[object]]
name = "Gio.UnixCredentialsMessage"
status = "generate"
Expand Down Expand Up @@ -1601,6 +1633,11 @@ cfg_condition = "unix"
version = "2.0"
rename = "for_file_path"

[[object]]
name = "Gio.UnixMountMonitor"
status = "generate"
cfg_condition = "unix"

[[object]]
name = "Gio.UnixMountPoint"
status = "generate"
Expand Down
124 changes: 124 additions & 0 deletions gio/src/auto/dbus_object_manager_server.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, DBusConnection, DBusObjectManager, DBusObjectSkeleton};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
#[doc(alias = "GDBusObjectManagerServer")]
pub struct DBusObjectManagerServer(Object<ffi::GDBusObjectManagerServer, ffi::GDBusObjectManagerServerClass>) @implements DBusObjectManager;

match fn {
type_ => || ffi::g_dbus_object_manager_server_get_type(),
}
}

impl DBusObjectManagerServer {
pub const NONE: Option<&'static DBusObjectManagerServer> = None;

#[doc(alias = "g_dbus_object_manager_server_new")]
pub fn new(object_path: &str) -> DBusObjectManagerServer {
unsafe {
from_glib_full(ffi::g_dbus_object_manager_server_new(
object_path.to_glib_none().0,
))
}
}
}

pub trait DBusObjectManagerServerExt: IsA<DBusObjectManagerServer> + 'static {
#[doc(alias = "g_dbus_object_manager_server_export")]
fn export(&self, object: &impl IsA<DBusObjectSkeleton>) {
unsafe {
ffi::g_dbus_object_manager_server_export(
self.as_ref().to_glib_none().0,
object.as_ref().to_glib_none().0,
);
}
}

#[doc(alias = "g_dbus_object_manager_server_export_uniquely")]
fn export_uniquely(&self, object: &impl IsA<DBusObjectSkeleton>) {
unsafe {
ffi::g_dbus_object_manager_server_export_uniquely(
self.as_ref().to_glib_none().0,
object.as_ref().to_glib_none().0,
);
}
}

#[doc(alias = "g_dbus_object_manager_server_get_connection")]
#[doc(alias = "get_connection")]
fn connection(&self) -> Option<DBusConnection> {
unsafe {
from_glib_full(ffi::g_dbus_object_manager_server_get_connection(
self.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "g_dbus_object_manager_server_is_exported")]
fn is_exported(&self, object: &impl IsA<DBusObjectSkeleton>) -> bool {
unsafe {
from_glib(ffi::g_dbus_object_manager_server_is_exported(
self.as_ref().to_glib_none().0,
object.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "g_dbus_object_manager_server_set_connection")]
#[doc(alias = "connection")]
fn set_connection(&self, connection: Option<&DBusConnection>) {
unsafe {
ffi::g_dbus_object_manager_server_set_connection(
self.as_ref().to_glib_none().0,
connection.to_glib_none().0,
);
}
}

#[doc(alias = "g_dbus_object_manager_server_unexport")]
fn unexport(&self, object_path: &str) -> bool {
unsafe {
from_glib(ffi::g_dbus_object_manager_server_unexport(
self.as_ref().to_glib_none().0,
object_path.to_glib_none().0,
))
}
}

#[doc(alias = "connection")]
fn connect_connection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_connection_trampoline<
P: IsA<DBusObjectManagerServer>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GDBusObjectManagerServer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(DBusObjectManagerServer::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::connection\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_connection_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}

impl<O: IsA<DBusObjectManagerServer>> DBusObjectManagerServerExt for O {}
53 changes: 53 additions & 0 deletions gio/src/auto/dbus_object_proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, DBusConnection, DBusObject};
use glib::{prelude::*, translate::*};

glib::wrapper! {
#[doc(alias = "GDBusObjectProxy")]
pub struct DBusObjectProxy(Object<ffi::GDBusObjectProxy, ffi::GDBusObjectProxyClass>) @implements DBusObject;

match fn {
type_ => || ffi::g_dbus_object_proxy_get_type(),
}
}

impl DBusObjectProxy {
pub const NONE: Option<&'static DBusObjectProxy> = None;

#[doc(alias = "g_dbus_object_proxy_new")]
pub fn new(connection: &DBusConnection, object_path: &str) -> DBusObjectProxy {
unsafe {
from_glib_full(ffi::g_dbus_object_proxy_new(
connection.to_glib_none().0,
object_path.to_glib_none().0,
))
}
}
}

pub trait DBusObjectProxyExt: IsA<DBusObjectProxy> + 'static {
#[doc(alias = "g_dbus_object_proxy_get_connection")]
#[doc(alias = "get_connection")]
fn connection(&self) -> DBusConnection {
unsafe {
from_glib_none(ffi::g_dbus_object_proxy_get_connection(
self.as_ref().to_glib_none().0,
))
}
}

#[doc(alias = "g-connection")]
fn g_connection(&self) -> Option<DBusConnection> {
ObjectExt::property(self.as_ref(), "g-connection")
}

#[doc(alias = "g-object-path")]
fn g_object_path(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "g-object-path")
}
}

impl<O: IsA<DBusObjectProxy>> DBusObjectProxyExt for O {}
Loading

0 comments on commit 94435b2

Please sign in to comment.