Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Add new types #125

Merged
merged 8 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ generate = [
"Gio.ConverterOutputStream",
"Gio.ConverterFlags",
"Gio.ConverterResult",
"Gio.CredentialsType",
"Gio.DataOutputStream",
"Gio.DataStreamByteOrder",
"Gio.DataStreamNewlineType",
Expand All @@ -29,6 +30,7 @@ generate = [
"Gio.EmblemOrigin",
"Gio.EmblemedIcon",
"Gio.FileCreateFlags",
"Gio.FileIcon",
"Gio.FileInfo",
"Gio.FileInputStream",
"Gio.FileIOStream",
Expand Down Expand Up @@ -78,6 +80,7 @@ generate = [
"Gio.SocketService",
"Gio.SocketType",
"Gio.SrvTarget",
"Gio.SubprocessFlags",
"Gio.TcpConnection",
"Gio.ThreadedSocketService",
"Gio.ThemedIcon",
Expand Down Expand Up @@ -160,7 +163,7 @@ status = "generate"
[[object.function]]
name = "get"
[object.function.return]
nullable = false
nullable = false

[[object]]
name = "Gio.AppLaunchContext"
Expand Down Expand Up @@ -246,6 +249,18 @@ status = "generate"
name = "convert"
ignore = true

[[object]]
name = "Gio.Credentials"
status = "generate"
[[object.function]]
name = "get_unix_pid"
cfg_condition = "unix"
[[object.function]]
name = "get_unix_user"
cfg_condition = "unix"
[[object.function]]
name = "set_unix_user"
cfg_condition = "unix"

[[object]]
name = "Gio.DataInputStream"
Expand Down Expand Up @@ -342,6 +357,18 @@ status = "generate"
#readonly
ignore = true

[[object]]
name = "Gio.InetAddressMask"
status = "generate"
[[object.function]]
name = "get_address"
[object.function.return]
nullable = false
[[object.function]]
name = "equal"
# conflicting implementations
ignore = true

[[object]]
name = "Gio.InputStream"
status = "generate"
Expand Down Expand Up @@ -544,6 +571,52 @@ name = "Gio.SettingsSchemaKey"
status = "generate"
version = "2.40"

[[object]]
name = "Gio.Subprocess"
status = "generate"
[[object.function]]
name = "newv"
[[object.function.parameter]]
name = "argv"
string_type = "os_string"
[[object.function]]
name = "communicate_utf8_async"
ignore = true
[[object.function]]
name = "communicate_utf8_async_future"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to ignore that one here. It is generated as a result of the non-futures function and does not exist as such in C

ignore = true

[[object]]
name = "Gio.SubprocessLauncher"
status = "generate"
[[object.function]]
name = "spawnv"
[[object.function.parameter]]
name = "argv"
string_type = "os_string"
[[object.function]]
name = "setenv"
[[object.function.parameter]]
name = "variable"
string_type = "os_string"
[[object.function.parameter]]
name = "value"
string_type = "os_string"
[[object.function]]
name = "unsetenv"
[[object.function.parameter]]
name = "variable"
string_type = "os_string"
[[object.function]]
pattern = "take_.*"
ignore = true
[[object.function]]
pattern = "set_std.*file_path"
cfg_condition = "unix"
[[object.function]]
name = "set_child_setup"
cfg_condition = "unix"

[[object]]
name = "Gio.TlsPassword"
status = "generate"
Expand Down
114 changes: 114 additions & 0 deletions src/auto/credentials.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// 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 Error;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::fmt;
use std::mem;
use std::ptr;

glib_wrapper! {
pub struct Credentials(Object<ffi::GCredentials, ffi::GCredentialsClass>);

match fn {
get_type => || ffi::g_credentials_get_type(),
}
}

impl Credentials {
pub fn new() -> Credentials {
unsafe {
from_glib_full(ffi::g_credentials_new())
}
}
}

impl Default for Credentials {
fn default() -> Self {
Self::new()
}
}

impl fmt::Display for Credentials {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", CredentialsExt::to_string(self))
}
}

pub trait CredentialsExt {
//fn get_native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option<Fundamental: Pointer>;

#[cfg(any(unix, feature = "dox"))]
#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_unix_pid(&self) -> Result<i32, Error>;

#[cfg(any(unix, feature = "dox"))]
fn get_unix_user(&self) -> Result<(), Error>;

fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), Error>;

//fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer);

#[cfg(any(unix, feature = "dox"))]
fn set_unix_user(&self, uid: u32) -> Result<(), Error>;

fn to_string(&self) -> String;
}

impl<O: IsA<Credentials>> CredentialsExt for O {
//fn get_native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option<Fundamental: Pointer> {
// unsafe { TODO: call ffi::g_credentials_get_native() }
//}

#[cfg(any(unix, feature = "dox"))]
#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_unix_pid(&self) -> Result<i32, Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_credentials_get_unix_pid(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }
}
}

