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

Commit a4eee77

Browse files
Merge pull request #125 from GuillaumeGomez/new-types2
Add new types
2 parents b170234 + 2d7017a commit a4eee77

13 files changed

+1368
-5
lines changed

Gir.toml

+71-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ generate = [
1919
"Gio.ConverterOutputStream",
2020
"Gio.ConverterFlags",
2121
"Gio.ConverterResult",
22+
"Gio.CredentialsType",
2223
"Gio.DataOutputStream",
2324
"Gio.DataStreamByteOrder",
2425
"Gio.DataStreamNewlineType",
@@ -29,6 +30,7 @@ generate = [
2930
"Gio.EmblemOrigin",
3031
"Gio.EmblemedIcon",
3132
"Gio.FileCreateFlags",
33+
"Gio.FileIcon",
3234
"Gio.FileInfo",
3335
"Gio.FileInputStream",
3436
"Gio.FileIOStream",
@@ -78,6 +80,7 @@ generate = [
7880
"Gio.SocketService",
7981
"Gio.SocketType",
8082
"Gio.SrvTarget",
83+
"Gio.SubprocessFlags",
8184
"Gio.TcpConnection",
8285
"Gio.ThreadedSocketService",
8386
"Gio.ThemedIcon",
@@ -160,7 +163,7 @@ status = "generate"
160163
[[object.function]]
161164
name = "get"
162165
[object.function.return]
163-
nullable = false
166+
nullable = false
164167

165168
[[object]]
166169
name = "Gio.AppLaunchContext"
@@ -246,6 +249,18 @@ status = "generate"
246249
name = "convert"
247250
ignore = true
248251

252+
[[object]]
253+
name = "Gio.Credentials"
254+
status = "generate"
255+
[[object.function]]
256+
name = "get_unix_pid"
257+
cfg_condition = "unix"
258+
[[object.function]]
259+
name = "get_unix_user"
260+
cfg_condition = "unix"
261+
[[object.function]]
262+
name = "set_unix_user"
263+
cfg_condition = "unix"
249264

250265
[[object]]
251266
name = "Gio.DataInputStream"
@@ -342,6 +357,18 @@ status = "generate"
342357
#readonly
343358
ignore = true
344359

360+
[[object]]
361+
name = "Gio.InetAddressMask"
362+
status = "generate"
363+
[[object.function]]
364+
name = "get_address"
365+
[object.function.return]
366+
nullable = false
367+
[[object.function]]
368+
name = "equal"
369+
# conflicting implementations
370+
ignore = true
371+
345372
[[object]]
346373
name = "Gio.InputStream"
347374
status = "generate"
@@ -544,6 +571,49 @@ name = "Gio.SettingsSchemaKey"
544571
status = "generate"
545572
version = "2.40"
546573

574+
[[object]]
575+
name = "Gio.Subprocess"
576+
status = "generate"
577+
[[object.function]]
578+
name = "newv"
579+
[[object.function.parameter]]
580+
name = "argv"
581+
string_type = "os_string"
582+
[[object.function]]
583+
name = "communicate_utf8_async"
584+
ignore = true
585+
586+
[[object]]
587+
name = "Gio.SubprocessLauncher"
588+
status = "generate"
589+
[[object.function]]
590+
name = "spawnv"
591+
[[object.function.parameter]]
592+
name = "argv"
593+
string_type = "os_string"
594+
[[object.function]]
595+
name = "setenv"
596+
[[object.function.parameter]]
597+
name = "variable"
598+
string_type = "os_string"
599+
[[object.function.parameter]]
600+
name = "value"
601+
string_type = "os_string"
602+
[[object.function]]
603+
name = "unsetenv"
604+
[[object.function.parameter]]
605+
name = "variable"
606+
string_type = "os_string"
607+
[[object.function]]
608+
pattern = "take_.*"
609+
ignore = true
610+
[[object.function]]
611+
pattern = "set_std.*file_path"
612+
cfg_condition = "unix"
613+
[[object.function]]
614+
name = "set_child_setup"
615+
cfg_condition = "unix"
616+
547617
[[object]]
548618
name = "Gio.TlsPassword"
549619
status = "generate"

src/auto/credentials.rs

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
3+
// DO NOT EDIT
4+
5+
use Error;
6+
use ffi;
7+
use glib::object::IsA;
8+
use glib::translate::*;
9+
use glib_ffi;
10+
use gobject_ffi;
11+
use std::fmt;
12+
use std::mem;
13+
use std::ptr;
14+
15+
glib_wrapper! {
16+
pub struct Credentials(Object<ffi::GCredentials, ffi::GCredentialsClass>);
17+
18+
match fn {
19+
get_type => || ffi::g_credentials_get_type(),
20+
}
21+
}
22+
23+
impl Credentials {
24+
pub fn new() -> Credentials {
25+
unsafe {
26+
from_glib_full(ffi::g_credentials_new())
27+
}
28+
}
29+
}
30+
31+
impl Default for Credentials {
32+
fn default() -> Self {
33+
Self::new()
34+
}
35+
}
36+
37+
impl fmt::Display for Credentials {
38+
#[inline]
39+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
40+
write!(f, "{}", CredentialsExt::to_string(self))
41+
}
42+
}
43+
44+
pub trait CredentialsExt {
45+
//fn get_native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option<Fundamental: Pointer>;
46+
47+
#[cfg(any(unix, feature = "dox"))]
48+
#[cfg(any(feature = "v2_36", feature = "dox"))]
49+
fn get_unix_pid(&self) -> Result<i32, Error>;
50+
51+
#[cfg(any(unix, feature = "dox"))]
52+
fn get_unix_user(&self) -> Result<(), Error>;
53+
54+
fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), Error>;
55+
56+
//fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer);
57+
58+
#[cfg(any(unix, feature = "dox"))]
59+
fn set_unix_user(&self, uid: u32) -> Result<(), Error>;
60+
61+
fn to_string(&self) -> String;
62+
}
63+
64+
impl<O: IsA<Credentials>> CredentialsExt for O {
65+
//fn get_native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option<Fundamental: Pointer> {
66+
// unsafe { TODO: call ffi::g_credentials_get_native() }
67+
//}
68+
69+
#[cfg(any(unix, feature = "dox"))]
70+
#[cfg(any(feature = "v2_36", feature = "dox"))]
71+
fn get_unix_pid(&self) -> Result<i32, Error> {
72+
unsafe {
73+
let mut error = ptr::null_mut();
74+
let ret = ffi::g_credentials_get_unix_pid(self.to_glib_none().0, &mut error);
75+
if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }
76+
}
77+
}
78+
79+
#[cfg(any(unix, feature = "dox"))]
80+
fn get_unix_user(&self) -> Result<(), Error> {
81+
unsafe {
82+
let mut error = ptr::null_mut();
83+
let _ = ffi::g_credentials_get_unix_user(self.to_glib_none().0, &mut error);
84+
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
85+
}
86+
}
87+
88+
fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), Error> {
89+
unsafe {
90+
let mut error = ptr::null_mut();
91+
let _ = ffi::g_credentials_is_same_user(self.to_glib_none().0, other_credentials.to_glib_none().0, &mut error);
92+
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
93+
}
94+
}
95+
96+
//fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer) {
97+
// unsafe { TODO: call ffi::g_credentials_set_native() }
98+
//}
99+
100+
#[cfg(any(unix, feature = "dox"))]
101+
fn set_unix_user(&self, uid: u32) -> Result<(), Error> {
102+
unsafe {
103+
let mut error = ptr::null_mut();
104+
let _ = ffi::g_credentials_set_unix_user(self.to_glib_none().0, uid, &mut error);
105+
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
106+
}
107+
}
108+
109+
fn to_string(&self) -> String {
110+
unsafe {
111+
from_glib_full(ffi::g_credentials_to_string(self.to_glib_none().0))
112+
}
113+
}
114+
}

