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

Commit

Permalink
Add new types
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jun 14, 2018
1 parent d0aa122 commit 3d5a896
Show file tree
Hide file tree
Showing 12 changed files with 1,030 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Gir.toml
Expand Up @@ -14,12 +14,18 @@ generate = [
"Gio.ApplicationFlags",
"Gio.AskPasswordFlags",
"Gio.BufferedOutputStream",
"Gio.Converter",
"Gio.ConverterFlags",
"Gio.ConverterResult",
"Gio.DataOutputStream",
"Gio.DataStreamByteOrder",
"Gio.DataStreamNewlineType",
"Gio.Drive",
"Gio.DriveStartFlags",
"Gio.DriveStartStopType",
"Gio.Emblem",
"Gio.EmblemOrigin",
"Gio.EmblemedIcon",
"Gio.FileCreateFlags",
"Gio.FileInfo",
"Gio.FileInputStream",
Expand Down Expand Up @@ -88,13 +94,17 @@ generate = [
"Gio.TlsRehandshakeMode",
"Gio.TlsServerConnection",
"Gio.Volume",
"Gio.ZlibCompressor",
"Gio.ZlibCompressorFormat",
"Gio.ZlibDecompressor",
]

ignore = [
]

manual = [
"GLib.Bytes",
"GLib.KeyFile",
"GLib.Error",
"GLib.Variant",
"GLib.VariantType",
Expand Down Expand Up @@ -232,6 +242,15 @@ status = "generate"
#return vec of u8
ignore = true

[[object]]
name = "Gio.DesktopAppInfo"
status = "generate"
cfg_condition = "not(windows)"
[[object.function]]
name = "search"
# returns vec of string
ignore = true

[[object]]
name = "Gio.File"
status = "generate"
Expand Down
48 changes: 48 additions & 0 deletions src/auto/converter.rs
@@ -0,0 +1,48 @@
// 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 ConverterFlags;
use ConverterResult;
use Error;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
pub struct Converter(Object<ffi::GConverter, ffi::GConverterIface>);

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

pub trait ConverterExt {
fn convert(&self, inbuf: &[u8], outbuf: &[u8], flags: ConverterFlags) -> Result<(ConverterResult, usize, usize), Error>;

fn reset(&self);
}

impl<O: IsA<Converter>> ConverterExt for O {
fn convert(&self, inbuf: &[u8], outbuf: &[u8], flags: ConverterFlags) -> Result<(ConverterResult, usize, usize), Error> {
let inbuf_size = inbuf.len() as usize;
let outbuf_size = outbuf.len() as usize;
unsafe {
let mut bytes_read = mem::uninitialized();
let mut bytes_written = mem::uninitialized();
let mut error = ptr::null_mut();
let ret = ffi::g_converter_convert(self.to_glib_none().0, inbuf.to_glib_none().0, inbuf_size, outbuf.to_glib_none().0, outbuf_size, flags.to_glib(), &mut bytes_read, &mut bytes_written, &mut error);
if error.is_null() { Ok((from_glib(ret), bytes_read, bytes_written)) } else { Err(from_glib_full(error)) }
}
}

fn reset(&self) {
unsafe {
ffi::g_converter_reset(self.to_glib_none().0);
}
}
}
230 changes: 230 additions & 0 deletions src/auto/desktop_app_info.rs
@@ -0,0 +1,230 @@
// 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 AppInfo;
#[cfg(any(feature = "v2_38", feature = "dox"))]
use AppLaunchContext;
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;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
pub struct DesktopAppInfo(Object<ffi::GDesktopAppInfo, ffi::GDesktopAppInfoClass>): AppInfo;

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

impl DesktopAppInfo {
pub fn new(desktop_id: &str) -> DesktopAppInfo {
unsafe {
from_glib_full(ffi::g_desktop_app_info_new(desktop_id.to_glib_none().0))
}
}

pub fn new_from_filename<P: AsRef<std::path::Path>>(filename: P) -> DesktopAppInfo {
unsafe {
from_glib_full(ffi::g_desktop_app_info_new_from_filename(filename.as_ref().to_glib_none().0))
}
}

pub fn new_from_keyfile(key_file: &glib::KeyFile) -> DesktopAppInfo {
unsafe {
from_glib_full(ffi::g_desktop_app_info_new_from_keyfile(key_file.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_42", feature = "dox"))]
pub fn get_implementations(interface: &str) -> Vec<DesktopAppInfo> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_desktop_app_info_get_implementations(interface.to_glib_none().0))
}
}

#[cfg_attr(feature = "v2_42", deprecated)]
pub fn set_desktop_env(desktop_env: &str) {
unsafe {
ffi::g_desktop_app_info_set_desktop_env(desktop_env.to_glib_none().0);
}
}
}

pub trait DesktopAppInfoExt {
#[cfg(any(feature = "v2_38", feature = "dox"))]
fn get_action_name(&self, action_name: &str) -> Option<String>;

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_boolean(&self, key: &str) -> bool;

fn get_categories(&self) -> Option<String>;

fn get_filename(&self) -> Option<std::path::PathBuf>;

fn get_generic_name(&self) -> Option<String>;

fn get_is_hidden(&self) -> bool;

fn get_keywords(&self) -> Vec<String>;

#[cfg(any(feature = "v2_56", feature = "dox"))]
fn get_locale_string(&self, key: &str) -> Option<String>;

fn get_nodisplay(&self) -> bool;

fn get_show_in<'a, P: Into<Option<&'a str>>>(&self, desktop_env: P) -> bool;

#[cfg(any(feature = "v2_34", feature = "dox"))]
fn get_startup_wm_class(&self) -> Option<String>;

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_string(&self, key: &str) -> Option<String>;

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn has_key(&self, key: &str) -> bool;

#[cfg(any(feature = "v2_38", feature = "dox"))]
fn launch_action<'a, P: Into<Option<&'a AppLaunchContext>>>(&self, action_name: &str, launch_context: P);

//fn launch_uris_as_manager<'a, 'b, 'c, P: Into<Option<&'a AppLaunchContext>>, Q: Into<Option<&'b /*Ignored*/glib::SpawnChildSetupFunc>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>, S: Into<Option<&'c /*Unimplemented*/DesktopAppLaunchCallback>>, T: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, uris: &[&str], launch_context: P, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Q, user_setup_data: R, pid_callback: S, pid_callback_data: T) -> Result<(), Error>;

#[cfg(any(feature = "v2_38", feature = "dox"))]
fn list_actions(&self) -> Vec<String>;

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

impl<O: IsA<DesktopAppInfo> + IsA<glib::object::Object>> DesktopAppInfoExt for O {
#[cfg(any(feature = "v2_38", feature = "dox"))]
fn get_action_name(&self, action_name: &str) -> Option<String> {
unsafe {
from_glib_full(ffi::g_desktop_app_info_get_action_name(self.to_glib_none().0, action_name.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_boolean(&self, key: &str) -> bool {
unsafe {
from_glib(ffi::g_desktop_app_info_get_boolean(self.to_glib_none().0, key.to_glib_none().0))
}
}

fn get_categories(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::g_desktop_app_info_get_categories(self.to_glib_none().0))
}
}

fn get_filename(&self) -> Option<std::path::PathBuf> {
unsafe {
from_glib_none(ffi::g_desktop_app_info_get_filename(self.to_glib_none().0))
}
}

fn get_generic_name(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::g_desktop_app_info_get_generic_name(self.to_glib_none().0))
}
}

fn get_is_hidden(&self) -> bool {
unsafe {
from_glib(ffi::g_desktop_app_info_get_is_hidden(self.to_glib_none().0))
}
}

fn get_keywords(&self) -> Vec<String> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_get_keywords(self.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_56", feature = "dox"))]
fn get_locale_string(&self, key: &str) -> Option<String> {
unsafe {
from_glib_full(ffi::g_desktop_app_info_get_locale_string(self.to_glib_none().0, key.to_glib_none().0))
}
}

fn get_nodisplay(&self) -> bool {
unsafe {
from_glib(ffi::g_desktop_app_info_get_nodisplay(self.to_glib_none().0))
}
}

fn get_show_in<'a, P: Into<Option<&'a str>>>(&self, desktop_env: P) -> bool {
let desktop_env = desktop_env.into();
let desktop_env = desktop_env.to_glib_none();
unsafe {
from_glib(ffi::g_desktop_app_info_get_show_in(self.to_glib_none().0, desktop_env.0))
}
}

#[cfg(any(feature = "v2_34", feature = "dox"))]
fn get_startup_wm_class(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::g_desktop_app_info_get_startup_wm_class(self.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn get_string(&self, key: &str) -> Option<String> {
unsafe {
from_glib_full(ffi::g_desktop_app_info_get_string(self.to_glib_none().0, key.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_36", feature = "dox"))]
fn has_key(&self, key: &str) -> bool {
unsafe {
from_glib(ffi::g_desktop_app_info_has_key(self.to_glib_none().0, key.to_glib_none().0))
}
}

#[cfg(any(feature = "v2_38", feature = "dox"))]
fn launch_action<'a, P: Into<Option<&'a AppLaunchContext>>>(&self, action_name: &str, launch_context: P) {
let launch_context = launch_context.into();
let launch_context = launch_context.to_glib_none();
unsafe {
ffi::g_desktop_app_info_launch_action(self.to_glib_none().0, action_name.to_glib_none().0, launch_context.0);
}
}

//fn launch_uris_as_manager<'a, 'b, 'c, P: Into<Option<&'a AppLaunchContext>>, Q: Into<Option<&'b /*Ignored*/glib::SpawnChildSetupFunc>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>, S: Into<Option<&'c /*Unimplemented*/DesktopAppLaunchCallback>>, T: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, uris: &[&str], launch_context: P, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Q, user_setup_data: R, pid_callback: S, pid_callback_data: T) -> Result<(), Error> {
// unsafe { TODO: call ffi::g_desktop_app_info_launch_uris_as_manager() }
//}

#[cfg(any(feature = "v2_38", feature = "dox"))]
fn list_actions(&self) -> Vec<String> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_list_actions(self.to_glib_none().0))
}
}

fn connect_property_filename_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::filename",
transmute(notify_filename_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}

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

0 comments on commit 3d5a896

Please sign in to comment.