#[cfg(any(unix, feature = "dox"))]
fn get_unix_user(&self) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::g_credentials_get_unix_user(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}

fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::g_credentials_is_same_user(self.to_glib_none().0, other_credentials.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}

//fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer) {
// unsafe { TODO: call ffi::g_credentials_set_native() }
//}

#[cfg(any(unix, feature = "dox"))]
fn set_unix_user(&self, uid: u32) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::g_credentials_set_unix_user(self.to_glib_none().0, uid, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}

fn to_string(&self) -> String {
unsafe {
from_glib_full(ffi::g_credentials_to_string(self.to_glib_none().0))
}
}
}
68 changes: 68 additions & 0 deletions src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,74 @@ impl SetValue for ConverterResult {
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum CredentialsType {
Invalid,
LinuxUcred,
FreebsdCmsgcred,
OpenbsdSockpeercred,
SolarisUcred,
NetbsdUnpcbid,
#[doc(hidden)]
__Unknown(i32),
}

#[doc(hidden)]
impl ToGlib for CredentialsType {
type GlibType = ffi::GCredentialsType;

fn to_glib(&self) -> ffi::GCredentialsType {
match *self {
CredentialsType::Invalid => ffi::G_CREDENTIALS_TYPE_INVALID,
CredentialsType::LinuxUcred => ffi::G_CREDENTIALS_TYPE_LINUX_UCRED,
CredentialsType::FreebsdCmsgcred => ffi::G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED,
CredentialsType::OpenbsdSockpeercred => ffi::G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED,
CredentialsType::SolarisUcred => ffi::G_CREDENTIALS_TYPE_SOLARIS_UCRED,
CredentialsType::NetbsdUnpcbid => ffi::G_CREDENTIALS_TYPE_NETBSD_UNPCBID,
CredentialsType::__Unknown(value) => value
}
}
}

#[doc(hidden)]
impl FromGlib<ffi::GCredentialsType> for CredentialsType {
fn from_glib(value: ffi::GCredentialsType) -> Self {
match value {
0 => CredentialsType::Invalid,
1 => CredentialsType::LinuxUcred,
2 => CredentialsType::FreebsdCmsgcred,
3 => CredentialsType::OpenbsdSockpeercred,
4 => CredentialsType::SolarisUcred,
5 => CredentialsType::NetbsdUnpcbid,
value => CredentialsType::__Unknown(value),
}
}
}

impl StaticType for CredentialsType {
fn static_type() -> Type {
unsafe { from_glib(ffi::g_credentials_type_get_type()) }
}
}

impl<'a> FromValueOptional<'a> for CredentialsType {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}

impl<'a> FromValue<'a> for CredentialsType {
unsafe fn from_value(value: &Value) -> Self {
from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}

impl SetValue for CredentialsType {
unsafe fn set_value(value: &mut Value, this: &Self) {
gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
}
}

#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum DataStreamByteOrder {
BigEndian,
Expand Down
65 changes: 65 additions & 0 deletions src/auto/file_icon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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 File;
use Icon;
use LoadableIcon;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
pub struct FileIcon(Object<ffi::GFileIcon, ffi::GFileIconClass>): Icon, LoadableIcon;

match fn {
get_type => || ffi::g_file_icon_get_type(),
}
}

impl FileIcon {
pub fn new<P: IsA<File>>(file: &P) -> FileIcon {
unsafe {
from_glib_full(ffi::g_file_icon_new(file.to_glib_none().0))
}
}
}

pub trait FileIconExt {
fn get_file(&self) -> Option<File>;

fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<FileIcon> + IsA<glib::object::Object>> FileIconExt for O {
fn get_file(&self) -> Option<File> {
unsafe {
from_glib_none(ffi::g_file_icon_get_file(self.to_glib_none().0))
}
}

fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::file",
transmute(notify_file_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}

unsafe extern "C" fn notify_file_trampoline<P>(this: *mut ffi::GFileIcon, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<FileIcon> {
callback_guard!();
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&FileIcon::from_glib_borrow(this).downcast_unchecked())
}
Loading