src/auto/enums.rs

+68
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,74 @@ impl SetValue for ConverterResult {
7676
}
7777
}
7878

79+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
80+
pub enum CredentialsType {
81+
Invalid,
82+
LinuxUcred,
83+
FreebsdCmsgcred,
84+
OpenbsdSockpeercred,
85+
SolarisUcred,
86+
NetbsdUnpcbid,
87+
#[doc(hidden)]
88+
__Unknown(i32),
89+
}
90+
91+
#[doc(hidden)]
92+
impl ToGlib for CredentialsType {
93+
type GlibType = ffi::GCredentialsType;
94+
95+
fn to_glib(&self) -> ffi::GCredentialsType {
96+
match *self {
97+
CredentialsType::Invalid => ffi::G_CREDENTIALS_TYPE_INVALID,
98+
CredentialsType::LinuxUcred => ffi::G_CREDENTIALS_TYPE_LINUX_UCRED,
99+
CredentialsType::FreebsdCmsgcred => ffi::G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED,
100+
CredentialsType::OpenbsdSockpeercred => ffi::G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED,
101+
CredentialsType::SolarisUcred => ffi::G_CREDENTIALS_TYPE_SOLARIS_UCRED,
102+
CredentialsType::NetbsdUnpcbid => ffi::G_CREDENTIALS_TYPE_NETBSD_UNPCBID,
103+
CredentialsType::__Unknown(value) => value
104+
}
105+
}
106+
}
107+
108+
#[doc(hidden)]
109+
impl FromGlib<ffi::GCredentialsType> for CredentialsType {
110+
fn from_glib(value: ffi::GCredentialsType) -> Self {
111+
match value {
112+
0 => CredentialsType::Invalid,
113+
1 => CredentialsType::LinuxUcred,
114+
2 => CredentialsType::FreebsdCmsgcred,
115+
3 => CredentialsType::OpenbsdSockpeercred,
116+
4 => CredentialsType::SolarisUcred,
117+
5 => CredentialsType::NetbsdUnpcbid,
118+
value => CredentialsType::__Unknown(value),
119+
}
120+
}
121+
}
122+
123+
impl StaticType for CredentialsType {
124+
fn static_type() -> Type {
125+
unsafe { from_glib(ffi::g_credentials_type_get_type()) }
126+
}
127+
}
128+
129+
impl<'a> FromValueOptional<'a> for CredentialsType {
130+
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
131+
Some(FromValue::from_value(value))
132+
}
133+
}
134+
135+
impl<'a> FromValue<'a> for CredentialsType {
136+
unsafe fn from_value(value: &Value) -> Self {
137+
from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0))
138+
}
139+
}
140+
141+
impl SetValue for CredentialsType {
142+
unsafe fn set_value(value: &mut Value, this: &Self) {
143+
gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
144+
}
145+
}
146+
79147
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
80148
pub enum DataStreamByteOrder {
81149
BigEndian,

src/auto/file_icon.rs

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
3+
// DO NOT EDIT
4+
5+
use File;
6+
use Icon;
7+
use LoadableIcon;
8+
use ffi;
9+
use glib;
10+
use glib::object::Downcast;
11+
use glib::object::IsA;
12+
use glib::signal::SignalHandlerId;
13+
use glib::signal::connect;
14+
use glib::translate::*;
15+
use glib_ffi;
16+
use gobject_ffi;
17+
use std::boxed::Box as Box_;
18+
use std::mem;
19+
use std::mem::transmute;
20+
use std::ptr;
21+
22+
glib_wrapper! {
23+
pub struct FileIcon(Object<ffi::GFileIcon, ffi::GFileIconClass>): Icon, LoadableIcon;
24+
25+
match fn {
26+
get_type => || ffi::g_file_icon_get_type(),
27+
}
28+
}
29+
30+
impl FileIcon {
31+
pub fn new<P: IsA<File>>(file: &P) -> FileIcon {
32+
unsafe {
33+
from_glib_full(ffi::g_file_icon_new(file.to_glib_none().0))
34+
}
35+
}
36+
}
37+
38+
pub trait FileIconExt {
39+
fn get_file(&self) -> Option<File>;
40+
41+
fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
42+
}
43+
44+
impl<O: IsA<FileIcon> + IsA<glib::object::Object>> FileIconExt for O {
45+
fn get_file(&self) -> Option<File> {
46+
unsafe {
47+
from_glib_none(ffi::g_file_icon_get_file(self.to_glib_none().0))
48+
}
49+
}
50+
51+
fn connect_property_file_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
52+
unsafe {
53+
let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
54+
connect(self.to_glib_none().0, "notify::file",
55+
transmute(notify_file_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
56+
}
57+
}
58+
}
59+
60+
unsafe extern "C" fn notify_file_trampoline<P>(this: *mut ffi::GFileIcon, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
61+
where P: IsA<FileIcon> {
62+
callback_guard!();
63+
let f: &&(Fn(&P) + 'static) = transmute(f);
64+
f(&FileIcon::from_glib_borrow(this).downcast_unchecked())
65+
}

0 commit comments

Comments
 (0)