gio-0.7.0/.gitignore010064400007650000024000000000231350341527700125050ustar0000000000000000Cargo.lock /target gio-0.7.0/.gitmodules010064400007650000024000000002401350341527700126730ustar0000000000000000[submodule "gir"] path = gir url = https://github.com/gtk-rs/gir.git [submodule "gir-files"] path = gir-files url = https://github.com/gtk-rs/gir-files.git gio-0.7.0/.travis.yml010064400007650000024000000035231350341657000126330ustar0000000000000000dist: xenial language: rust matrix: include: - os: linux rust: nightly env: GTK=3.14 FEATURES=futures - os: linux rust: nightly env: GTK=3.24 FEATURES=v2_48,futures - os: linux rust: beta env: GTK=3.14 FEATURES= - os: linux rust: beta env: GTK=3.24 FEATURES=v2_48 - os: linux rust: 1.34.0 env: GTK=3.14 FEATURES= - os: linux rust: 1.34.0 env: GTK=3.24 FEATURES=v2_48 - os: osx rust: nightly env: GTK=3.14 FEATURES=futures # - os: osx # rust: nightly # env: GTK=3.24 FEATURES=v2_48,futures - os: osx rust: beta env: GTK=3.14 FEATURES= # - os: osx # rust: beta # env: GTK=3.24 FEATURES=v2_48 - os: osx rust: stable env: GTK=3.14 FEATURES= # - os: osx # rust: stable # env: GTK=3.24 FEATURES=v2_48 addons: apt: packages: - libgtk-3-dev - libmount-dev before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gtk+3 cairo atk; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig; fi script: - rustc --version - if [ "$TRAVIS_RUST_VERSION" == "nightly" ] && [ "$GTK" == "3.14" ]; then rustup component add rustfmt; make regen_check; fi - cargo doc --features "dox,embed-lgpl-docs" - cargo test --features "$FEATURES,embed-lgpl-docs" # catch any sneaked in lgpl docs - cargo build --features "$FEATURES,purge-lgpl-docs" --jobs 1 - git diff -R --exit-code - rustc --version - mkdir .cargo - echo 'paths = ["."]' > .cargo/config - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples - cd _examples - ./build_travis.sh gio-0.7.0/appveyor.yml010064400007650000024000000014471350341527700131200ustar0000000000000000environment: matrix: - RUST: stable BITS: 32 - RUST: stable BITS: 64 install: - IF "%BITS%" == "32" SET ARCH=i686 - IF "%BITS%" == "64" SET ARCH=x86_64 - curl -sSf -o rustup-init.exe https://win.rustup.rs - rustup-init.exe --default-host "%ARCH%-pc-windows-gnu" --default-toolchain %RUST% -y - SET PATH=C:\Users\appveyor\.cargo\bin;C:\msys64\mingw%BITS%\bin;%PATH%;C:\msys64\usr\bin - rustc -Vv - cargo -Vv - pacman --noconfirm -S mingw-w64-%ARCH%-gtk3 build_script: - cargo doc --features "dox" - cargo test - cargo test --features v2_58 - mkdir .cargo - echo paths = ["."] > .cargo\config - git clone -q --depth 50 -b pending https://github.com/gtk-rs/examples _examples - cd _examples - cargo build - cargo build --features gtk_3_24 test: false gio-0.7.0/build.rs010064400007650000024000000007771350341657000121770ustar0000000000000000fn main() { manage_docs(); } #[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))] fn manage_docs() { extern crate lgpl_docs; const PATH: &'static str = "src"; const IGNORES: &'static [&'static str] = &["lib.rs", "prelude.rs"]; lgpl_docs::purge(PATH, IGNORES); if cfg!(feature = "embed-lgpl-docs") { lgpl_docs::embed(lgpl_docs::Library::Gio, PATH, IGNORES); } } #[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))] fn manage_docs() {} gio-0.7.0/Cargo.toml.orig010064400007650000024000000026641350341713700134160ustar0000000000000000[package] name = "gio" license = "MIT" homepage = "http://gtk-rs.org/" authors = ["The Gtk-rs Project Developers"] keywords = ["glib", "gio", "gtk-rs", "gnome"] readme = "README.md" documentation = "http://gtk-rs.org/docs/gio/" version = "0.7.0" description = "Rust bindings for the Gio library" repository = "https://github.com/gtk-rs/gio" build = "build.rs" exclude = [ "gir-files/*", ] [badges] appveyor = { repository = "GuillaumeGomez/gio", service = "github" } travis-ci = { repository = "gtk-rs/gio" } [lib] name = "gio" [features] v2_44 = ["gio-sys/v2_44", "glib/v2_44"] v2_46 = ["v2_44", "gio-sys/v2_46", "glib/v2_46"] v2_48 = ["v2_46", "gio-sys/v2_48", "glib/v2_48"] v2_50 = ["v2_48", "gio-sys/v2_50", "glib/v2_50"] v2_52 = ["v2_50", "gio-sys/v2_52", "glib/v2_52"] v2_54 = ["v2_52", "gio-sys/v2_54", "glib/v2_54"] v2_56 = ["v2_54", "gio-sys/v2_56", "glib/v2_56"] v2_58 = ["v2_56", "gio-sys/v2_58", "glib/v2_58"] dox = ["gio-sys/dox", "glib/dox"] purge-lgpl-docs = ["gtk-rs-lgpl-docs"] embed-lgpl-docs = ["gtk-rs-lgpl-docs"] futures = ["futures-preview", "glib/futures"] subclassing = ["glib/subclassing"] [build-dependencies.gtk-rs-lgpl-docs] version = "0.1.3" optional = true [dependencies] gobject-sys = "0.9.0" gio-sys = "0.9.0" glib = "0.8.0" glib-sys = "0.9.0" libc = "0.2" bitflags = "1.0" lazy_static = "1.0" futures-preview = { version = "0.3.0-alpha", optional = true } fragile = "0.3" [dev-dependencies] gir-format-check = "^0.1" gio-0.7.0/Cargo.toml0000644000000041640000000000000076600ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "gio" version = "0.7.0" authors = ["The Gtk-rs Project Developers"] build = "build.rs" exclude = ["gir-files/*"] description = "Rust bindings for the Gio library" homepage = "http://gtk-rs.org/" documentation = "http://gtk-rs.org/docs/gio/" readme = "README.md" keywords = ["glib", "gio", "gtk-rs", "gnome"] license = "MIT" repository = "https://github.com/gtk-rs/gio" [lib] name = "gio" [dependencies.bitflags] version = "1.0" [dependencies.fragile] version = "0.3" [dependencies.futures-preview] version = "0.3.0-alpha" optional = true [dependencies.gio-sys] version = "0.9.0" [dependencies.glib] version = "0.8.0" [dependencies.glib-sys] version = "0.9.0" [dependencies.gobject-sys] version = "0.9.0" [dependencies.lazy_static] version = "1.0" [dependencies.libc] version = "0.2" [dev-dependencies.gir-format-check] version = "^0.1" [build-dependencies.gtk-rs-lgpl-docs] version = "0.1.3" optional = true [features] dox = ["gio-sys/dox", "glib/dox"] embed-lgpl-docs = ["gtk-rs-lgpl-docs"] futures = ["futures-preview", "glib/futures"] purge-lgpl-docs = ["gtk-rs-lgpl-docs"] subclassing = ["glib/subclassing"] v2_44 = ["gio-sys/v2_44", "glib/v2_44"] v2_46 = ["v2_44", "gio-sys/v2_46", "glib/v2_46"] v2_48 = ["v2_46", "gio-sys/v2_48", "glib/v2_48"] v2_50 = ["v2_48", "gio-sys/v2_50", "glib/v2_50"] v2_52 = ["v2_50", "gio-sys/v2_52", "glib/v2_52"] v2_54 = ["v2_52", "gio-sys/v2_54", "glib/v2_54"] v2_56 = ["v2_54", "gio-sys/v2_56", "glib/v2_56"] v2_58 = ["v2_56", "gio-sys/v2_58", "glib/v2_58"] [badges.appveyor] repository = "GuillaumeGomez/gio" service = "github" [badges.travis-ci] repository = "gtk-rs/gio" gio-0.7.0/COPYRIGHT010064400007650000024000000050021350341527700120120ustar0000000000000000The Gtk-rs Project is copyright 2013-2016, The Gtk-rs Project Developers: Adam Crume Adolfo Ochagavía Andre Bogus Anton Konjahin Arne Dussin Boden Garman Brian Kropf Bryant Mairs Chris Greenaway Chris Palmer Corey Farwell Daniel Zalevskiy David Li Edward Shaw Edward Yang Esption Evgenii Pashkin Geoffrey French Gleb Kozyrev Glenn Watson Google Inc. Guillaume Gomez Gulshan Singh Jakob Gillich James Shepherdson Jeremy Letang John Vrbanac kennytm Laurence Tratt Lionel Flandrin Lucas Werkmeister Lukas Diekmann Mathijs Henquet Maxwell Koo mitaa Nick Herman Nicolas Koch Oliver Schneider Ömer Sinan Ağacan Ralph Giles Paul Dennis Paul Hendry Philipp Brüschweiler Raphael Nestler Robertas Romain Gauthier S.J.R. van Schaik Sebastian Schulze Silvio Fricke Simon Sapin Steve Klabnik Tobias Bales trolleyman Umur Gedik UrKr Vojtech Kral Zach Oakes Zach Ploskey The Gtk-rs Project is licensed under the MIT license, see the LICENSE file or . This project provides interoperability with various GNOME libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL, see the LGPL file. gio-0.7.0/Gir.toml010064400007650000024000000447411350341657000121470ustar0000000000000000[options] girs_dir = "gir-files" library = "Gio" version = "2.0" min_cfg_version = "2.42" target_path = "." work_mode = "normal" single_version_file = true deprecate_by_min_version = true generate = [ # "Gio.Task", "Gio.Action", "Gio.ActionMap", "Gio.AppInfoCreateFlags", "Gio.ApplicationFlags", "Gio.AskPasswordFlags", "Gio.BufferedOutputStream", "Gio.CharsetConverter", "Gio.ConverterFlags", "Gio.ConverterInputStream", "Gio.ConverterOutputStream", "Gio.ConverterResult", "Gio.CredentialsType", "Gio.DataOutputStream", "Gio.DataStreamByteOrder", "Gio.DataStreamNewlineType", "Gio.Drive", "Gio.DriveStartFlags", "Gio.DriveStartStopType", "Gio.Emblem", "Gio.EmblemedIcon", "Gio.EmblemOrigin", "Gio.FileAttributeStatus", "Gio.FileAttributeType", "Gio.FileCopyFlags", "Gio.FileCreateFlags", "Gio.FileIcon", "Gio.FileInfo", "Gio.FileInputStream", "Gio.FileIOStream", "Gio.FileMeasureFlags", "Gio.FileMonitor", "Gio.FileMonitorEvent", "Gio.FileMonitorFlags", "Gio.FilenameCompleter", "Gio.FileOutputStream", "Gio.FileQueryInfoFlags", "Gio.FileType", "Gio.Icon", "Gio.IOErrorEnum", "Gio.IOStreamSpliceFlags", "Gio.ListModel", "Gio.LoadableIcon", "Gio.Menu", "Gio.MenuAttributeIter", "Gio.MenuItem", "Gio.MenuLinkIter", "Gio.MenuModel", "Gio.Mount", "Gio.MountMountFlags", "Gio.MountOperation", "Gio.MountOperationResult", "Gio.MountUnmountFlags", "Gio.NetworkConnectivity", "Gio.NetworkMonitor", "Gio.NetworkService", "Gio.NotificationPriority", "Gio.OutputStreamSpliceFlags", "Gio.PasswordSave", "Gio.Permission", "Gio.PropertyAction", "Gio.Proxy", "Gio.ProxyResolver", "Gio.RemoteActionGroup", "Gio.Resolver", "Gio.ResolverRecordType", "Gio.ResourceError", "Gio.ResourceLookupFlags", "Gio.Seekable", "Gio.SettingsBackend", "Gio.SettingsBindFlags", "Gio.SettingsBindGetMapping", "Gio.SettingsBindSetMapping", "Gio.SettingsGetMapping", "Gio.SettingsSchema", "Gio.SettingsSchemaSource", "Gio.SimpleActionGroup", "Gio.SimplePermission", "Gio.SocketAddressEnumerator", "Gio.SocketClient", "Gio.SocketClientEvent", "Gio.SocketConnectable", "Gio.SocketConnection", "Gio.SocketFamily", "Gio.SocketListenerEvent", "Gio.SocketProtocol", "Gio.SocketService", "Gio.SocketType", "Gio.SrvTarget", "Gio.SubprocessFlags", "Gio.TcpConnection", "Gio.ThreadedSocketService", "Gio.TlsAuthenticationMode", "Gio.TlsCertificate", "Gio.TlsCertificateFlags", "Gio.TlsCertificateRequestFlags", "Gio.TlsClientConnection", "Gio.TlsConnection", "Gio.TlsDatabase", "Gio.TlsDatabaseLookupFlags", "Gio.TlsDatabaseVerifyFlags", "Gio.TlsFileDatabase", "Gio.TlsInteraction", "Gio.TlsInteractionResult", "Gio.TlsPasswordFlags", "Gio.TlsRehandshakeMode", "Gio.TlsServerConnection", "Gio.Volume", "Gio.ZlibCompressor", "Gio.ZlibCompressorFormat", "Gio.ZlibDecompressor", ] builders = [ "Gio.BufferedInputStream", "Gio.BufferedOutputStream", "Gio.CharsetConverterBuilder", "Gio.ConverterInputStreamBuilder", "Gio.ConverterOutputStreamBuilder", "Gio.DataInputStreamBuilder", "Gio.DataOutputStreamBuilder", ] ignore = [ ] manual = [ "GLib.Bytes", "GLib.DateTime", "GLib.Error", "GLib.IOCondition", "GLib.KeyFile", "GLib.MainContext", "GLib.OptionArg", "GLib.OptionFlags", "GLib.Priority", "GLib.Quark", "GLib.SeekType", "GLib.Source", "GLib.TimeVal", "GLib.Variant", "GLib.VariantType", "GObject.Object", "GObject.Value", ] [[object]] name = "Gio.*" status = "generate" [[object.function]] pattern = "unix_.+" cfg_condition = "unix" [[object.function]] pattern = "pollable_stream_.+" #belong to Stream, works only with PollableStream, need mutable buffer reference ignore = true [[object.function]] pattern = "pollable_source_.+" #belong to Stream, works only with PollableStream, need mutable buffer reference ignore = true [[object.function]] name = "unix_is_system_device_path" [[object.function.parameter]] name = "device_path" string_type = "filename" [[object]] name = "Gio.ActionGroup" status = "generate" [[object.function]] name = "query_action" ignore = true [[object]] name = "Gio.AppInfo" status = "generate" [[object.function]] name = "create_from_commandline" [[object.function.parameter]] name = "commandline" string_type = "os_string" [[object]] name = "Gio.AppInfoMonitor" status = "generate" [[object.function]] name = "get" [object.function.return] nullable = false [[object]] name = "Gio.AppLaunchContext" status = "generate" [[object.function]] name = "get_environment" [object.function.return] string_type = "os_string" [[object.function]] pattern = "(un)?setenv" [[object.function.parameter]] name = "variable" string_type = "os_string" [[object.function.parameter]] name = "value" string_type = "os_string" [[object]] name = "Gio.Application" status = "generate" manual_traits = ["ApplicationExtManual"] generate_builder = true [[object.signal]] name = "open" ignore = true [[object.function]] name = "run" ignore = true [[object]] name = "Gio.ApplicationCommandLine" status = "generate" [[object.function]] name = "create_file_for_arg" [[object.function.parameter]] name = "arg" string_type = "os_string" [[object.function]] name = "get_arguments" [object.function.return] string_type = "os_string" [[object.function]] name = "get_environ" [object.function.return] string_type = "os_string" [[object.function]] name = "getenv" [[object.function.parameter]] name = "name" string_type = "os_string" [[object]] name = "Gio.BufferedInputStream" status = "generate" [[object.function]] name = "peek" #have almost same peek_buffer ignore = true [[object]] name = "Gio.BytesIcon" status = "generate" [[object.property]] name = "bytes" version = "2.38" [[object]] name = "Gio.Cancellable" status = "generate" concurrency = "send+sync" [[object.function]] name = "reset" #undefined behaviour ignore = true [[object.function]] name = "source_new" # Needs manual bindings for setting callback, etc ignore = true [[object]] name = "Gio.Converter" status = "generate" manual_traits = ["ConverterExtManual"] [[object.function]] 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" status = "generate" [[object.function]] name = "read_line" #return vec of u8 ignore = true [[object.function]] name = "read_line_async" #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" concurrency = "send+sync" manual_traits = ["FileExtManual"] [[object.function]] name = "new_for_path" [object.function.return] nullable = false [[object.function]] name = "new_for_uri" [object.function.return] nullable = false [[object.function]] name = "new_for_commandline_arg" [[object.function.parameter]] name = "arg" string_type = "os_string" [object.function.return] nullable = false [[object.function]] name = "new_for_commandline_arg_and_cwd" [[object.function.parameter]] name = "arg" string_type = "os_string" [object.function.return] nullable = false [[object.function]] name = "hash" ignore = true [[object.function]] name = "enumerate_children_async" # FileEnumerator ignore = true [[object.function]] name = "find_enclosing_mount_async" # Mount ignore = true [[object.function]] name = "replace_contents_async" # AsRef ignore = true [[object.function]] name = "get_uri_scheme" [object.function.return] nullable = false [[object.function]] name = "get_uri" [object.function.return] nullable = false [[object]] name = "Gio.FileAttributeMatcher" status = "generate" [[object.function]] name = "enumerate_next" # Better API with `IntoIter` ignore = true [[object.function]] name = "subtract" [[object.function.parameter]] name = "subtract" nullable = true [[object]] name = "Gio.FilterInputStream" status = "generate" [[object.property]] name = "base-stream" #readonly ignore = true [[object]] name = "Gio.FilterOutputStream" status = "generate" [[object.property]] name = "base-stream" #readonly ignore = true [[object.property]] name = "close-base-stream" #has get/set function, ConstructOnly generate = ["notify"] [[object]] name = "Gio.InetAddressMask" status = "generate" concurrency = "send+sync" [[object.function]] name = "get_address" [object.function.return] nullable = false [[object]] name = "Gio.InetAddress" status = "generate" concurrency = "send+sync" [[object.function]] name = "new_from_bytes" # broken and needs some closer integration with the corresponding std types ignore = true [[object.function]] name = "to_bytes" # broken and needs some closer integration with the corresponding std types ignore = true [[object]] name = "Gio.InetSocketAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.InputStream" status = "generate" manual_traits = ["InputStreamExtManual"] [[object.function]] pattern = "read(_all)?(_async)?" #mutable buffer ignore = true [[object]] name = "Gio.IOStream" status = "generate" [[object.function]] name = "splice_async" #g_io_stream_splice_finish accept only 2 parameters instead normal 3 (no source_object) ignore = true [[object.property]] name = "input-stream" #readonly ignore = true [[object.property]] name = "output-stream" #readonly ignore = true [[object]] name = "Gio.ListStore" status = "generate" generate_builder = true manual_traits = ["ListStoreExtManual"] [[object]] name = "Gio.MemoryInputStream" status = "generate" [[object.function]] name = "new_from_data" #destroy function will called on passed data, so boxing free as in glib::Bytes impossible ignore = true [[object.function]] name = "add_data" #destroy function will called on passed data, so boxing free as in glib::Bytes impossible ignore = true [[object]] name = "Gio.MemoryOutputStream" status = "generate" [[object.function]] name = "new" #unsupported memory allocators ignore = true [[object.function]] name = "get_data" #uncontrolled lifetime ignore = true [[object.function]] name = "get_size" #not usable ignore = true [[object.function]] name = "steal_data" #unsupported memory allocators ignore = true [[object.property]] name = "data" #uncontrolled lifetime ignore = true [[object.property]] name = "size" #not usable ignore = true [[object.property]] name = "destroy-function" #unsupported memory allocators ignore = true [[object.property]] name = "realloc-function" #unsupported memory allocators ignore = true [[object]] name = "Gio.NetworkAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.Notification" status = "generate" [[object]] name = "Gio.OutputStream" status = "generate" manual_traits = ["OutputStreamExtManual"] [[object.function]] name = "write_async" #AsRef ignore = true [[object.function]] name = "write_all_async" #AsRef ignore = true [[object.function]] name = "write_all" # special return value ignore = true [[object]] name = "Gio.PollableInputStream" status = "generate" manual_traits = ["PollableInputStreamExtManual"] [[object.function]] name = "create_source" # manual source implementation ignore = true [[object.function]] name = "read_nonblocking" # wrong mutability ignore = true [[object]] name = "Gio.PollableOutputStream" status = "generate" manual_traits = ["PollableOutputStreamExtManual"] [[object.function]] name = "create_source" # manual source implementation ignore = true [[object]] name = "Gio.ProxyAddress" status = "generate" concurrency = "send+sync" [[object.function]] name = "get_destination_hostname" [object.function.return] nullable = false [[object.function]] name = "get_protocol" [object.function.return] nullable = false [[object]] name = "Gio.Resource" status = "generate" [[object.function]] name = "new_from_data" # Requires special alignment, see # https://bugzilla.gnome.org/show_bug.cgi?id=790030 ignore = true [[object]] name = "Gio.Settings" status = "generate" [[object.signal]] name = "writable-change-event" inhibit = true [[object]] name = "Gio.SettingsSchemaKey" status = "generate" version = "2.40" [[object]] name = "Gio.SimpleAction" status = "generate" [[object.property]] name = "parameter-type" #value glib::VariantTy ignore = true [[object.property]] name = "state" #value glib::VariantTy ignore = true [[object]] name = "Gio.SimpleIOStream" status = "generate" [[object.property]] name = "input-stream" #readonly ignore = true [[object.property]] name = "output-stream" #readonly ignore = true [[object]] name = "Gio.Socket" status = "generate" concurrency = "send-unique" manual_traits = ["SocketExtManual"] [[object.function]] name = "new_from_fd" # has to use RawFd / SOCKET ignore = true [[object.function]] name = "get_fd" # has to use RawFd / SOCKET ignore = true [[object.property]] name = "fd" # has to use RawFd / SOCKET ignore = true [[object.function]] name = "create_source" # needs custom impl for Source callback ignore = true [[object.function]] pattern = "receive.*" # &[u8] ignore = true [[object.function]] pattern = "send.*" # &[u8] ignore = true [[object]] name = "Gio.SocketAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.SocketListener" status = "generate" manual_traits = ["SocketListenerExtManual"] [[object.function]] name = "accept_socket_async" # finish function misses nullable return annotation ignore = true [[object.function]] name = "accept_async" # finish function misses nullable return annotation ignore = true [[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 = "send_signal" cfg_condition = "not(windows)" [[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.ThemedIcon" status = "generate" [[object.property]] name = "names" # ConstructOnly generate = ["notify"] [[object]] name = "Gio.TlsPassword" status = "generate" [[object.function]] name = "get_value" # missing inout annotation ignore = true [[object.function]] # missing (element-type guint8) annotation name = "set_value" ignore = true [[object]] name = "Gio.UnixInputStream" status = "generate" cfg_condition = "unix" manual_traits = ["UnixInputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd ignore = true [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks ignore = true [[object.function]] name = "get_fd" # has to use RawFd ignore = true [[object.property]] name = "fd" # has to use RawFd ignore = true [[object.property]] name = "close-fd" ignore = true [[object]] name = "Gio.UnixOutputStream" status = "generate" cfg_condition = "unix" manual_traits = ["UnixOutputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd ignore = true [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks ignore = true [[object.function]] name = "get_fd" # has to use RawFd ignore = true [[object.property]] name = "fd" # has to use RawFd ignore = true [[object.property]] name = "close-fd" ignore = true [[object]] name = "Gio.UnixSocketAddress" status = "generate" concurrency = "send+sync" cfg_condition = "unix" manual_traits = ["UnixSocketAddressExtManual"] [[object.function]] name = "new" ignore = true [[object.function]] name = "get_path" ignore = true [[object.property]] name = "path" ignore = true [[object]] name = "Gio.UnixSocketAddressType" status = "generate" cfg_condition = "unix" [[object]] name = "Gio.Vfs" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.VolumeMonitor" status = "generate" [[object.function]] name = "get" [object.function.return] nullable = false gio-0.7.0/LGPL010064400007650000024000000613141350341527700112100ustar0000000000000000 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA. Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! gio-0.7.0/LICENSE010064400007650000024000000021201350341527700115220ustar0000000000000000The MIT License (MIT) Copyright (c) 2013-2015, The Gtk-rs Project Developers. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gio-0.7.0/Makefile010064400007650000024000000012561350341657000121630ustar0000000000000000GIR = gir/target/bin/gir GIR_SRC = gir/Cargo.toml gir/Cargo.lock gir/build.rs $(shell find gir/src -name '*.rs') GIR_FILES = gir-files/Gio-2.0.gir # Run `gir` generating the bindings gir : src/auto/mod.rs cargo fmt doc: $(GIR) $(GIR_FILES) $(GIR) -m doc -c Gir.toml not_bound: $(GIR) $(GIR_FILES) $(GIR) -m not_bound -c Gir.toml regen_check: $(GIR) $(GIR_FILES) rm src/auto/* $(GIR) -c Gir.toml cargo fmt git diff -R --exit-code src/auto/mod.rs : Gir.toml $(GIR) $(GIR_FILES) $(GIR) -c Gir.toml $(GIR) : $(GIR_SRC) rm -f gir/target/bin/gir cargo install --path gir --root gir/target rm -f gir/target/.crates.toml $(GIR_SRC) $(GIR_FILES) : git submodule update --init gio-0.7.0/README.md010064400007650000024000000011331350341527700117770ustar0000000000000000# gio [![Build Status](https://travis-ci.org/gtk-rs/gio.png?branch=master)](https://travis-ci.org/gtk-rs/gio) [![Build status](https://ci.appveyor.com/api/projects/status/4773nkca4q8ayn4x/branch/master?svg=true)](https://ci.appveyor.com/project/GuillaumeGomez/gio) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gtk-rs/gtk) GIO bindings for Rust. - [Gtk-rs project site](http://gtk-rs.org/) - [Online documentation](http://gtk-rs.org/docs/) - [Readme](https://github.com/gtk-rs/gtk/blob/master/README.md) in our [main repo](https://github.com/gtk-rs/gtk) ## License MIT gio-0.7.0/src/application.rs010064400007650000024000000033531350341657000141630ustar0000000000000000use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::{connect_raw, SignalHandlerId}; use glib::translate::*; use glib::GString; use glib_sys; use libc; use std::boxed::Box as Box_; use std::mem::transmute; use Application; use File; pub trait ApplicationExtManual { fn run(&self, argv: &[String]) -> i32; fn connect_open(&self, f: F) -> SignalHandlerId; } impl> ApplicationExtManual for O { fn run(&self, argv: &[String]) -> i32 { let argc = argv.len() as i32; unsafe { gio_sys::g_application_run(self.as_ref().to_glib_none().0, argc, argv.to_glib_none().0) } } fn connect_open(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn open_trampoline( this: *mut gio_sys::GApplication, files: *const *mut gio_sys::GFile, n_files: libc::c_int, hint: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); let files: Vec = FromGlibContainer::from_glib_none_num(files, n_files as usize); f( &Application::from_glib_borrow(this).unsafe_cast(), &files, &GString::from_glib_borrow(hint), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"open\0".as_ptr() as *const _, Some(transmute(open_trampoline:: as usize)), Box_::into_raw(f), ) } } } gio-0.7.0/src/auto/action.rs010064400007650000024000000206211350341657000141020ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; glib_wrapper! { pub struct Action(Interface); match fn { get_type => || gio_sys::g_action_get_type(), } } impl Action { pub fn name_is_valid(action_name: &str) -> bool { unsafe { from_glib(gio_sys::g_action_name_is_valid( action_name.to_glib_none().0, )) } } pub fn parse_detailed_name(detailed_name: &str) -> Result<(GString, glib::Variant), Error> { unsafe { let mut action_name = ptr::null_mut(); let mut target_value = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_action_parse_detailed_name( detailed_name.to_glib_none().0, &mut action_name, &mut target_value, &mut error, ); if error.is_null() { Ok((from_glib_full(action_name), from_glib_full(target_value))) } else { Err(from_glib_full(error)) } } } pub fn print_detailed_name( action_name: &str, target_value: Option<&glib::Variant>, ) -> Option { unsafe { from_glib_full(gio_sys::g_action_print_detailed_name( action_name.to_glib_none().0, target_value.to_glib_none().0, )) } } } pub const NONE_ACTION: Option<&Action> = None; pub trait ActionExt: 'static { fn activate(&self, parameter: Option<&glib::Variant>); fn change_state(&self, value: &glib::Variant); fn get_enabled(&self) -> bool; fn get_name(&self) -> Option; fn get_parameter_type(&self) -> Option; fn get_state(&self) -> Option; fn get_state_hint(&self) -> Option; fn get_state_type(&self) -> Option; fn connect_property_enabled_notify(&self, f: F) -> SignalHandlerId; fn connect_property_name_notify(&self, f: F) -> SignalHandlerId; fn connect_property_parameter_type_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_state_notify(&self, f: F) -> SignalHandlerId; fn connect_property_state_type_notify(&self, f: F) -> SignalHandlerId; } impl> ActionExt for O { fn activate(&self, parameter: Option<&glib::Variant>) { unsafe { gio_sys::g_action_activate(self.as_ref().to_glib_none().0, parameter.to_glib_none().0); } } fn change_state(&self, value: &glib::Variant) { unsafe { gio_sys::g_action_change_state(self.as_ref().to_glib_none().0, value.to_glib_none().0); } } fn get_enabled(&self) -> bool { unsafe { from_glib(gio_sys::g_action_get_enabled( self.as_ref().to_glib_none().0, )) } } fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_action_get_name(self.as_ref().to_glib_none().0)) } } fn get_parameter_type(&self) -> Option { unsafe { from_glib_none(gio_sys::g_action_get_parameter_type( self.as_ref().to_glib_none().0, )) } } fn get_state(&self) -> Option { unsafe { from_glib_full(gio_sys::g_action_get_state(self.as_ref().to_glib_none().0)) } } fn get_state_hint(&self) -> Option { unsafe { from_glib_full(gio_sys::g_action_get_state_hint( self.as_ref().to_glib_none().0, )) } } fn get_state_type(&self) -> Option { unsafe { from_glib_none(gio_sys::g_action_get_state_type( self.as_ref().to_glib_none().0, )) } } fn connect_property_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline( this: *mut gio_sys::GAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Action::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enabled\0".as_ptr() as *const _, Some(transmute(notify_enabled_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_name_trampoline( this: *mut gio_sys::GAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Action::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::name\0".as_ptr() as *const _, Some(transmute(notify_name_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_parameter_type_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_parameter_type_trampoline( this: *mut gio_sys::GAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Action::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::parameter-type\0".as_ptr() as *const _, Some(transmute( notify_parameter_type_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_state_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline( this: *mut gio_sys::GAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Action::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _, Some(transmute(notify_state_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_state_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline( this: *mut gio_sys::GAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Action::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state-type\0".as_ptr() as *const _, Some(transmute(notify_state_type_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Action { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Action") } } gio-0.7.0/src/auto/action_group.rs010064400007650000024000000233461350341657000153250ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib_wrapper! { pub struct ActionGroup(Interface); match fn { get_type => || gio_sys::g_action_group_get_type(), } } pub const NONE_ACTION_GROUP: Option<&ActionGroup> = None; pub trait ActionGroupExt: 'static { fn action_added(&self, action_name: &str); fn action_enabled_changed(&self, action_name: &str, enabled: bool); fn action_removed(&self, action_name: &str); fn action_state_changed(&self, action_name: &str, state: &glib::Variant); fn activate_action(&self, action_name: &str, parameter: Option<&glib::Variant>); fn change_action_state(&self, action_name: &str, value: &glib::Variant); fn get_action_enabled(&self, action_name: &str) -> bool; fn get_action_parameter_type(&self, action_name: &str) -> Option; fn get_action_state(&self, action_name: &str) -> Option; fn get_action_state_hint(&self, action_name: &str) -> Option; fn get_action_state_type(&self, action_name: &str) -> Option; fn has_action(&self, action_name: &str) -> bool; fn list_actions(&self) -> Vec; fn connect_action_added(&self, f: F) -> SignalHandlerId; fn connect_action_enabled_changed( &self, f: F, ) -> SignalHandlerId; fn connect_action_removed(&self, f: F) -> SignalHandlerId; fn connect_action_state_changed( &self, f: F, ) -> SignalHandlerId; } impl> ActionGroupExt for O { fn action_added(&self, action_name: &str) { unsafe { gio_sys::g_action_group_action_added( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } fn action_enabled_changed(&self, action_name: &str, enabled: bool) { unsafe { gio_sys::g_action_group_action_enabled_changed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, enabled.to_glib(), ); } } fn action_removed(&self, action_name: &str) { unsafe { gio_sys::g_action_group_action_removed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } fn action_state_changed(&self, action_name: &str, state: &glib::Variant) { unsafe { gio_sys::g_action_group_action_state_changed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, state.to_glib_none().0, ); } } fn activate_action(&self, action_name: &str, parameter: Option<&glib::Variant>) { unsafe { gio_sys::g_action_group_activate_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, parameter.to_glib_none().0, ); } } fn change_action_state(&self, action_name: &str, value: &glib::Variant) { unsafe { gio_sys::g_action_group_change_action_state( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, value.to_glib_none().0, ); } } fn get_action_enabled(&self, action_name: &str) -> bool { unsafe { from_glib(gio_sys::g_action_group_get_action_enabled( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn get_action_parameter_type(&self, action_name: &str) -> Option { unsafe { from_glib_none(gio_sys::g_action_group_get_action_parameter_type( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn get_action_state(&self, action_name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_action_group_get_action_state( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn get_action_state_hint(&self, action_name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_action_group_get_action_state_hint( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn get_action_state_type(&self, action_name: &str) -> Option { unsafe { from_glib_none(gio_sys::g_action_group_get_action_state_type( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn has_action(&self, action_name: &str) -> bool { unsafe { from_glib(gio_sys::g_action_group_has_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn list_actions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_action_group_list_actions( self.as_ref().to_glib_none().0, )) } } fn connect_action_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn action_added_trampoline( this: *mut gio_sys::GActionGroup, action_name: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &ActionGroup::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(action_name), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"action-added\0".as_ptr() as *const _, Some(transmute(action_added_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_action_enabled_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_enabled_changed_trampoline( this: *mut gio_sys::GActionGroup, action_name: *mut libc::c_char, enabled: glib_sys::gboolean, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &ActionGroup::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(action_name), from_glib(enabled), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"action-enabled-changed\0".as_ptr() as *const _, Some(transmute( action_enabled_changed_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_action_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn action_removed_trampoline( this: *mut gio_sys::GActionGroup, action_name: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &ActionGroup::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(action_name), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"action-removed\0".as_ptr() as *const _, Some(transmute(action_removed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_action_state_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_state_changed_trampoline< P, F: Fn(&P, &str, &glib::Variant) + 'static, >( this: *mut gio_sys::GActionGroup, action_name: *mut libc::c_char, value: *mut glib_sys::GVariant, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &ActionGroup::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(action_name), &from_glib_borrow(value), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"action-state-changed\0".as_ptr() as *const _, Some(transmute( action_state_changed_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for ActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ActionGroup") } } gio-0.7.0/src/auto/action_map.rs010064400007650000024000000036141350341657000147420ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use Action; glib_wrapper! { pub struct ActionMap(Interface); match fn { get_type => || gio_sys::g_action_map_get_type(), } } pub const NONE_ACTION_MAP: Option<&ActionMap> = None; pub trait ActionMapExt: 'static { fn add_action>(&self, action: &P); //fn add_action_entries(&self, entries: /*Ignored*/&[&ActionEntry], user_data: /*Unimplemented*/Option); fn lookup_action(&self, action_name: &str) -> Option; fn remove_action(&self, action_name: &str); } impl> ActionMapExt for O { fn add_action>(&self, action: &P) { unsafe { gio_sys::g_action_map_add_action( self.as_ref().to_glib_none().0, action.as_ref().to_glib_none().0, ); } } //fn add_action_entries(&self, entries: /*Ignored*/&[&ActionEntry], user_data: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_action_map_add_action_entries() } //} fn lookup_action(&self, action_name: &str) -> Option { unsafe { from_glib_none(gio_sys::g_action_map_lookup_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn remove_action(&self, action_name: &str) { unsafe { gio_sys::g_action_map_remove_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } } impl fmt::Display for ActionMap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ActionMap") } } gio-0.7.0/src/auto/app_info.rs010064400007650000024000000345221350341657000144250ustar0000000000000000// 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 #[cfg(feature = "futures")] #[cfg(any(feature = "v2_50", feature = "dox"))] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; #[cfg(any(feature = "v2_50", feature = "dox"))] use glib_sys; #[cfg(any(feature = "v2_50", feature = "dox"))] use gobject_sys; use std; #[cfg(feature = "futures")] #[cfg(any(feature = "v2_50", feature = "dox"))] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use AppInfoCreateFlags; use AppLaunchContext; #[cfg(any(feature = "v2_50", feature = "dox"))] use Cancellable; use Error; use File; use Icon; glib_wrapper! { pub struct AppInfo(Interface); match fn { get_type => || gio_sys::g_app_info_get_type(), } } impl AppInfo { pub fn create_from_commandline>( commandline: P, application_name: Option<&str>, flags: AppInfoCreateFlags, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_app_info_create_from_commandline( commandline.as_ref().to_glib_none().0, application_name.to_glib_none().0, flags.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn get_all() -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_app_info_get_all()) } } pub fn get_all_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_app_info_get_all_for_type( content_type.to_glib_none().0, )) } } pub fn get_default_for_type(content_type: &str, must_support_uris: bool) -> Option { unsafe { from_glib_full(gio_sys::g_app_info_get_default_for_type( content_type.to_glib_none().0, must_support_uris.to_glib(), )) } } pub fn get_default_for_uri_scheme(uri_scheme: &str) -> Option { unsafe { from_glib_full(gio_sys::g_app_info_get_default_for_uri_scheme( uri_scheme.to_glib_none().0, )) } } pub fn get_fallback_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_app_info_get_fallback_for_type( content_type.to_glib_none().0, )) } } pub fn get_recommended_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_app_info_get_recommended_for_type( content_type.to_glib_none().0, )) } } pub fn launch_default_for_uri>( uri: &str, context: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_launch_default_for_uri( uri.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_50", feature = "dox"))] pub fn launch_default_for_uri_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( uri: &str, context: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn launch_default_for_uri_async_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_launch_default_for_uri_finish(res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = launch_default_for_uri_async_trampoline::; unsafe { gio_sys::g_app_info_launch_default_for_uri_async( uri.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_50", feature = "dox"))] pub fn launch_default_for_uri_async_future + Clone + 'static>( uri: &str, context: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let uri = String::from(uri); let context = context.map(ToOwned::to_owned); GioFuture::new(&(), move |_obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); Self::launch_default_for_uri_async( &uri, context.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } pub fn reset_type_associations(content_type: &str) { unsafe { gio_sys::g_app_info_reset_type_associations(content_type.to_glib_none().0); } } } pub const NONE_APP_INFO: Option<&AppInfo> = None; pub trait AppInfoExt: 'static { fn add_supports_type(&self, content_type: &str) -> Result<(), Error>; fn can_delete(&self) -> bool; fn can_remove_supports_type(&self) -> bool; fn delete(&self) -> bool; fn dup(&self) -> Option; fn equal>(&self, appinfo2: &P) -> bool; fn get_commandline(&self) -> Option; fn get_description(&self) -> Option; fn get_display_name(&self) -> Option; fn get_executable(&self) -> Option; fn get_icon(&self) -> Option; fn get_id(&self) -> Option; fn get_name(&self) -> Option; fn get_supported_types(&self) -> Vec; fn launch>( &self, files: &[File], context: Option<&P>, ) -> Result<(), Error>; fn launch_uris>( &self, uris: &[&str], context: Option<&P>, ) -> Result<(), Error>; fn remove_supports_type(&self, content_type: &str) -> Result<(), Error>; fn set_as_default_for_extension>( &self, extension: P, ) -> Result<(), Error>; fn set_as_default_for_type(&self, content_type: &str) -> Result<(), Error>; fn set_as_last_used_for_type(&self, content_type: &str) -> Result<(), Error>; fn should_show(&self) -> bool; fn supports_files(&self) -> bool; fn supports_uris(&self) -> bool; } impl> AppInfoExt for O { fn add_supports_type(&self, content_type: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_add_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn can_delete(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_can_delete( self.as_ref().to_glib_none().0, )) } } fn can_remove_supports_type(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_can_remove_supports_type( self.as_ref().to_glib_none().0, )) } } fn delete(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_delete(self.as_ref().to_glib_none().0)) } } fn dup(&self) -> Option { unsafe { from_glib_full(gio_sys::g_app_info_dup(self.as_ref().to_glib_none().0)) } } fn equal>(&self, appinfo2: &P) -> bool { unsafe { from_glib(gio_sys::g_app_info_equal( self.as_ref().to_glib_none().0, appinfo2.as_ref().to_glib_none().0, )) } } fn get_commandline(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_commandline( self.as_ref().to_glib_none().0, )) } } fn get_description(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_description( self.as_ref().to_glib_none().0, )) } } fn get_display_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_display_name( self.as_ref().to_glib_none().0, )) } } fn get_executable(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_executable( self.as_ref().to_glib_none().0, )) } } fn get_icon(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_icon(self.as_ref().to_glib_none().0)) } } fn get_id(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_id(self.as_ref().to_glib_none().0)) } } fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_app_info_get_name(self.as_ref().to_glib_none().0)) } } fn get_supported_types(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_app_info_get_supported_types( self.as_ref().to_glib_none().0, )) } } fn launch>( &self, files: &[File], context: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_launch( self.as_ref().to_glib_none().0, files.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn launch_uris>( &self, uris: &[&str], context: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_launch_uris( self.as_ref().to_glib_none().0, uris.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn remove_supports_type(&self, content_type: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_remove_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_default_for_extension>( &self, extension: P, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_set_as_default_for_extension( self.as_ref().to_glib_none().0, extension.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_default_for_type(&self, content_type: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_set_as_default_for_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_last_used_for_type(&self, content_type: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_app_info_set_as_last_used_for_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn should_show(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_should_show( self.as_ref().to_glib_none().0, )) } } fn supports_files(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_supports_files( self.as_ref().to_glib_none().0, )) } } fn supports_uris(&self) -> bool { unsafe { from_glib(gio_sys::g_app_info_supports_uris( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for AppInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AppInfo") } } gio-0.7.0/src/auto/app_info_monitor.rs010064400007650000024000000027521350341657000161740ustar0000000000000000// 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 gio_sys; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib_wrapper! { pub struct AppInfoMonitor(Object); match fn { get_type => || gio_sys::g_app_info_monitor_get_type(), } } impl AppInfoMonitor { pub fn get() -> AppInfoMonitor { unsafe { from_glib_full(gio_sys::g_app_info_monitor_get()) } } pub fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut gio_sys::GAppInfoMonitor, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for AppInfoMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AppInfoMonitor") } } gio-0.7.0/src/auto/app_launch_context.rs010064400007650000024000000131311350341657000165010ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use libc; use std; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use AppInfo; use File; glib_wrapper! { pub struct AppLaunchContext(Object); match fn { get_type => || gio_sys::g_app_launch_context_get_type(), } } impl AppLaunchContext { pub fn new() -> AppLaunchContext { unsafe { from_glib_full(gio_sys::g_app_launch_context_new()) } } } impl Default for AppLaunchContext { fn default() -> Self { Self::new() } } pub const NONE_APP_LAUNCH_CONTEXT: Option<&AppLaunchContext> = None; pub trait AppLaunchContextExt: 'static { fn get_display>(&self, info: &P, files: &[File]) -> Option; fn get_environment(&self) -> Vec; fn get_startup_notify_id>(&self, info: &P, files: &[File]) -> Option; fn launch_failed(&self, startup_notify_id: &str); fn setenv, Q: AsRef>(&self, variable: P, value: Q); fn unsetenv>(&self, variable: P); fn connect_launch_failed(&self, f: F) -> SignalHandlerId; fn connect_launched( &self, f: F, ) -> SignalHandlerId; } impl> AppLaunchContextExt for O { fn get_display>(&self, info: &P, files: &[File]) -> Option { unsafe { from_glib_full(gio_sys::g_app_launch_context_get_display( self.as_ref().to_glib_none().0, info.as_ref().to_glib_none().0, files.to_glib_none().0, )) } } fn get_environment(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_app_launch_context_get_environment( self.as_ref().to_glib_none().0, )) } } fn get_startup_notify_id>(&self, info: &P, files: &[File]) -> Option { unsafe { from_glib_full(gio_sys::g_app_launch_context_get_startup_notify_id( self.as_ref().to_glib_none().0, info.as_ref().to_glib_none().0, files.to_glib_none().0, )) } } fn launch_failed(&self, startup_notify_id: &str) { unsafe { gio_sys::g_app_launch_context_launch_failed( self.as_ref().to_glib_none().0, startup_notify_id.to_glib_none().0, ); } } fn setenv, Q: AsRef>(&self, variable: P, value: Q) { unsafe { gio_sys::g_app_launch_context_setenv( self.as_ref().to_glib_none().0, variable.as_ref().to_glib_none().0, value.as_ref().to_glib_none().0, ); } } fn unsetenv>(&self, variable: P) { unsafe { gio_sys::g_app_launch_context_unsetenv( self.as_ref().to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } fn connect_launch_failed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn launch_failed_trampoline( this: *mut gio_sys::GAppLaunchContext, startup_notify_id: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &AppLaunchContext::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(startup_notify_id), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"launch-failed\0".as_ptr() as *const _, Some(transmute(launch_failed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_launched( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn launched_trampoline( this: *mut gio_sys::GAppLaunchContext, info: *mut gio_sys::GAppInfo, platform_data: *mut glib_sys::GVariant, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &AppLaunchContext::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(info), &from_glib_borrow(platform_data), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"launched\0".as_ptr() as *const _, Some(transmute(launched_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for AppLaunchContext { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "AppLaunchContext") } } gio-0.7.0/src/auto/application.rs010064400007650000024000000634241350341657000151400ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use ActionGroup; use ActionMap; use ApplicationCommandLine; use ApplicationFlags; use Cancellable; use Error; use File; use Notification; glib_wrapper! { pub struct Application(Object) @implements ActionGroup, ActionMap; match fn { get_type => || gio_sys::g_application_get_type(), } } impl Application { pub fn new(application_id: Option<&str>, flags: ApplicationFlags) -> Application { unsafe { from_glib_full(gio_sys::g_application_new( application_id.to_glib_none().0, flags.to_glib(), )) } } pub fn get_default() -> Option { unsafe { from_glib_none(gio_sys::g_application_get_default()) } } pub fn id_is_valid(application_id: &str) -> bool { unsafe { from_glib(gio_sys::g_application_id_is_valid( application_id.to_glib_none().0, )) } } } pub struct ApplicationBuilder { action_group: Option, application_id: Option, flags: Option, inactivity_timeout: Option, resource_base_path: Option, } impl ApplicationBuilder { pub fn new() -> Self { Self { action_group: None, application_id: None, flags: None, inactivity_timeout: None, resource_base_path: None, } } pub fn build(self) -> Application { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref action_group) = self.action_group { properties.push(("action-group", action_group)); } if let Some(ref application_id) = self.application_id { properties.push(("application-id", application_id)); } if let Some(ref flags) = self.flags { properties.push(("flags", flags)); } if let Some(ref inactivity_timeout) = self.inactivity_timeout { properties.push(("inactivity-timeout", inactivity_timeout)); } if let Some(ref resource_base_path) = self.resource_base_path { properties.push(("resource-base-path", resource_base_path)); } glib::Object::new(Application::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn action_group(mut self, action_group: &ActionGroup) -> Self { self.action_group = Some(action_group.clone()); self } pub fn application_id(mut self, application_id: &str) -> Self { self.application_id = Some(application_id.to_string()); self } pub fn flags(mut self, flags: ApplicationFlags) -> Self { self.flags = Some(flags); self } pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self { self.inactivity_timeout = Some(inactivity_timeout); self } pub fn resource_base_path(mut self, resource_base_path: &str) -> Self { self.resource_base_path = Some(resource_base_path.to_string()); self } } pub const NONE_APPLICATION: Option<&Application> = None; pub trait ApplicationExt: 'static { fn activate(&self); fn add_main_option( &self, long_name: &str, short_name: glib::Char, flags: glib::OptionFlags, arg: glib::OptionArg, description: &str, arg_description: Option<&str>, ); //fn add_main_option_entries(&self, entries: /*Ignored*/&[&glib::OptionEntry]); //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup); #[cfg(any(feature = "v2_44", feature = "dox"))] fn bind_busy_property>(&self, object: &P, property: &str); fn get_application_id(&self) -> Option; //fn get_dbus_connection(&self) -> /*Ignored*/Option; fn get_dbus_object_path(&self) -> Option; fn get_flags(&self) -> ApplicationFlags; fn get_inactivity_timeout(&self) -> u32; #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_is_busy(&self) -> bool; fn get_is_registered(&self) -> bool; fn get_is_remote(&self) -> bool; fn get_resource_base_path(&self) -> Option; fn hold(&self); fn mark_busy(&self); fn open(&self, files: &[File], hint: &str); fn quit(&self); fn register>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn release(&self); fn send_notification(&self, id: Option<&str>, notification: &Notification); fn set_application_id(&self, application_id: Option<&str>); fn set_default(&self); fn set_flags(&self, flags: ApplicationFlags); fn set_inactivity_timeout(&self, inactivity_timeout: u32); #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_description(&self, description: Option<&str>); #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_parameter_string(&self, parameter_string: Option<&str>); #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_summary(&self, summary: Option<&str>); fn set_resource_base_path(&self, resource_path: Option<&str>); #[cfg(any(feature = "v2_44", feature = "dox"))] fn unbind_busy_property>(&self, object: &P, property: &str); fn unmark_busy(&self); fn withdraw_notification(&self, id: &str); fn set_property_action_group(&self, action_group: Option<&ActionGroup>); fn connect_activate(&self, f: F) -> SignalHandlerId; fn connect_command_line i32 + 'static>( &self, f: F, ) -> SignalHandlerId; //fn connect_handle_local_options(&self, f: F) -> SignalHandlerId; fn connect_shutdown(&self, f: F) -> SignalHandlerId; fn connect_startup(&self, f: F) -> SignalHandlerId; fn connect_property_action_group_notify(&self, f: F) -> SignalHandlerId; fn connect_property_application_id_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_flags_notify(&self, f: F) -> SignalHandlerId; fn connect_property_inactivity_timeout_notify( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_property_is_busy_notify(&self, f: F) -> SignalHandlerId; fn connect_property_is_registered_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_remote_notify(&self, f: F) -> SignalHandlerId; fn connect_property_resource_base_path_notify( &self, f: F, ) -> SignalHandlerId; } impl> ApplicationExt for O { fn activate(&self) { unsafe { gio_sys::g_application_activate(self.as_ref().to_glib_none().0); } } fn add_main_option( &self, long_name: &str, short_name: glib::Char, flags: glib::OptionFlags, arg: glib::OptionArg, description: &str, arg_description: Option<&str>, ) { unsafe { gio_sys::g_application_add_main_option( self.as_ref().to_glib_none().0, long_name.to_glib_none().0, short_name.to_glib(), flags.to_glib(), arg.to_glib(), description.to_glib_none().0, arg_description.to_glib_none().0, ); } } //fn add_main_option_entries(&self, entries: /*Ignored*/&[&glib::OptionEntry]) { // unsafe { TODO: call gio_sys:g_application_add_main_option_entries() } //} //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup) { // unsafe { TODO: call gio_sys:g_application_add_option_group() } //} #[cfg(any(feature = "v2_44", feature = "dox"))] fn bind_busy_property>(&self, object: &P, property: &str) { unsafe { gio_sys::g_application_bind_busy_property( self.as_ref().to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, ); } } fn get_application_id(&self) -> Option { unsafe { from_glib_none(gio_sys::g_application_get_application_id( self.as_ref().to_glib_none().0, )) } } //fn get_dbus_connection(&self) -> /*Ignored*/Option { // unsafe { TODO: call gio_sys:g_application_get_dbus_connection() } //} fn get_dbus_object_path(&self) -> Option { unsafe { from_glib_none(gio_sys::g_application_get_dbus_object_path( self.as_ref().to_glib_none().0, )) } } fn get_flags(&self) -> ApplicationFlags { unsafe { from_glib(gio_sys::g_application_get_flags( self.as_ref().to_glib_none().0, )) } } fn get_inactivity_timeout(&self) -> u32 { unsafe { gio_sys::g_application_get_inactivity_timeout(self.as_ref().to_glib_none().0) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_is_busy(&self) -> bool { unsafe { from_glib(gio_sys::g_application_get_is_busy( self.as_ref().to_glib_none().0, )) } } fn get_is_registered(&self) -> bool { unsafe { from_glib(gio_sys::g_application_get_is_registered( self.as_ref().to_glib_none().0, )) } } fn get_is_remote(&self) -> bool { unsafe { from_glib(gio_sys::g_application_get_is_remote( self.as_ref().to_glib_none().0, )) } } fn get_resource_base_path(&self) -> Option { unsafe { from_glib_none(gio_sys::g_application_get_resource_base_path( self.as_ref().to_glib_none().0, )) } } fn hold(&self) { unsafe { gio_sys::g_application_hold(self.as_ref().to_glib_none().0); } } fn mark_busy(&self) { unsafe { gio_sys::g_application_mark_busy(self.as_ref().to_glib_none().0); } } fn open(&self, files: &[File], hint: &str) { let n_files = files.len() as i32; unsafe { gio_sys::g_application_open( self.as_ref().to_glib_none().0, files.to_glib_none().0, n_files, hint.to_glib_none().0, ); } } fn quit(&self) { unsafe { gio_sys::g_application_quit(self.as_ref().to_glib_none().0); } } fn register>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_application_register( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn release(&self) { unsafe { gio_sys::g_application_release(self.as_ref().to_glib_none().0); } } fn send_notification(&self, id: Option<&str>, notification: &Notification) { unsafe { gio_sys::g_application_send_notification( self.as_ref().to_glib_none().0, id.to_glib_none().0, notification.to_glib_none().0, ); } } fn set_application_id(&self, application_id: Option<&str>) { unsafe { gio_sys::g_application_set_application_id( self.as_ref().to_glib_none().0, application_id.to_glib_none().0, ); } } fn set_default(&self) { unsafe { gio_sys::g_application_set_default(self.as_ref().to_glib_none().0); } } fn set_flags(&self, flags: ApplicationFlags) { unsafe { gio_sys::g_application_set_flags(self.as_ref().to_glib_none().0, flags.to_glib()); } } fn set_inactivity_timeout(&self, inactivity_timeout: u32) { unsafe { gio_sys::g_application_set_inactivity_timeout( self.as_ref().to_glib_none().0, inactivity_timeout, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_description(&self, description: Option<&str>) { unsafe { gio_sys::g_application_set_option_context_description( self.as_ref().to_glib_none().0, description.to_glib_none().0, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_parameter_string(&self, parameter_string: Option<&str>) { unsafe { gio_sys::g_application_set_option_context_parameter_string( self.as_ref().to_glib_none().0, parameter_string.to_glib_none().0, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn set_option_context_summary(&self, summary: Option<&str>) { unsafe { gio_sys::g_application_set_option_context_summary( self.as_ref().to_glib_none().0, summary.to_glib_none().0, ); } } fn set_resource_base_path(&self, resource_path: Option<&str>) { unsafe { gio_sys::g_application_set_resource_base_path( self.as_ref().to_glib_none().0, resource_path.to_glib_none().0, ); } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn unbind_busy_property>(&self, object: &P, property: &str) { unsafe { gio_sys::g_application_unbind_busy_property( self.as_ref().to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, ); } } fn unmark_busy(&self) { unsafe { gio_sys::g_application_unmark_busy(self.as_ref().to_glib_none().0); } } fn withdraw_notification(&self, id: &str) { unsafe { gio_sys::g_application_withdraw_notification( self.as_ref().to_glib_none().0, id.to_glib_none().0, ); } } fn set_property_action_group(&self, action_group: Option<&ActionGroup>) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"action-group\0".as_ptr() as *const _, Value::from(action_group).to_glib_none().0, ); } } fn connect_activate(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn activate_trampoline( this: *mut gio_sys::GApplication, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"activate\0".as_ptr() as *const _, Some(transmute(activate_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_command_line i32 + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn command_line_trampoline< P, F: Fn(&P, &ApplicationCommandLine) -> i32 + 'static, >( this: *mut gio_sys::GApplication, command_line: *mut gio_sys::GApplicationCommandLine, f: glib_sys::gpointer, ) -> libc::c_int where P: IsA, { let f: &F = &*(f as *const F); f( &Application::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(command_line), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"command-line\0".as_ptr() as *const _, Some(transmute(command_line_trampoline:: as usize)), Box_::into_raw(f), ) } } //fn connect_handle_local_options(&self, f: F) -> SignalHandlerId { // Ignored options: GLib.VariantDict //} fn connect_shutdown(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn shutdown_trampoline( this: *mut gio_sys::GApplication, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"shutdown\0".as_ptr() as *const _, Some(transmute(shutdown_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_startup(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn startup_trampoline( this: *mut gio_sys::GApplication, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"startup\0".as_ptr() as *const _, Some(transmute(startup_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_action_group_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_action_group_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::action-group\0".as_ptr() as *const _, Some(transmute( notify_action_group_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_application_id_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_application_id_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::application-id\0".as_ptr() as *const _, Some(transmute( notify_application_id_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_flags_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::flags\0".as_ptr() as *const _, Some(transmute(notify_flags_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_inactivity_timeout_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_inactivity_timeout_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::inactivity-timeout\0".as_ptr() as *const _, Some(transmute( notify_inactivity_timeout_trampoline:: as usize, )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_property_is_busy_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_busy_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-busy\0".as_ptr() as *const _, Some(transmute(notify_is_busy_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_is_registered_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_registered_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-registered\0".as_ptr() as *const _, Some(transmute( notify_is_registered_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_remote_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_remote_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-remote\0".as_ptr() as *const _, Some(transmute(notify_is_remote_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_resource_base_path_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_resource_base_path_trampoline( this: *mut gio_sys::GApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Application::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::resource-base-path\0".as_ptr() as *const _, Some(transmute( notify_resource_base_path_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for Application { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Application") } } gio-0.7.0/src/auto/application_command_line.rs010064400007650000024000000135671350341657000176500ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use File; use InputStream; glib_wrapper! { pub struct ApplicationCommandLine(Object); match fn { get_type => || gio_sys::g_application_command_line_get_type(), } } pub const NONE_APPLICATION_COMMAND_LINE: Option<&ApplicationCommandLine> = None; pub trait ApplicationCommandLineExt: 'static { fn create_file_for_arg>(&self, arg: P) -> Option; fn get_arguments(&self) -> Vec; fn get_cwd(&self) -> Option; fn get_environ(&self) -> Vec; fn get_exit_status(&self) -> i32; fn get_is_remote(&self) -> bool; //fn get_options_dict(&self) -> /*Ignored*/Option; fn get_platform_data(&self) -> Option; fn get_stdin(&self) -> Option; fn getenv>(&self, name: P) -> Option; //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); fn set_exit_status(&self, exit_status: i32); fn connect_property_is_remote_notify(&self, f: F) -> SignalHandlerId; } impl> ApplicationCommandLineExt for O { fn create_file_for_arg>(&self, arg: P) -> Option { unsafe { from_glib_full(gio_sys::g_application_command_line_create_file_for_arg( self.as_ref().to_glib_none().0, arg.as_ref().to_glib_none().0, )) } } fn get_arguments(&self) -> Vec { unsafe { let mut argc = mem::uninitialized(); let ret = FromGlibContainer::from_glib_full_num( gio_sys::g_application_command_line_get_arguments( self.as_ref().to_glib_none().0, &mut argc, ), argc as usize, ); ret } } fn get_cwd(&self) -> Option { unsafe { from_glib_none(gio_sys::g_application_command_line_get_cwd( self.as_ref().to_glib_none().0, )) } } fn get_environ(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_application_command_line_get_environ( self.as_ref().to_glib_none().0, )) } } fn get_exit_status(&self) -> i32 { unsafe { gio_sys::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) } } fn get_is_remote(&self) -> bool { unsafe { from_glib(gio_sys::g_application_command_line_get_is_remote( self.as_ref().to_glib_none().0, )) } } //fn get_options_dict(&self) -> /*Ignored*/Option { // unsafe { TODO: call gio_sys:g_application_command_line_get_options_dict() } //} fn get_platform_data(&self) -> Option { unsafe { from_glib_full(gio_sys::g_application_command_line_get_platform_data( self.as_ref().to_glib_none().0, )) } } fn get_stdin(&self) -> Option { unsafe { from_glib_full(gio_sys::g_application_command_line_get_stdin( self.as_ref().to_glib_none().0, )) } } fn getenv>(&self, name: P) -> Option { unsafe { from_glib_none(gio_sys::g_application_command_line_getenv( self.as_ref().to_glib_none().0, name.as_ref().to_glib_none().0, )) } } //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_application_command_line_print() } //} //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_application_command_line_printerr() } //} fn set_exit_status(&self, exit_status: i32) { unsafe { gio_sys::g_application_command_line_set_exit_status( self.as_ref().to_glib_none().0, exit_status, ); } } fn connect_property_is_remote_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_remote_trampoline( this: *mut gio_sys::GApplicationCommandLine, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&ApplicationCommandLine::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-remote\0".as_ptr() as *const _, Some(transmute(notify_is_remote_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ApplicationCommandLine { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ApplicationCommandLine") } } gio-0.7.0/src/auto/buffered_input_stream.rs010064400007650000024000000217721350341657000172110ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use FilterInputStream; use InputStream; use Seekable; glib_wrapper! { pub struct BufferedInputStream(Object) @extends FilterInputStream, InputStream, @implements Seekable; match fn { get_type => || gio_sys::g_buffered_input_stream_get_type(), } } impl BufferedInputStream { pub fn new>(base_stream: &P) -> BufferedInputStream { unsafe { InputStream::from_glib_full(gio_sys::g_buffered_input_stream_new( base_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } pub fn new_sized>(base_stream: &P, size: usize) -> BufferedInputStream { unsafe { InputStream::from_glib_full(gio_sys::g_buffered_input_stream_new_sized( base_stream.as_ref().to_glib_none().0, size, )) .unsafe_cast() } } } pub struct BufferedInputStreamBuilder { buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl BufferedInputStreamBuilder { pub fn new() -> Self { Self { buffer_size: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> BufferedInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(BufferedInputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream(mut self, base_stream: &InputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_BUFFERED_INPUT_STREAM: Option<&BufferedInputStream> = None; pub trait BufferedInputStreamExt: 'static { fn fill>( &self, count: isize, cancellable: Option<&P>, ) -> Result; fn fill_async, Q: FnOnce(Result) + Send + 'static>( &self, count: isize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn fill_async_future( &self, count: isize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn get_available(&self) -> usize; fn get_buffer_size(&self) -> usize; fn peek_buffer(&self) -> Vec; fn read_byte>(&self, cancellable: Option<&P>) -> Result; fn set_buffer_size(&self, size: usize); fn connect_property_buffer_size_notify(&self, f: F) -> SignalHandlerId; } impl> BufferedInputStreamExt for O { fn fill>( &self, count: isize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_buffered_input_stream_fill( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn fill_async, Q: FnOnce(Result) + Send + 'static>( &self, count: isize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn fill_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_buffered_input_stream_fill_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = fill_async_trampoline::; unsafe { gio_sys::g_buffered_input_stream_fill_async( self.as_ref().to_glib_none().0, count, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn fill_async_future( &self, count: isize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.fill_async(count, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn get_available(&self) -> usize { unsafe { gio_sys::g_buffered_input_stream_get_available(self.as_ref().to_glib_none().0) } } fn get_buffer_size(&self) -> usize { unsafe { gio_sys::g_buffered_input_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } fn peek_buffer(&self) -> Vec { unsafe { let mut count = mem::uninitialized(); let ret = FromGlibContainer::from_glib_none_num( gio_sys::g_buffered_input_stream_peek_buffer( self.as_ref().to_glib_none().0, &mut count, ), count as usize, ); ret } } fn read_byte>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_buffered_input_stream_read_byte( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn set_buffer_size(&self, size: usize) { unsafe { gio_sys::g_buffered_input_stream_set_buffer_size(self.as_ref().to_glib_none().0, size); } } fn connect_property_buffer_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_buffer_size_trampoline( this: *mut gio_sys::GBufferedInputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&BufferedInputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::buffer-size\0".as_ptr() as *const _, Some(transmute(notify_buffer_size_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for BufferedInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "BufferedInputStream") } } gio-0.7.0/src/auto/buffered_output_stream.rs010064400007650000024000000143751350341657000174130ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use FilterOutputStream; use OutputStream; use Seekable; glib_wrapper! { pub struct BufferedOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements Seekable; match fn { get_type => || gio_sys::g_buffered_output_stream_get_type(), } } impl BufferedOutputStream { pub fn new>(base_stream: &P) -> BufferedOutputStream { unsafe { OutputStream::from_glib_full(gio_sys::g_buffered_output_stream_new( base_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } pub fn new_sized>(base_stream: &P, size: usize) -> BufferedOutputStream { unsafe { OutputStream::from_glib_full(gio_sys::g_buffered_output_stream_new_sized( base_stream.as_ref().to_glib_none().0, size, )) .unsafe_cast() } } } pub struct BufferedOutputStreamBuilder { auto_grow: Option, buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl BufferedOutputStreamBuilder { pub fn new() -> Self { Self { auto_grow: None, buffer_size: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> BufferedOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref auto_grow) = self.auto_grow { properties.push(("auto-grow", auto_grow)); } if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(BufferedOutputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn auto_grow(mut self, auto_grow: bool) -> Self { self.auto_grow = Some(auto_grow); self } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream(mut self, base_stream: &OutputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_BUFFERED_OUTPUT_STREAM: Option<&BufferedOutputStream> = None; pub trait BufferedOutputStreamExt: 'static { fn get_auto_grow(&self) -> bool; fn get_buffer_size(&self) -> usize; fn set_auto_grow(&self, auto_grow: bool); fn set_buffer_size(&self, size: usize); fn connect_property_auto_grow_notify(&self, f: F) -> SignalHandlerId; fn connect_property_buffer_size_notify(&self, f: F) -> SignalHandlerId; } impl> BufferedOutputStreamExt for O { fn get_auto_grow(&self) -> bool { unsafe { from_glib(gio_sys::g_buffered_output_stream_get_auto_grow( self.as_ref().to_glib_none().0, )) } } fn get_buffer_size(&self) -> usize { unsafe { gio_sys::g_buffered_output_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } fn set_auto_grow(&self, auto_grow: bool) { unsafe { gio_sys::g_buffered_output_stream_set_auto_grow( self.as_ref().to_glib_none().0, auto_grow.to_glib(), ); } } fn set_buffer_size(&self, size: usize) { unsafe { gio_sys::g_buffered_output_stream_set_buffer_size(self.as_ref().to_glib_none().0, size); } } fn connect_property_auto_grow_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_auto_grow_trampoline( this: *mut gio_sys::GBufferedOutputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&BufferedOutputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::auto-grow\0".as_ptr() as *const _, Some(transmute(notify_auto_grow_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_buffer_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_buffer_size_trampoline( this: *mut gio_sys::GBufferedOutputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&BufferedOutputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::buffer-size\0".as_ptr() as *const _, Some(transmute(notify_buffer_size_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for BufferedOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "BufferedOutputStream") } } gio-0.7.0/src/auto/bytes_icon.rs010064400007650000024000000015501350341657000147630ustar0000000000000000// 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 gio_sys; use glib; use glib::translate::*; use std::fmt; use Icon; use LoadableIcon; glib_wrapper! { pub struct BytesIcon(Object) @implements Icon, LoadableIcon; match fn { get_type => || gio_sys::g_bytes_icon_get_type(), } } impl BytesIcon { pub fn new(bytes: &glib::Bytes) -> BytesIcon { unsafe { from_glib_full(gio_sys::g_bytes_icon_new(bytes.to_glib_none().0)) } } pub fn get_bytes(&self) -> Option { unsafe { from_glib_none(gio_sys::g_bytes_icon_get_bytes(self.to_glib_none().0)) } } } impl fmt::Display for BytesIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "BytesIcon") } } gio-0.7.0/src/auto/cancellable.rs010064400007650000024000000106531350341657000150560ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; glib_wrapper! { pub struct Cancellable(Object); match fn { get_type => || gio_sys::g_cancellable_get_type(), } } impl Cancellable { pub fn new() -> Cancellable { unsafe { from_glib_full(gio_sys::g_cancellable_new()) } } pub fn get_current() -> Option { unsafe { from_glib_none(gio_sys::g_cancellable_get_current()) } } } impl Default for Cancellable { fn default() -> Self { Self::new() } } unsafe impl Send for Cancellable {} unsafe impl Sync for Cancellable {} pub const NONE_CANCELLABLE: Option<&Cancellable> = None; pub trait CancellableExt: 'static { fn cancel(&self); //fn connect(&self, callback: P, data: /*Unimplemented*/Option) -> libc::c_ulong; fn disconnect(&self, handler_id: libc::c_ulong); fn get_fd(&self) -> i32; fn is_cancelled(&self) -> bool; //fn make_pollfd(&self, pollfd: /*Ignored*/&mut glib::PollFD) -> bool; fn pop_current(&self); fn push_current(&self); fn release_fd(&self); fn set_error_if_cancelled(&self) -> Result<(), Error>; fn connect_cancelled(&self, f: F) -> SignalHandlerId; } impl> CancellableExt for O { fn cancel(&self) { unsafe { gio_sys::g_cancellable_cancel(self.as_ref().to_glib_none().0); } } //fn connect(&self, callback: P, data: /*Unimplemented*/Option) -> libc::c_ulong { // unsafe { TODO: call gio_sys:g_cancellable_connect() } //} fn disconnect(&self, handler_id: libc::c_ulong) { unsafe { gio_sys::g_cancellable_disconnect(self.as_ref().to_glib_none().0, handler_id); } } fn get_fd(&self) -> i32 { unsafe { gio_sys::g_cancellable_get_fd(self.as_ref().to_glib_none().0) } } fn is_cancelled(&self) -> bool { unsafe { from_glib(gio_sys::g_cancellable_is_cancelled( self.as_ref().to_glib_none().0, )) } } //fn make_pollfd(&self, pollfd: /*Ignored*/&mut glib::PollFD) -> bool { // unsafe { TODO: call gio_sys:g_cancellable_make_pollfd() } //} fn pop_current(&self) { unsafe { gio_sys::g_cancellable_pop_current(self.as_ref().to_glib_none().0); } } fn push_current(&self) { unsafe { gio_sys::g_cancellable_push_current(self.as_ref().to_glib_none().0); } } fn release_fd(&self) { unsafe { gio_sys::g_cancellable_release_fd(self.as_ref().to_glib_none().0); } } fn set_error_if_cancelled(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_cancellable_set_error_if_cancelled( self.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect_cancelled(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn cancelled_trampoline( this: *mut gio_sys::GCancellable, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Cancellable::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"cancelled\0".as_ptr() as *const _, Some(transmute(cancelled_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Cancellable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Cancellable") } } gio-0.7.0/src/auto/charset_converter.rs010064400007650000024000000131741350341657000163520ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::ToValue; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Converter; use Error; glib_wrapper! { pub struct CharsetConverter(Object) @implements Converter; match fn { get_type => || gio_sys::g_charset_converter_get_type(), } } impl CharsetConverter { pub fn new(to_charset: &str, from_charset: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_charset_converter_new( to_charset.to_glib_none().0, from_charset.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub struct CharsetConverterBuilder { from_charset: Option, to_charset: Option, use_fallback: Option, } impl CharsetConverterBuilder { pub fn new() -> Self { Self { from_charset: None, to_charset: None, use_fallback: None, } } pub fn build(self) -> CharsetConverter { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref from_charset) = self.from_charset { properties.push(("from-charset", from_charset)); } if let Some(ref to_charset) = self.to_charset { properties.push(("to-charset", to_charset)); } if let Some(ref use_fallback) = self.use_fallback { properties.push(("use-fallback", use_fallback)); } glib::Object::new(CharsetConverter::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn from_charset(mut self, from_charset: &str) -> Self { self.from_charset = Some(from_charset.to_string()); self } pub fn to_charset(mut self, to_charset: &str) -> Self { self.to_charset = Some(to_charset.to_string()); self } pub fn use_fallback(mut self, use_fallback: bool) -> Self { self.use_fallback = Some(use_fallback); self } } pub const NONE_CHARSET_CONVERTER: Option<&CharsetConverter> = None; pub trait CharsetConverterExt: 'static { fn get_num_fallbacks(&self) -> u32; fn get_use_fallback(&self) -> bool; fn set_use_fallback(&self, use_fallback: bool); fn get_property_from_charset(&self) -> Option; fn get_property_to_charset(&self) -> Option; fn connect_property_use_fallback_notify(&self, f: F) -> SignalHandlerId; } impl> CharsetConverterExt for O { fn get_num_fallbacks(&self) -> u32 { unsafe { gio_sys::g_charset_converter_get_num_fallbacks(self.as_ref().to_glib_none().0) } } fn get_use_fallback(&self) -> bool { unsafe { from_glib(gio_sys::g_charset_converter_get_use_fallback( self.as_ref().to_glib_none().0, )) } } fn set_use_fallback(&self, use_fallback: bool) { unsafe { gio_sys::g_charset_converter_set_use_fallback( self.as_ref().to_glib_none().0, use_fallback.to_glib(), ); } } fn get_property_from_charset(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"from-charset\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn get_property_to_charset(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"to-charset\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn connect_property_use_fallback_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_use_fallback_trampoline( this: *mut gio_sys::GCharsetConverter, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&CharsetConverter::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::use-fallback\0".as_ptr() as *const _, Some(transmute( notify_use_fallback_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for CharsetConverter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "CharsetConverter") } } gio-0.7.0/src/auto/constants.rs010064400007650000024000000543271350341657000146530ustar0000000000000000// 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 gio_sys; use std::ffi::CStr; lazy_static! { pub static ref DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } #[cfg(any(feature = "v2_58", feature = "dox"))] lazy_static! { pub static ref DRIVE_IDENTIFIER_KIND_UNIX_DEVICE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_DELETE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_READ: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_READ) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_RENAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_TRASH: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ACCESS_CAN_WRITE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_DOS_IS_ARCHIVE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_DOS_IS_SYSTEM: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_DOS_IS_SYSTEM) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ETAG_VALUE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ETAG_VALUE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_FREE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_FREE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_READONLY: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_READONLY) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_REMOTE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_SIZE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_SIZE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_TYPE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_TYPE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_USED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_USED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_GVFS_BACKEND: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_GVFS_BACKEND) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ID_FILE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ID_FILE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_ID_FILESYSTEM: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_ID_FILESYSTEM) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_START: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_OWNER_GROUP: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_OWNER_GROUP) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_OWNER_USER: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_OWNER_USER) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_OWNER_USER_REAL: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_OWNER_USER_REAL) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_PREVIEW_ICON: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_PREVIEW_ICON) .to_str() .unwrap() }; } #[cfg(any(feature = "v2_52", feature = "dox"))] lazy_static! { pub static ref FILE_ATTRIBUTE_RECENT_MODIFIED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_RECENT_MODIFIED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_SELINUX_CONTEXT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_SELINUX_CONTEXT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_COPY_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_COPY_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_DESCRIPTION: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_EDIT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_ICON: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_ICON) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_IS_BACKUP: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_IS_HIDDEN: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_IS_SYMLINK: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL) .to_str() .unwrap() }; } #[cfg(any(feature = "v2_46", feature = "dox"))] lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_IS_VOLATILE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_SIZE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_SIZE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_SORT_ORDER: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_TARGET_URI: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_TARGET_URI) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_STANDARD_TYPE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_STANDARD_TYPE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_THUMBNAILING_FAILED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_THUMBNAIL_IS_VALID: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_THUMBNAIL_PATH: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_THUMBNAIL_PATH) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_ACCESS: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_ACCESS) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_ACCESS_USEC: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_CHANGED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_CHANGED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_CHANGED_USEC: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_CHANGED_USEC) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_CREATED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_CREATED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_CREATED_USEC: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_CREATED_USEC) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_MODIFIED: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_MODIFIED) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TIME_MODIFIED_USEC: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TRASH_DELETION_DATE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TRASH_DELETION_DATE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TRASH_ITEM_COUNT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_TRASH_ORIG_PATH: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_TRASH_ORIG_PATH) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_BLOCKS: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_BLOCKS) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_BLOCK_SIZE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_DEVICE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_DEVICE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_GID: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_GID) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_INODE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_INODE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_MODE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_MODE) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_NLINK: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_NLINK) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_RDEV: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_RDEV) .to_str() .unwrap() }; } lazy_static! { pub static ref FILE_ATTRIBUTE_UNIX_UID: &'static str = unsafe { CStr::from_ptr(gio_sys::G_FILE_ATTRIBUTE_UNIX_UID) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_ATTRIBUTE_ACTION: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_ATTRIBUTE_ACTION) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_ATTRIBUTE_ACTION_NAMESPACE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_ATTRIBUTE_ACTION_NAMESPACE) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_ATTRIBUTE_ICON: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_ATTRIBUTE_ICON) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_ATTRIBUTE_LABEL: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_ATTRIBUTE_LABEL) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_ATTRIBUTE_TARGET: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_ATTRIBUTE_TARGET) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_LINK_SECTION: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_LINK_SECTION) .to_str() .unwrap() }; } lazy_static! { pub static ref MENU_LINK_SUBMENU: &'static str = unsafe { CStr::from_ptr(gio_sys::G_MENU_LINK_SUBMENU) .to_str() .unwrap() }; } lazy_static! { pub static ref NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref NETWORK_MONITOR_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_NETWORK_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref PROXY_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_PROXY_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref PROXY_RESOLVER_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_PROXY_RESOLVER_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref SETTINGS_BACKEND_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_SETTINGS_BACKEND_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref TLS_BACKEND_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_TLS_BACKEND_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT) .to_str() .unwrap() }; } lazy_static! { pub static ref TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER: &'static str = unsafe { CStr::from_ptr(gio_sys::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER) .to_str() .unwrap() }; } lazy_static! { pub static ref VFS_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VFS_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_CLASS: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_CLASS) .to_str() .unwrap() }; } #[cfg_attr(feature = "v2_58", deprecated)] lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_HAL_UDI: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_HAL_UDI) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_LABEL: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_LABEL) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_NFS_MOUNT: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_UNIX_DEVICE: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_IDENTIFIER_KIND_UUID: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_IDENTIFIER_KIND_UUID) .to_str() .unwrap() }; } lazy_static! { pub static ref VOLUME_MONITOR_EXTENSION_POINT_NAME: &'static str = unsafe { CStr::from_ptr(gio_sys::G_VOLUME_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }; } gio-0.7.0/src/auto/converter.rs010064400007650000024000000014231350341657000146330ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; glib_wrapper! { pub struct Converter(Interface); match fn { get_type => || gio_sys::g_converter_get_type(), } } pub const NONE_CONVERTER: Option<&Converter> = None; pub trait ConverterExt: 'static { fn reset(&self); } impl> ConverterExt for O { fn reset(&self) { unsafe { gio_sys::g_converter_reset(self.as_ref().to_glib_none().0); } } } impl fmt::Display for Converter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Converter") } } gio-0.7.0/src/auto/converter_input_stream.rs010064400007650000024000000061711350341657000174320ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; use Converter; use FilterInputStream; use InputStream; use PollableInputStream; glib_wrapper! { pub struct ConverterInputStream(Object) @extends FilterInputStream, InputStream, @implements PollableInputStream; match fn { get_type => || gio_sys::g_converter_input_stream_get_type(), } } impl ConverterInputStream { pub fn new, Q: IsA>( base_stream: &P, converter: &Q, ) -> ConverterInputStream { unsafe { InputStream::from_glib_full(gio_sys::g_converter_input_stream_new( base_stream.as_ref().to_glib_none().0, converter.as_ref().to_glib_none().0, )) .unsafe_cast() } } } pub struct ConverterInputStreamBuilder { converter: Option, base_stream: Option, close_base_stream: Option, } impl ConverterInputStreamBuilder { pub fn new() -> Self { Self { converter: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> ConverterInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref converter) = self.converter { properties.push(("converter", converter)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(ConverterInputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn converter(mut self, converter: &Converter) -> Self { self.converter = Some(converter.clone()); self } pub fn base_stream(mut self, base_stream: &InputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_CONVERTER_INPUT_STREAM: Option<&ConverterInputStream> = None; pub trait ConverterInputStreamExt: 'static { fn get_converter(&self) -> Option; } impl> ConverterInputStreamExt for O { fn get_converter(&self) -> Option { unsafe { from_glib_none(gio_sys::g_converter_input_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ConverterInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ConverterInputStream") } } gio-0.7.0/src/auto/converter_output_stream.rs010064400007650000024000000062271350341657000176350ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; use Converter; use FilterOutputStream; use OutputStream; use PollableOutputStream; glib_wrapper! { pub struct ConverterOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements PollableOutputStream; match fn { get_type => || gio_sys::g_converter_output_stream_get_type(), } } impl ConverterOutputStream { pub fn new, Q: IsA>( base_stream: &P, converter: &Q, ) -> ConverterOutputStream { unsafe { OutputStream::from_glib_full(gio_sys::g_converter_output_stream_new( base_stream.as_ref().to_glib_none().0, converter.as_ref().to_glib_none().0, )) .unsafe_cast() } } } pub struct ConverterOutputStreamBuilder { converter: Option, base_stream: Option, close_base_stream: Option, } impl ConverterOutputStreamBuilder { pub fn new() -> Self { Self { converter: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> ConverterOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref converter) = self.converter { properties.push(("converter", converter)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(ConverterOutputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn converter(mut self, converter: &Converter) -> Self { self.converter = Some(converter.clone()); self } pub fn base_stream(mut self, base_stream: &OutputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_CONVERTER_OUTPUT_STREAM: Option<&ConverterOutputStream> = None; pub trait ConverterOutputStreamExt: 'static { fn get_converter(&self) -> Option; } impl> ConverterOutputStreamExt for O { fn get_converter(&self) -> Option { unsafe { from_glib_none(gio_sys::g_converter_output_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ConverterOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ConverterOutputStream") } } gio-0.7.0/src/auto/credentials.rs010064400007650000024000000057001350341657000151230ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::GString; use std::fmt; use std::ptr; use Error; glib_wrapper! { pub struct Credentials(Object); match fn { get_type => || gio_sys::g_credentials_get_type(), } } impl Credentials { pub fn new() -> Credentials { unsafe { from_glib_full(gio_sys::g_credentials_new()) } } //pub fn get_native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option { // unsafe { TODO: call gio_sys:g_credentials_get_native() } //} #[cfg(any(unix, feature = "dox"))] pub fn get_unix_pid(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::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"))] pub fn get_unix_user(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_credentials_get_unix_user(self.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } pub fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::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)) } } } //pub fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer) { // unsafe { TODO: call gio_sys:g_credentials_set_native() } //} #[cfg(any(unix, feature = "dox"))] pub fn set_unix_user(&self, uid: u32) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_credentials_set_unix_user(self.to_glib_none().0, uid, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } pub fn to_string(&self) -> GString { unsafe { from_glib_full(gio_sys::g_credentials_to_string(self.to_glib_none().0)) } } } impl Default for Credentials { fn default() -> Self { Self::new() } } impl fmt::Display for Credentials { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Credentials") } } gio-0.7.0/src/auto/data_input_stream.rs010064400007650000024000000473361350341657000163440ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::ToValue; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; use BufferedInputStream; use Cancellable; use DataStreamByteOrder; use DataStreamNewlineType; use Error; use FilterInputStream; use InputStream; use Seekable; glib_wrapper! { pub struct DataInputStream(Object) @extends BufferedInputStream, FilterInputStream, InputStream, @implements Seekable; match fn { get_type => || gio_sys::g_data_input_stream_get_type(), } } impl DataInputStream { pub fn new>(base_stream: &P) -> DataInputStream { unsafe { from_glib_full(gio_sys::g_data_input_stream_new( base_stream.as_ref().to_glib_none().0, )) } } } pub struct DataInputStreamBuilder { byte_order: Option, newline_type: Option, buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl DataInputStreamBuilder { pub fn new() -> Self { Self { byte_order: None, newline_type: None, buffer_size: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> DataInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref byte_order) = self.byte_order { properties.push(("byte-order", byte_order)); } if let Some(ref newline_type) = self.newline_type { properties.push(("newline-type", newline_type)); } if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(DataInputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn byte_order(mut self, byte_order: DataStreamByteOrder) -> Self { self.byte_order = Some(byte_order); self } pub fn newline_type(mut self, newline_type: DataStreamNewlineType) -> Self { self.newline_type = Some(newline_type); self } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream(mut self, base_stream: &InputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_DATA_INPUT_STREAM: Option<&DataInputStream> = None; pub trait DataInputStreamExt: 'static { fn get_byte_order(&self) -> DataStreamByteOrder; fn get_newline_type(&self) -> DataStreamNewlineType; fn read_byte>(&self, cancellable: Option<&P>) -> Result; fn read_int16>(&self, cancellable: Option<&P>) -> Result; fn read_int32>(&self, cancellable: Option<&P>) -> Result; fn read_int64>(&self, cancellable: Option<&P>) -> Result; //fn read_line_finish_utf8(&self, result: /*Ignored*/&AsyncResult) -> Result<(Option, usize), Error>; fn read_line_utf8>( &self, cancellable: Option<&P>, ) -> Result<(Option, usize), Error>; fn read_uint16>(&self, cancellable: Option<&P>) -> Result; fn read_uint32>(&self, cancellable: Option<&P>) -> Result; fn read_uint64>(&self, cancellable: Option<&P>) -> Result; #[cfg_attr(feature = "v2_56", deprecated)] fn read_until>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), Error>; #[cfg_attr(feature = "v2_56", deprecated)] fn read_until_async< P: IsA, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg_attr(feature = "v2_56", deprecated)] #[cfg(feature = "futures")] fn read_until_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn read_upto>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), Error>; fn read_upto_async< P: IsA, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn read_upto_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn set_byte_order(&self, order: DataStreamByteOrder); fn set_newline_type(&self, type_: DataStreamNewlineType); fn connect_property_byte_order_notify(&self, f: F) -> SignalHandlerId; fn connect_property_newline_type_notify(&self, f: F) -> SignalHandlerId; } impl> DataInputStreamExt for O { fn get_byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(gio_sys::g_data_input_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } fn get_newline_type(&self) -> DataStreamNewlineType { unsafe { from_glib(gio_sys::g_data_input_stream_get_newline_type( self.as_ref().to_glib_none().0, )) } } fn read_byte>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_byte( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_int16>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_int16( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_int32>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_int32( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_int64>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_int64( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } //fn read_line_finish_utf8(&self, result: /*Ignored*/&AsyncResult) -> Result<(Option, usize), Error> { // unsafe { TODO: call gio_sys:g_data_input_stream_read_line_finish_utf8() } //} fn read_line_utf8>( &self, cancellable: Option<&P>, ) -> Result<(Option, usize), Error> { unsafe { let mut length = mem::uninitialized(); let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_line_utf8( self.as_ref().to_glib_none().0, &mut length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), length)) } else { Err(from_glib_full(error)) } } } fn read_uint16>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_uint16( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_uint32>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_uint32( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_uint64>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_uint64( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn read_until>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), Error> { unsafe { let mut length = mem::uninitialized(); let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_until( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0, &mut length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), length)) } else { Err(from_glib_full(error)) } } } fn read_until_async< P: IsA, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn read_until_async_trampoline< Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut length = mem::uninitialized(); let ret = gio_sys::g_data_input_stream_read_until_finish( _source_object as *mut _, res, &mut length, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), length)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = read_until_async_trampoline::; unsafe { gio_sys::g_data_input_stream_read_until_async( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn read_until_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let stop_chars = String::from(stop_chars); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_until_async(&stop_chars, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn read_upto>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), Error> { let stop_chars_len = stop_chars.len() as isize; unsafe { let mut length = mem::uninitialized(); let mut error = ptr::null_mut(); let ret = gio_sys::g_data_input_stream_read_upto( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0, stop_chars_len, &mut length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), length)) } else { Err(from_glib_full(error)) } } } fn read_upto_async< P: IsA, Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let stop_chars_len = stop_chars.len() as isize; let user_data: Box = Box::new(callback); unsafe extern "C" fn read_upto_async_trampoline< Q: FnOnce(Result<(GString, usize), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut length = mem::uninitialized(); let ret = gio_sys::g_data_input_stream_read_upto_finish( _source_object as *mut _, res, &mut length, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), length)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = read_upto_async_trampoline::; unsafe { gio_sys::g_data_input_stream_read_upto_async( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0, stop_chars_len, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn read_upto_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let stop_chars = String::from(stop_chars); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_upto_async(&stop_chars, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn set_byte_order(&self, order: DataStreamByteOrder) { unsafe { gio_sys::g_data_input_stream_set_byte_order( self.as_ref().to_glib_none().0, order.to_glib(), ); } } fn set_newline_type(&self, type_: DataStreamNewlineType) { unsafe { gio_sys::g_data_input_stream_set_newline_type( self.as_ref().to_glib_none().0, type_.to_glib(), ); } } fn connect_property_byte_order_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_byte_order_trampoline( this: *mut gio_sys::GDataInputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&DataInputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::byte-order\0".as_ptr() as *const _, Some(transmute(notify_byte_order_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_newline_type_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_newline_type_trampoline( this: *mut gio_sys::GDataInputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&DataInputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::newline-type\0".as_ptr() as *const _, Some(transmute( notify_newline_type_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for DataInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "DataInputStream") } } gio-0.7.0/src/auto/data_output_stream.rs010064400007650000024000000237121350341657000165350ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use DataStreamByteOrder; use Error; use FilterOutputStream; use OutputStream; use Seekable; glib_wrapper! { pub struct DataOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements Seekable; match fn { get_type => || gio_sys::g_data_output_stream_get_type(), } } impl DataOutputStream { pub fn new>(base_stream: &P) -> DataOutputStream { unsafe { from_glib_full(gio_sys::g_data_output_stream_new( base_stream.as_ref().to_glib_none().0, )) } } } pub struct DataOutputStreamBuilder { byte_order: Option, base_stream: Option, close_base_stream: Option, } impl DataOutputStreamBuilder { pub fn new() -> Self { Self { byte_order: None, base_stream: None, close_base_stream: None, } } pub fn build(self) -> DataOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref byte_order) = self.byte_order { properties.push(("byte-order", byte_order)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new(DataOutputStream::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } pub fn byte_order(mut self, byte_order: DataStreamByteOrder) -> Self { self.byte_order = Some(byte_order); self } pub fn base_stream(mut self, base_stream: &OutputStream) -> Self { self.base_stream = Some(base_stream.clone()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_DATA_OUTPUT_STREAM: Option<&DataOutputStream> = None; pub trait DataOutputStreamExt: 'static { fn get_byte_order(&self) -> DataStreamByteOrder; fn put_byte>(&self, data: u8, cancellable: Option<&P>) -> Result<(), Error>; fn put_int16>( &self, data: i16, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_int32>( &self, data: i32, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_int64>( &self, data: i64, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_string>( &self, str: &str, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_uint16>( &self, data: u16, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_uint32>( &self, data: u32, cancellable: Option<&P>, ) -> Result<(), Error>; fn put_uint64>( &self, data: u64, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_byte_order(&self, order: DataStreamByteOrder); fn connect_property_byte_order_notify(&self, f: F) -> SignalHandlerId; } impl> DataOutputStreamExt for O { fn get_byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(gio_sys::g_data_output_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } fn put_byte>( &self, data: u8, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_byte( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int16>( &self, data: i16, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_int16( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int32>( &self, data: i32, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_int32( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int64>( &self, data: i64, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_int64( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_string>( &self, str: &str, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_string( self.as_ref().to_glib_none().0, str.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint16>( &self, data: u16, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_uint16( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint32>( &self, data: u32, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_uint32( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint64>( &self, data: u64, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_data_output_stream_put_uint64( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_byte_order(&self, order: DataStreamByteOrder) { unsafe { gio_sys::g_data_output_stream_set_byte_order( self.as_ref().to_glib_none().0, order.to_glib(), ); } } fn connect_property_byte_order_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_byte_order_trampoline( this: *mut gio_sys::GDataOutputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&DataOutputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::byte-order\0".as_ptr() as *const _, Some(transmute(notify_byte_order_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for DataOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "DataOutputStream") } } gio-0.7.0/src/auto/desktop_app_info.rs010064400007650000024000000202661350341657000161560ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use std; use std::fmt; use AppInfo; use AppLaunchContext; glib_wrapper! { pub struct DesktopAppInfo(Object) @implements AppInfo; match fn { get_type => || gio_sys::g_desktop_app_info_get_type(), } } impl DesktopAppInfo { pub fn new(desktop_id: &str) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_new(desktop_id.to_glib_none().0)) } } pub fn new_from_filename>(filename: P) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_new_from_filename( filename.as_ref().to_glib_none().0, )) } } pub fn new_from_keyfile(key_file: &glib::KeyFile) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_new_from_keyfile( key_file.to_glib_none().0, )) } } pub fn get_implementations(interface: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_desktop_app_info_get_implementations( interface.to_glib_none().0, )) } } } pub const NONE_DESKTOP_APP_INFO: Option<&DesktopAppInfo> = None; pub trait DesktopAppInfoExt: 'static { fn get_action_name(&self, action_name: &str) -> Option; fn get_boolean(&self, key: &str) -> bool; fn get_categories(&self) -> Option; fn get_filename(&self) -> Option; fn get_generic_name(&self) -> Option; fn get_is_hidden(&self) -> bool; fn get_keywords(&self) -> Vec; #[cfg(any(feature = "v2_56", feature = "dox"))] fn get_locale_string(&self, key: &str) -> Option; fn get_nodisplay(&self) -> bool; fn get_show_in(&self, desktop_env: Option<&str>) -> bool; fn get_startup_wm_class(&self) -> Option; fn get_string(&self, key: &str) -> Option; fn has_key(&self, key: &str) -> bool; fn launch_action>( &self, action_name: &str, launch_context: Option<&P>, ); //fn launch_uris_as_manager>(&self, uris: &[&str], launch_context: Option<&P>, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Option>, pid_callback: /*Unimplemented*/FnMut(&DesktopAppInfo, /*Ignored*/glib::Pid), pid_callback_data: /*Unimplemented*/Option) -> Result<(), Error>; //#[cfg(any(feature = "v2_58", feature = "dox"))] //fn launch_uris_as_manager_with_fds>(&self, uris: &[&str], launch_context: Option<&P>, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Option>, pid_callback: /*Unimplemented*/FnMut(&DesktopAppInfo, /*Ignored*/glib::Pid), pid_callback_data: /*Unimplemented*/Option, stdin_fd: i32, stdout_fd: i32, stderr_fd: i32) -> Result<(), Error>; fn list_actions(&self) -> Vec; } impl> DesktopAppInfoExt for O { fn get_action_name(&self, action_name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_get_action_name( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } fn get_boolean(&self, key: &str) -> bool { unsafe { from_glib(gio_sys::g_desktop_app_info_get_boolean( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_categories(&self) -> Option { unsafe { from_glib_none(gio_sys::g_desktop_app_info_get_categories( self.as_ref().to_glib_none().0, )) } } fn get_filename(&self) -> Option { unsafe { from_glib_none(gio_sys::g_desktop_app_info_get_filename( self.as_ref().to_glib_none().0, )) } } fn get_generic_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_desktop_app_info_get_generic_name( self.as_ref().to_glib_none().0, )) } } fn get_is_hidden(&self) -> bool { unsafe { from_glib(gio_sys::g_desktop_app_info_get_is_hidden( self.as_ref().to_glib_none().0, )) } } fn get_keywords(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_desktop_app_info_get_keywords( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn get_locale_string(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_get_locale_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_nodisplay(&self) -> bool { unsafe { from_glib(gio_sys::g_desktop_app_info_get_nodisplay( self.as_ref().to_glib_none().0, )) } } fn get_show_in(&self, desktop_env: Option<&str>) -> bool { unsafe { from_glib(gio_sys::g_desktop_app_info_get_show_in( self.as_ref().to_glib_none().0, desktop_env.to_glib_none().0, )) } } fn get_startup_wm_class(&self) -> Option { unsafe { from_glib_none(gio_sys::g_desktop_app_info_get_startup_wm_class( self.as_ref().to_glib_none().0, )) } } fn get_string(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_desktop_app_info_get_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn has_key(&self, key: &str) -> bool { unsafe { from_glib(gio_sys::g_desktop_app_info_has_key( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn launch_action>( &self, action_name: &str, launch_context: Option<&P>, ) { unsafe { gio_sys::g_desktop_app_info_launch_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, launch_context.map(|p| p.as_ref()).to_glib_none().0, ); } } //fn launch_uris_as_manager>(&self, uris: &[&str], launch_context: Option<&P>, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Option>, pid_callback: /*Unimplemented*/FnMut(&DesktopAppInfo, /*Ignored*/glib::Pid), pid_callback_data: /*Unimplemented*/Option) -> Result<(), Error> { // unsafe { TODO: call gio_sys:g_desktop_app_info_launch_uris_as_manager() } //} //#[cfg(any(feature = "v2_58", feature = "dox"))] //fn launch_uris_as_manager_with_fds>(&self, uris: &[&str], launch_context: Option<&P>, spawn_flags: /*Ignored*/glib::SpawnFlags, user_setup: Option>, pid_callback: /*Unimplemented*/FnMut(&DesktopAppInfo, /*Ignored*/glib::Pid), pid_callback_data: /*Unimplemented*/Option, stdin_fd: i32, stdout_fd: i32, stderr_fd: i32) -> Result<(), Error> { // unsafe { TODO: call gio_sys:g_desktop_app_info_launch_uris_as_manager_with_fds() } //} fn list_actions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_desktop_app_info_list_actions( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for DesktopAppInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "DesktopAppInfo") } } gio-0.7.0/src/auto/drive.rs010064400007650000024000000453731350341657000137510ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use DriveStartFlags; use DriveStartStopType; use Error; use Icon; use MountOperation; use MountUnmountFlags; use Volume; glib_wrapper! { pub struct Drive(Interface); match fn { get_type => || gio_sys::g_drive_get_type(), } } pub const NONE_DRIVE: Option<&Drive> = None; pub trait DriveExt: 'static { fn can_eject(&self) -> bool; fn can_poll_for_media(&self) -> bool; fn can_start(&self) -> bool; fn can_start_degraded(&self) -> bool; fn can_stop(&self) -> bool; fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn enumerate_identifiers(&self) -> Vec; fn get_icon(&self) -> Option; fn get_identifier(&self, kind: &str) -> Option; fn get_name(&self) -> Option; fn get_sort_key(&self) -> Option; fn get_start_stop_type(&self) -> DriveStartStopType; fn get_symbolic_icon(&self) -> Option; fn get_volumes(&self) -> Vec; fn has_media(&self) -> bool; fn has_volumes(&self) -> bool; fn is_media_check_automatic(&self) -> bool; fn is_media_removable(&self) -> bool; #[cfg(any(feature = "v2_50", feature = "dox"))] fn is_removable(&self) -> bool; fn poll_for_media, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn poll_for_media_future( &self, ) -> Box_> + std::marker::Unpin>; fn start< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn start_future + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn stop< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn stop_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn connect_changed(&self, f: F) -> SignalHandlerId; fn connect_disconnected(&self, f: F) -> SignalHandlerId; fn connect_eject_button(&self, f: F) -> SignalHandlerId; fn connect_stop_button(&self, f: F) -> SignalHandlerId; } impl> DriveExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_can_eject(self.as_ref().to_glib_none().0)) } } fn can_poll_for_media(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_can_poll_for_media( self.as_ref().to_glib_none().0, )) } } fn can_start(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_can_start(self.as_ref().to_glib_none().0)) } } fn can_start_degraded(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_can_start_degraded( self.as_ref().to_glib_none().0, )) } } fn can_stop(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_can_stop(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_drive_eject_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = eject_with_operation_trampoline::; unsafe { gio_sys::g_drive_eject_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_drive_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } fn get_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_drive_get_icon(self.as_ref().to_glib_none().0)) } } fn get_identifier(&self, kind: &str) -> Option { unsafe { from_glib_full(gio_sys::g_drive_get_identifier( self.as_ref().to_glib_none().0, kind.to_glib_none().0, )) } } fn get_name(&self) -> Option { unsafe { from_glib_full(gio_sys::g_drive_get_name(self.as_ref().to_glib_none().0)) } } fn get_sort_key(&self) -> Option { unsafe { from_glib_none(gio_sys::g_drive_get_sort_key( self.as_ref().to_glib_none().0, )) } } fn get_start_stop_type(&self) -> DriveStartStopType { unsafe { from_glib(gio_sys::g_drive_get_start_stop_type( self.as_ref().to_glib_none().0, )) } } fn get_symbolic_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_drive_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn get_volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_drive_get_volumes( self.as_ref().to_glib_none().0, )) } } fn has_media(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_has_media(self.as_ref().to_glib_none().0)) } } fn has_volumes(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_has_volumes(self.as_ref().to_glib_none().0)) } } fn is_media_check_automatic(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_is_media_check_automatic( self.as_ref().to_glib_none().0, )) } } fn is_media_removable(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_is_media_removable( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn is_removable(&self) -> bool { unsafe { from_glib(gio_sys::g_drive_is_removable( self.as_ref().to_glib_none().0, )) } } fn poll_for_media, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn poll_for_media_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_drive_poll_for_media_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = poll_for_media_trampoline::; unsafe { gio_sys::g_drive_poll_for_media( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn poll_for_media_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.poll_for_media(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn start< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn start_trampoline) + Send + 'static>( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_drive_start_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = start_trampoline::; unsafe { gio_sys::g_drive_start( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn start_future + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.start( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn stop< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn stop_trampoline) + Send + 'static>( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_drive_stop_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = stop_trampoline::; unsafe { gio_sys::g_drive_stop( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn stop_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.stop( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Drive::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_disconnected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn disconnected_trampoline( this: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Drive::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"disconnected\0".as_ptr() as *const _, Some(transmute(disconnected_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_eject_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn eject_button_trampoline( this: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Drive::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"eject-button\0".as_ptr() as *const _, Some(transmute(eject_button_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_stop_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn stop_button_trampoline( this: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Drive::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"stop-button\0".as_ptr() as *const _, Some(transmute(stop_button_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Drive { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Drive") } } gio-0.7.0/src/auto/emblem.rs010064400007650000024000000023751350341657000140740ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use EmblemOrigin; use Icon; glib_wrapper! { pub struct Emblem(Object) @implements Icon; match fn { get_type => || gio_sys::g_emblem_get_type(), } } impl Emblem { pub fn new>(icon: &P) -> Emblem { unsafe { from_glib_full(gio_sys::g_emblem_new(icon.as_ref().to_glib_none().0)) } } pub fn new_with_origin>(icon: &P, origin: EmblemOrigin) -> Emblem { unsafe { from_glib_full(gio_sys::g_emblem_new_with_origin( icon.as_ref().to_glib_none().0, origin.to_glib(), )) } } pub fn get_icon(&self) -> Option { unsafe { from_glib_none(gio_sys::g_emblem_get_icon(self.to_glib_none().0)) } } pub fn get_origin(&self) -> EmblemOrigin { unsafe { from_glib(gio_sys::g_emblem_get_origin(self.to_glib_none().0)) } } } impl fmt::Display for Emblem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Emblem") } } gio-0.7.0/src/auto/emblemed_icon.rs010064400007650000024000000047531350341657000154170ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::Value; use gobject_sys; use std::fmt; use Emblem; use Icon; glib_wrapper! { pub struct EmblemedIcon(Object) @implements Icon; match fn { get_type => || gio_sys::g_emblemed_icon_get_type(), } } impl EmblemedIcon { pub fn new>(icon: &P, emblem: Option<&Emblem>) -> EmblemedIcon { unsafe { from_glib_full(gio_sys::g_emblemed_icon_new( icon.as_ref().to_glib_none().0, emblem.to_glib_none().0, )) } } } pub const NONE_EMBLEMED_ICON: Option<&EmblemedIcon> = None; pub trait EmblemedIconExt: 'static { fn add_emblem(&self, emblem: &Emblem); fn clear_emblems(&self); fn get_emblems(&self) -> Vec; fn get_icon(&self) -> Option; fn get_property_gicon(&self) -> Option; } impl> EmblemedIconExt for O { fn add_emblem(&self, emblem: &Emblem) { unsafe { gio_sys::g_emblemed_icon_add_emblem( self.as_ref().to_glib_none().0, emblem.to_glib_none().0, ); } } fn clear_emblems(&self) { unsafe { gio_sys::g_emblemed_icon_clear_emblems(self.as_ref().to_glib_none().0); } } fn get_emblems(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_emblemed_icon_get_emblems( self.as_ref().to_glib_none().0, )) } } fn get_icon(&self) -> Option { unsafe { from_glib_none(gio_sys::g_emblemed_icon_get_icon( self.as_ref().to_glib_none().0, )) } } fn get_property_gicon(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"gicon\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } } impl fmt::Display for EmblemedIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "EmblemedIcon") } } gio-0.7.0/src/auto/enums.rs010064400007650000024000002437721350341657000137720ustar0000000000000000// 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 gio_sys; use glib::error::ErrorDomain; use glib::translate::*; use glib::value::FromValue; use glib::value::FromValueOptional; use glib::value::SetValue; use glib::value::Value; use glib::Quark; use glib::StaticType; use glib::Type; use gobject_sys; use std::fmt; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum ConverterResult { Error, Converted, Finished, Flushed, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for ConverterResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ConverterResult::{}", match *self { ConverterResult::Error => "Error", ConverterResult::Converted => "Converted", ConverterResult::Finished => "Finished", ConverterResult::Flushed => "Flushed", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for ConverterResult { type GlibType = gio_sys::GConverterResult; fn to_glib(&self) -> gio_sys::GConverterResult { match *self { ConverterResult::Error => gio_sys::G_CONVERTER_ERROR, ConverterResult::Converted => gio_sys::G_CONVERTER_CONVERTED, ConverterResult::Finished => gio_sys::G_CONVERTER_FINISHED, ConverterResult::Flushed => gio_sys::G_CONVERTER_FLUSHED, ConverterResult::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ConverterResult { fn from_glib(value: gio_sys::GConverterResult) -> Self { match value { 0 => ConverterResult::Error, 1 => ConverterResult::Converted, 2 => ConverterResult::Finished, 3 => ConverterResult::Flushed, value => ConverterResult::__Unknown(value), } } } impl StaticType for ConverterResult { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_converter_result_get_type()) } } } impl<'a> FromValueOptional<'a> for ConverterResult { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ConverterResult { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for ConverterResult { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum CredentialsType { Invalid, LinuxUcred, FreebsdCmsgcred, OpenbsdSockpeercred, SolarisUcred, NetbsdUnpcbid, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for CredentialsType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "CredentialsType::{}", match *self { CredentialsType::Invalid => "Invalid", CredentialsType::LinuxUcred => "LinuxUcred", CredentialsType::FreebsdCmsgcred => "FreebsdCmsgcred", CredentialsType::OpenbsdSockpeercred => "OpenbsdSockpeercred", CredentialsType::SolarisUcred => "SolarisUcred", CredentialsType::NetbsdUnpcbid => "NetbsdUnpcbid", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for CredentialsType { type GlibType = gio_sys::GCredentialsType; fn to_glib(&self) -> gio_sys::GCredentialsType { match *self { CredentialsType::Invalid => gio_sys::G_CREDENTIALS_TYPE_INVALID, CredentialsType::LinuxUcred => gio_sys::G_CREDENTIALS_TYPE_LINUX_UCRED, CredentialsType::FreebsdCmsgcred => gio_sys::G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, CredentialsType::OpenbsdSockpeercred => { gio_sys::G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED } CredentialsType::SolarisUcred => gio_sys::G_CREDENTIALS_TYPE_SOLARIS_UCRED, CredentialsType::NetbsdUnpcbid => gio_sys::G_CREDENTIALS_TYPE_NETBSD_UNPCBID, CredentialsType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for CredentialsType { fn from_glib(value: gio_sys::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(gio_sys::g_credentials_type_get_type()) } } } impl<'a> FromValueOptional<'a> for CredentialsType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for CredentialsType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for CredentialsType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum DataStreamByteOrder { BigEndian, LittleEndian, HostEndian, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for DataStreamByteOrder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DataStreamByteOrder::{}", match *self { DataStreamByteOrder::BigEndian => "BigEndian", DataStreamByteOrder::LittleEndian => "LittleEndian", DataStreamByteOrder::HostEndian => "HostEndian", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for DataStreamByteOrder { type GlibType = gio_sys::GDataStreamByteOrder; fn to_glib(&self) -> gio_sys::GDataStreamByteOrder { match *self { DataStreamByteOrder::BigEndian => gio_sys::G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN, DataStreamByteOrder::LittleEndian => gio_sys::G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN, DataStreamByteOrder::HostEndian => gio_sys::G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN, DataStreamByteOrder::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DataStreamByteOrder { fn from_glib(value: gio_sys::GDataStreamByteOrder) -> Self { match value { 0 => DataStreamByteOrder::BigEndian, 1 => DataStreamByteOrder::LittleEndian, 2 => DataStreamByteOrder::HostEndian, value => DataStreamByteOrder::__Unknown(value), } } } impl StaticType for DataStreamByteOrder { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_data_stream_byte_order_get_type()) } } } impl<'a> FromValueOptional<'a> for DataStreamByteOrder { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for DataStreamByteOrder { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for DataStreamByteOrder { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum DataStreamNewlineType { Lf, Cr, CrLf, Any, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for DataStreamNewlineType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DataStreamNewlineType::{}", match *self { DataStreamNewlineType::Lf => "Lf", DataStreamNewlineType::Cr => "Cr", DataStreamNewlineType::CrLf => "CrLf", DataStreamNewlineType::Any => "Any", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for DataStreamNewlineType { type GlibType = gio_sys::GDataStreamNewlineType; fn to_glib(&self) -> gio_sys::GDataStreamNewlineType { match *self { DataStreamNewlineType::Lf => gio_sys::G_DATA_STREAM_NEWLINE_TYPE_LF, DataStreamNewlineType::Cr => gio_sys::G_DATA_STREAM_NEWLINE_TYPE_CR, DataStreamNewlineType::CrLf => gio_sys::G_DATA_STREAM_NEWLINE_TYPE_CR_LF, DataStreamNewlineType::Any => gio_sys::G_DATA_STREAM_NEWLINE_TYPE_ANY, DataStreamNewlineType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DataStreamNewlineType { fn from_glib(value: gio_sys::GDataStreamNewlineType) -> Self { match value { 0 => DataStreamNewlineType::Lf, 1 => DataStreamNewlineType::Cr, 2 => DataStreamNewlineType::CrLf, 3 => DataStreamNewlineType::Any, value => DataStreamNewlineType::__Unknown(value), } } } impl StaticType for DataStreamNewlineType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_data_stream_newline_type_get_type()) } } } impl<'a> FromValueOptional<'a> for DataStreamNewlineType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for DataStreamNewlineType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for DataStreamNewlineType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum DriveStartStopType { Unknown, Shutdown, Network, Multidisk, Password, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for DriveStartStopType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DriveStartStopType::{}", match *self { DriveStartStopType::Unknown => "Unknown", DriveStartStopType::Shutdown => "Shutdown", DriveStartStopType::Network => "Network", DriveStartStopType::Multidisk => "Multidisk", DriveStartStopType::Password => "Password", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for DriveStartStopType { type GlibType = gio_sys::GDriveStartStopType; fn to_glib(&self) -> gio_sys::GDriveStartStopType { match *self { DriveStartStopType::Unknown => gio_sys::G_DRIVE_START_STOP_TYPE_UNKNOWN, DriveStartStopType::Shutdown => gio_sys::G_DRIVE_START_STOP_TYPE_SHUTDOWN, DriveStartStopType::Network => gio_sys::G_DRIVE_START_STOP_TYPE_NETWORK, DriveStartStopType::Multidisk => gio_sys::G_DRIVE_START_STOP_TYPE_MULTIDISK, DriveStartStopType::Password => gio_sys::G_DRIVE_START_STOP_TYPE_PASSWORD, DriveStartStopType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DriveStartStopType { fn from_glib(value: gio_sys::GDriveStartStopType) -> Self { match value { 0 => DriveStartStopType::Unknown, 1 => DriveStartStopType::Shutdown, 2 => DriveStartStopType::Network, 3 => DriveStartStopType::Multidisk, 4 => DriveStartStopType::Password, value => DriveStartStopType::__Unknown(value), } } } impl StaticType for DriveStartStopType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_drive_start_stop_type_get_type()) } } } impl<'a> FromValueOptional<'a> for DriveStartStopType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for DriveStartStopType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for DriveStartStopType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum EmblemOrigin { Unknown, Device, Livemetadata, Tag, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for EmblemOrigin { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "EmblemOrigin::{}", match *self { EmblemOrigin::Unknown => "Unknown", EmblemOrigin::Device => "Device", EmblemOrigin::Livemetadata => "Livemetadata", EmblemOrigin::Tag => "Tag", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for EmblemOrigin { type GlibType = gio_sys::GEmblemOrigin; fn to_glib(&self) -> gio_sys::GEmblemOrigin { match *self { EmblemOrigin::Unknown => gio_sys::G_EMBLEM_ORIGIN_UNKNOWN, EmblemOrigin::Device => gio_sys::G_EMBLEM_ORIGIN_DEVICE, EmblemOrigin::Livemetadata => gio_sys::G_EMBLEM_ORIGIN_LIVEMETADATA, EmblemOrigin::Tag => gio_sys::G_EMBLEM_ORIGIN_TAG, EmblemOrigin::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for EmblemOrigin { fn from_glib(value: gio_sys::GEmblemOrigin) -> Self { match value { 0 => EmblemOrigin::Unknown, 1 => EmblemOrigin::Device, 2 => EmblemOrigin::Livemetadata, 3 => EmblemOrigin::Tag, value => EmblemOrigin::__Unknown(value), } } } impl StaticType for EmblemOrigin { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_emblem_origin_get_type()) } } } impl<'a> FromValueOptional<'a> for EmblemOrigin { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for EmblemOrigin { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for EmblemOrigin { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum FileAttributeStatus { Unset, Set, ErrorSetting, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for FileAttributeStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileAttributeStatus::{}", match *self { FileAttributeStatus::Unset => "Unset", FileAttributeStatus::Set => "Set", FileAttributeStatus::ErrorSetting => "ErrorSetting", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for FileAttributeStatus { type GlibType = gio_sys::GFileAttributeStatus; fn to_glib(&self) -> gio_sys::GFileAttributeStatus { match *self { FileAttributeStatus::Unset => gio_sys::G_FILE_ATTRIBUTE_STATUS_UNSET, FileAttributeStatus::Set => gio_sys::G_FILE_ATTRIBUTE_STATUS_SET, FileAttributeStatus::ErrorSetting => gio_sys::G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, FileAttributeStatus::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileAttributeStatus { fn from_glib(value: gio_sys::GFileAttributeStatus) -> Self { match value { 0 => FileAttributeStatus::Unset, 1 => FileAttributeStatus::Set, 2 => FileAttributeStatus::ErrorSetting, value => FileAttributeStatus::__Unknown(value), } } } impl StaticType for FileAttributeStatus { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_attribute_status_get_type()) } } } impl<'a> FromValueOptional<'a> for FileAttributeStatus { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileAttributeStatus { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for FileAttributeStatus { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum FileAttributeType { Invalid, String, ByteString, Boolean, Uint32, Int32, Uint64, Int64, Object, Stringv, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for FileAttributeType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileAttributeType::{}", match *self { FileAttributeType::Invalid => "Invalid", FileAttributeType::String => "String", FileAttributeType::ByteString => "ByteString", FileAttributeType::Boolean => "Boolean", FileAttributeType::Uint32 => "Uint32", FileAttributeType::Int32 => "Int32", FileAttributeType::Uint64 => "Uint64", FileAttributeType::Int64 => "Int64", FileAttributeType::Object => "Object", FileAttributeType::Stringv => "Stringv", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for FileAttributeType { type GlibType = gio_sys::GFileAttributeType; fn to_glib(&self) -> gio_sys::GFileAttributeType { match *self { FileAttributeType::Invalid => gio_sys::G_FILE_ATTRIBUTE_TYPE_INVALID, FileAttributeType::String => gio_sys::G_FILE_ATTRIBUTE_TYPE_STRING, FileAttributeType::ByteString => gio_sys::G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, FileAttributeType::Boolean => gio_sys::G_FILE_ATTRIBUTE_TYPE_BOOLEAN, FileAttributeType::Uint32 => gio_sys::G_FILE_ATTRIBUTE_TYPE_UINT32, FileAttributeType::Int32 => gio_sys::G_FILE_ATTRIBUTE_TYPE_INT32, FileAttributeType::Uint64 => gio_sys::G_FILE_ATTRIBUTE_TYPE_UINT64, FileAttributeType::Int64 => gio_sys::G_FILE_ATTRIBUTE_TYPE_INT64, FileAttributeType::Object => gio_sys::G_FILE_ATTRIBUTE_TYPE_OBJECT, FileAttributeType::Stringv => gio_sys::G_FILE_ATTRIBUTE_TYPE_STRINGV, FileAttributeType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileAttributeType { fn from_glib(value: gio_sys::GFileAttributeType) -> Self { match value { 0 => FileAttributeType::Invalid, 1 => FileAttributeType::String, 2 => FileAttributeType::ByteString, 3 => FileAttributeType::Boolean, 4 => FileAttributeType::Uint32, 5 => FileAttributeType::Int32, 6 => FileAttributeType::Uint64, 7 => FileAttributeType::Int64, 8 => FileAttributeType::Object, 9 => FileAttributeType::Stringv, value => FileAttributeType::__Unknown(value), } } } impl StaticType for FileAttributeType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_attribute_type_get_type()) } } } impl<'a> FromValueOptional<'a> for FileAttributeType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileAttributeType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for FileAttributeType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum FileMonitorEvent { Changed, ChangesDoneHint, Deleted, Created, AttributeChanged, PreUnmount, Unmounted, Moved, Renamed, MovedIn, MovedOut, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for FileMonitorEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileMonitorEvent::{}", match *self { FileMonitorEvent::Changed => "Changed", FileMonitorEvent::ChangesDoneHint => "ChangesDoneHint", FileMonitorEvent::Deleted => "Deleted", FileMonitorEvent::Created => "Created", FileMonitorEvent::AttributeChanged => "AttributeChanged", FileMonitorEvent::PreUnmount => "PreUnmount", FileMonitorEvent::Unmounted => "Unmounted", FileMonitorEvent::Moved => "Moved", FileMonitorEvent::Renamed => "Renamed", FileMonitorEvent::MovedIn => "MovedIn", FileMonitorEvent::MovedOut => "MovedOut", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for FileMonitorEvent { type GlibType = gio_sys::GFileMonitorEvent; fn to_glib(&self) -> gio_sys::GFileMonitorEvent { match *self { FileMonitorEvent::Changed => gio_sys::G_FILE_MONITOR_EVENT_CHANGED, FileMonitorEvent::ChangesDoneHint => gio_sys::G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, FileMonitorEvent::Deleted => gio_sys::G_FILE_MONITOR_EVENT_DELETED, FileMonitorEvent::Created => gio_sys::G_FILE_MONITOR_EVENT_CREATED, FileMonitorEvent::AttributeChanged => gio_sys::G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED, FileMonitorEvent::PreUnmount => gio_sys::G_FILE_MONITOR_EVENT_PRE_UNMOUNT, FileMonitorEvent::Unmounted => gio_sys::G_FILE_MONITOR_EVENT_UNMOUNTED, FileMonitorEvent::Moved => gio_sys::G_FILE_MONITOR_EVENT_MOVED, FileMonitorEvent::Renamed => gio_sys::G_FILE_MONITOR_EVENT_RENAMED, FileMonitorEvent::MovedIn => gio_sys::G_FILE_MONITOR_EVENT_MOVED_IN, FileMonitorEvent::MovedOut => gio_sys::G_FILE_MONITOR_EVENT_MOVED_OUT, FileMonitorEvent::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileMonitorEvent { fn from_glib(value: gio_sys::GFileMonitorEvent) -> Self { match value { 0 => FileMonitorEvent::Changed, 1 => FileMonitorEvent::ChangesDoneHint, 2 => FileMonitorEvent::Deleted, 3 => FileMonitorEvent::Created, 4 => FileMonitorEvent::AttributeChanged, 5 => FileMonitorEvent::PreUnmount, 6 => FileMonitorEvent::Unmounted, 7 => FileMonitorEvent::Moved, 8 => FileMonitorEvent::Renamed, 9 => FileMonitorEvent::MovedIn, 10 => FileMonitorEvent::MovedOut, value => FileMonitorEvent::__Unknown(value), } } } impl StaticType for FileMonitorEvent { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_monitor_event_get_type()) } } } impl<'a> FromValueOptional<'a> for FileMonitorEvent { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileMonitorEvent { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for FileMonitorEvent { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum FileType { Unknown, Regular, Directory, SymbolicLink, Special, Shortcut, Mountable, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for FileType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileType::{}", match *self { FileType::Unknown => "Unknown", FileType::Regular => "Regular", FileType::Directory => "Directory", FileType::SymbolicLink => "SymbolicLink", FileType::Special => "Special", FileType::Shortcut => "Shortcut", FileType::Mountable => "Mountable", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for FileType { type GlibType = gio_sys::GFileType; fn to_glib(&self) -> gio_sys::GFileType { match *self { FileType::Unknown => gio_sys::G_FILE_TYPE_UNKNOWN, FileType::Regular => gio_sys::G_FILE_TYPE_REGULAR, FileType::Directory => gio_sys::G_FILE_TYPE_DIRECTORY, FileType::SymbolicLink => gio_sys::G_FILE_TYPE_SYMBOLIC_LINK, FileType::Special => gio_sys::G_FILE_TYPE_SPECIAL, FileType::Shortcut => gio_sys::G_FILE_TYPE_SHORTCUT, FileType::Mountable => gio_sys::G_FILE_TYPE_MOUNTABLE, FileType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileType { fn from_glib(value: gio_sys::GFileType) -> Self { match value { 0 => FileType::Unknown, 1 => FileType::Regular, 2 => FileType::Directory, 3 => FileType::SymbolicLink, 4 => FileType::Special, 5 => FileType::Shortcut, 6 => FileType::Mountable, value => FileType::__Unknown(value), } } } impl StaticType for FileType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_type_get_type()) } } } impl<'a> FromValueOptional<'a> for FileType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for FileType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum IOErrorEnum { Failed, NotFound, Exists, IsDirectory, NotDirectory, NotEmpty, NotRegularFile, NotSymbolicLink, NotMountableFile, FilenameTooLong, InvalidFilename, TooManyLinks, NoSpace, InvalidArgument, PermissionDenied, NotSupported, NotMounted, AlreadyMounted, Closed, Cancelled, Pending, ReadOnly, CantCreateBackup, WrongEtag, TimedOut, WouldRecurse, Busy, WouldBlock, HostNotFound, WouldMerge, FailedHandled, TooManyOpenFiles, NotInitialized, AddressInUse, PartialInput, InvalidData, DbusError, HostUnreachable, NetworkUnreachable, ConnectionRefused, ProxyFailed, ProxyAuthFailed, ProxyNeedAuth, ProxyNotAllowed, BrokenPipe, NotConnected, MessageTooLarge, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for IOErrorEnum { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "IOErrorEnum::{}", match *self { IOErrorEnum::Failed => "Failed", IOErrorEnum::NotFound => "NotFound", IOErrorEnum::Exists => "Exists", IOErrorEnum::IsDirectory => "IsDirectory", IOErrorEnum::NotDirectory => "NotDirectory", IOErrorEnum::NotEmpty => "NotEmpty", IOErrorEnum::NotRegularFile => "NotRegularFile", IOErrorEnum::NotSymbolicLink => "NotSymbolicLink", IOErrorEnum::NotMountableFile => "NotMountableFile", IOErrorEnum::FilenameTooLong => "FilenameTooLong", IOErrorEnum::InvalidFilename => "InvalidFilename", IOErrorEnum::TooManyLinks => "TooManyLinks", IOErrorEnum::NoSpace => "NoSpace", IOErrorEnum::InvalidArgument => "InvalidArgument", IOErrorEnum::PermissionDenied => "PermissionDenied", IOErrorEnum::NotSupported => "NotSupported", IOErrorEnum::NotMounted => "NotMounted", IOErrorEnum::AlreadyMounted => "AlreadyMounted", IOErrorEnum::Closed => "Closed", IOErrorEnum::Cancelled => "Cancelled", IOErrorEnum::Pending => "Pending", IOErrorEnum::ReadOnly => "ReadOnly", IOErrorEnum::CantCreateBackup => "CantCreateBackup", IOErrorEnum::WrongEtag => "WrongEtag", IOErrorEnum::TimedOut => "TimedOut", IOErrorEnum::WouldRecurse => "WouldRecurse", IOErrorEnum::Busy => "Busy", IOErrorEnum::WouldBlock => "WouldBlock", IOErrorEnum::HostNotFound => "HostNotFound", IOErrorEnum::WouldMerge => "WouldMerge", IOErrorEnum::FailedHandled => "FailedHandled", IOErrorEnum::TooManyOpenFiles => "TooManyOpenFiles", IOErrorEnum::NotInitialized => "NotInitialized", IOErrorEnum::AddressInUse => "AddressInUse", IOErrorEnum::PartialInput => "PartialInput", IOErrorEnum::InvalidData => "InvalidData", IOErrorEnum::DbusError => "DbusError", IOErrorEnum::HostUnreachable => "HostUnreachable", IOErrorEnum::NetworkUnreachable => "NetworkUnreachable", IOErrorEnum::ConnectionRefused => "ConnectionRefused", IOErrorEnum::ProxyFailed => "ProxyFailed", IOErrorEnum::ProxyAuthFailed => "ProxyAuthFailed", IOErrorEnum::ProxyNeedAuth => "ProxyNeedAuth", IOErrorEnum::ProxyNotAllowed => "ProxyNotAllowed", IOErrorEnum::BrokenPipe => "BrokenPipe", IOErrorEnum::NotConnected => "NotConnected", IOErrorEnum::MessageTooLarge => "MessageTooLarge", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for IOErrorEnum { type GlibType = gio_sys::GIOErrorEnum; fn to_glib(&self) -> gio_sys::GIOErrorEnum { match *self { IOErrorEnum::Failed => gio_sys::G_IO_ERROR_FAILED, IOErrorEnum::NotFound => gio_sys::G_IO_ERROR_NOT_FOUND, IOErrorEnum::Exists => gio_sys::G_IO_ERROR_EXISTS, IOErrorEnum::IsDirectory => gio_sys::G_IO_ERROR_IS_DIRECTORY, IOErrorEnum::NotDirectory => gio_sys::G_IO_ERROR_NOT_DIRECTORY, IOErrorEnum::NotEmpty => gio_sys::G_IO_ERROR_NOT_EMPTY, IOErrorEnum::NotRegularFile => gio_sys::G_IO_ERROR_NOT_REGULAR_FILE, IOErrorEnum::NotSymbolicLink => gio_sys::G_IO_ERROR_NOT_SYMBOLIC_LINK, IOErrorEnum::NotMountableFile => gio_sys::G_IO_ERROR_NOT_MOUNTABLE_FILE, IOErrorEnum::FilenameTooLong => gio_sys::G_IO_ERROR_FILENAME_TOO_LONG, IOErrorEnum::InvalidFilename => gio_sys::G_IO_ERROR_INVALID_FILENAME, IOErrorEnum::TooManyLinks => gio_sys::G_IO_ERROR_TOO_MANY_LINKS, IOErrorEnum::NoSpace => gio_sys::G_IO_ERROR_NO_SPACE, IOErrorEnum::InvalidArgument => gio_sys::G_IO_ERROR_INVALID_ARGUMENT, IOErrorEnum::PermissionDenied => gio_sys::G_IO_ERROR_PERMISSION_DENIED, IOErrorEnum::NotSupported => gio_sys::G_IO_ERROR_NOT_SUPPORTED, IOErrorEnum::NotMounted => gio_sys::G_IO_ERROR_NOT_MOUNTED, IOErrorEnum::AlreadyMounted => gio_sys::G_IO_ERROR_ALREADY_MOUNTED, IOErrorEnum::Closed => gio_sys::G_IO_ERROR_CLOSED, IOErrorEnum::Cancelled => gio_sys::G_IO_ERROR_CANCELLED, IOErrorEnum::Pending => gio_sys::G_IO_ERROR_PENDING, IOErrorEnum::ReadOnly => gio_sys::G_IO_ERROR_READ_ONLY, IOErrorEnum::CantCreateBackup => gio_sys::G_IO_ERROR_CANT_CREATE_BACKUP, IOErrorEnum::WrongEtag => gio_sys::G_IO_ERROR_WRONG_ETAG, IOErrorEnum::TimedOut => gio_sys::G_IO_ERROR_TIMED_OUT, IOErrorEnum::WouldRecurse => gio_sys::G_IO_ERROR_WOULD_RECURSE, IOErrorEnum::Busy => gio_sys::G_IO_ERROR_BUSY, IOErrorEnum::WouldBlock => gio_sys::G_IO_ERROR_WOULD_BLOCK, IOErrorEnum::HostNotFound => gio_sys::G_IO_ERROR_HOST_NOT_FOUND, IOErrorEnum::WouldMerge => gio_sys::G_IO_ERROR_WOULD_MERGE, IOErrorEnum::FailedHandled => gio_sys::G_IO_ERROR_FAILED_HANDLED, IOErrorEnum::TooManyOpenFiles => gio_sys::G_IO_ERROR_TOO_MANY_OPEN_FILES, IOErrorEnum::NotInitialized => gio_sys::G_IO_ERROR_NOT_INITIALIZED, IOErrorEnum::AddressInUse => gio_sys::G_IO_ERROR_ADDRESS_IN_USE, IOErrorEnum::PartialInput => gio_sys::G_IO_ERROR_PARTIAL_INPUT, IOErrorEnum::InvalidData => gio_sys::G_IO_ERROR_INVALID_DATA, IOErrorEnum::DbusError => gio_sys::G_IO_ERROR_DBUS_ERROR, IOErrorEnum::HostUnreachable => gio_sys::G_IO_ERROR_HOST_UNREACHABLE, IOErrorEnum::NetworkUnreachable => gio_sys::G_IO_ERROR_NETWORK_UNREACHABLE, IOErrorEnum::ConnectionRefused => gio_sys::G_IO_ERROR_CONNECTION_REFUSED, IOErrorEnum::ProxyFailed => gio_sys::G_IO_ERROR_PROXY_FAILED, IOErrorEnum::ProxyAuthFailed => gio_sys::G_IO_ERROR_PROXY_AUTH_FAILED, IOErrorEnum::ProxyNeedAuth => gio_sys::G_IO_ERROR_PROXY_NEED_AUTH, IOErrorEnum::ProxyNotAllowed => gio_sys::G_IO_ERROR_PROXY_NOT_ALLOWED, IOErrorEnum::BrokenPipe => gio_sys::G_IO_ERROR_BROKEN_PIPE, IOErrorEnum::NotConnected => gio_sys::G_IO_ERROR_NOT_CONNECTED, IOErrorEnum::MessageTooLarge => gio_sys::G_IO_ERROR_MESSAGE_TOO_LARGE, IOErrorEnum::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for IOErrorEnum { fn from_glib(value: gio_sys::GIOErrorEnum) -> Self { match value { 0 => IOErrorEnum::Failed, 1 => IOErrorEnum::NotFound, 2 => IOErrorEnum::Exists, 3 => IOErrorEnum::IsDirectory, 4 => IOErrorEnum::NotDirectory, 5 => IOErrorEnum::NotEmpty, 6 => IOErrorEnum::NotRegularFile, 7 => IOErrorEnum::NotSymbolicLink, 8 => IOErrorEnum::NotMountableFile, 9 => IOErrorEnum::FilenameTooLong, 10 => IOErrorEnum::InvalidFilename, 11 => IOErrorEnum::TooManyLinks, 12 => IOErrorEnum::NoSpace, 13 => IOErrorEnum::InvalidArgument, 14 => IOErrorEnum::PermissionDenied, 15 => IOErrorEnum::NotSupported, 16 => IOErrorEnum::NotMounted, 17 => IOErrorEnum::AlreadyMounted, 18 => IOErrorEnum::Closed, 19 => IOErrorEnum::Cancelled, 20 => IOErrorEnum::Pending, 21 => IOErrorEnum::ReadOnly, 22 => IOErrorEnum::CantCreateBackup, 23 => IOErrorEnum::WrongEtag, 24 => IOErrorEnum::TimedOut, 25 => IOErrorEnum::WouldRecurse, 26 => IOErrorEnum::Busy, 27 => IOErrorEnum::WouldBlock, 28 => IOErrorEnum::HostNotFound, 29 => IOErrorEnum::WouldMerge, 30 => IOErrorEnum::FailedHandled, 31 => IOErrorEnum::TooManyOpenFiles, 32 => IOErrorEnum::NotInitialized, 33 => IOErrorEnum::AddressInUse, 34 => IOErrorEnum::PartialInput, 35 => IOErrorEnum::InvalidData, 36 => IOErrorEnum::DbusError, 37 => IOErrorEnum::HostUnreachable, 38 => IOErrorEnum::NetworkUnreachable, 39 => IOErrorEnum::ConnectionRefused, 40 => IOErrorEnum::ProxyFailed, 41 => IOErrorEnum::ProxyAuthFailed, 42 => IOErrorEnum::ProxyNeedAuth, 43 => IOErrorEnum::ProxyNotAllowed, 44 => IOErrorEnum::BrokenPipe, 45 => IOErrorEnum::NotConnected, 46 => IOErrorEnum::MessageTooLarge, value => IOErrorEnum::__Unknown(value), } } } impl ErrorDomain for IOErrorEnum { fn domain() -> Quark { unsafe { from_glib(gio_sys::g_io_error_quark()) } } fn code(self) -> i32 { self.to_glib() } fn from(code: i32) -> Option { match code { 0 => Some(IOErrorEnum::Failed), 1 => Some(IOErrorEnum::NotFound), 2 => Some(IOErrorEnum::Exists), 3 => Some(IOErrorEnum::IsDirectory), 4 => Some(IOErrorEnum::NotDirectory), 5 => Some(IOErrorEnum::NotEmpty), 6 => Some(IOErrorEnum::NotRegularFile), 7 => Some(IOErrorEnum::NotSymbolicLink), 8 => Some(IOErrorEnum::NotMountableFile), 9 => Some(IOErrorEnum::FilenameTooLong), 10 => Some(IOErrorEnum::InvalidFilename), 11 => Some(IOErrorEnum::TooManyLinks), 12 => Some(IOErrorEnum::NoSpace), 13 => Some(IOErrorEnum::InvalidArgument), 14 => Some(IOErrorEnum::PermissionDenied), 15 => Some(IOErrorEnum::NotSupported), 16 => Some(IOErrorEnum::NotMounted), 17 => Some(IOErrorEnum::AlreadyMounted), 18 => Some(IOErrorEnum::Closed), 19 => Some(IOErrorEnum::Cancelled), 20 => Some(IOErrorEnum::Pending), 21 => Some(IOErrorEnum::ReadOnly), 22 => Some(IOErrorEnum::CantCreateBackup), 23 => Some(IOErrorEnum::WrongEtag), 24 => Some(IOErrorEnum::TimedOut), 25 => Some(IOErrorEnum::WouldRecurse), 26 => Some(IOErrorEnum::Busy), 27 => Some(IOErrorEnum::WouldBlock), 28 => Some(IOErrorEnum::HostNotFound), 29 => Some(IOErrorEnum::WouldMerge), 30 => Some(IOErrorEnum::FailedHandled), 31 => Some(IOErrorEnum::TooManyOpenFiles), 32 => Some(IOErrorEnum::NotInitialized), 33 => Some(IOErrorEnum::AddressInUse), 34 => Some(IOErrorEnum::PartialInput), 35 => Some(IOErrorEnum::InvalidData), 36 => Some(IOErrorEnum::DbusError), 37 => Some(IOErrorEnum::HostUnreachable), 38 => Some(IOErrorEnum::NetworkUnreachable), 39 => Some(IOErrorEnum::ConnectionRefused), 40 => Some(IOErrorEnum::ProxyFailed), 41 => Some(IOErrorEnum::ProxyAuthFailed), 42 => Some(IOErrorEnum::ProxyNeedAuth), 43 => Some(IOErrorEnum::ProxyNotAllowed), 44 => Some(IOErrorEnum::BrokenPipe), 45 => Some(IOErrorEnum::NotConnected), 46 => Some(IOErrorEnum::MessageTooLarge), _ => Some(IOErrorEnum::Failed), } } } impl StaticType for IOErrorEnum { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_io_error_enum_get_type()) } } } impl<'a> FromValueOptional<'a> for IOErrorEnum { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for IOErrorEnum { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for IOErrorEnum { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum MountOperationResult { Handled, Aborted, Unhandled, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for MountOperationResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "MountOperationResult::{}", match *self { MountOperationResult::Handled => "Handled", MountOperationResult::Aborted => "Aborted", MountOperationResult::Unhandled => "Unhandled", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for MountOperationResult { type GlibType = gio_sys::GMountOperationResult; fn to_glib(&self) -> gio_sys::GMountOperationResult { match *self { MountOperationResult::Handled => gio_sys::G_MOUNT_OPERATION_HANDLED, MountOperationResult::Aborted => gio_sys::G_MOUNT_OPERATION_ABORTED, MountOperationResult::Unhandled => gio_sys::G_MOUNT_OPERATION_UNHANDLED, MountOperationResult::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for MountOperationResult { fn from_glib(value: gio_sys::GMountOperationResult) -> Self { match value { 0 => MountOperationResult::Handled, 1 => MountOperationResult::Aborted, 2 => MountOperationResult::Unhandled, value => MountOperationResult::__Unknown(value), } } } impl StaticType for MountOperationResult { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_mount_operation_result_get_type()) } } } impl<'a> FromValueOptional<'a> for MountOperationResult { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for MountOperationResult { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for MountOperationResult { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[cfg(any(feature = "v2_44", feature = "dox"))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum NetworkConnectivity { Local, Limited, Portal, Full, #[doc(hidden)] __Unknown(i32), } #[cfg(any(feature = "v2_44", feature = "dox"))] impl fmt::Display for NetworkConnectivity { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "NetworkConnectivity::{}", match *self { NetworkConnectivity::Local => "Local", NetworkConnectivity::Limited => "Limited", NetworkConnectivity::Portal => "Portal", NetworkConnectivity::Full => "Full", _ => "Unknown", } ) } } #[cfg(any(feature = "v2_44", feature = "dox"))] #[doc(hidden)] impl ToGlib for NetworkConnectivity { type GlibType = gio_sys::GNetworkConnectivity; fn to_glib(&self) -> gio_sys::GNetworkConnectivity { match *self { NetworkConnectivity::Local => gio_sys::G_NETWORK_CONNECTIVITY_LOCAL, NetworkConnectivity::Limited => gio_sys::G_NETWORK_CONNECTIVITY_LIMITED, NetworkConnectivity::Portal => gio_sys::G_NETWORK_CONNECTIVITY_PORTAL, NetworkConnectivity::Full => gio_sys::G_NETWORK_CONNECTIVITY_FULL, NetworkConnectivity::__Unknown(value) => value, } } } #[cfg(any(feature = "v2_44", feature = "dox"))] #[doc(hidden)] impl FromGlib for NetworkConnectivity { fn from_glib(value: gio_sys::GNetworkConnectivity) -> Self { match value { 1 => NetworkConnectivity::Local, 2 => NetworkConnectivity::Limited, 3 => NetworkConnectivity::Portal, 4 => NetworkConnectivity::Full, value => NetworkConnectivity::__Unknown(value), } } } #[cfg(any(feature = "v2_44", feature = "dox"))] impl StaticType for NetworkConnectivity { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_network_connectivity_get_type()) } } } #[cfg(any(feature = "v2_44", feature = "dox"))] impl<'a> FromValueOptional<'a> for NetworkConnectivity { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } #[cfg(any(feature = "v2_44", feature = "dox"))] impl<'a> FromValue<'a> for NetworkConnectivity { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(any(feature = "v2_44", feature = "dox"))] impl SetValue for NetworkConnectivity { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum NotificationPriority { Normal, Low, High, Urgent, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for NotificationPriority { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "NotificationPriority::{}", match *self { NotificationPriority::Normal => "Normal", NotificationPriority::Low => "Low", NotificationPriority::High => "High", NotificationPriority::Urgent => "Urgent", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for NotificationPriority { type GlibType = gio_sys::GNotificationPriority; fn to_glib(&self) -> gio_sys::GNotificationPriority { match *self { NotificationPriority::Normal => gio_sys::G_NOTIFICATION_PRIORITY_NORMAL, NotificationPriority::Low => gio_sys::G_NOTIFICATION_PRIORITY_LOW, NotificationPriority::High => gio_sys::G_NOTIFICATION_PRIORITY_HIGH, NotificationPriority::Urgent => gio_sys::G_NOTIFICATION_PRIORITY_URGENT, NotificationPriority::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for NotificationPriority { fn from_glib(value: gio_sys::GNotificationPriority) -> Self { match value { 0 => NotificationPriority::Normal, 1 => NotificationPriority::Low, 2 => NotificationPriority::High, 3 => NotificationPriority::Urgent, value => NotificationPriority::__Unknown(value), } } } impl StaticType for NotificationPriority { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_notification_priority_get_type()) } } } impl<'a> FromValueOptional<'a> for NotificationPriority { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for NotificationPriority { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for NotificationPriority { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum PasswordSave { Never, ForSession, Permanently, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for PasswordSave { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "PasswordSave::{}", match *self { PasswordSave::Never => "Never", PasswordSave::ForSession => "ForSession", PasswordSave::Permanently => "Permanently", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for PasswordSave { type GlibType = gio_sys::GPasswordSave; fn to_glib(&self) -> gio_sys::GPasswordSave { match *self { PasswordSave::Never => gio_sys::G_PASSWORD_SAVE_NEVER, PasswordSave::ForSession => gio_sys::G_PASSWORD_SAVE_FOR_SESSION, PasswordSave::Permanently => gio_sys::G_PASSWORD_SAVE_PERMANENTLY, PasswordSave::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PasswordSave { fn from_glib(value: gio_sys::GPasswordSave) -> Self { match value { 0 => PasswordSave::Never, 1 => PasswordSave::ForSession, 2 => PasswordSave::Permanently, value => PasswordSave::__Unknown(value), } } } impl StaticType for PasswordSave { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_password_save_get_type()) } } } impl<'a> FromValueOptional<'a> for PasswordSave { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for PasswordSave { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for PasswordSave { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum ResolverRecordType { Srv, Mx, Txt, Soa, Ns, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for ResolverRecordType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ResolverRecordType::{}", match *self { ResolverRecordType::Srv => "Srv", ResolverRecordType::Mx => "Mx", ResolverRecordType::Txt => "Txt", ResolverRecordType::Soa => "Soa", ResolverRecordType::Ns => "Ns", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for ResolverRecordType { type GlibType = gio_sys::GResolverRecordType; fn to_glib(&self) -> gio_sys::GResolverRecordType { match *self { ResolverRecordType::Srv => gio_sys::G_RESOLVER_RECORD_SRV, ResolverRecordType::Mx => gio_sys::G_RESOLVER_RECORD_MX, ResolverRecordType::Txt => gio_sys::G_RESOLVER_RECORD_TXT, ResolverRecordType::Soa => gio_sys::G_RESOLVER_RECORD_SOA, ResolverRecordType::Ns => gio_sys::G_RESOLVER_RECORD_NS, ResolverRecordType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ResolverRecordType { fn from_glib(value: gio_sys::GResolverRecordType) -> Self { match value { 1 => ResolverRecordType::Srv, 2 => ResolverRecordType::Mx, 3 => ResolverRecordType::Txt, 4 => ResolverRecordType::Soa, 5 => ResolverRecordType::Ns, value => ResolverRecordType::__Unknown(value), } } } impl StaticType for ResolverRecordType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_resolver_record_type_get_type()) } } } impl<'a> FromValueOptional<'a> for ResolverRecordType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ResolverRecordType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for ResolverRecordType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum ResourceError { NotFound, Internal, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for ResourceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ResourceError::{}", match *self { ResourceError::NotFound => "NotFound", ResourceError::Internal => "Internal", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for ResourceError { type GlibType = gio_sys::GResourceError; fn to_glib(&self) -> gio_sys::GResourceError { match *self { ResourceError::NotFound => gio_sys::G_RESOURCE_ERROR_NOT_FOUND, ResourceError::Internal => gio_sys::G_RESOURCE_ERROR_INTERNAL, ResourceError::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ResourceError { fn from_glib(value: gio_sys::GResourceError) -> Self { match value { 0 => ResourceError::NotFound, 1 => ResourceError::Internal, value => ResourceError::__Unknown(value), } } } impl ErrorDomain for ResourceError { fn domain() -> Quark { unsafe { from_glib(gio_sys::g_resource_error_quark()) } } fn code(self) -> i32 { self.to_glib() } fn from(code: i32) -> Option { match code { 0 => Some(ResourceError::NotFound), 1 => Some(ResourceError::Internal), value => Some(ResourceError::__Unknown(value)), } } } impl StaticType for ResourceError { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_resource_error_get_type()) } } } impl<'a> FromValueOptional<'a> for ResourceError { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ResourceError { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for ResourceError { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum SocketClientEvent { Resolving, Resolved, Connecting, Connected, ProxyNegotiating, ProxyNegotiated, TlsHandshaking, TlsHandshaked, Complete, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for SocketClientEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketClientEvent::{}", match *self { SocketClientEvent::Resolving => "Resolving", SocketClientEvent::Resolved => "Resolved", SocketClientEvent::Connecting => "Connecting", SocketClientEvent::Connected => "Connected", SocketClientEvent::ProxyNegotiating => "ProxyNegotiating", SocketClientEvent::ProxyNegotiated => "ProxyNegotiated", SocketClientEvent::TlsHandshaking => "TlsHandshaking", SocketClientEvent::TlsHandshaked => "TlsHandshaked", SocketClientEvent::Complete => "Complete", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for SocketClientEvent { type GlibType = gio_sys::GSocketClientEvent; fn to_glib(&self) -> gio_sys::GSocketClientEvent { match *self { SocketClientEvent::Resolving => gio_sys::G_SOCKET_CLIENT_RESOLVING, SocketClientEvent::Resolved => gio_sys::G_SOCKET_CLIENT_RESOLVED, SocketClientEvent::Connecting => gio_sys::G_SOCKET_CLIENT_CONNECTING, SocketClientEvent::Connected => gio_sys::G_SOCKET_CLIENT_CONNECTED, SocketClientEvent::ProxyNegotiating => gio_sys::G_SOCKET_CLIENT_PROXY_NEGOTIATING, SocketClientEvent::ProxyNegotiated => gio_sys::G_SOCKET_CLIENT_PROXY_NEGOTIATED, SocketClientEvent::TlsHandshaking => gio_sys::G_SOCKET_CLIENT_TLS_HANDSHAKING, SocketClientEvent::TlsHandshaked => gio_sys::G_SOCKET_CLIENT_TLS_HANDSHAKED, SocketClientEvent::Complete => gio_sys::G_SOCKET_CLIENT_COMPLETE, SocketClientEvent::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketClientEvent { fn from_glib(value: gio_sys::GSocketClientEvent) -> Self { match value { 0 => SocketClientEvent::Resolving, 1 => SocketClientEvent::Resolved, 2 => SocketClientEvent::Connecting, 3 => SocketClientEvent::Connected, 4 => SocketClientEvent::ProxyNegotiating, 5 => SocketClientEvent::ProxyNegotiated, 6 => SocketClientEvent::TlsHandshaking, 7 => SocketClientEvent::TlsHandshaked, 8 => SocketClientEvent::Complete, value => SocketClientEvent::__Unknown(value), } } } impl StaticType for SocketClientEvent { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_socket_client_event_get_type()) } } } impl<'a> FromValueOptional<'a> for SocketClientEvent { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SocketClientEvent { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for SocketClientEvent { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum SocketFamily { Invalid, Unix, Ipv4, Ipv6, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for SocketFamily { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketFamily::{}", match *self { SocketFamily::Invalid => "Invalid", SocketFamily::Unix => "Unix", SocketFamily::Ipv4 => "Ipv4", SocketFamily::Ipv6 => "Ipv6", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for SocketFamily { type GlibType = gio_sys::GSocketFamily; fn to_glib(&self) -> gio_sys::GSocketFamily { match *self { SocketFamily::Invalid => gio_sys::G_SOCKET_FAMILY_INVALID, SocketFamily::Unix => gio_sys::G_SOCKET_FAMILY_UNIX, SocketFamily::Ipv4 => gio_sys::G_SOCKET_FAMILY_IPV4, SocketFamily::Ipv6 => gio_sys::G_SOCKET_FAMILY_IPV6, SocketFamily::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketFamily { fn from_glib(value: gio_sys::GSocketFamily) -> Self { match value { 0 => SocketFamily::Invalid, 1 => SocketFamily::Unix, 2 => SocketFamily::Ipv4, 10 => SocketFamily::Ipv6, value => SocketFamily::__Unknown(value), } } } impl StaticType for SocketFamily { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_socket_family_get_type()) } } } impl<'a> FromValueOptional<'a> for SocketFamily { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SocketFamily { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for SocketFamily { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[cfg(any(feature = "v2_46", feature = "dox"))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum SocketListenerEvent { Binding, Bound, Listening, Listened, #[doc(hidden)] __Unknown(i32), } #[cfg(any(feature = "v2_46", feature = "dox"))] impl fmt::Display for SocketListenerEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketListenerEvent::{}", match *self { SocketListenerEvent::Binding => "Binding", SocketListenerEvent::Bound => "Bound", SocketListenerEvent::Listening => "Listening", SocketListenerEvent::Listened => "Listened", _ => "Unknown", } ) } } #[cfg(any(feature = "v2_46", feature = "dox"))] #[doc(hidden)] impl ToGlib for SocketListenerEvent { type GlibType = gio_sys::GSocketListenerEvent; fn to_glib(&self) -> gio_sys::GSocketListenerEvent { match *self { SocketListenerEvent::Binding => gio_sys::G_SOCKET_LISTENER_BINDING, SocketListenerEvent::Bound => gio_sys::G_SOCKET_LISTENER_BOUND, SocketListenerEvent::Listening => gio_sys::G_SOCKET_LISTENER_LISTENING, SocketListenerEvent::Listened => gio_sys::G_SOCKET_LISTENER_LISTENED, SocketListenerEvent::__Unknown(value) => value, } } } #[cfg(any(feature = "v2_46", feature = "dox"))] #[doc(hidden)] impl FromGlib for SocketListenerEvent { fn from_glib(value: gio_sys::GSocketListenerEvent) -> Self { match value { 0 => SocketListenerEvent::Binding, 1 => SocketListenerEvent::Bound, 2 => SocketListenerEvent::Listening, 3 => SocketListenerEvent::Listened, value => SocketListenerEvent::__Unknown(value), } } } #[cfg(any(feature = "v2_46", feature = "dox"))] impl StaticType for SocketListenerEvent { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_socket_listener_event_get_type()) } } } #[cfg(any(feature = "v2_46", feature = "dox"))] impl<'a> FromValueOptional<'a> for SocketListenerEvent { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } #[cfg(any(feature = "v2_46", feature = "dox"))] impl<'a> FromValue<'a> for SocketListenerEvent { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(any(feature = "v2_46", feature = "dox"))] impl SetValue for SocketListenerEvent { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum SocketProtocol { Unknown, Default, Tcp, Udp, Sctp, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for SocketProtocol { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketProtocol::{}", match *self { SocketProtocol::Unknown => "Unknown", SocketProtocol::Default => "Default", SocketProtocol::Tcp => "Tcp", SocketProtocol::Udp => "Udp", SocketProtocol::Sctp => "Sctp", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for SocketProtocol { type GlibType = gio_sys::GSocketProtocol; fn to_glib(&self) -> gio_sys::GSocketProtocol { match *self { SocketProtocol::Unknown => gio_sys::G_SOCKET_PROTOCOL_UNKNOWN, SocketProtocol::Default => gio_sys::G_SOCKET_PROTOCOL_DEFAULT, SocketProtocol::Tcp => gio_sys::G_SOCKET_PROTOCOL_TCP, SocketProtocol::Udp => gio_sys::G_SOCKET_PROTOCOL_UDP, SocketProtocol::Sctp => gio_sys::G_SOCKET_PROTOCOL_SCTP, SocketProtocol::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketProtocol { fn from_glib(value: gio_sys::GSocketProtocol) -> Self { match value { -1 => SocketProtocol::Unknown, 0 => SocketProtocol::Default, 6 => SocketProtocol::Tcp, 17 => SocketProtocol::Udp, 132 => SocketProtocol::Sctp, value => SocketProtocol::__Unknown(value), } } } impl StaticType for SocketProtocol { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_socket_protocol_get_type()) } } } impl<'a> FromValueOptional<'a> for SocketProtocol { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SocketProtocol { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for SocketProtocol { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum SocketType { Invalid, Stream, Datagram, Seqpacket, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for SocketType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketType::{}", match *self { SocketType::Invalid => "Invalid", SocketType::Stream => "Stream", SocketType::Datagram => "Datagram", SocketType::Seqpacket => "Seqpacket", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for SocketType { type GlibType = gio_sys::GSocketType; fn to_glib(&self) -> gio_sys::GSocketType { match *self { SocketType::Invalid => gio_sys::G_SOCKET_TYPE_INVALID, SocketType::Stream => gio_sys::G_SOCKET_TYPE_STREAM, SocketType::Datagram => gio_sys::G_SOCKET_TYPE_DATAGRAM, SocketType::Seqpacket => gio_sys::G_SOCKET_TYPE_SEQPACKET, SocketType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketType { fn from_glib(value: gio_sys::GSocketType) -> Self { match value { 0 => SocketType::Invalid, 1 => SocketType::Stream, 2 => SocketType::Datagram, 3 => SocketType::Seqpacket, value => SocketType::__Unknown(value), } } } impl StaticType for SocketType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_socket_type_get_type()) } } } impl<'a> FromValueOptional<'a> for SocketType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SocketType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for SocketType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum TlsAuthenticationMode { None, Requested, Required, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for TlsAuthenticationMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsAuthenticationMode::{}", match *self { TlsAuthenticationMode::None => "None", TlsAuthenticationMode::Requested => "Requested", TlsAuthenticationMode::Required => "Required", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for TlsAuthenticationMode { type GlibType = gio_sys::GTlsAuthenticationMode; fn to_glib(&self) -> gio_sys::GTlsAuthenticationMode { match *self { TlsAuthenticationMode::None => gio_sys::G_TLS_AUTHENTICATION_NONE, TlsAuthenticationMode::Requested => gio_sys::G_TLS_AUTHENTICATION_REQUESTED, TlsAuthenticationMode::Required => gio_sys::G_TLS_AUTHENTICATION_REQUIRED, TlsAuthenticationMode::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsAuthenticationMode { fn from_glib(value: gio_sys::GTlsAuthenticationMode) -> Self { match value { 0 => TlsAuthenticationMode::None, 1 => TlsAuthenticationMode::Requested, 2 => TlsAuthenticationMode::Required, value => TlsAuthenticationMode::__Unknown(value), } } } impl StaticType for TlsAuthenticationMode { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_authentication_mode_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsAuthenticationMode { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsAuthenticationMode { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for TlsAuthenticationMode { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum TlsCertificateRequestFlags { None, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for TlsCertificateRequestFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsCertificateRequestFlags::{}", match *self { TlsCertificateRequestFlags::None => "None", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for TlsCertificateRequestFlags { type GlibType = gio_sys::GTlsCertificateRequestFlags; fn to_glib(&self) -> gio_sys::GTlsCertificateRequestFlags { match *self { TlsCertificateRequestFlags::None => gio_sys::G_TLS_CERTIFICATE_REQUEST_NONE, TlsCertificateRequestFlags::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsCertificateRequestFlags { fn from_glib(value: gio_sys::GTlsCertificateRequestFlags) -> Self { match value { 0 => TlsCertificateRequestFlags::None, value => TlsCertificateRequestFlags::__Unknown(value), } } } impl StaticType for TlsCertificateRequestFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_certificate_request_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsCertificateRequestFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsCertificateRequestFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for TlsCertificateRequestFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum TlsDatabaseLookupFlags { None, Keypair, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for TlsDatabaseLookupFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsDatabaseLookupFlags::{}", match *self { TlsDatabaseLookupFlags::None => "None", TlsDatabaseLookupFlags::Keypair => "Keypair", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for TlsDatabaseLookupFlags { type GlibType = gio_sys::GTlsDatabaseLookupFlags; fn to_glib(&self) -> gio_sys::GTlsDatabaseLookupFlags { match *self { TlsDatabaseLookupFlags::None => gio_sys::G_TLS_DATABASE_LOOKUP_NONE, TlsDatabaseLookupFlags::Keypair => gio_sys::G_TLS_DATABASE_LOOKUP_KEYPAIR, TlsDatabaseLookupFlags::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsDatabaseLookupFlags { fn from_glib(value: gio_sys::GTlsDatabaseLookupFlags) -> Self { match value { 0 => TlsDatabaseLookupFlags::None, 1 => TlsDatabaseLookupFlags::Keypair, value => TlsDatabaseLookupFlags::__Unknown(value), } } } impl StaticType for TlsDatabaseLookupFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_database_lookup_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsDatabaseLookupFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsDatabaseLookupFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for TlsDatabaseLookupFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum TlsInteractionResult { Unhandled, Handled, Failed, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for TlsInteractionResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsInteractionResult::{}", match *self { TlsInteractionResult::Unhandled => "Unhandled", TlsInteractionResult::Handled => "Handled", TlsInteractionResult::Failed => "Failed", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for TlsInteractionResult { type GlibType = gio_sys::GTlsInteractionResult; fn to_glib(&self) -> gio_sys::GTlsInteractionResult { match *self { TlsInteractionResult::Unhandled => gio_sys::G_TLS_INTERACTION_UNHANDLED, TlsInteractionResult::Handled => gio_sys::G_TLS_INTERACTION_HANDLED, TlsInteractionResult::Failed => gio_sys::G_TLS_INTERACTION_FAILED, TlsInteractionResult::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsInteractionResult { fn from_glib(value: gio_sys::GTlsInteractionResult) -> Self { match value { 0 => TlsInteractionResult::Unhandled, 1 => TlsInteractionResult::Handled, 2 => TlsInteractionResult::Failed, value => TlsInteractionResult::__Unknown(value), } } } impl StaticType for TlsInteractionResult { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_interaction_result_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsInteractionResult { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsInteractionResult { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for TlsInteractionResult { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum TlsRehandshakeMode { Never, Safely, Unsafely, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for TlsRehandshakeMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsRehandshakeMode::{}", match *self { TlsRehandshakeMode::Never => "Never", TlsRehandshakeMode::Safely => "Safely", TlsRehandshakeMode::Unsafely => "Unsafely", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for TlsRehandshakeMode { type GlibType = gio_sys::GTlsRehandshakeMode; fn to_glib(&self) -> gio_sys::GTlsRehandshakeMode { match *self { TlsRehandshakeMode::Never => gio_sys::G_TLS_REHANDSHAKE_NEVER, TlsRehandshakeMode::Safely => gio_sys::G_TLS_REHANDSHAKE_SAFELY, TlsRehandshakeMode::Unsafely => gio_sys::G_TLS_REHANDSHAKE_UNSAFELY, TlsRehandshakeMode::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsRehandshakeMode { fn from_glib(value: gio_sys::GTlsRehandshakeMode) -> Self { match value { 0 => TlsRehandshakeMode::Never, 1 => TlsRehandshakeMode::Safely, 2 => TlsRehandshakeMode::Unsafely, value => TlsRehandshakeMode::__Unknown(value), } } } impl StaticType for TlsRehandshakeMode { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_rehandshake_mode_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsRehandshakeMode { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsRehandshakeMode { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for TlsRehandshakeMode { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum UnixSocketAddressType { Invalid, Anonymous, Path, Abstract, AbstractPadded, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for UnixSocketAddressType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "UnixSocketAddressType::{}", match *self { UnixSocketAddressType::Invalid => "Invalid", UnixSocketAddressType::Anonymous => "Anonymous", UnixSocketAddressType::Path => "Path", UnixSocketAddressType::Abstract => "Abstract", UnixSocketAddressType::AbstractPadded => "AbstractPadded", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for UnixSocketAddressType { type GlibType = gio_sys::GUnixSocketAddressType; fn to_glib(&self) -> gio_sys::GUnixSocketAddressType { match *self { UnixSocketAddressType::Invalid => gio_sys::G_UNIX_SOCKET_ADDRESS_INVALID, UnixSocketAddressType::Anonymous => gio_sys::G_UNIX_SOCKET_ADDRESS_ANONYMOUS, UnixSocketAddressType::Path => gio_sys::G_UNIX_SOCKET_ADDRESS_PATH, UnixSocketAddressType::Abstract => gio_sys::G_UNIX_SOCKET_ADDRESS_ABSTRACT, UnixSocketAddressType::AbstractPadded => gio_sys::G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, UnixSocketAddressType::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for UnixSocketAddressType { fn from_glib(value: gio_sys::GUnixSocketAddressType) -> Self { match value { 0 => UnixSocketAddressType::Invalid, 1 => UnixSocketAddressType::Anonymous, 2 => UnixSocketAddressType::Path, 3 => UnixSocketAddressType::Abstract, 4 => UnixSocketAddressType::AbstractPadded, value => UnixSocketAddressType::__Unknown(value), } } } impl StaticType for UnixSocketAddressType { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_unix_socket_address_type_get_type()) } } } impl<'a> FromValueOptional<'a> for UnixSocketAddressType { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for UnixSocketAddressType { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for UnixSocketAddressType { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] pub enum ZlibCompressorFormat { Zlib, Gzip, Raw, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for ZlibCompressorFormat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ZlibCompressorFormat::{}", match *self { ZlibCompressorFormat::Zlib => "Zlib", ZlibCompressorFormat::Gzip => "Gzip", ZlibCompressorFormat::Raw => "Raw", _ => "Unknown", } ) } } #[doc(hidden)] impl ToGlib for ZlibCompressorFormat { type GlibType = gio_sys::GZlibCompressorFormat; fn to_glib(&self) -> gio_sys::GZlibCompressorFormat { match *self { ZlibCompressorFormat::Zlib => gio_sys::G_ZLIB_COMPRESSOR_FORMAT_ZLIB, ZlibCompressorFormat::Gzip => gio_sys::G_ZLIB_COMPRESSOR_FORMAT_GZIP, ZlibCompressorFormat::Raw => gio_sys::G_ZLIB_COMPRESSOR_FORMAT_RAW, ZlibCompressorFormat::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ZlibCompressorFormat { fn from_glib(value: gio_sys::GZlibCompressorFormat) -> Self { match value { 0 => ZlibCompressorFormat::Zlib, 1 => ZlibCompressorFormat::Gzip, 2 => ZlibCompressorFormat::Raw, value => ZlibCompressorFormat::__Unknown(value), } } } impl StaticType for ZlibCompressorFormat { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_zlib_compressor_format_get_type()) } } } impl<'a> FromValueOptional<'a> for ZlibCompressorFormat { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ZlibCompressorFormat { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0)) } } impl SetValue for ZlibCompressorFormat { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) } } gio-0.7.0/src/auto/file.rs010064400007650000024000003341371350341657000135560ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::ptr; use AppInfo; use Cancellable; use DriveStartFlags; use Error; use FileCopyFlags; use FileCreateFlags; use FileIOStream; use FileInfo; use FileInputStream; use FileMeasureFlags; use FileMonitor; use FileMonitorFlags; use FileOutputStream; use FileQueryInfoFlags; use FileType; use Mount; use MountMountFlags; use MountOperation; use MountUnmountFlags; glib_wrapper! { pub struct File(Interface); match fn { get_type => || gio_sys::g_file_get_type(), } } impl File { //#[cfg(any(feature = "v2_56", feature = "dox"))] //pub fn new_build_filename>(first_element: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option { // unsafe { TODO: call gio_sys:g_file_new_build_filename() } //} pub fn new_for_commandline_arg>(arg: P) -> File { unsafe { from_glib_full(gio_sys::g_file_new_for_commandline_arg( arg.as_ref().to_glib_none().0, )) } } pub fn new_for_commandline_arg_and_cwd, Q: AsRef>( arg: P, cwd: Q, ) -> File { unsafe { from_glib_full(gio_sys::g_file_new_for_commandline_arg_and_cwd( arg.as_ref().to_glib_none().0, cwd.as_ref().to_glib_none().0, )) } } pub fn new_for_path>(path: P) -> File { unsafe { from_glib_full(gio_sys::g_file_new_for_path(path.as_ref().to_glib_none().0)) } } pub fn new_for_uri(uri: &str) -> File { unsafe { from_glib_full(gio_sys::g_file_new_for_uri(uri.to_glib_none().0)) } } pub fn new_tmp>(tmpl: P) -> Result<(File, FileIOStream), Error> { unsafe { let mut iostream = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_file_new_tmp(tmpl.as_ref().to_glib_none().0, &mut iostream, &mut error); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(iostream))) } else { Err(from_glib_full(error)) } } } pub fn parse_name(parse_name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_file_parse_name(parse_name.to_glib_none().0)) } } } unsafe impl Send for File {} unsafe impl Sync for File {} pub const NONE_FILE: Option<&File> = None; pub trait FileExt: 'static { fn append_to>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; fn append_to_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn append_to_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn copy, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), Error>; //fn copy_async, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, S: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S); //#[cfg(feature = "futures")] //fn copy_async_future + Clone + 'static, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Box_> + std::marker::Unpin>; fn copy_attributes, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, ) -> Result<(), Error>; fn create>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; fn create_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn create_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn create_readwrite>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; fn create_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn create_readwrite_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn delete>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn delete_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn delete_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn dup(&self) -> Option; fn eject_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn eject_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; //fn enumerate_children>(&self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result; fn equal>(&self, file2: &P) -> bool; fn find_enclosing_mount>( &self, cancellable: Option<&P>, ) -> Result; fn get_basename(&self) -> Option; fn get_child>(&self, name: P) -> Option; fn get_child_for_display_name(&self, display_name: &str) -> Result; fn get_parent(&self) -> Option; fn get_parse_name(&self) -> Option; fn get_path(&self) -> Option; fn get_relative_path>(&self, descendant: &P) -> Option; fn get_uri(&self) -> GString; fn get_uri_scheme(&self) -> GString; fn has_parent>(&self, parent: Option<&P>) -> bool; fn has_prefix>(&self, prefix: &P) -> bool; fn has_uri_scheme(&self, uri_scheme: &str) -> bool; fn is_native(&self) -> bool; #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes>( &self, cancellable: Option<&P>, ) -> Result<(glib::Bytes, Option), Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes_async< P: IsA, Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes_async_future( &self, ) -> Box_> + std::marker::Unpin>; fn load_contents>( &self, cancellable: Option<&P>, ) -> Result<(Vec, GString), Error>; fn load_contents_async< P: IsA, Q: FnOnce(Result<(Vec, GString), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn load_contents_async_future( &self, ) -> Box_, GString), Error>> + std::marker::Unpin>; //fn load_partial_contents_async, Q: FnOnce(Result<(Vec, GString), Error>) + Send + 'static, R: FnOnce(Result<(Vec, GString), Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R); //#[cfg(feature = "futures")] //fn load_partial_contents_async_future, GString), Error>) + Send + 'static>(&self, read_more_callback: Q) -> Box_, GString), Error>> + std::marker::Unpin>; fn make_directory>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn make_directory_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn make_directory_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn make_directory_with_parents>( &self, cancellable: Option<&P>, ) -> Result<(), Error>; fn make_symbolic_link, Q: IsA>( &self, symlink_value: P, cancellable: Option<&Q>, ) -> Result<(), Error>; fn measure_disk_usage>( &self, flags: FileMeasureFlags, cancellable: Option<&P>, progress_callback: Option>, ) -> Result<(u64, u64, u64), Error>; //fn measure_disk_usage_async, Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R); //#[cfg(feature = "futures")] //fn measure_disk_usage_async_future) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Box_> + std::marker::Unpin>; fn monitor>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; fn monitor_directory>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; fn monitor_file>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; fn mount_enclosing_volume< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn mount_enclosing_volume_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn mount_mountable< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn mount_mountable_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn move_, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), Error>; fn open_readwrite>( &self, cancellable: Option<&P>, ) -> Result; fn open_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn open_readwrite_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; #[cfg(any(feature = "v2_56", feature = "dox"))] fn peek_path(&self) -> Option; fn poll_mountable, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn poll_mountable_future( &self, ) -> Box_> + std::marker::Unpin>; fn query_default_handler>( &self, cancellable: Option<&P>, ) -> Result; fn query_exists>(&self, cancellable: Option<&P>) -> bool; fn query_file_type>( &self, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> FileType; fn query_filesystem_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; fn query_filesystem_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn query_filesystem_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn query_info>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result; fn query_info_async, Q: FnOnce(Result) + Send + 'static>( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; //fn query_settable_attributes>(&self, cancellable: Option<&P>) -> Result; //fn query_writable_namespaces>(&self, cancellable: Option<&P>) -> Result; fn read>(&self, cancellable: Option<&P>) -> Result; fn read_async, Q: FnOnce(Result) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn read_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn replace>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; fn replace_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn replace_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn replace_contents>( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; //fn replace_contents_bytes_async, Q: FnOnce(Result<(), Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q); fn replace_readwrite>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; fn replace_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn replace_readwrite_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn resolve_relative_path>(&self, relative_path: P) -> Option; //fn set_attribute>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), Error>; fn set_attribute_byte_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attribute_int32>( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attribute_int64>( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attribute_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attribute_uint32>( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attribute_uint64>( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_attributes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn set_attributes_async_future( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn set_attributes_from_info>( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error>; fn set_display_name>( &self, display_name: &str, cancellable: Option<&P>, ) -> Result; fn set_display_name_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, display_name: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn set_display_name_async_future( &self, display_name: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn start_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: DriveStartFlags, start_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn start_mountable_future + Clone + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn stop_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn stop_mountable_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn supports_thread_contexts(&self) -> bool; fn trash>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn trash_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn trash_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn unmount_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn unmount_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; } impl> FileExt for O { fn append_to>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_append_to( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn append_to_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn append_to_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_append_to_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = append_to_async_trampoline::; unsafe { gio_sys::g_file_append_to_async( self.as_ref().to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn append_to_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.append_to_async(flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn copy, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), Error> { let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback; unsafe extern "C" fn progress_callback_func, Q: IsA>( current_num_bytes: i64, total_num_bytes: i64, user_data: glib_sys::gpointer, ) { let callback: *mut Option<&mut dyn (FnMut(i64, i64))> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(i64, i64))>; if let Some(ref mut callback) = *callback { callback(current_num_bytes, total_num_bytes) } else { panic!("cannot get closure...") }; } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func:: as _) } else { None }; let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data; unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_copy( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, super_callback0 as *const _ as usize as *mut _, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } //fn copy_async, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, S: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S) { // unsafe { TODO: call gio_sys:g_file_copy_async() } //} //#[cfg(feature = "futures")] //fn copy_async_future + Clone + 'static, R: FnOnce(Result<(), Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Box_> + std::marker::Unpin> { //use GioFuture; //use fragile::Fragile; //let destination = destination.clone(); //let progress_callback = progress_callback.map(ToOwned::to_owned); //GioFuture::new(self, move |obj, send| { // let cancellable = Cancellable::new(); // let send = Fragile::new(send); // obj.copy_async( // &destination, // flags, // io_priority, // Some(&cancellable), // progress_callback.as_ref().map(::std::borrow::Borrow::borrow), // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} fn copy_attributes, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_copy_attributes( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn create>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_create( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn create_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn create_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_create_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = create_async_trampoline::; unsafe { gio_sys::g_file_create_async( self.as_ref().to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn create_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.create_async(flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn create_readwrite>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_create_readwrite( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn create_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn create_readwrite_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_create_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = create_readwrite_async_trampoline::; unsafe { gio_sys::g_file_create_readwrite_async( self.as_ref().to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn create_readwrite_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.create_readwrite_async(flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn delete>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_delete( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn delete_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn delete_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_delete_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = delete_async_trampoline::; unsafe { gio_sys::g_file_delete_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn delete_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.delete_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn dup(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_dup(self.as_ref().to_glib_none().0)) } } fn eject_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn eject_mountable_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_eject_mountable_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = eject_mountable_with_operation_trampoline::; unsafe { gio_sys::g_file_eject_mountable_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn eject_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.eject_mountable_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } //fn enumerate_children>(&self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result { // unsafe { TODO: call gio_sys:g_file_enumerate_children() } //} fn equal>(&self, file2: &P) -> bool { unsafe { from_glib(gio_sys::g_file_equal( self.as_ref().to_glib_none().0, file2.as_ref().to_glib_none().0, )) } } fn find_enclosing_mount>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_find_enclosing_mount( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_basename(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_basename(self.as_ref().to_glib_none().0)) } } fn get_child>(&self, name: P) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_child( self.as_ref().to_glib_none().0, name.as_ref().to_glib_none().0, )) } } fn get_child_for_display_name(&self, display_name: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_get_child_for_display_name( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_parent(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_parent(self.as_ref().to_glib_none().0)) } } fn get_parse_name(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_parse_name( self.as_ref().to_glib_none().0, )) } } fn get_path(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_path(self.as_ref().to_glib_none().0)) } } fn get_relative_path>(&self, descendant: &P) -> Option { unsafe { from_glib_full(gio_sys::g_file_get_relative_path( self.as_ref().to_glib_none().0, descendant.as_ref().to_glib_none().0, )) } } fn get_uri(&self) -> GString { unsafe { from_glib_full(gio_sys::g_file_get_uri(self.as_ref().to_glib_none().0)) } } fn get_uri_scheme(&self) -> GString { unsafe { from_glib_full(gio_sys::g_file_get_uri_scheme( self.as_ref().to_glib_none().0, )) } } fn has_parent>(&self, parent: Option<&P>) -> bool { unsafe { from_glib(gio_sys::g_file_has_parent( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, )) } } fn has_prefix>(&self, prefix: &P) -> bool { unsafe { from_glib(gio_sys::g_file_has_prefix( self.as_ref().to_glib_none().0, prefix.as_ref().to_glib_none().0, )) } } fn has_uri_scheme(&self, uri_scheme: &str) -> bool { unsafe { from_glib(gio_sys::g_file_has_uri_scheme( self.as_ref().to_glib_none().0, uri_scheme.to_glib_none().0, )) } } fn is_native(&self) -> bool { unsafe { from_glib(gio_sys::g_file_is_native(self.as_ref().to_glib_none().0)) } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes>( &self, cancellable: Option<&P>, ) -> Result<(glib::Bytes, Option), Error> { unsafe { let mut etag_out = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_file_load_bytes( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut etag_out, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(etag_out))) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes_async< P: IsA, Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn load_bytes_async_trampoline< Q: FnOnce(Result<(glib::Bytes, GString), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut etag_out = ptr::null_mut(); let ret = gio_sys::g_file_load_bytes_finish( _source_object as *mut _, res, &mut etag_out, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(etag_out))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = load_bytes_async_trampoline::; unsafe { gio_sys::g_file_load_bytes_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_56", feature = "dox"))] fn load_bytes_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.load_bytes_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn load_contents>( &self, cancellable: Option<&P>, ) -> Result<(Vec, GString), Error> { unsafe { let mut contents = ptr::null_mut(); let mut length = mem::uninitialized(); let mut etag_out = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_file_load_contents( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut contents, &mut length, &mut etag_out, &mut error, ); if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length as usize), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) } } } fn load_contents_async< P: IsA, Q: FnOnce(Result<(Vec, GString), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn load_contents_async_trampoline< Q: FnOnce(Result<(Vec, GString), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut contents = ptr::null_mut(); let mut length = mem::uninitialized(); let mut etag_out = ptr::null_mut(); let _ = gio_sys::g_file_load_contents_finish( _source_object as *mut _, res, &mut contents, &mut length, &mut etag_out, &mut error, ); let result = if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length as usize), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = load_contents_async_trampoline::; unsafe { gio_sys::g_file_load_contents_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn load_contents_async_future( &self, ) -> Box_, GString), Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.load_contents_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } //fn load_partial_contents_async, Q: FnOnce(Result<(Vec, GString), Error>) + Send + 'static, R: FnOnce(Result<(Vec, GString), Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R) { // unsafe { TODO: call gio_sys:g_file_load_partial_contents_async() } //} //#[cfg(feature = "futures")] //fn load_partial_contents_async_future, GString), Error>) + Send + 'static>(&self, read_more_callback: Q) -> Box_, GString), Error>> + std::marker::Unpin> { //use GioFuture; //use fragile::Fragile; //GioFuture::new(self, move |obj, send| { // let cancellable = Cancellable::new(); // let send = Fragile::new(send); // obj.load_partial_contents_async( // Some(&cancellable), // read_more_callback, // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} fn make_directory>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_make_directory( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn make_directory_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn make_directory_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_make_directory_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = make_directory_async_trampoline::; unsafe { gio_sys::g_file_make_directory_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn make_directory_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.make_directory_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn make_directory_with_parents>( &self, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_make_directory_with_parents( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn make_symbolic_link, Q: IsA>( &self, symlink_value: P, cancellable: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_make_symbolic_link( self.as_ref().to_glib_none().0, symlink_value.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn measure_disk_usage>( &self, flags: FileMeasureFlags, cancellable: Option<&P>, progress_callback: Option>, ) -> Result<(u64, u64, u64), Error> { let progress_callback_data: Box_>> = Box::new(progress_callback); unsafe extern "C" fn progress_callback_func>( reporting: glib_sys::gboolean, current_size: u64, num_dirs: u64, num_files: u64, user_data: glib_sys::gpointer, ) { let reporting = from_glib(reporting); let callback: &Option> = &*(user_data as *mut _); if let Some(ref callback) = *callback { callback(reporting, current_size, num_dirs, num_files) } else { panic!("cannot get closure...") }; } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func::

as _) } else { None }; let super_callback0: Box_>> = progress_callback_data; unsafe { let mut disk_usage = mem::uninitialized(); let mut num_dirs = mem::uninitialized(); let mut num_files = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_file_measure_disk_usage( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, Box::into_raw(super_callback0) as *mut _, &mut disk_usage, &mut num_dirs, &mut num_files, &mut error, ); if error.is_null() { Ok((disk_usage, num_dirs, num_files)) } else { Err(from_glib_full(error)) } } } //fn measure_disk_usage_async, Q: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R) { // unsafe { TODO: call gio_sys:g_file_measure_disk_usage_async() } //} //#[cfg(feature = "futures")] //fn measure_disk_usage_async_future) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Box_> + std::marker::Unpin> { //use GioFuture; //use fragile::Fragile; //let progress_callback = progress_callback.map(ToOwned::to_owned); //GioFuture::new(self, move |obj, send| { // let cancellable = Cancellable::new(); // let send = Fragile::new(send); // obj.measure_disk_usage_async( // flags, // io_priority, // Some(&cancellable), // progress_callback.as_ref().map(::std::borrow::Borrow::borrow), // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} fn monitor>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_monitor( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn monitor_directory>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_monitor_directory( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn monitor_file>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_monitor_file( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn mount_enclosing_volume< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn mount_enclosing_volume_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_mount_enclosing_volume_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = mount_enclosing_volume_trampoline::; unsafe { gio_sys::g_file_mount_enclosing_volume( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn mount_enclosing_volume_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.mount_enclosing_volume( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn mount_mountable< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn mount_mountable_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_mount_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = mount_mountable_trampoline::; unsafe { gio_sys::g_file_mount_mountable( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn mount_mountable_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.mount_mountable( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn move_, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), Error> { let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback; unsafe extern "C" fn progress_callback_func, Q: IsA>( current_num_bytes: i64, total_num_bytes: i64, user_data: glib_sys::gpointer, ) { let callback: *mut Option<&mut dyn (FnMut(i64, i64))> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(i64, i64))>; if let Some(ref mut callback) = *callback { callback(current_num_bytes, total_num_bytes) } else { panic!("cannot get closure...") }; } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func:: as _) } else { None }; let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data; unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_move( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, super_callback0 as *const _ as usize as *mut _, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn open_readwrite>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_open_readwrite( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn open_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn open_readwrite_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_open_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = open_readwrite_async_trampoline::; unsafe { gio_sys::g_file_open_readwrite_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn open_readwrite_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.open_readwrite_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } #[cfg(any(feature = "v2_56", feature = "dox"))] fn peek_path(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_peek_path(self.as_ref().to_glib_none().0)) } } fn poll_mountable, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn poll_mountable_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_poll_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = poll_mountable_trampoline::; unsafe { gio_sys::g_file_poll_mountable( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn poll_mountable_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.poll_mountable(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn query_default_handler>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_query_default_handler( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_exists>(&self, cancellable: Option<&P>) -> bool { unsafe { from_glib(gio_sys::g_file_query_exists( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, )) } } fn query_file_type>( &self, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> FileType { unsafe { from_glib(gio_sys::g_file_query_file_type( self.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, )) } } fn query_filesystem_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_query_filesystem_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_filesystem_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn query_filesystem_info_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_query_filesystem_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = query_filesystem_info_async_trampoline::; unsafe { gio_sys::g_file_query_filesystem_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn query_filesystem_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let attributes = String::from(attributes); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.query_filesystem_info_async( &attributes, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn query_info>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_query_info_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = query_info_async_trampoline::; unsafe { gio_sys::g_file_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let attributes = String::from(attributes); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.query_info_async( &attributes, flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } //fn query_settable_attributes>(&self, cancellable: Option<&P>) -> Result { // unsafe { TODO: call gio_sys:g_file_query_settable_attributes() } //} //fn query_writable_namespaces>(&self, cancellable: Option<&P>) -> Result { // unsafe { TODO: call gio_sys:g_file_query_writable_namespaces() } //} fn read>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_read( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn read_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn read_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_read_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = read_async_trampoline::; unsafe { gio_sys::g_file_read_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn read_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn replace>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_replace( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.to_glib(), flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn replace_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn replace_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_replace_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = replace_async_trampoline::; unsafe { gio_sys::g_file_replace_async( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.to_glib(), flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn replace_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let etag = etag.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.replace_async( etag.as_ref().map(::std::borrow::Borrow::borrow), make_backup, flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn replace_contents>( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { let length = contents.len() as usize; unsafe { let mut new_etag = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_file_replace_contents( self.as_ref().to_glib_none().0, contents.to_glib_none().0, length, etag.to_glib_none().0, make_backup.to_glib(), flags.to_glib(), &mut new_etag, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(new_etag)) } else { Err(from_glib_full(error)) } } } //fn replace_contents_bytes_async, Q: FnOnce(Result<(), Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q) { // unsafe { TODO: call gio_sys:g_file_replace_contents_bytes_async() } //} fn replace_readwrite>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_replace_readwrite( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.to_glib(), flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn replace_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn replace_readwrite_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_replace_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = replace_readwrite_async_trampoline::; unsafe { gio_sys::g_file_replace_readwrite_async( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.to_glib(), flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn replace_readwrite_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let etag = etag.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.replace_readwrite_async( etag.as_ref().map(::std::borrow::Borrow::borrow), make_backup, flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn resolve_relative_path>(&self, relative_path: P) -> Option { unsafe { from_glib_full(gio_sys::g_file_resolve_relative_path( self.as_ref().to_glib_none().0, relative_path.as_ref().to_glib_none().0, )) } } //fn set_attribute>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), Error> { // unsafe { TODO: call gio_sys:g_file_set_attribute() } //} fn set_attribute_byte_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_byte_string( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_int32>( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_int32( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_int64>( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_int64( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_string( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_uint32>( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_uint32( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_uint64>( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attribute_uint64( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attributes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn set_attributes_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut info = ptr::null_mut(); let _ = gio_sys::g_file_set_attributes_finish( _source_object as *mut _, res, &mut info, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(info)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = set_attributes_async_trampoline::; unsafe { gio_sys::g_file_set_attributes_async( self.as_ref().to_glib_none().0, info.to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn set_attributes_async_future( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let info = info.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.set_attributes_async(&info, flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn set_attributes_from_info>( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_set_attributes_from_info( self.as_ref().to_glib_none().0, info.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_display_name>( &self, display_name: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_set_display_name( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn set_display_name_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, display_name: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn set_display_name_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_set_display_name_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = set_display_name_async_trampoline::; unsafe { gio_sys::g_file_set_display_name_async( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn set_display_name_async_future( &self, display_name: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let display_name = String::from(display_name); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.set_display_name_async( &display_name, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn start_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: DriveStartFlags, start_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn start_mountable_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_start_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = start_mountable_trampoline::; unsafe { gio_sys::g_file_start_mountable( self.as_ref().to_glib_none().0, flags.to_glib(), start_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn start_mountable_future + Clone + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let start_operation = start_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.start_mountable( flags, start_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn stop_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn stop_mountable_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_stop_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = stop_mountable_trampoline::; unsafe { gio_sys::g_file_stop_mountable( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn stop_mountable_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.stop_mountable( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn supports_thread_contexts(&self) -> bool { unsafe { from_glib(gio_sys::g_file_supports_thread_contexts( self.as_ref().to_glib_none().0, )) } } fn trash>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_trash( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn trash_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn trash_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_trash_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = trash_async_trampoline::; unsafe { gio_sys::g_file_trash_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn trash_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.trash_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn unmount_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn unmount_mountable_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_file_unmount_mountable_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = unmount_mountable_with_operation_trampoline::; unsafe { gio_sys::g_file_unmount_mountable_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn unmount_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.unmount_mountable_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } } impl fmt::Display for File { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "File") } } gio-0.7.0/src/auto/file_attribute_matcher.rs010064400007650000024000000043741350341657000173410ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::GString; use std::fmt; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FileAttributeMatcher(Shared); match fn { ref => |ptr| gio_sys::g_file_attribute_matcher_ref(ptr), unref => |ptr| gio_sys::g_file_attribute_matcher_unref(ptr), get_type => || gio_sys::g_file_attribute_matcher_get_type(), } } impl FileAttributeMatcher { pub fn new(attributes: &str) -> FileAttributeMatcher { unsafe { from_glib_full(gio_sys::g_file_attribute_matcher_new( attributes.to_glib_none().0, )) } } pub fn enumerate_namespace(&self, ns: &str) -> bool { unsafe { from_glib(gio_sys::g_file_attribute_matcher_enumerate_namespace( self.to_glib_none().0, ns.to_glib_none().0, )) } } pub fn matches(&self, attribute: &str) -> bool { unsafe { from_glib(gio_sys::g_file_attribute_matcher_matches( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn matches_only(&self, attribute: &str) -> bool { unsafe { from_glib(gio_sys::g_file_attribute_matcher_matches_only( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn subtract( &self, subtract: Option<&FileAttributeMatcher>, ) -> Option { unsafe { from_glib_full(gio_sys::g_file_attribute_matcher_subtract( self.to_glib_none().0, subtract.to_glib_none().0, )) } } fn to_string(&self) -> GString { unsafe { from_glib_full(gio_sys::g_file_attribute_matcher_to_string( self.to_glib_none().0, )) } } } impl fmt::Display for FileAttributeMatcher { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_string()) } } gio-0.7.0/src/auto/file_icon.rs010064400007650000024000000016201350341657000145520ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use File; use Icon; use LoadableIcon; glib_wrapper! { pub struct FileIcon(Object) @implements Icon, LoadableIcon; match fn { get_type => || gio_sys::g_file_icon_get_type(), } } impl FileIcon { pub fn new>(file: &P) -> FileIcon { unsafe { from_glib_full(gio_sys::g_file_icon_new(file.as_ref().to_glib_none().0)) } } pub fn get_file(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_icon_get_file(self.to_glib_none().0)) } } } impl fmt::Display for FileIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileIcon") } } gio-0.7.0/src/auto/file_info.rs010064400007650000024000000347261350341657000145720ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use std; use std::fmt; use FileAttributeMatcher; use FileAttributeStatus; use FileAttributeType; use FileType; use Icon; glib_wrapper! { pub struct FileInfo(Object); match fn { get_type => || gio_sys::g_file_info_get_type(), } } impl FileInfo { pub fn new() -> FileInfo { unsafe { from_glib_full(gio_sys::g_file_info_new()) } } pub fn clear_status(&self) { unsafe { gio_sys::g_file_info_clear_status(self.to_glib_none().0); } } pub fn copy_into(&self, dest_info: &FileInfo) { unsafe { gio_sys::g_file_info_copy_into(self.to_glib_none().0, dest_info.to_glib_none().0); } } pub fn dup(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_info_dup(self.to_glib_none().0)) } } pub fn get_attribute_as_string(&self, attribute: &str) -> Option { unsafe { from_glib_full(gio_sys::g_file_info_get_attribute_as_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_boolean(&self, attribute: &str) -> bool { unsafe { from_glib(gio_sys::g_file_info_get_attribute_boolean( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_byte_string(&self, attribute: &str) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_attribute_byte_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } //pub fn get_attribute_data(&self, attribute: &str, value_pp: /*Unimplemented*/&mut Fundamental: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> { // unsafe { TODO: call gio_sys:g_file_info_get_attribute_data() } //} pub fn get_attribute_int32(&self, attribute: &str) -> i32 { unsafe { gio_sys::g_file_info_get_attribute_int32( self.to_glib_none().0, attribute.to_glib_none().0, ) } } pub fn get_attribute_int64(&self, attribute: &str) -> i64 { unsafe { gio_sys::g_file_info_get_attribute_int64( self.to_glib_none().0, attribute.to_glib_none().0, ) } } pub fn get_attribute_object(&self, attribute: &str) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_attribute_object( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_status(&self, attribute: &str) -> FileAttributeStatus { unsafe { from_glib(gio_sys::g_file_info_get_attribute_status( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_string(&self, attribute: &str) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_attribute_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_stringv(&self, attribute: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_file_info_get_attribute_stringv( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_type(&self, attribute: &str) -> FileAttributeType { unsafe { from_glib(gio_sys::g_file_info_get_attribute_type( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn get_attribute_uint32(&self, attribute: &str) -> u32 { unsafe { gio_sys::g_file_info_get_attribute_uint32( self.to_glib_none().0, attribute.to_glib_none().0, ) } } pub fn get_attribute_uint64(&self, attribute: &str) -> u64 { unsafe { gio_sys::g_file_info_get_attribute_uint64( self.to_glib_none().0, attribute.to_glib_none().0, ) } } pub fn get_content_type(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_content_type(self.to_glib_none().0)) } } pub fn get_deletion_date(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_info_get_deletion_date( self.to_glib_none().0, )) } } pub fn get_display_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_display_name(self.to_glib_none().0)) } } pub fn get_edit_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_edit_name(self.to_glib_none().0)) } } pub fn get_etag(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_etag(self.to_glib_none().0)) } } pub fn get_file_type(&self) -> FileType { unsafe { from_glib(gio_sys::g_file_info_get_file_type(self.to_glib_none().0)) } } pub fn get_icon(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_icon(self.to_glib_none().0)) } } pub fn get_is_backup(&self) -> bool { unsafe { from_glib(gio_sys::g_file_info_get_is_backup(self.to_glib_none().0)) } } pub fn get_is_hidden(&self) -> bool { unsafe { from_glib(gio_sys::g_file_info_get_is_hidden(self.to_glib_none().0)) } } pub fn get_is_symlink(&self) -> bool { unsafe { from_glib(gio_sys::g_file_info_get_is_symlink(self.to_glib_none().0)) } } pub fn get_modification_time(&self) -> glib::TimeVal { unsafe { let mut result = glib::TimeVal::uninitialized(); gio_sys::g_file_info_get_modification_time( self.to_glib_none().0, result.to_glib_none_mut().0, ); result } } pub fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_name(self.to_glib_none().0)) } } pub fn get_size(&self) -> i64 { unsafe { gio_sys::g_file_info_get_size(self.to_glib_none().0) } } pub fn get_sort_order(&self) -> i32 { unsafe { gio_sys::g_file_info_get_sort_order(self.to_glib_none().0) } } pub fn get_symbolic_icon(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_symbolic_icon( self.to_glib_none().0, )) } } pub fn get_symlink_target(&self) -> Option { unsafe { from_glib_none(gio_sys::g_file_info_get_symlink_target( self.to_glib_none().0, )) } } pub fn has_attribute(&self, attribute: &str) -> bool { unsafe { from_glib(gio_sys::g_file_info_has_attribute( self.to_glib_none().0, attribute.to_glib_none().0, )) } } pub fn has_namespace(&self, name_space: &str) -> bool { unsafe { from_glib(gio_sys::g_file_info_has_namespace( self.to_glib_none().0, name_space.to_glib_none().0, )) } } pub fn list_attributes(&self, name_space: Option<&str>) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_file_info_list_attributes( self.to_glib_none().0, name_space.to_glib_none().0, )) } } pub fn remove_attribute(&self, attribute: &str) { unsafe { gio_sys::g_file_info_remove_attribute( self.to_glib_none().0, attribute.to_glib_none().0, ); } } //pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Fundamental: Pointer) { // unsafe { TODO: call gio_sys:g_file_info_set_attribute() } //} pub fn set_attribute_boolean(&self, attribute: &str, attr_value: bool) { unsafe { gio_sys::g_file_info_set_attribute_boolean( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib(), ); } } pub fn set_attribute_byte_string(&self, attribute: &str, attr_value: &str) { unsafe { gio_sys::g_file_info_set_attribute_byte_string( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib_none().0, ); } } pub fn set_attribute_int32(&self, attribute: &str, attr_value: i32) { unsafe { gio_sys::g_file_info_set_attribute_int32( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } pub fn set_attribute_int64(&self, attribute: &str, attr_value: i64) { unsafe { gio_sys::g_file_info_set_attribute_int64( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } pub fn set_attribute_mask(&self, mask: &FileAttributeMatcher) { unsafe { gio_sys::g_file_info_set_attribute_mask(self.to_glib_none().0, mask.to_glib_none().0); } } pub fn set_attribute_object>(&self, attribute: &str, attr_value: &P) { unsafe { gio_sys::g_file_info_set_attribute_object( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.as_ref().to_glib_none().0, ); } } pub fn set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool { unsafe { from_glib(gio_sys::g_file_info_set_attribute_status( self.to_glib_none().0, attribute.to_glib_none().0, status.to_glib(), )) } } pub fn set_attribute_string(&self, attribute: &str, attr_value: &str) { unsafe { gio_sys::g_file_info_set_attribute_string( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib_none().0, ); } } pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) { unsafe { gio_sys::g_file_info_set_attribute_stringv( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib_none().0, ); } } pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) { unsafe { gio_sys::g_file_info_set_attribute_uint32( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } pub fn set_attribute_uint64(&self, attribute: &str, attr_value: u64) { unsafe { gio_sys::g_file_info_set_attribute_uint64( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } pub fn set_content_type(&self, content_type: &str) { unsafe { gio_sys::g_file_info_set_content_type( self.to_glib_none().0, content_type.to_glib_none().0, ); } } pub fn set_display_name(&self, display_name: &str) { unsafe { gio_sys::g_file_info_set_display_name( self.to_glib_none().0, display_name.to_glib_none().0, ); } } pub fn set_edit_name(&self, edit_name: &str) { unsafe { gio_sys::g_file_info_set_edit_name(self.to_glib_none().0, edit_name.to_glib_none().0); } } pub fn set_file_type(&self, type_: FileType) { unsafe { gio_sys::g_file_info_set_file_type(self.to_glib_none().0, type_.to_glib()); } } pub fn set_icon>(&self, icon: &P) { unsafe { gio_sys::g_file_info_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } pub fn set_is_hidden(&self, is_hidden: bool) { unsafe { gio_sys::g_file_info_set_is_hidden(self.to_glib_none().0, is_hidden.to_glib()); } } pub fn set_is_symlink(&self, is_symlink: bool) { unsafe { gio_sys::g_file_info_set_is_symlink(self.to_glib_none().0, is_symlink.to_glib()); } } pub fn set_modification_time(&self, mtime: &mut glib::TimeVal) { unsafe { gio_sys::g_file_info_set_modification_time( self.to_glib_none().0, mtime.to_glib_none_mut().0, ); } } pub fn set_name>(&self, name: P) { unsafe { gio_sys::g_file_info_set_name(self.to_glib_none().0, name.as_ref().to_glib_none().0); } } pub fn set_size(&self, size: i64) { unsafe { gio_sys::g_file_info_set_size(self.to_glib_none().0, size); } } pub fn set_sort_order(&self, sort_order: i32) { unsafe { gio_sys::g_file_info_set_sort_order(self.to_glib_none().0, sort_order); } } pub fn set_symbolic_icon>(&self, icon: &P) { unsafe { gio_sys::g_file_info_set_symbolic_icon( self.to_glib_none().0, icon.as_ref().to_glib_none().0, ); } } pub fn set_symlink_target(&self, symlink_target: &str) { unsafe { gio_sys::g_file_info_set_symlink_target( self.to_glib_none().0, symlink_target.to_glib_none().0, ); } } pub fn unset_attribute_mask(&self) { unsafe { gio_sys::g_file_info_unset_attribute_mask(self.to_glib_none().0); } } } impl Default for FileInfo { fn default() -> Self { Self::new() } } impl fmt::Display for FileInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileInfo") } } gio-0.7.0/src/auto/file_input_stream.rs010064400007650000024000000106541350341657000163430ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use FileInfo; use InputStream; use Seekable; glib_wrapper! { pub struct FileInputStream(Object) @extends InputStream, @implements Seekable; match fn { get_type => || gio_sys::g_file_input_stream_get_type(), } } pub const NONE_FILE_INPUT_STREAM: Option<&FileInputStream> = None; pub trait FileInputStreamExt: 'static { fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; fn query_info_async, Q: FnOnce(Result) + Send + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; } impl> FileInputStreamExt for O { fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_input_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_input_stream_query_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = query_info_async_trampoline::; unsafe { gio_sys::g_file_input_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let attributes = String::from(attributes); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.query_info_async(&attributes, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for FileInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileInputStream") } } gio-0.7.0/src/auto/file_io_stream.rs010064400007650000024000000112041350341657000156030ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use FileInfo; use IOStream; use Seekable; glib_wrapper! { pub struct FileIOStream(Object) @extends IOStream, @implements Seekable; match fn { get_type => || gio_sys::g_file_io_stream_get_type(), } } pub const NONE_FILE_IO_STREAM: Option<&FileIOStream> = None; pub trait FileIOStreamExt: 'static { fn get_etag(&self) -> Option; fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; fn query_info_async, Q: FnOnce(Result) + Send + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; } impl> FileIOStreamExt for O { fn get_etag(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_io_stream_get_etag( self.as_ref().to_glib_none().0, )) } } fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_io_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_io_stream_query_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = query_info_async_trampoline::; unsafe { gio_sys::g_file_io_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let attributes = String::from(attributes); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.query_info_async(&attributes, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for FileIOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileIOStream") } } gio-0.7.0/src/auto/file_monitor.rs010064400007650000024000000142651350341657000153220ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use File; use FileMonitorEvent; glib_wrapper! { pub struct FileMonitor(Object); match fn { get_type => || gio_sys::g_file_monitor_get_type(), } } pub const NONE_FILE_MONITOR: Option<&FileMonitor> = None; pub trait FileMonitorExt: 'static { fn cancel(&self) -> bool; fn emit_event, Q: IsA>( &self, child: &P, other_file: &Q, event_type: FileMonitorEvent, ); fn is_cancelled(&self) -> bool; fn set_rate_limit(&self, limit_msecs: i32); fn get_property_cancelled(&self) -> bool; fn get_property_rate_limit(&self) -> i32; fn connect_changed, FileMonitorEvent) + 'static>( &self, f: F, ) -> SignalHandlerId; fn connect_property_cancelled_notify(&self, f: F) -> SignalHandlerId; fn connect_property_rate_limit_notify(&self, f: F) -> SignalHandlerId; } impl> FileMonitorExt for O { fn cancel(&self) -> bool { unsafe { from_glib(gio_sys::g_file_monitor_cancel( self.as_ref().to_glib_none().0, )) } } fn emit_event, Q: IsA>( &self, child: &P, other_file: &Q, event_type: FileMonitorEvent, ) { unsafe { gio_sys::g_file_monitor_emit_event( self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, other_file.as_ref().to_glib_none().0, event_type.to_glib(), ); } } fn is_cancelled(&self) -> bool { unsafe { from_glib(gio_sys::g_file_monitor_is_cancelled( self.as_ref().to_glib_none().0, )) } } fn set_rate_limit(&self, limit_msecs: i32) { unsafe { gio_sys::g_file_monitor_set_rate_limit(self.as_ref().to_glib_none().0, limit_msecs); } } fn get_property_cancelled(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"cancelled\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn get_property_rate_limit(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"rate-limit\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_changed, FileMonitorEvent) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline< P, F: Fn(&P, &File, Option<&File>, FileMonitorEvent) + 'static, >( this: *mut gio_sys::GFileMonitor, file: *mut gio_sys::GFile, other_file: *mut gio_sys::GFile, event_type: gio_sys::GFileMonitorEvent, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &FileMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(file), Option::::from_glib_borrow(other_file).as_ref(), from_glib(event_type), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_cancelled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_cancelled_trampoline( this: *mut gio_sys::GFileMonitor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FileMonitor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::cancelled\0".as_ptr() as *const _, Some(transmute(notify_cancelled_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_rate_limit_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_rate_limit_trampoline( this: *mut gio_sys::GFileMonitor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FileMonitor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::rate-limit\0".as_ptr() as *const _, Some(transmute(notify_rate_limit_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for FileMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileMonitor") } } gio-0.7.0/src/auto/file_output_stream.rs010064400007650000024000000113141350341657000165360ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use FileInfo; use OutputStream; use Seekable; glib_wrapper! { pub struct FileOutputStream(Object) @extends OutputStream, @implements Seekable; match fn { get_type => || gio_sys::g_file_output_stream_get_type(), } } pub const NONE_FILE_OUTPUT_STREAM: Option<&FileOutputStream> = None; pub trait FileOutputStreamExt: 'static { fn get_etag(&self) -> Option; fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; fn query_info_async, Q: FnOnce(Result) + Send + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; } impl> FileOutputStreamExt for O { fn get_etag(&self) -> Option { unsafe { from_glib_full(gio_sys::g_file_output_stream_get_etag( self.as_ref().to_glib_none().0, )) } } fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_output_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_file_output_stream_query_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = query_info_async_trampoline::; unsafe { gio_sys::g_file_output_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let attributes = String::from(attributes); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.query_info_async(&attributes, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for FileOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FileOutputStream") } } gio-0.7.0/src/auto/filename_completer.rs010064400007650000024000000061231350341657000164600ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib_wrapper! { pub struct FilenameCompleter(Object); match fn { get_type => || gio_sys::g_filename_completer_get_type(), } } impl FilenameCompleter { pub fn new() -> FilenameCompleter { unsafe { from_glib_full(gio_sys::g_filename_completer_new()) } } } impl Default for FilenameCompleter { fn default() -> Self { Self::new() } } pub const NONE_FILENAME_COMPLETER: Option<&FilenameCompleter> = None; pub trait FilenameCompleterExt: 'static { fn get_completion_suffix(&self, initial_text: &str) -> Option; fn get_completions(&self, initial_text: &str) -> Vec; fn set_dirs_only(&self, dirs_only: bool); fn connect_got_completion_data(&self, f: F) -> SignalHandlerId; } impl> FilenameCompleterExt for O { fn get_completion_suffix(&self, initial_text: &str) -> Option { unsafe { from_glib_full(gio_sys::g_filename_completer_get_completion_suffix( self.as_ref().to_glib_none().0, initial_text.to_glib_none().0, )) } } fn get_completions(&self, initial_text: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_filename_completer_get_completions( self.as_ref().to_glib_none().0, initial_text.to_glib_none().0, )) } } fn set_dirs_only(&self, dirs_only: bool) { unsafe { gio_sys::g_filename_completer_set_dirs_only( self.as_ref().to_glib_none().0, dirs_only.to_glib(), ); } } fn connect_got_completion_data(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn got_completion_data_trampoline( this: *mut gio_sys::GFilenameCompleter, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FilenameCompleter::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"got-completion-data\0".as_ptr() as *const _, Some(transmute( got_completion_data_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for FilenameCompleter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FilenameCompleter") } } gio-0.7.0/src/auto/filter_input_stream.rs010064400007650000024000000055161350341657000167120ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use InputStream; glib_wrapper! { pub struct FilterInputStream(Object) @extends InputStream; match fn { get_type => || gio_sys::g_filter_input_stream_get_type(), } } pub const NONE_FILTER_INPUT_STREAM: Option<&FilterInputStream> = None; pub trait FilterInputStreamExt: 'static { fn get_base_stream(&self) -> Option; fn get_close_base_stream(&self) -> bool; fn set_close_base_stream(&self, close_base: bool); fn connect_property_close_base_stream_notify( &self, f: F, ) -> SignalHandlerId; } impl> FilterInputStreamExt for O { fn get_base_stream(&self) -> Option { unsafe { from_glib_none(gio_sys::g_filter_input_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } fn get_close_base_stream(&self) -> bool { unsafe { from_glib(gio_sys::g_filter_input_stream_get_close_base_stream( self.as_ref().to_glib_none().0, )) } } fn set_close_base_stream(&self, close_base: bool) { unsafe { gio_sys::g_filter_input_stream_set_close_base_stream( self.as_ref().to_glib_none().0, close_base.to_glib(), ); } } fn connect_property_close_base_stream_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_close_base_stream_trampoline( this: *mut gio_sys::GFilterInputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FilterInputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::close-base-stream\0".as_ptr() as *const _, Some(transmute( notify_close_base_stream_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for FilterInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FilterInputStream") } } gio-0.7.0/src/auto/filter_output_stream.rs010064400007650000024000000055441350341657000171140ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use OutputStream; glib_wrapper! { pub struct FilterOutputStream(Object) @extends OutputStream; match fn { get_type => || gio_sys::g_filter_output_stream_get_type(), } } pub const NONE_FILTER_OUTPUT_STREAM: Option<&FilterOutputStream> = None; pub trait FilterOutputStreamExt: 'static { fn get_base_stream(&self) -> Option; fn get_close_base_stream(&self) -> bool; fn set_close_base_stream(&self, close_base: bool); fn connect_property_close_base_stream_notify( &self, f: F, ) -> SignalHandlerId; } impl> FilterOutputStreamExt for O { fn get_base_stream(&self) -> Option { unsafe { from_glib_none(gio_sys::g_filter_output_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } fn get_close_base_stream(&self) -> bool { unsafe { from_glib(gio_sys::g_filter_output_stream_get_close_base_stream( self.as_ref().to_glib_none().0, )) } } fn set_close_base_stream(&self, close_base: bool) { unsafe { gio_sys::g_filter_output_stream_set_close_base_stream( self.as_ref().to_glib_none().0, close_base.to_glib(), ); } } fn connect_property_close_base_stream_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_close_base_stream_trampoline( this: *mut gio_sys::GFilterOutputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&FilterOutputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::close-base-stream\0".as_ptr() as *const _, Some(transmute( notify_close_base_stream_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for FilterOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "FilterOutputStream") } } gio-0.7.0/src/auto/flags.rs010064400007650000024000000627031350341657000137300ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::value::FromValue; use glib::value::FromValueOptional; use glib::value::SetValue; use glib::value::Value; use glib::StaticType; use glib::Type; use gobject_sys; bitflags! { pub struct AppInfoCreateFlags: u32 { const NONE = 0; const NEEDS_TERMINAL = 1; const SUPPORTS_URIS = 2; const SUPPORTS_STARTUP_NOTIFICATION = 4; } } #[doc(hidden)] impl ToGlib for AppInfoCreateFlags { type GlibType = gio_sys::GAppInfoCreateFlags; fn to_glib(&self) -> gio_sys::GAppInfoCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AppInfoCreateFlags { fn from_glib(value: gio_sys::GAppInfoCreateFlags) -> AppInfoCreateFlags { AppInfoCreateFlags::from_bits_truncate(value) } } impl StaticType for AppInfoCreateFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_app_info_create_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for AppInfoCreateFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for AppInfoCreateFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for AppInfoCreateFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct ApplicationFlags: u32 { const FLAGS_NONE = 0; const IS_SERVICE = 1; const IS_LAUNCHER = 2; const HANDLES_OPEN = 4; const HANDLES_COMMAND_LINE = 8; const SEND_ENVIRONMENT = 16; const NON_UNIQUE = 32; const CAN_OVERRIDE_APP_ID = 64; } } #[doc(hidden)] impl ToGlib for ApplicationFlags { type GlibType = gio_sys::GApplicationFlags; fn to_glib(&self) -> gio_sys::GApplicationFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ApplicationFlags { fn from_glib(value: gio_sys::GApplicationFlags) -> ApplicationFlags { ApplicationFlags::from_bits_truncate(value) } } impl StaticType for ApplicationFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_application_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for ApplicationFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ApplicationFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for ApplicationFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct AskPasswordFlags: u32 { const NEED_PASSWORD = 1; const NEED_USERNAME = 2; const NEED_DOMAIN = 4; const SAVING_SUPPORTED = 8; const ANONYMOUS_SUPPORTED = 16; const TCRYPT = 32; } } #[doc(hidden)] impl ToGlib for AskPasswordFlags { type GlibType = gio_sys::GAskPasswordFlags; fn to_glib(&self) -> gio_sys::GAskPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AskPasswordFlags { fn from_glib(value: gio_sys::GAskPasswordFlags) -> AskPasswordFlags { AskPasswordFlags::from_bits_truncate(value) } } impl StaticType for AskPasswordFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_ask_password_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for AskPasswordFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for AskPasswordFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for AskPasswordFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct ConverterFlags: u32 { const NONE = 0; const INPUT_AT_END = 1; const FLUSH = 2; } } #[doc(hidden)] impl ToGlib for ConverterFlags { type GlibType = gio_sys::GConverterFlags; fn to_glib(&self) -> gio_sys::GConverterFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ConverterFlags { fn from_glib(value: gio_sys::GConverterFlags) -> ConverterFlags { ConverterFlags::from_bits_truncate(value) } } impl StaticType for ConverterFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_converter_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for ConverterFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ConverterFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for ConverterFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct DriveStartFlags: u32 { const NONE = 0; } } #[doc(hidden)] impl ToGlib for DriveStartFlags { type GlibType = gio_sys::GDriveStartFlags; fn to_glib(&self) -> gio_sys::GDriveStartFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DriveStartFlags { fn from_glib(value: gio_sys::GDriveStartFlags) -> DriveStartFlags { DriveStartFlags::from_bits_truncate(value) } } impl StaticType for DriveStartFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_drive_start_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for DriveStartFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for DriveStartFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for DriveStartFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct FileCopyFlags: u32 { const NONE = 0; const OVERWRITE = 1; const BACKUP = 2; const NOFOLLOW_SYMLINKS = 4; const ALL_METADATA = 8; const NO_FALLBACK_FOR_MOVE = 16; const TARGET_DEFAULT_PERMS = 32; } } #[doc(hidden)] impl ToGlib for FileCopyFlags { type GlibType = gio_sys::GFileCopyFlags; fn to_glib(&self) -> gio_sys::GFileCopyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCopyFlags { fn from_glib(value: gio_sys::GFileCopyFlags) -> FileCopyFlags { FileCopyFlags::from_bits_truncate(value) } } impl StaticType for FileCopyFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_copy_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for FileCopyFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileCopyFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for FileCopyFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct FileCreateFlags: u32 { const NONE = 0; const PRIVATE = 1; const REPLACE_DESTINATION = 2; } } #[doc(hidden)] impl ToGlib for FileCreateFlags { type GlibType = gio_sys::GFileCreateFlags; fn to_glib(&self) -> gio_sys::GFileCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCreateFlags { fn from_glib(value: gio_sys::GFileCreateFlags) -> FileCreateFlags { FileCreateFlags::from_bits_truncate(value) } } impl StaticType for FileCreateFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_create_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for FileCreateFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileCreateFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for FileCreateFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct FileMeasureFlags: u32 { const NONE = 0; const REPORT_ANY_ERROR = 2; const APPARENT_SIZE = 4; const NO_XDEV = 8; } } #[doc(hidden)] impl ToGlib for FileMeasureFlags { type GlibType = gio_sys::GFileMeasureFlags; fn to_glib(&self) -> gio_sys::GFileMeasureFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMeasureFlags { fn from_glib(value: gio_sys::GFileMeasureFlags) -> FileMeasureFlags { FileMeasureFlags::from_bits_truncate(value) } } impl StaticType for FileMeasureFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_measure_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for FileMeasureFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileMeasureFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for FileMeasureFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct FileMonitorFlags: u32 { const NONE = 0; const WATCH_MOUNTS = 1; const SEND_MOVED = 2; const WATCH_HARD_LINKS = 4; const WATCH_MOVES = 8; } } #[doc(hidden)] impl ToGlib for FileMonitorFlags { type GlibType = gio_sys::GFileMonitorFlags; fn to_glib(&self) -> gio_sys::GFileMonitorFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMonitorFlags { fn from_glib(value: gio_sys::GFileMonitorFlags) -> FileMonitorFlags { FileMonitorFlags::from_bits_truncate(value) } } impl StaticType for FileMonitorFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_monitor_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for FileMonitorFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileMonitorFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for FileMonitorFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct FileQueryInfoFlags: u32 { const NONE = 0; const NOFOLLOW_SYMLINKS = 1; } } #[doc(hidden)] impl ToGlib for FileQueryInfoFlags { type GlibType = gio_sys::GFileQueryInfoFlags; fn to_glib(&self) -> gio_sys::GFileQueryInfoFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileQueryInfoFlags { fn from_glib(value: gio_sys::GFileQueryInfoFlags) -> FileQueryInfoFlags { FileQueryInfoFlags::from_bits_truncate(value) } } impl StaticType for FileQueryInfoFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_file_query_info_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for FileQueryInfoFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for FileQueryInfoFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for FileQueryInfoFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct IOStreamSpliceFlags: u32 { const NONE = 0; const CLOSE_STREAM1 = 1; const CLOSE_STREAM2 = 2; const WAIT_FOR_BOTH = 4; } } #[doc(hidden)] impl ToGlib for IOStreamSpliceFlags { type GlibType = gio_sys::GIOStreamSpliceFlags; fn to_glib(&self) -> gio_sys::GIOStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for IOStreamSpliceFlags { fn from_glib(value: gio_sys::GIOStreamSpliceFlags) -> IOStreamSpliceFlags { IOStreamSpliceFlags::from_bits_truncate(value) } } impl StaticType for IOStreamSpliceFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_io_stream_splice_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for IOStreamSpliceFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for IOStreamSpliceFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for IOStreamSpliceFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct MountMountFlags: u32 { const NONE = 0; } } #[doc(hidden)] impl ToGlib for MountMountFlags { type GlibType = gio_sys::GMountMountFlags; fn to_glib(&self) -> gio_sys::GMountMountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountMountFlags { fn from_glib(value: gio_sys::GMountMountFlags) -> MountMountFlags { MountMountFlags::from_bits_truncate(value) } } impl StaticType for MountMountFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_mount_mount_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for MountMountFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for MountMountFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for MountMountFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct MountUnmountFlags: u32 { const NONE = 0; const FORCE = 1; } } #[doc(hidden)] impl ToGlib for MountUnmountFlags { type GlibType = gio_sys::GMountUnmountFlags; fn to_glib(&self) -> gio_sys::GMountUnmountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountUnmountFlags { fn from_glib(value: gio_sys::GMountUnmountFlags) -> MountUnmountFlags { MountUnmountFlags::from_bits_truncate(value) } } impl StaticType for MountUnmountFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_mount_unmount_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for MountUnmountFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for MountUnmountFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for MountUnmountFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct OutputStreamSpliceFlags: u32 { const NONE = 0; const CLOSE_SOURCE = 1; const CLOSE_TARGET = 2; } } #[doc(hidden)] impl ToGlib for OutputStreamSpliceFlags { type GlibType = gio_sys::GOutputStreamSpliceFlags; fn to_glib(&self) -> gio_sys::GOutputStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for OutputStreamSpliceFlags { fn from_glib(value: gio_sys::GOutputStreamSpliceFlags) -> OutputStreamSpliceFlags { OutputStreamSpliceFlags::from_bits_truncate(value) } } impl StaticType for OutputStreamSpliceFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_output_stream_splice_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for OutputStreamSpliceFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for OutputStreamSpliceFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for OutputStreamSpliceFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct ResourceLookupFlags: u32 { const NONE = 0; } } #[doc(hidden)] impl ToGlib for ResourceLookupFlags { type GlibType = gio_sys::GResourceLookupFlags; fn to_glib(&self) -> gio_sys::GResourceLookupFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ResourceLookupFlags { fn from_glib(value: gio_sys::GResourceLookupFlags) -> ResourceLookupFlags { ResourceLookupFlags::from_bits_truncate(value) } } impl StaticType for ResourceLookupFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_resource_lookup_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for ResourceLookupFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for ResourceLookupFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for ResourceLookupFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct SettingsBindFlags: u32 { const DEFAULT = 0; const GET = 1; const SET = 2; const NO_SENSITIVITY = 4; const GET_NO_CHANGES = 8; const INVERT_BOOLEAN = 16; } } #[doc(hidden)] impl ToGlib for SettingsBindFlags { type GlibType = gio_sys::GSettingsBindFlags; fn to_glib(&self) -> gio_sys::GSettingsBindFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SettingsBindFlags { fn from_glib(value: gio_sys::GSettingsBindFlags) -> SettingsBindFlags { SettingsBindFlags::from_bits_truncate(value) } } impl StaticType for SettingsBindFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_settings_bind_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for SettingsBindFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SettingsBindFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for SettingsBindFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct SubprocessFlags: u32 { const NONE = 0; const STDIN_PIPE = 1; const STDIN_INHERIT = 2; const STDOUT_PIPE = 4; const STDOUT_SILENCE = 8; const STDERR_PIPE = 16; const STDERR_SILENCE = 32; const STDERR_MERGE = 64; const INHERIT_FDS = 128; } } #[doc(hidden)] impl ToGlib for SubprocessFlags { type GlibType = gio_sys::GSubprocessFlags; fn to_glib(&self) -> gio_sys::GSubprocessFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SubprocessFlags { fn from_glib(value: gio_sys::GSubprocessFlags) -> SubprocessFlags { SubprocessFlags::from_bits_truncate(value) } } impl StaticType for SubprocessFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_subprocess_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for SubprocessFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for SubprocessFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for SubprocessFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct TlsCertificateFlags: u32 { const UNKNOWN_CA = 1; const BAD_IDENTITY = 2; const NOT_ACTIVATED = 4; const EXPIRED = 8; const REVOKED = 16; const INSECURE = 32; const GENERIC_ERROR = 64; const VALIDATE_ALL = 127; } } #[doc(hidden)] impl ToGlib for TlsCertificateFlags { type GlibType = gio_sys::GTlsCertificateFlags; fn to_glib(&self) -> gio_sys::GTlsCertificateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsCertificateFlags { fn from_glib(value: gio_sys::GTlsCertificateFlags) -> TlsCertificateFlags { TlsCertificateFlags::from_bits_truncate(value) } } impl StaticType for TlsCertificateFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_certificate_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsCertificateFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsCertificateFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for TlsCertificateFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct TlsDatabaseVerifyFlags: u32 { const NONE = 0; } } #[doc(hidden)] impl ToGlib for TlsDatabaseVerifyFlags { type GlibType = gio_sys::GTlsDatabaseVerifyFlags; fn to_glib(&self) -> gio_sys::GTlsDatabaseVerifyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsDatabaseVerifyFlags { fn from_glib(value: gio_sys::GTlsDatabaseVerifyFlags) -> TlsDatabaseVerifyFlags { TlsDatabaseVerifyFlags::from_bits_truncate(value) } } impl StaticType for TlsDatabaseVerifyFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_database_verify_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsDatabaseVerifyFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsDatabaseVerifyFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for TlsDatabaseVerifyFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } bitflags! { pub struct TlsPasswordFlags: u32 { const NONE = 0; const RETRY = 2; const MANY_TRIES = 4; const FINAL_TRY = 8; } } #[doc(hidden)] impl ToGlib for TlsPasswordFlags { type GlibType = gio_sys::GTlsPasswordFlags; fn to_glib(&self) -> gio_sys::GTlsPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsPasswordFlags { fn from_glib(value: gio_sys::GTlsPasswordFlags) -> TlsPasswordFlags { TlsPasswordFlags::from_bits_truncate(value) } } impl StaticType for TlsPasswordFlags { fn static_type() -> Type { unsafe { from_glib(gio_sys::g_tls_password_flags_get_type()) } } } impl<'a> FromValueOptional<'a> for TlsPasswordFlags { unsafe fn from_value_optional(value: &Value) -> Option { Some(FromValue::from_value(value)) } } impl<'a> FromValue<'a> for TlsPasswordFlags { unsafe fn from_value(value: &Value) -> Self { from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for TlsPasswordFlags { unsafe fn set_value(value: &mut Value, this: &Self) { gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } gio-0.7.0/src/auto/functions.rs010064400007650000024000000547441350341657000146520ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::mem; use std::ptr; use Cancellable; use Error; use File; use IOErrorEnum; use IOStream; use Icon; use InputStream; use Resource; use ResourceLookupFlags; use SettingsBackend; //pub fn bus_get, Q: FnOnce(Result) + Send + 'static>(bus_type: /*Ignored*/BusType, cancellable: Option<&P>, callback: Q) { // unsafe { TODO: call gio_sys:g_bus_get() } //} //#[cfg(feature = "futures")] //pub fn bus_get_future(bus_type: /*Ignored*/BusType) -> Box_> + std::marker::Unpin> { //use GioFuture; //use fragile::Fragile; //GioFuture::new(&(), move |_obj, send| { // let cancellable = Cancellable::new(); // let send = Fragile::new(send); // bus_get( // bus_type, // Some(&cancellable), // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} //pub fn bus_get_sync>(bus_type: /*Ignored*/BusType, cancellable: Option<&P>) -> Result { // unsafe { TODO: call gio_sys:g_bus_get_sync() } //} //pub fn bus_own_name(bus_type: /*Ignored*/BusType, name: &str, flags: /*Ignored*/BusNameOwnerFlags, bus_acquired_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), name_acquired_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), name_lost_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), user_data: /*Unimplemented*/Option) -> u32 { // unsafe { TODO: call gio_sys:g_bus_own_name() } //} //pub fn bus_own_name_on_connection(connection: /*Ignored*/&DBusConnection, name: &str, flags: /*Ignored*/BusNameOwnerFlags, name_acquired_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), name_lost_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), user_data: /*Unimplemented*/Option) -> u32 { // unsafe { TODO: call gio_sys:g_bus_own_name_on_connection() } //} //pub fn bus_own_name_on_connection_with_closures(connection: /*Ignored*/&DBusConnection, name: &str, flags: /*Ignored*/BusNameOwnerFlags, name_acquired_closure: /*Ignored*/Option<&glib::Closure>, name_lost_closure: /*Ignored*/Option<&glib::Closure>) -> u32 { // unsafe { TODO: call gio_sys:g_bus_own_name_on_connection_with_closures() } //} //pub fn bus_own_name_with_closures(bus_type: /*Ignored*/BusType, name: &str, flags: /*Ignored*/BusNameOwnerFlags, bus_acquired_closure: /*Ignored*/Option<&glib::Closure>, name_acquired_closure: /*Ignored*/Option<&glib::Closure>, name_lost_closure: /*Ignored*/Option<&glib::Closure>) -> u32 { // unsafe { TODO: call gio_sys:g_bus_own_name_with_closures() } //} pub fn bus_unown_name(owner_id: u32) { unsafe { gio_sys::g_bus_unown_name(owner_id); } } pub fn bus_unwatch_name(watcher_id: u32) { unsafe { gio_sys::g_bus_unwatch_name(watcher_id); } } //pub fn bus_watch_name(bus_type: /*Ignored*/BusType, name: &str, flags: /*Ignored*/BusNameWatcherFlags, name_appeared_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str, &str), name_vanished_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), user_data: /*Unimplemented*/Option) -> u32 { // unsafe { TODO: call gio_sys:g_bus_watch_name() } //} //pub fn bus_watch_name_on_connection(connection: /*Ignored*/&DBusConnection, name: &str, flags: /*Ignored*/BusNameWatcherFlags, name_appeared_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str, &str), name_vanished_handler: /*Unimplemented*/Fn(/*Ignored*/DBusConnection, &str), user_data: /*Unimplemented*/Option) -> u32 { // unsafe { TODO: call gio_sys:g_bus_watch_name_on_connection() } //} //pub fn bus_watch_name_on_connection_with_closures(connection: /*Ignored*/&DBusConnection, name: &str, flags: /*Ignored*/BusNameWatcherFlags, name_appeared_closure: /*Ignored*/Option<&glib::Closure>, name_vanished_closure: /*Ignored*/Option<&glib::Closure>) -> u32 { // unsafe { TODO: call gio_sys:g_bus_watch_name_on_connection_with_closures() } //} //pub fn bus_watch_name_with_closures(bus_type: /*Ignored*/BusType, name: &str, flags: /*Ignored*/BusNameWatcherFlags, name_appeared_closure: /*Ignored*/Option<&glib::Closure>, name_vanished_closure: /*Ignored*/Option<&glib::Closure>) -> u32 { // unsafe { TODO: call gio_sys:g_bus_watch_name_with_closures() } //} pub fn content_type_can_be_executable(type_: &str) -> bool { unsafe { from_glib(gio_sys::g_content_type_can_be_executable( type_.to_glib_none().0, )) } } pub fn content_type_equals(type1: &str, type2: &str) -> bool { unsafe { from_glib(gio_sys::g_content_type_equals( type1.to_glib_none().0, type2.to_glib_none().0, )) } } pub fn content_type_from_mime_type(mime_type: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_from_mime_type( mime_type.to_glib_none().0, )) } } pub fn content_type_get_description(type_: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_get_description( type_.to_glib_none().0, )) } } pub fn content_type_get_generic_icon_name(type_: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_get_generic_icon_name( type_.to_glib_none().0, )) } } pub fn content_type_get_icon(type_: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_get_icon(type_.to_glib_none().0)) } } pub fn content_type_get_mime_type(type_: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_get_mime_type( type_.to_glib_none().0, )) } } pub fn content_type_get_symbolic_icon(type_: &str) -> Option { unsafe { from_glib_full(gio_sys::g_content_type_get_symbolic_icon( type_.to_glib_none().0, )) } } pub fn content_type_guess(filename: Option<&str>, data: &[u8]) -> (GString, bool) { let data_size = data.len() as usize; unsafe { let mut result_uncertain = mem::uninitialized(); let ret = from_glib_full(gio_sys::g_content_type_guess( filename.to_glib_none().0, data.to_glib_none().0, data_size, &mut result_uncertain, )); (ret, from_glib(result_uncertain)) } } pub fn content_type_guess_for_tree>(root: &P) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_content_type_guess_for_tree( root.as_ref().to_glib_none().0, )) } } pub fn content_type_is_a(type_: &str, supertype: &str) -> bool { unsafe { from_glib(gio_sys::g_content_type_is_a( type_.to_glib_none().0, supertype.to_glib_none().0, )) } } #[cfg(any(feature = "v2_52", feature = "dox"))] pub fn content_type_is_mime_type(type_: &str, mime_type: &str) -> bool { unsafe { from_glib(gio_sys::g_content_type_is_mime_type( type_.to_glib_none().0, mime_type.to_glib_none().0, )) } } pub fn content_type_is_unknown(type_: &str) -> bool { unsafe { from_glib(gio_sys::g_content_type_is_unknown(type_.to_glib_none().0)) } } pub fn content_types_get_registered() -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_content_types_get_registered()) } } pub fn dbus_address_escape_value(string: &str) -> Option { unsafe { from_glib_full(gio_sys::g_dbus_address_escape_value( string.to_glib_none().0, )) } } //pub fn dbus_address_get_for_bus_sync>(bus_type: /*Ignored*/BusType, cancellable: Option<&P>) -> Result { // unsafe { TODO: call gio_sys:g_dbus_address_get_for_bus_sync() } //} pub fn dbus_address_get_stream< P: IsA, Q: FnOnce(Result<(IOStream, GString), Error>) + Send + 'static, >( address: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn dbus_address_get_stream_trampoline< Q: FnOnce(Result<(IOStream, GString), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut out_guid = ptr::null_mut(); let ret = gio_sys::g_dbus_address_get_stream_finish(res, &mut out_guid, &mut error); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_guid))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = dbus_address_get_stream_trampoline::; unsafe { gio_sys::g_dbus_address_get_stream( address.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn dbus_address_get_stream_future( address: &str, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let address = String::from(address); GioFuture::new(&(), move |_obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); dbus_address_get_stream(&address, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } pub fn dbus_address_get_stream_sync>( address: &str, cancellable: Option<&P>, ) -> Result<(IOStream, GString), Error> { unsafe { let mut out_guid = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_dbus_address_get_stream_sync( address.to_glib_none().0, &mut out_guid, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_guid))) } else { Err(from_glib_full(error)) } } } pub fn dbus_generate_guid() -> Option { unsafe { from_glib_full(gio_sys::g_dbus_generate_guid()) } } pub fn dbus_gvalue_to_gvariant( gvalue: &glib::Value, type_: &glib::VariantTy, ) -> Option { unsafe { from_glib_full(gio_sys::g_dbus_gvalue_to_gvariant( gvalue.to_glib_none().0, type_.to_glib_none().0, )) } } pub fn dbus_gvariant_to_gvalue(value: &glib::Variant) -> glib::Value { unsafe { let mut out_gvalue = glib::Value::uninitialized(); gio_sys::g_dbus_gvariant_to_gvalue(value.to_glib_none().0, out_gvalue.to_glib_none_mut().0); out_gvalue } } pub fn dbus_is_address(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_address(string.to_glib_none().0)) } } pub fn dbus_is_guid(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_guid(string.to_glib_none().0)) } } pub fn dbus_is_interface_name(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_interface_name(string.to_glib_none().0)) } } pub fn dbus_is_member_name(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_member_name(string.to_glib_none().0)) } } pub fn dbus_is_name(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_name(string.to_glib_none().0)) } } pub fn dbus_is_supported_address(string: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_dbus_is_supported_address(string.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } pub fn dbus_is_unique_name(string: &str) -> bool { unsafe { from_glib(gio_sys::g_dbus_is_unique_name(string.to_glib_none().0)) } } pub fn io_error_from_errno(err_no: i32) -> IOErrorEnum { unsafe { from_glib(gio_sys::g_io_error_from_errno(err_no)) } } pub fn io_error_quark() -> glib::Quark { unsafe { from_glib(gio_sys::g_io_error_quark()) } } //pub fn io_modules_load_all_in_directory>(dirname: P) -> /*Ignored*/Vec { // unsafe { TODO: call gio_sys:g_io_modules_load_all_in_directory() } //} //pub fn io_modules_load_all_in_directory_with_scope>(dirname: P, scope: /*Ignored*/&mut IOModuleScope) -> /*Ignored*/Vec { // unsafe { TODO: call gio_sys:g_io_modules_load_all_in_directory_with_scope() } //} pub fn io_modules_scan_all_in_directory>(dirname: P) { unsafe { gio_sys::g_io_modules_scan_all_in_directory(dirname.as_ref().to_glib_none().0); } } //pub fn io_modules_scan_all_in_directory_with_scope>(dirname: P, scope: /*Ignored*/&mut IOModuleScope) { // unsafe { TODO: call gio_sys:g_io_modules_scan_all_in_directory_with_scope() } //} pub fn io_scheduler_cancel_all_jobs() { unsafe { gio_sys::g_io_scheduler_cancel_all_jobs(); } } //pub fn io_scheduler_push_job>(job_func: /*Unimplemented*/Fn(/*Ignored*/IOSchedulerJob, Option<&Cancellable>) -> bool, user_data: /*Unimplemented*/Option, io_priority: i32, cancellable: Option<&P>) { // unsafe { TODO: call gio_sys:g_io_scheduler_push_job() } //} pub fn keyfile_settings_backend_new( filename: &str, root_path: &str, root_group: Option<&str>, ) -> Option { unsafe { from_glib_full(gio_sys::g_keyfile_settings_backend_new( filename.to_glib_none().0, root_path.to_glib_none().0, root_group.to_glib_none().0, )) } } pub fn memory_settings_backend_new() -> Option { unsafe { from_glib_full(gio_sys::g_memory_settings_backend_new()) } } pub fn networking_init() { unsafe { gio_sys::g_networking_init(); } } pub fn null_settings_backend_new() -> Option { unsafe { from_glib_full(gio_sys::g_null_settings_backend_new()) } } pub fn resources_enumerate_children( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resources_enumerate_children( path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn resources_get_info( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result<(usize, u32), Error> { unsafe { let mut size = mem::uninitialized(); let mut flags = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_resources_get_info( path.to_glib_none().0, lookup_flags.to_glib(), &mut size, &mut flags, &mut error, ); if error.is_null() { Ok((size, flags)) } else { Err(from_glib_full(error)) } } } pub fn resources_lookup_data( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resources_lookup_data( path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn resources_open_stream( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resources_open_stream( path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn resources_register(resource: &Resource) { unsafe { gio_sys::g_resources_register(resource.to_glib_none().0); } } pub fn resources_unregister(resource: &Resource) { unsafe { gio_sys::g_resources_unregister(resource.to_glib_none().0); } } //#[cfg_attr(feature = "v2_46", deprecated)] //pub fn simple_async_report_error_in_idle, Q: FnOnce(Result<(), Error>) + 'static>(object: Option<&P>, callback: Q, domain: glib::Quark, code: i32, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_simple_async_report_error_in_idle() } //} //#[cfg_attr(feature = "v2_46", deprecated)] //pub fn simple_async_report_gerror_in_idle, Q: FnOnce(Result<(), Error>) + 'static>(object: Option<&P>, callback: Q, error: &Error) { // unsafe { TODO: call gio_sys:g_simple_async_report_gerror_in_idle() } //} //#[cfg_attr(feature = "v2_46", deprecated)] //pub fn simple_async_report_take_gerror_in_idle, Q: FnOnce(Result<(), Error>) + 'static>(object: Option<&P>, callback: Q, error: &mut Error) { // unsafe { TODO: call gio_sys:g_simple_async_report_take_gerror_in_idle() } //} #[cfg(any(unix, feature = "dox"))] pub fn unix_is_mount_path_system_internal>(mount_path: P) -> bool { unsafe { from_glib(gio_sys::g_unix_is_mount_path_system_internal( mount_path.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] #[cfg(any(feature = "v2_56", feature = "dox"))] pub fn unix_is_system_device_path>(device_path: P) -> bool { unsafe { from_glib(gio_sys::g_unix_is_system_device_path( device_path.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] #[cfg(any(feature = "v2_56", feature = "dox"))] pub fn unix_is_system_fs_type(fs_type: &str) -> bool { unsafe { from_glib(gio_sys::g_unix_is_system_fs_type(fs_type.to_glib_none().0)) } } //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_at>(mount_path: P) -> (/*Ignored*/UnixMountEntry, u64) { // unsafe { TODO: call gio_sys:g_unix_mount_at() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_compare(mount1: /*Ignored*/&mut UnixMountEntry, mount2: /*Ignored*/&mut UnixMountEntry) -> i32 { // unsafe { TODO: call gio_sys:g_unix_mount_compare() } //} //#[cfg(any(unix, feature = "dox"))] //#[cfg(any(feature = "v2_54", feature = "dox"))] //pub fn unix_mount_copy(mount_entry: /*Ignored*/&mut UnixMountEntry) -> /*Ignored*/Option { // unsafe { TODO: call gio_sys:g_unix_mount_copy() } //} //#[cfg(any(unix, feature = "dox"))] //#[cfg(any(feature = "v2_52", feature = "dox"))] //pub fn unix_mount_for>(file_path: P) -> (/*Ignored*/UnixMountEntry, u64) { // unsafe { TODO: call gio_sys:g_unix_mount_for() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_free(mount_entry: /*Ignored*/&mut UnixMountEntry) { // unsafe { TODO: call gio_sys:g_unix_mount_free() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_get_device_path(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_get_device_path() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_get_fs_type(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_get_fs_type() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_get_mount_path(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_get_mount_path() } //} //#[cfg(any(unix, feature = "dox"))] //#[cfg(any(feature = "v2_58", feature = "dox"))] //pub fn unix_mount_get_options(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_get_options() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_guess_can_eject(mount_entry: /*Ignored*/&mut UnixMountEntry) -> bool { // unsafe { TODO: call gio_sys:g_unix_mount_guess_can_eject() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_guess_icon(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_guess_icon() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_guess_name(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_guess_name() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_guess_should_display(mount_entry: /*Ignored*/&mut UnixMountEntry) -> bool { // unsafe { TODO: call gio_sys:g_unix_mount_guess_should_display() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_guess_symbolic_icon(mount_entry: /*Ignored*/&mut UnixMountEntry) -> Option { // unsafe { TODO: call gio_sys:g_unix_mount_guess_symbolic_icon() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_is_readonly(mount_entry: /*Ignored*/&mut UnixMountEntry) -> bool { // unsafe { TODO: call gio_sys:g_unix_mount_is_readonly() } //} //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_is_system_internal(mount_entry: /*Ignored*/&mut UnixMountEntry) -> bool { // unsafe { TODO: call gio_sys:g_unix_mount_is_system_internal() } //} #[cfg(any(unix, feature = "dox"))] pub fn unix_mount_points_changed_since(time: u64) -> bool { unsafe { from_glib(gio_sys::g_unix_mount_points_changed_since(time)) } } //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mount_points_get() -> (/*Ignored*/Vec, u64) { // unsafe { TODO: call gio_sys:g_unix_mount_points_get() } //} #[cfg(any(unix, feature = "dox"))] pub fn unix_mounts_changed_since(time: u64) -> bool { unsafe { from_glib(gio_sys::g_unix_mounts_changed_since(time)) } } //#[cfg(any(unix, feature = "dox"))] //pub fn unix_mounts_get() -> (/*Ignored*/Vec, u64) { // unsafe { TODO: call gio_sys:g_unix_mounts_get() } //} gio-0.7.0/src/auto/icon.rs010064400007650000024000000041341350341657000135560ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use std::fmt; use std::ptr; use Error; glib_wrapper! { pub struct Icon(Interface); match fn { get_type => || gio_sys::g_icon_get_type(), } } impl Icon { pub fn deserialize(value: &glib::Variant) -> Option { unsafe { from_glib_full(gio_sys::g_icon_deserialize(value.to_glib_none().0)) } } pub fn hash(&self) -> u32 { unsafe { gio_sys::g_icon_hash( ToGlibPtr::<*mut gio_sys::GIcon>::to_glib_none(self).0 as glib_sys::gconstpointer, ) } } pub fn new_for_string(str: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_icon_new_for_string(str.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub const NONE_ICON: Option<&Icon> = None; pub trait IconExt: 'static { fn equal>(&self, icon2: Option<&P>) -> bool; fn serialize(&self) -> Option; fn to_string(&self) -> Option; } impl> IconExt for O { fn equal>(&self, icon2: Option<&P>) -> bool { unsafe { from_glib(gio_sys::g_icon_equal( self.as_ref().to_glib_none().0, icon2.map(|p| p.as_ref()).to_glib_none().0, )) } } fn serialize(&self) -> Option { unsafe { from_glib_full(gio_sys::g_icon_serialize(self.as_ref().to_glib_none().0)) } } fn to_string(&self) -> Option { unsafe { from_glib_full(gio_sys::g_icon_to_string(self.as_ref().to_glib_none().0)) } } } impl fmt::Display for Icon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Icon") } } gio-0.7.0/src/auto/inet_address.rs010064400007650000024000000374771350341657000153120ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use SocketFamily; glib_wrapper! { pub struct InetAddress(Object); match fn { get_type => || gio_sys::g_inet_address_get_type(), } } impl InetAddress { pub fn new_any(family: SocketFamily) -> InetAddress { unsafe { from_glib_full(gio_sys::g_inet_address_new_any(family.to_glib())) } } pub fn new_from_string(string: &str) -> InetAddress { unsafe { from_glib_full(gio_sys::g_inet_address_new_from_string( string.to_glib_none().0, )) } } pub fn new_loopback(family: SocketFamily) -> InetAddress { unsafe { from_glib_full(gio_sys::g_inet_address_new_loopback(family.to_glib())) } } } unsafe impl Send for InetAddress {} unsafe impl Sync for InetAddress {} pub const NONE_INET_ADDRESS: Option<&InetAddress> = None; pub trait InetAddressExt: 'static { fn equal>(&self, other_address: &P) -> bool; fn get_family(&self) -> SocketFamily; fn get_is_any(&self) -> bool; fn get_is_link_local(&self) -> bool; fn get_is_loopback(&self) -> bool; fn get_is_mc_global(&self) -> bool; fn get_is_mc_link_local(&self) -> bool; fn get_is_mc_node_local(&self) -> bool; fn get_is_mc_org_local(&self) -> bool; fn get_is_mc_site_local(&self) -> bool; fn get_is_multicast(&self) -> bool; fn get_is_site_local(&self) -> bool; fn get_native_size(&self) -> usize; fn to_string(&self) -> GString; //fn get_property_bytes(&self) -> /*Unimplemented*/Fundamental: Pointer; fn connect_property_is_any_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_link_local_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_loopback_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_mc_global_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_mc_link_local_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_mc_node_local_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_mc_org_local_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_mc_site_local_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_multicast_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_is_site_local_notify( &self, f: F, ) -> SignalHandlerId; } impl> InetAddressExt for O { fn equal>(&self, other_address: &P) -> bool { unsafe { from_glib(gio_sys::g_inet_address_equal( self.as_ref().to_glib_none().0, other_address.as_ref().to_glib_none().0, )) } } fn get_family(&self) -> SocketFamily { unsafe { from_glib(gio_sys::g_inet_address_get_family( self.as_ref().to_glib_none().0, )) } } fn get_is_any(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_any( self.as_ref().to_glib_none().0, )) } } fn get_is_link_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_link_local( self.as_ref().to_glib_none().0, )) } } fn get_is_loopback(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_loopback( self.as_ref().to_glib_none().0, )) } } fn get_is_mc_global(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_mc_global( self.as_ref().to_glib_none().0, )) } } fn get_is_mc_link_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_mc_link_local( self.as_ref().to_glib_none().0, )) } } fn get_is_mc_node_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_mc_node_local( self.as_ref().to_glib_none().0, )) } } fn get_is_mc_org_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_mc_org_local( self.as_ref().to_glib_none().0, )) } } fn get_is_mc_site_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_mc_site_local( self.as_ref().to_glib_none().0, )) } } fn get_is_multicast(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_multicast( self.as_ref().to_glib_none().0, )) } } fn get_is_site_local(&self) -> bool { unsafe { from_glib(gio_sys::g_inet_address_get_is_site_local( self.as_ref().to_glib_none().0, )) } } fn get_native_size(&self) -> usize { unsafe { gio_sys::g_inet_address_get_native_size(self.as_ref().to_glib_none().0) } } fn to_string(&self) -> GString { unsafe { from_glib_full(gio_sys::g_inet_address_to_string( self.as_ref().to_glib_none().0, )) } } //fn get_property_bytes(&self) -> /*Unimplemented*/Fundamental: Pointer { // unsafe { // let mut value = Value::from_type(::static_type()); // gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"bytes\0".as_ptr() as *const _, value.to_glib_none_mut().0); // value.get().unwrap() // } //} fn connect_property_is_any_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_any_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-any\0".as_ptr() as *const _, Some(transmute(notify_is_any_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_is_link_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_link_local_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-link-local\0".as_ptr() as *const _, Some(transmute( notify_is_link_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_loopback_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_loopback_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-loopback\0".as_ptr() as *const _, Some(transmute(notify_is_loopback_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_is_mc_global_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_global_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-global\0".as_ptr() as *const _, Some(transmute( notify_is_mc_global_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_mc_link_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_link_local_trampoline< P, F: Fn(&P) + Send + Sync + 'static, >( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-link-local\0".as_ptr() as *const _, Some(transmute( notify_is_mc_link_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_mc_node_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_node_local_trampoline< P, F: Fn(&P) + Send + Sync + 'static, >( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-node-local\0".as_ptr() as *const _, Some(transmute( notify_is_mc_node_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_mc_org_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_org_local_trampoline< P, F: Fn(&P) + Send + Sync + 'static, >( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-org-local\0".as_ptr() as *const _, Some(transmute( notify_is_mc_org_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_mc_site_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_site_local_trampoline< P, F: Fn(&P) + Send + Sync + 'static, >( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-site-local\0".as_ptr() as *const _, Some(transmute( notify_is_mc_site_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_multicast_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_multicast_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-multicast\0".as_ptr() as *const _, Some(transmute( notify_is_multicast_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_is_site_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_site_local_trampoline( this: *mut gio_sys::GInetAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-site-local\0".as_ptr() as *const _, Some(transmute( notify_is_site_local_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for InetAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "InetAddress") } } gio-0.7.0/src/auto/inet_address_mask.rs010064400007650000024000000164501350341657000163110ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; use InetAddress; use SocketFamily; glib_wrapper! { pub struct InetAddressMask(Object); match fn { get_type => || gio_sys::g_inet_address_mask_get_type(), } } impl InetAddressMask { pub fn new>(addr: &P, length: u32) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_inet_address_mask_new( addr.as_ref().to_glib_none().0, length, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_string(mask_string: &str) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_inet_address_mask_new_from_string( mask_string.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl Send for InetAddressMask {} unsafe impl Sync for InetAddressMask {} pub const NONE_INET_ADDRESS_MASK: Option<&InetAddressMask> = None; pub trait InetAddressMaskExt: 'static { fn equal>(&self, mask2: &P) -> bool; fn get_address(&self) -> InetAddress; fn get_family(&self) -> SocketFamily; fn get_length(&self) -> u32; fn matches>(&self, address: &P) -> bool; fn to_string(&self) -> GString; fn set_property_address(&self, address: Option<&InetAddress>); fn set_property_length(&self, length: u32); fn connect_property_address_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_family_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_length_notify( &self, f: F, ) -> SignalHandlerId; } impl> InetAddressMaskExt for O { fn equal>(&self, mask2: &P) -> bool { unsafe { from_glib(gio_sys::g_inet_address_mask_equal( self.as_ref().to_glib_none().0, mask2.as_ref().to_glib_none().0, )) } } fn get_address(&self) -> InetAddress { unsafe { from_glib_none(gio_sys::g_inet_address_mask_get_address( self.as_ref().to_glib_none().0, )) } } fn get_family(&self) -> SocketFamily { unsafe { from_glib(gio_sys::g_inet_address_mask_get_family( self.as_ref().to_glib_none().0, )) } } fn get_length(&self) -> u32 { unsafe { gio_sys::g_inet_address_mask_get_length(self.as_ref().to_glib_none().0) } } fn matches>(&self, address: &P) -> bool { unsafe { from_glib(gio_sys::g_inet_address_mask_matches( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, )) } } fn to_string(&self) -> GString { unsafe { from_glib_full(gio_sys::g_inet_address_mask_to_string( self.as_ref().to_glib_none().0, )) } } fn set_property_address(&self, address: Option<&InetAddress>) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"address\0".as_ptr() as *const _, Value::from(address).to_glib_none().0, ); } } fn set_property_length(&self, length: u32) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"length\0".as_ptr() as *const _, Value::from(&length).to_glib_none().0, ); } } fn connect_property_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_address_trampoline( this: *mut gio_sys::GInetAddressMask, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddressMask::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::address\0".as_ptr() as *const _, Some(transmute(notify_address_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_family_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline( this: *mut gio_sys::GInetAddressMask, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddressMask::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(transmute(notify_family_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_length_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_length_trampoline( this: *mut gio_sys::GInetAddressMask, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&InetAddressMask::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::length\0".as_ptr() as *const _, Some(transmute(notify_length_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for InetAddressMask { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "InetAddressMask") } } gio-0.7.0/src/auto/inet_socket_address.rs010064400007650000024000000045651350341657000166520ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; use InetAddress; use SocketAddress; use SocketConnectable; glib_wrapper! { pub struct InetSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; match fn { get_type => || gio_sys::g_inet_socket_address_get_type(), } } impl InetSocketAddress { pub fn new>(address: &P, port: u16) -> InetSocketAddress { unsafe { SocketAddress::from_glib_full(gio_sys::g_inet_socket_address_new( address.as_ref().to_glib_none().0, port, )) .unsafe_cast() } } pub fn new_from_string(address: &str, port: u32) -> InetSocketAddress { unsafe { SocketAddress::from_glib_full(gio_sys::g_inet_socket_address_new_from_string( address.to_glib_none().0, port, )) .unsafe_cast() } } } unsafe impl Send for InetSocketAddress {} unsafe impl Sync for InetSocketAddress {} pub const NONE_INET_SOCKET_ADDRESS: Option<&InetSocketAddress> = None; pub trait InetSocketAddressExt: 'static { fn get_address(&self) -> Option; fn get_flowinfo(&self) -> u32; fn get_port(&self) -> u16; fn get_scope_id(&self) -> u32; } impl> InetSocketAddressExt for O { fn get_address(&self) -> Option { unsafe { from_glib_none(gio_sys::g_inet_socket_address_get_address( self.as_ref().to_glib_none().0, )) } } fn get_flowinfo(&self) -> u32 { unsafe { gio_sys::g_inet_socket_address_get_flowinfo(self.as_ref().to_glib_none().0) } } fn get_port(&self) -> u16 { unsafe { gio_sys::g_inet_socket_address_get_port(self.as_ref().to_glib_none().0) } } fn get_scope_id(&self) -> u32 { unsafe { gio_sys::g_inet_socket_address_get_scope_id(self.as_ref().to_glib_none().0) } } } impl fmt::Display for InetSocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "InetSocketAddress") } } gio-0.7.0/src/auto/input_stream.rs010064400007650000024000000261731350341657000153470ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; glib_wrapper! { pub struct InputStream(Object); match fn { get_type => || gio_sys::g_input_stream_get_type(), } } pub const NONE_INPUT_STREAM: Option<&InputStream> = None; pub trait InputStreamExt: 'static { fn clear_pending(&self); fn close>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn has_pending(&self) -> bool; fn is_closed(&self) -> bool; fn read_bytes>( &self, count: usize, cancellable: Option<&P>, ) -> Result; fn read_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn read_bytes_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn set_pending(&self) -> Result<(), Error>; fn skip>( &self, count: usize, cancellable: Option<&P>, ) -> Result; fn skip_async, Q: FnOnce(Result) + Send + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn skip_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; } impl> InputStreamExt for O { fn clear_pending(&self) { unsafe { gio_sys::g_input_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_input_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_input_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = close_async_trampoline::; unsafe { gio_sys::g_input_stream_close_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.close_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn has_pending(&self) -> bool { unsafe { from_glib(gio_sys::g_input_stream_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(gio_sys::g_input_stream_is_closed( self.as_ref().to_glib_none().0, )) } } fn read_bytes>( &self, count: usize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_read_bytes( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn read_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn read_bytes_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_read_bytes_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = read_bytes_async_trampoline::; unsafe { gio_sys::g_input_stream_read_bytes_async( self.as_ref().to_glib_none().0, count, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn read_bytes_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_bytes_async(count, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn set_pending(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_input_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn skip>( &self, count: usize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_skip( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn skip_async, Q: FnOnce(Result) + Send + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn skip_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_skip_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = skip_async_trampoline::; unsafe { gio_sys::g_input_stream_skip_async( self.as_ref().to_glib_none().0, count, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn skip_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.skip_async(count, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for InputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "InputStream") } } gio-0.7.0/src/auto/io_stream.rs010064400007650000024000000153171350341657000146150ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use InputStream; use OutputStream; glib_wrapper! { pub struct IOStream(Object); match fn { get_type => || gio_sys::g_io_stream_get_type(), } } impl IOStream {} pub const NONE_IO_STREAM: Option<&IOStream> = None; pub trait IOStreamExt: 'static { fn clear_pending(&self); fn close>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn get_input_stream(&self) -> Option; fn get_output_stream(&self) -> Option; fn has_pending(&self) -> bool; fn is_closed(&self) -> bool; fn set_pending(&self) -> Result<(), Error>; fn get_property_closed(&self) -> bool; fn connect_property_closed_notify(&self, f: F) -> SignalHandlerId; } impl> IOStreamExt for O { fn clear_pending(&self) { unsafe { gio_sys::g_io_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_io_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_io_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = close_async_trampoline::; unsafe { gio_sys::g_io_stream_close_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.close_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn get_input_stream(&self) -> Option { unsafe { from_glib_none(gio_sys::g_io_stream_get_input_stream( self.as_ref().to_glib_none().0, )) } } fn get_output_stream(&self) -> Option { unsafe { from_glib_none(gio_sys::g_io_stream_get_output_stream( self.as_ref().to_glib_none().0, )) } } fn has_pending(&self) -> bool { unsafe { from_glib(gio_sys::g_io_stream_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(gio_sys::g_io_stream_is_closed( self.as_ref().to_glib_none().0, )) } } fn set_pending(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_io_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn get_property_closed(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"closed\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_property_closed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_closed_trampoline( this: *mut gio_sys::GIOStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&IOStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::closed\0".as_ptr() as *const _, Some(transmute(notify_closed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for IOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "IOStream") } } gio-0.7.0/src/auto/list_model.rs010064400007650000024000000103151350341657000147570ustar0000000000000000// 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 gio_sys; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib::object::Cast; use glib::object::IsA; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib::signal::connect_raw; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib::signal::SignalHandlerId; use glib::translate::*; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib_sys; #[cfg(any(feature = "v2_44", feature = "dox"))] use libc; #[cfg(any(feature = "v2_44", feature = "dox"))] use std::boxed::Box as Box_; use std::fmt; #[cfg(any(feature = "v2_44", feature = "dox"))] use std::mem::transmute; glib_wrapper! { pub struct ListModel(Interface); match fn { get_type => || gio_sys::g_list_model_get_type(), } } pub const NONE_LIST_MODEL: Option<&ListModel> = None; pub trait ListModelExt: 'static { //#[cfg(any(feature = "v2_44", feature = "dox"))] //fn get_item(&self, position: u32) -> /*Unimplemented*/Option; #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_item_type(&self) -> glib::types::Type; #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_n_items(&self) -> u32; #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_object(&self, position: u32) -> Option; #[cfg(any(feature = "v2_44", feature = "dox"))] fn items_changed(&self, position: u32, removed: u32, added: u32); #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_items_changed(&self, f: F) -> SignalHandlerId; } impl> ListModelExt for O { //#[cfg(any(feature = "v2_44", feature = "dox"))] //fn get_item(&self, position: u32) -> /*Unimplemented*/Option { // unsafe { TODO: call gio_sys:g_list_model_get_item() } //} #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_item_type(&self) -> glib::types::Type { unsafe { from_glib(gio_sys::g_list_model_get_item_type( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_n_items(&self) -> u32 { unsafe { gio_sys::g_list_model_get_n_items(self.as_ref().to_glib_none().0) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_object(&self, position: u32) -> Option { unsafe { from_glib_full(gio_sys::g_list_model_get_object( self.as_ref().to_glib_none().0, position, )) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn items_changed(&self, position: u32, removed: u32, added: u32) { unsafe { gio_sys::g_list_model_items_changed( self.as_ref().to_glib_none().0, position, removed, added, ); } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_items_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn items_changed_trampoline( this: *mut gio_sys::GListModel, position: libc::c_uint, removed: libc::c_uint, added: libc::c_uint, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &ListModel::from_glib_borrow(this).unsafe_cast(), position, removed, added, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"items-changed\0".as_ptr() as *const _, Some(transmute(items_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ListModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ListModel") } } gio-0.7.0/src/auto/list_store.rs010064400007650000024000000123661350341657000150230ustar0000000000000000// 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 gio_sys; #[cfg(any(feature = "v2_44", feature = "dox"))] use glib; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; use ListModel; glib_wrapper! { pub struct ListStore(Object) @implements ListModel; match fn { get_type => || gio_sys::g_list_store_get_type(), } } impl ListStore { #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn new(item_type: glib::types::Type) -> ListStore { unsafe { from_glib_full(gio_sys::g_list_store_new(item_type.to_glib())) } } } pub struct ListStoreBuilder { #[cfg(any(feature = "v2_44", feature = "dox"))] item_type: Option, } impl ListStoreBuilder { pub fn new() -> Self { Self { #[cfg(any(feature = "v2_44", feature = "dox"))] item_type: None, } } pub fn build(self) -> ListStore { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; #[cfg(any(feature = "v2_44", feature = "dox"))] { if let Some(ref item_type) = self.item_type { properties.push(("item-type", item_type)); } } glib::Object::new(ListStore::static_type(), &properties) .expect("object new") .downcast() .expect("downcast") } #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn item_type(mut self, item_type: glib::types::Type) -> Self { self.item_type = Some(item_type); self } } pub const NONE_LIST_STORE: Option<&ListStore> = None; pub trait ListStoreExt: 'static { #[cfg(any(feature = "v2_44", feature = "dox"))] fn append>(&self, item: &P); #[cfg(any(feature = "v2_44", feature = "dox"))] fn insert>(&self, position: u32, item: &P); //#[cfg(any(feature = "v2_44", feature = "dox"))] //fn insert_sorted>(&self, item: &P, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option, /*Unimplemented*/Option) -> i32, user_data: /*Unimplemented*/Option) -> u32; #[cfg(any(feature = "v2_44", feature = "dox"))] fn remove(&self, position: u32); #[cfg(any(feature = "v2_44", feature = "dox"))] fn remove_all(&self); //#[cfg(any(feature = "v2_46", feature = "dox"))] //fn sort(&self, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option, /*Unimplemented*/Option) -> i32, user_data: /*Unimplemented*/Option); #[cfg(any(feature = "v2_44", feature = "dox"))] fn splice(&self, position: u32, n_removals: u32, additions: &[glib::Object]); } impl> ListStoreExt for O { #[cfg(any(feature = "v2_44", feature = "dox"))] fn append>(&self, item: &P) { unsafe { gio_sys::g_list_store_append( self.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0, ); } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn insert>(&self, position: u32, item: &P) { unsafe { gio_sys::g_list_store_insert( self.as_ref().to_glib_none().0, position, item.as_ref().to_glib_none().0, ); } } //#[cfg(any(feature = "v2_44", feature = "dox"))] //fn insert_sorted>(&self, item: &P, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option, /*Unimplemented*/Option) -> i32, user_data: /*Unimplemented*/Option) -> u32 { // unsafe { TODO: call gio_sys:g_list_store_insert_sorted() } //} #[cfg(any(feature = "v2_44", feature = "dox"))] fn remove(&self, position: u32) { unsafe { gio_sys::g_list_store_remove(self.as_ref().to_glib_none().0, position); } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn remove_all(&self) { unsafe { gio_sys::g_list_store_remove_all(self.as_ref().to_glib_none().0); } } //#[cfg(any(feature = "v2_46", feature = "dox"))] //fn sort(&self, compare_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option, /*Unimplemented*/Option) -> i32, user_data: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_list_store_sort() } //} #[cfg(any(feature = "v2_44", feature = "dox"))] fn splice(&self, position: u32, n_removals: u32, additions: &[glib::Object]) { let n_additions = additions.len() as u32; unsafe { gio_sys::g_list_store_splice( self.as_ref().to_glib_none().0, position, n_removals, additions.to_glib_none().0, n_additions, ); } } } impl fmt::Display for ListStore { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ListStore") } } gio-0.7.0/src/auto/loadable_icon.rs010064400007650000024000000103071350341657000154000ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use Icon; use InputStream; glib_wrapper! { pub struct LoadableIcon(Interface) @requires Icon; match fn { get_type => || gio_sys::g_loadable_icon_get_type(), } } pub const NONE_LOADABLE_ICON: Option<&LoadableIcon> = None; pub trait LoadableIconExt: 'static { fn load>( &self, size: i32, cancellable: Option<&P>, ) -> Result<(InputStream, GString), Error>; fn load_async< P: IsA, Q: FnOnce(Result<(InputStream, GString), Error>) + Send + 'static, >( &self, size: i32, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn load_async_future( &self, size: i32, ) -> Box_> + std::marker::Unpin>; } impl> LoadableIconExt for O { fn load>( &self, size: i32, cancellable: Option<&P>, ) -> Result<(InputStream, GString), Error> { unsafe { let mut type_ = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_loadable_icon_load( self.as_ref().to_glib_none().0, size, &mut type_, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(type_))) } else { Err(from_glib_full(error)) } } } fn load_async< P: IsA, Q: FnOnce(Result<(InputStream, GString), Error>) + Send + 'static, >( &self, size: i32, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn load_async_trampoline< Q: FnOnce(Result<(InputStream, GString), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut type_ = ptr::null_mut(); let ret = gio_sys::g_loadable_icon_load_finish( _source_object as *mut _, res, &mut type_, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(type_))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = load_async_trampoline::; unsafe { gio_sys::g_loadable_icon_load_async( self.as_ref().to_glib_none().0, size, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn load_async_future( &self, size: i32, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.load_async(size, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for LoadableIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "LoadableIcon") } } gio-0.7.0/src/auto/memory_input_stream.rs010064400007650000024000000033321350341657000167270ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; use InputStream; use PollableInputStream; use Seekable; glib_wrapper! { pub struct MemoryInputStream(Object) @extends InputStream, @implements PollableInputStream, Seekable; match fn { get_type => || gio_sys::g_memory_input_stream_get_type(), } } impl MemoryInputStream { pub fn new() -> MemoryInputStream { unsafe { InputStream::from_glib_full(gio_sys::g_memory_input_stream_new()).unsafe_cast() } } pub fn new_from_bytes(bytes: &glib::Bytes) -> MemoryInputStream { unsafe { InputStream::from_glib_full(gio_sys::g_memory_input_stream_new_from_bytes( bytes.to_glib_none().0, )) .unsafe_cast() } } } impl Default for MemoryInputStream { fn default() -> Self { Self::new() } } pub const NONE_MEMORY_INPUT_STREAM: Option<&MemoryInputStream> = None; pub trait MemoryInputStreamExt: 'static { fn add_bytes(&self, bytes: &glib::Bytes); } impl> MemoryInputStreamExt for O { fn add_bytes(&self, bytes: &glib::Bytes) { unsafe { gio_sys::g_memory_input_stream_add_bytes( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, ); } } } impl fmt::Display for MemoryInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MemoryInputStream") } } gio-0.7.0/src/auto/memory_output_stream.rs010064400007650000024000000052341350341657000171330ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use OutputStream; use PollableOutputStream; use Seekable; glib_wrapper! { pub struct MemoryOutputStream(Object) @extends OutputStream, @implements PollableOutputStream, Seekable; match fn { get_type => || gio_sys::g_memory_output_stream_get_type(), } } impl MemoryOutputStream { pub fn new_resizable() -> MemoryOutputStream { unsafe { OutputStream::from_glib_full(gio_sys::g_memory_output_stream_new_resizable()) .unsafe_cast() } } } pub const NONE_MEMORY_OUTPUT_STREAM: Option<&MemoryOutputStream> = None; pub trait MemoryOutputStreamExt: 'static { fn get_data_size(&self) -> usize; fn steal_as_bytes(&self) -> Option; fn connect_property_data_size_notify(&self, f: F) -> SignalHandlerId; } impl> MemoryOutputStreamExt for O { fn get_data_size(&self) -> usize { unsafe { gio_sys::g_memory_output_stream_get_data_size(self.as_ref().to_glib_none().0) } } fn steal_as_bytes(&self) -> Option { unsafe { from_glib_full(gio_sys::g_memory_output_stream_steal_as_bytes( self.as_ref().to_glib_none().0, )) } } fn connect_property_data_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_data_size_trampoline( this: *mut gio_sys::GMemoryOutputStream, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MemoryOutputStream::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::data-size\0".as_ptr() as *const _, Some(transmute(notify_data_size_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for MemoryOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MemoryOutputStream") } } gio-0.7.0/src/auto/menu.rs010064400007650000024000000107661350341657000136020ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use MenuItem; use MenuModel; glib_wrapper! { pub struct Menu(Object) @extends MenuModel; match fn { get_type => || gio_sys::g_menu_get_type(), } } impl Menu { pub fn new() -> Menu { unsafe { from_glib_full(gio_sys::g_menu_new()) } } pub fn append(&self, label: Option<&str>, detailed_action: Option<&str>) { unsafe { gio_sys::g_menu_append( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } pub fn append_item(&self, item: &MenuItem) { unsafe { gio_sys::g_menu_append_item(self.to_glib_none().0, item.to_glib_none().0); } } pub fn append_section>(&self, label: Option<&str>, section: &P) { unsafe { gio_sys::g_menu_append_section( self.to_glib_none().0, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } pub fn append_submenu>(&self, label: Option<&str>, submenu: &P) { unsafe { gio_sys::g_menu_append_submenu( self.to_glib_none().0, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } pub fn freeze(&self) { unsafe { gio_sys::g_menu_freeze(self.to_glib_none().0); } } pub fn insert(&self, position: i32, label: Option<&str>, detailed_action: Option<&str>) { unsafe { gio_sys::g_menu_insert( self.to_glib_none().0, position, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } pub fn insert_item(&self, position: i32, item: &MenuItem) { unsafe { gio_sys::g_menu_insert_item(self.to_glib_none().0, position, item.to_glib_none().0); } } pub fn insert_section>( &self, position: i32, label: Option<&str>, section: &P, ) { unsafe { gio_sys::g_menu_insert_section( self.to_glib_none().0, position, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } pub fn insert_submenu>( &self, position: i32, label: Option<&str>, submenu: &P, ) { unsafe { gio_sys::g_menu_insert_submenu( self.to_glib_none().0, position, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } pub fn prepend(&self, label: Option<&str>, detailed_action: Option<&str>) { unsafe { gio_sys::g_menu_prepend( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } pub fn prepend_item(&self, item: &MenuItem) { unsafe { gio_sys::g_menu_prepend_item(self.to_glib_none().0, item.to_glib_none().0); } } pub fn prepend_section>(&self, label: Option<&str>, section: &P) { unsafe { gio_sys::g_menu_prepend_section( self.to_glib_none().0, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } pub fn prepend_submenu>(&self, label: Option<&str>, submenu: &P) { unsafe { gio_sys::g_menu_prepend_submenu( self.to_glib_none().0, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } pub fn remove(&self, position: i32) { unsafe { gio_sys::g_menu_remove(self.to_glib_none().0, position); } } pub fn remove_all(&self) { unsafe { gio_sys::g_menu_remove_all(self.to_glib_none().0); } } } impl Default for Menu { fn default() -> Self { Self::new() } } impl fmt::Display for Menu { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Menu") } } gio-0.7.0/src/auto/menu_attribute_iter.rs010064400007650000024000000041401350341657000166750ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::fmt; use std::ptr; glib_wrapper! { pub struct MenuAttributeIter(Object); match fn { get_type => || gio_sys::g_menu_attribute_iter_get_type(), } } pub const NONE_MENU_ATTRIBUTE_ITER: Option<&MenuAttributeIter> = None; pub trait MenuAttributeIterExt: 'static { fn get_name(&self) -> Option; fn get_next(&self) -> Option<(GString, glib::Variant)>; fn get_value(&self) -> Option; fn next(&self) -> bool; } impl> MenuAttributeIterExt for O { fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_menu_attribute_iter_get_name( self.as_ref().to_glib_none().0, )) } } fn get_next(&self) -> Option<(GString, glib::Variant)> { unsafe { let mut out_name = ptr::null(); let mut value = ptr::null_mut(); let ret = from_glib(gio_sys::g_menu_attribute_iter_get_next( self.as_ref().to_glib_none().0, &mut out_name, &mut value, )); if ret { Some((from_glib_none(out_name), from_glib_full(value))) } else { None } } } fn get_value(&self) -> Option { unsafe { from_glib_full(gio_sys::g_menu_attribute_iter_get_value( self.as_ref().to_glib_none().0, )) } } fn next(&self) -> bool { unsafe { from_glib(gio_sys::g_menu_attribute_iter_next( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for MenuAttributeIter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MenuAttributeIter") } } gio-0.7.0/src/auto/menu_item.rs010064400007650000024000000120761350341657000146140ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use std::fmt; use Icon; use MenuModel; glib_wrapper! { pub struct MenuItem(Object); match fn { get_type => || gio_sys::g_menu_item_get_type(), } } impl MenuItem { pub fn new(label: Option<&str>, detailed_action: Option<&str>) -> MenuItem { unsafe { from_glib_full(gio_sys::g_menu_item_new( label.to_glib_none().0, detailed_action.to_glib_none().0, )) } } pub fn new_from_model>(model: &P, item_index: i32) -> MenuItem { unsafe { from_glib_full(gio_sys::g_menu_item_new_from_model( model.as_ref().to_glib_none().0, item_index, )) } } pub fn new_section>(label: Option<&str>, section: &P) -> MenuItem { unsafe { from_glib_full(gio_sys::g_menu_item_new_section( label.to_glib_none().0, section.as_ref().to_glib_none().0, )) } } pub fn new_submenu>(label: Option<&str>, submenu: &P) -> MenuItem { unsafe { from_glib_full(gio_sys::g_menu_item_new_submenu( label.to_glib_none().0, submenu.as_ref().to_glib_none().0, )) } } //pub fn get_attribute(&self, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gio_sys:g_menu_item_get_attribute() } //} pub fn get_attribute_value( &self, attribute: &str, expected_type: Option<&glib::VariantTy>, ) -> Option { unsafe { from_glib_full(gio_sys::g_menu_item_get_attribute_value( self.to_glib_none().0, attribute.to_glib_none().0, expected_type.to_glib_none().0, )) } } pub fn get_link(&self, link: &str) -> Option { unsafe { from_glib_full(gio_sys::g_menu_item_get_link( self.to_glib_none().0, link.to_glib_none().0, )) } } //pub fn set_action_and_target(&self, action: Option<&str>, format_string: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_menu_item_set_action_and_target() } //} pub fn set_action_and_target_value( &self, action: Option<&str>, target_value: Option<&glib::Variant>, ) { unsafe { gio_sys::g_menu_item_set_action_and_target_value( self.to_glib_none().0, action.to_glib_none().0, target_value.to_glib_none().0, ); } } //pub fn set_attribute(&self, attribute: &str, format_string: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_menu_item_set_attribute() } //} pub fn set_attribute_value(&self, attribute: &str, value: Option<&glib::Variant>) { unsafe { gio_sys::g_menu_item_set_attribute_value( self.to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, ); } } pub fn set_detailed_action(&self, detailed_action: &str) { unsafe { gio_sys::g_menu_item_set_detailed_action( self.to_glib_none().0, detailed_action.to_glib_none().0, ); } } pub fn set_icon>(&self, icon: &P) { unsafe { gio_sys::g_menu_item_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } pub fn set_label(&self, label: Option<&str>) { unsafe { gio_sys::g_menu_item_set_label(self.to_glib_none().0, label.to_glib_none().0); } } pub fn set_link>(&self, link: &str, model: Option<&P>) { unsafe { gio_sys::g_menu_item_set_link( self.to_glib_none().0, link.to_glib_none().0, model.map(|p| p.as_ref()).to_glib_none().0, ); } } pub fn set_section>(&self, section: Option<&P>) { unsafe { gio_sys::g_menu_item_set_section( self.to_glib_none().0, section.map(|p| p.as_ref()).to_glib_none().0, ); } } pub fn set_submenu>(&self, submenu: Option<&P>) { unsafe { gio_sys::g_menu_item_set_submenu( self.to_glib_none().0, submenu.map(|p| p.as_ref()).to_glib_none().0, ); } } } impl fmt::Display for MenuItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MenuItem") } } gio-0.7.0/src/auto/menu_link_iter.rs010064400007650000024000000040051350341657000156270ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::fmt; use std::ptr; use MenuModel; glib_wrapper! { pub struct MenuLinkIter(Object); match fn { get_type => || gio_sys::g_menu_link_iter_get_type(), } } pub const NONE_MENU_LINK_ITER: Option<&MenuLinkIter> = None; pub trait MenuLinkIterExt: 'static { fn get_name(&self) -> Option; fn get_next(&self) -> Option<(GString, MenuModel)>; fn get_value(&self) -> Option; fn next(&self) -> bool; } impl> MenuLinkIterExt for O { fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_menu_link_iter_get_name( self.as_ref().to_glib_none().0, )) } } fn get_next(&self) -> Option<(GString, MenuModel)> { unsafe { let mut out_link = ptr::null(); let mut value = ptr::null_mut(); let ret = from_glib(gio_sys::g_menu_link_iter_get_next( self.as_ref().to_glib_none().0, &mut out_link, &mut value, )); if ret { Some((from_glib_none(out_link), from_glib_full(value))) } else { None } } } fn get_value(&self) -> Option { unsafe { from_glib_full(gio_sys::g_menu_link_iter_get_value( self.as_ref().to_glib_none().0, )) } } fn next(&self) -> bool { unsafe { from_glib(gio_sys::g_menu_link_iter_next( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for MenuLinkIter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MenuLinkIter") } } gio-0.7.0/src/auto/menu_model.rs010064400007650000024000000114761350341657000147610ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use MenuAttributeIter; use MenuLinkIter; glib_wrapper! { pub struct MenuModel(Object); match fn { get_type => || gio_sys::g_menu_model_get_type(), } } pub const NONE_MENU_MODEL: Option<&MenuModel> = None; pub trait MenuModelExt: 'static { //fn get_item_attribute(&self, item_index: i32, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; fn get_item_attribute_value( &self, item_index: i32, attribute: &str, expected_type: Option<&glib::VariantTy>, ) -> Option; fn get_item_link(&self, item_index: i32, link: &str) -> Option; fn get_n_items(&self) -> i32; fn is_mutable(&self) -> bool; fn items_changed(&self, position: i32, removed: i32, added: i32); fn iterate_item_attributes(&self, item_index: i32) -> Option; fn iterate_item_links(&self, item_index: i32) -> Option; fn connect_items_changed(&self, f: F) -> SignalHandlerId; } impl> MenuModelExt for O { //fn get_item_attribute(&self, item_index: i32, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gio_sys:g_menu_model_get_item_attribute() } //} fn get_item_attribute_value( &self, item_index: i32, attribute: &str, expected_type: Option<&glib::VariantTy>, ) -> Option { unsafe { from_glib_full(gio_sys::g_menu_model_get_item_attribute_value( self.as_ref().to_glib_none().0, item_index, attribute.to_glib_none().0, expected_type.to_glib_none().0, )) } } fn get_item_link(&self, item_index: i32, link: &str) -> Option { unsafe { from_glib_full(gio_sys::g_menu_model_get_item_link( self.as_ref().to_glib_none().0, item_index, link.to_glib_none().0, )) } } fn get_n_items(&self) -> i32 { unsafe { gio_sys::g_menu_model_get_n_items(self.as_ref().to_glib_none().0) } } fn is_mutable(&self) -> bool { unsafe { from_glib(gio_sys::g_menu_model_is_mutable( self.as_ref().to_glib_none().0, )) } } fn items_changed(&self, position: i32, removed: i32, added: i32) { unsafe { gio_sys::g_menu_model_items_changed( self.as_ref().to_glib_none().0, position, removed, added, ); } } fn iterate_item_attributes(&self, item_index: i32) -> Option { unsafe { from_glib_full(gio_sys::g_menu_model_iterate_item_attributes( self.as_ref().to_glib_none().0, item_index, )) } } fn iterate_item_links(&self, item_index: i32) -> Option { unsafe { from_glib_full(gio_sys::g_menu_model_iterate_item_links( self.as_ref().to_glib_none().0, item_index, )) } } fn connect_items_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn items_changed_trampoline( this: *mut gio_sys::GMenuModel, position: libc::c_int, removed: libc::c_int, added: libc::c_int, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &MenuModel::from_glib_borrow(this).unsafe_cast(), position, removed, added, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"items-changed\0".as_ptr() as *const _, Some(transmute(items_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for MenuModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MenuModel") } } gio-0.7.0/src/auto/mod.rs010064400007650000024000000672741350341657000134230ustar0000000000000000// 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 mod action; pub use self::action::ActionExt; pub use self::action::{Action, NONE_ACTION}; mod action_group; pub use self::action_group::ActionGroupExt; pub use self::action_group::{ActionGroup, NONE_ACTION_GROUP}; mod action_map; pub use self::action_map::ActionMapExt; pub use self::action_map::{ActionMap, NONE_ACTION_MAP}; mod app_info; pub use self::app_info::AppInfoExt; pub use self::app_info::{AppInfo, NONE_APP_INFO}; mod app_info_monitor; pub use self::app_info_monitor::{AppInfoMonitor, AppInfoMonitorClass}; mod app_launch_context; pub use self::app_launch_context::AppLaunchContextExt; pub use self::app_launch_context::{ AppLaunchContext, AppLaunchContextClass, NONE_APP_LAUNCH_CONTEXT, }; mod application; pub use self::application::ApplicationBuilder; pub use self::application::ApplicationExt; pub use self::application::{Application, ApplicationClass, NONE_APPLICATION}; mod application_command_line; pub use self::application_command_line::ApplicationCommandLineExt; pub use self::application_command_line::{ ApplicationCommandLine, ApplicationCommandLineClass, NONE_APPLICATION_COMMAND_LINE, }; mod buffered_input_stream; pub use self::buffered_input_stream::BufferedInputStreamBuilder; pub use self::buffered_input_stream::BufferedInputStreamExt; pub use self::buffered_input_stream::{ BufferedInputStream, BufferedInputStreamClass, NONE_BUFFERED_INPUT_STREAM, }; mod buffered_output_stream; pub use self::buffered_output_stream::BufferedOutputStreamBuilder; pub use self::buffered_output_stream::BufferedOutputStreamExt; pub use self::buffered_output_stream::{ BufferedOutputStream, BufferedOutputStreamClass, NONE_BUFFERED_OUTPUT_STREAM, }; mod bytes_icon; pub use self::bytes_icon::{BytesIcon, BytesIconClass}; mod cancellable; pub use self::cancellable::CancellableExt; pub use self::cancellable::{Cancellable, CancellableClass, NONE_CANCELLABLE}; mod charset_converter; pub use self::charset_converter::CharsetConverterBuilder; pub use self::charset_converter::CharsetConverterExt; pub use self::charset_converter::{ CharsetConverter, CharsetConverterClass, NONE_CHARSET_CONVERTER, }; mod converter; pub use self::converter::ConverterExt; pub use self::converter::{Converter, NONE_CONVERTER}; mod converter_input_stream; pub use self::converter_input_stream::ConverterInputStreamBuilder; pub use self::converter_input_stream::ConverterInputStreamExt; pub use self::converter_input_stream::{ ConverterInputStream, ConverterInputStreamClass, NONE_CONVERTER_INPUT_STREAM, }; mod converter_output_stream; pub use self::converter_output_stream::ConverterOutputStreamBuilder; pub use self::converter_output_stream::ConverterOutputStreamExt; pub use self::converter_output_stream::{ ConverterOutputStream, ConverterOutputStreamClass, NONE_CONVERTER_OUTPUT_STREAM, }; mod credentials; pub use self::credentials::{Credentials, CredentialsClass}; mod data_input_stream; pub use self::data_input_stream::DataInputStreamBuilder; pub use self::data_input_stream::DataInputStreamExt; pub use self::data_input_stream::{DataInputStream, DataInputStreamClass, NONE_DATA_INPUT_STREAM}; mod data_output_stream; pub use self::data_output_stream::DataOutputStreamBuilder; pub use self::data_output_stream::DataOutputStreamExt; pub use self::data_output_stream::{ DataOutputStream, DataOutputStreamClass, NONE_DATA_OUTPUT_STREAM, }; #[cfg(any(not(windows), feature = "dox"))] mod desktop_app_info; #[cfg(any(not(windows), feature = "dox"))] pub use self::desktop_app_info::DesktopAppInfoExt; #[cfg(any(not(windows), feature = "dox"))] pub use self::desktop_app_info::{DesktopAppInfo, DesktopAppInfoClass, NONE_DESKTOP_APP_INFO}; mod drive; pub use self::drive::DriveExt; pub use self::drive::{Drive, NONE_DRIVE}; mod emblem; pub use self::emblem::{Emblem, EmblemClass}; mod emblemed_icon; pub use self::emblemed_icon::EmblemedIconExt; pub use self::emblemed_icon::{EmblemedIcon, EmblemedIconClass, NONE_EMBLEMED_ICON}; mod file; pub use self::file::FileExt; pub use self::file::{File, NONE_FILE}; mod file_io_stream; pub use self::file_io_stream::FileIOStreamExt; pub use self::file_io_stream::{FileIOStream, FileIOStreamClass, NONE_FILE_IO_STREAM}; mod file_icon; pub use self::file_icon::{FileIcon, FileIconClass}; mod file_info; pub use self::file_info::{FileInfo, FileInfoClass}; mod file_input_stream; pub use self::file_input_stream::FileInputStreamExt; pub use self::file_input_stream::{FileInputStream, FileInputStreamClass, NONE_FILE_INPUT_STREAM}; mod file_monitor; pub use self::file_monitor::FileMonitorExt; pub use self::file_monitor::{FileMonitor, FileMonitorClass, NONE_FILE_MONITOR}; mod file_output_stream; pub use self::file_output_stream::FileOutputStreamExt; pub use self::file_output_stream::{ FileOutputStream, FileOutputStreamClass, NONE_FILE_OUTPUT_STREAM, }; mod filename_completer; pub use self::filename_completer::FilenameCompleterExt; pub use self::filename_completer::{ FilenameCompleter, FilenameCompleterClass, NONE_FILENAME_COMPLETER, }; mod filter_input_stream; pub use self::filter_input_stream::FilterInputStreamExt; pub use self::filter_input_stream::{ FilterInputStream, FilterInputStreamClass, NONE_FILTER_INPUT_STREAM, }; mod filter_output_stream; pub use self::filter_output_stream::FilterOutputStreamExt; pub use self::filter_output_stream::{ FilterOutputStream, FilterOutputStreamClass, NONE_FILTER_OUTPUT_STREAM, }; mod io_stream; pub use self::io_stream::IOStreamExt; pub use self::io_stream::{IOStream, IOStreamClass, NONE_IO_STREAM}; mod icon; pub use self::icon::IconExt; pub use self::icon::{Icon, NONE_ICON}; mod inet_address; pub use self::inet_address::InetAddressExt; pub use self::inet_address::{InetAddress, InetAddressClass, NONE_INET_ADDRESS}; mod inet_address_mask; pub use self::inet_address_mask::InetAddressMaskExt; pub use self::inet_address_mask::{InetAddressMask, InetAddressMaskClass, NONE_INET_ADDRESS_MASK}; mod inet_socket_address; pub use self::inet_socket_address::InetSocketAddressExt; pub use self::inet_socket_address::{ InetSocketAddress, InetSocketAddressClass, NONE_INET_SOCKET_ADDRESS, }; mod input_stream; pub use self::input_stream::InputStreamExt; pub use self::input_stream::{InputStream, InputStreamClass, NONE_INPUT_STREAM}; #[cfg(any(feature = "v2_44", feature = "dox"))] mod list_model; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::list_model::ListModelExt; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::list_model::{ListModel, NONE_LIST_MODEL}; #[cfg(any(feature = "v2_44", feature = "dox"))] mod list_store; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::list_store::ListStoreBuilder; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::list_store::ListStoreExt; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::list_store::{ListStore, ListStoreClass, NONE_LIST_STORE}; mod loadable_icon; pub use self::loadable_icon::LoadableIconExt; pub use self::loadable_icon::{LoadableIcon, NONE_LOADABLE_ICON}; mod memory_input_stream; pub use self::memory_input_stream::MemoryInputStreamExt; pub use self::memory_input_stream::{ MemoryInputStream, MemoryInputStreamClass, NONE_MEMORY_INPUT_STREAM, }; mod memory_output_stream; pub use self::memory_output_stream::MemoryOutputStreamExt; pub use self::memory_output_stream::{ MemoryOutputStream, MemoryOutputStreamClass, NONE_MEMORY_OUTPUT_STREAM, }; mod menu; pub use self::menu::{Menu, MenuClass}; mod menu_attribute_iter; pub use self::menu_attribute_iter::MenuAttributeIterExt; pub use self::menu_attribute_iter::{ MenuAttributeIter, MenuAttributeIterClass, NONE_MENU_ATTRIBUTE_ITER, }; mod menu_item; pub use self::menu_item::{MenuItem, MenuItemClass}; mod menu_link_iter; pub use self::menu_link_iter::MenuLinkIterExt; pub use self::menu_link_iter::{MenuLinkIter, MenuLinkIterClass, NONE_MENU_LINK_ITER}; mod menu_model; pub use self::menu_model::MenuModelExt; pub use self::menu_model::{MenuModel, MenuModelClass, NONE_MENU_MODEL}; mod mount; pub use self::mount::MountExt; pub use self::mount::{Mount, NONE_MOUNT}; mod mount_operation; pub use self::mount_operation::MountOperationExt; pub use self::mount_operation::{MountOperation, MountOperationClass, NONE_MOUNT_OPERATION}; mod network_address; pub use self::network_address::NetworkAddressExt; pub use self::network_address::{NetworkAddress, NetworkAddressClass, NONE_NETWORK_ADDRESS}; mod network_monitor; pub use self::network_monitor::NetworkMonitorExt; pub use self::network_monitor::{NetworkMonitor, NONE_NETWORK_MONITOR}; mod network_service; pub use self::network_service::NetworkServiceExt; pub use self::network_service::{NetworkService, NetworkServiceClass, NONE_NETWORK_SERVICE}; mod notification; pub use self::notification::{Notification, NotificationClass}; mod output_stream; pub use self::output_stream::OutputStreamExt; pub use self::output_stream::{OutputStream, OutputStreamClass, NONE_OUTPUT_STREAM}; mod permission; pub use self::permission::PermissionExt; pub use self::permission::{Permission, PermissionClass, NONE_PERMISSION}; mod pollable_input_stream; pub use self::pollable_input_stream::PollableInputStreamExt; pub use self::pollable_input_stream::{PollableInputStream, NONE_POLLABLE_INPUT_STREAM}; mod pollable_output_stream; pub use self::pollable_output_stream::PollableOutputStreamExt; pub use self::pollable_output_stream::{PollableOutputStream, NONE_POLLABLE_OUTPUT_STREAM}; mod property_action; pub use self::property_action::{PropertyAction, PropertyActionClass}; mod proxy; pub use self::proxy::ProxyExt; pub use self::proxy::{Proxy, NONE_PROXY}; mod proxy_address; pub use self::proxy_address::ProxyAddressExt; pub use self::proxy_address::{ProxyAddress, ProxyAddressClass, NONE_PROXY_ADDRESS}; mod proxy_resolver; pub use self::proxy_resolver::ProxyResolverExt; pub use self::proxy_resolver::{ProxyResolver, NONE_PROXY_RESOLVER}; mod remote_action_group; pub use self::remote_action_group::RemoteActionGroupExt; pub use self::remote_action_group::{RemoteActionGroup, NONE_REMOTE_ACTION_GROUP}; mod resolver; pub use self::resolver::ResolverExt; pub use self::resolver::{Resolver, ResolverClass, NONE_RESOLVER}; mod seekable; pub use self::seekable::SeekableExt; pub use self::seekable::{Seekable, NONE_SEEKABLE}; mod settings; pub use self::settings::SettingsExt; pub use self::settings::{Settings, SettingsClass, NONE_SETTINGS}; mod settings_backend; pub use self::settings_backend::SettingsBackendExt; pub use self::settings_backend::{SettingsBackend, SettingsBackendClass, NONE_SETTINGS_BACKEND}; mod simple_action; pub use self::simple_action::{SimpleAction, SimpleActionClass}; mod simple_action_group; pub use self::simple_action_group::{ SimpleActionGroup, SimpleActionGroupClass, NONE_SIMPLE_ACTION_GROUP, }; #[cfg(any(feature = "v2_44", feature = "dox"))] mod simple_io_stream; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::simple_io_stream::{SimpleIOStream, SimpleIOStreamClass}; mod simple_permission; pub use self::simple_permission::{SimplePermission, SimplePermissionClass}; mod socket; pub use self::socket::SocketExt; pub use self::socket::{Socket, SocketClass, NONE_SOCKET}; mod socket_address; pub use self::socket_address::SocketAddressExt; pub use self::socket_address::{SocketAddress, SocketAddressClass, NONE_SOCKET_ADDRESS}; mod socket_address_enumerator; pub use self::socket_address_enumerator::SocketAddressEnumeratorExt; pub use self::socket_address_enumerator::{ SocketAddressEnumerator, SocketAddressEnumeratorClass, NONE_SOCKET_ADDRESS_ENUMERATOR, }; mod socket_client; pub use self::socket_client::SocketClientExt; pub use self::socket_client::{SocketClient, SocketClientClass, NONE_SOCKET_CLIENT}; mod socket_connectable; pub use self::socket_connectable::SocketConnectableExt; pub use self::socket_connectable::{SocketConnectable, NONE_SOCKET_CONNECTABLE}; mod socket_connection; pub use self::socket_connection::SocketConnectionExt; pub use self::socket_connection::{ SocketConnection, SocketConnectionClass, NONE_SOCKET_CONNECTION, }; mod socket_listener; pub use self::socket_listener::SocketListenerExt; pub use self::socket_listener::{SocketListener, SocketListenerClass, NONE_SOCKET_LISTENER}; mod socket_service; pub use self::socket_service::SocketServiceExt; pub use self::socket_service::{SocketService, SocketServiceClass, NONE_SOCKET_SERVICE}; mod subprocess; pub use self::subprocess::{Subprocess, SubprocessClass}; mod subprocess_launcher; pub use self::subprocess_launcher::{SubprocessLauncher, SubprocessLauncherClass}; mod tcp_connection; pub use self::tcp_connection::TcpConnectionExt; pub use self::tcp_connection::{TcpConnection, TcpConnectionClass, NONE_TCP_CONNECTION}; mod themed_icon; pub use self::themed_icon::{ThemedIcon, ThemedIconClass}; mod threaded_socket_service; pub use self::threaded_socket_service::ThreadedSocketServiceExt; pub use self::threaded_socket_service::{ ThreadedSocketService, ThreadedSocketServiceClass, NONE_THREADED_SOCKET_SERVICE, }; mod tls_certificate; pub use self::tls_certificate::TlsCertificateExt; pub use self::tls_certificate::{TlsCertificate, TlsCertificateClass, NONE_TLS_CERTIFICATE}; mod tls_client_connection; pub use self::tls_client_connection::TlsClientConnectionExt; pub use self::tls_client_connection::{TlsClientConnection, NONE_TLS_CLIENT_CONNECTION}; mod tls_connection; pub use self::tls_connection::TlsConnectionExt; pub use self::tls_connection::{TlsConnection, TlsConnectionClass, NONE_TLS_CONNECTION}; mod tls_database; pub use self::tls_database::TlsDatabaseExt; pub use self::tls_database::{TlsDatabase, TlsDatabaseClass, NONE_TLS_DATABASE}; mod tls_file_database; pub use self::tls_file_database::TlsFileDatabaseExt; pub use self::tls_file_database::{TlsFileDatabase, NONE_TLS_FILE_DATABASE}; mod tls_interaction; pub use self::tls_interaction::TlsInteractionExt; pub use self::tls_interaction::{TlsInteraction, TlsInteractionClass, NONE_TLS_INTERACTION}; mod tls_password; pub use self::tls_password::TlsPasswordExt; pub use self::tls_password::{TlsPassword, TlsPasswordClass, NONE_TLS_PASSWORD}; mod tls_server_connection; pub use self::tls_server_connection::TlsServerConnectionExt; pub use self::tls_server_connection::{TlsServerConnection, NONE_TLS_SERVER_CONNECTION}; #[cfg(any(unix, feature = "dox"))] mod unix_input_stream; #[cfg(any(unix, feature = "dox"))] pub use self::unix_input_stream::UnixInputStreamExt; #[cfg(any(unix, feature = "dox"))] pub use self::unix_input_stream::{UnixInputStream, UnixInputStreamClass, NONE_UNIX_INPUT_STREAM}; #[cfg(any(unix, feature = "dox"))] mod unix_output_stream; #[cfg(any(unix, feature = "dox"))] pub use self::unix_output_stream::UnixOutputStreamExt; #[cfg(any(unix, feature = "dox"))] pub use self::unix_output_stream::{ UnixOutputStream, UnixOutputStreamClass, NONE_UNIX_OUTPUT_STREAM, }; #[cfg(any(unix, feature = "dox"))] mod unix_socket_address; #[cfg(any(unix, feature = "dox"))] pub use self::unix_socket_address::UnixSocketAddressExt; #[cfg(any(unix, feature = "dox"))] pub use self::unix_socket_address::{ UnixSocketAddress, UnixSocketAddressClass, NONE_UNIX_SOCKET_ADDRESS, }; mod vfs; pub use self::vfs::VfsExt; pub use self::vfs::{Vfs, VfsClass, NONE_VFS}; mod volume; pub use self::volume::VolumeExt; pub use self::volume::{Volume, NONE_VOLUME}; mod volume_monitor; pub use self::volume_monitor::VolumeMonitorExt; pub use self::volume_monitor::{VolumeMonitor, VolumeMonitorClass, NONE_VOLUME_MONITOR}; mod zlib_compressor; pub use self::zlib_compressor::ZlibCompressorExt; pub use self::zlib_compressor::{ZlibCompressor, ZlibCompressorClass, NONE_ZLIB_COMPRESSOR}; mod zlib_decompressor; pub use self::zlib_decompressor::ZlibDecompressorExt; pub use self::zlib_decompressor::{ ZlibDecompressor, ZlibDecompressorClass, NONE_ZLIB_DECOMPRESSOR, }; mod file_attribute_matcher; pub use self::file_attribute_matcher::FileAttributeMatcher; mod resource; pub use self::resource::Resource; mod settings_schema; pub use self::settings_schema::SettingsSchema; mod settings_schema_key; pub use self::settings_schema_key::SettingsSchemaKey; mod settings_schema_source; pub use self::settings_schema_source::SettingsSchemaSource; mod srv_target; pub use self::srv_target::SrvTarget; mod enums; pub use self::enums::ConverterResult; pub use self::enums::CredentialsType; pub use self::enums::DataStreamByteOrder; pub use self::enums::DataStreamNewlineType; pub use self::enums::DriveStartStopType; pub use self::enums::EmblemOrigin; pub use self::enums::FileAttributeStatus; pub use self::enums::FileAttributeType; pub use self::enums::FileMonitorEvent; pub use self::enums::FileType; pub use self::enums::IOErrorEnum; pub use self::enums::MountOperationResult; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use self::enums::NetworkConnectivity; pub use self::enums::NotificationPriority; pub use self::enums::PasswordSave; pub use self::enums::ResolverRecordType; pub use self::enums::ResourceError; pub use self::enums::SocketClientEvent; pub use self::enums::SocketFamily; #[cfg(any(feature = "v2_46", feature = "dox"))] pub use self::enums::SocketListenerEvent; pub use self::enums::SocketProtocol; pub use self::enums::SocketType; pub use self::enums::TlsAuthenticationMode; pub use self::enums::TlsCertificateRequestFlags; pub use self::enums::TlsDatabaseLookupFlags; pub use self::enums::TlsInteractionResult; pub use self::enums::TlsRehandshakeMode; pub use self::enums::UnixSocketAddressType; pub use self::enums::ZlibCompressorFormat; mod flags; pub use self::flags::AppInfoCreateFlags; pub use self::flags::ApplicationFlags; pub use self::flags::AskPasswordFlags; pub use self::flags::ConverterFlags; pub use self::flags::DriveStartFlags; pub use self::flags::FileCopyFlags; pub use self::flags::FileCreateFlags; pub use self::flags::FileMeasureFlags; pub use self::flags::FileMonitorFlags; pub use self::flags::FileQueryInfoFlags; pub use self::flags::IOStreamSpliceFlags; pub use self::flags::MountMountFlags; pub use self::flags::MountUnmountFlags; pub use self::flags::OutputStreamSpliceFlags; pub use self::flags::ResourceLookupFlags; pub use self::flags::SettingsBindFlags; pub use self::flags::SubprocessFlags; pub use self::flags::TlsCertificateFlags; pub use self::flags::TlsDatabaseVerifyFlags; pub use self::flags::TlsPasswordFlags; pub mod functions; mod constants; pub use self::constants::DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME; #[cfg(any(feature = "v2_58", feature = "dox"))] pub use self::constants::DRIVE_IDENTIFIER_KIND_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_DELETE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_READ; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_RENAME; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_TRASH; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_WRITE; pub use self::constants::FILE_ATTRIBUTE_DOS_IS_ARCHIVE; pub use self::constants::FILE_ATTRIBUTE_DOS_IS_SYSTEM; pub use self::constants::FILE_ATTRIBUTE_ETAG_VALUE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_FREE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_READONLY; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_REMOTE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_SIZE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_TYPE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_USED; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW; pub use self::constants::FILE_ATTRIBUTE_GVFS_BACKEND; pub use self::constants::FILE_ATTRIBUTE_ID_FILE; pub use self::constants::FILE_ATTRIBUTE_ID_FILESYSTEM; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_START; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE; pub use self::constants::FILE_ATTRIBUTE_OWNER_GROUP; pub use self::constants::FILE_ATTRIBUTE_OWNER_USER; pub use self::constants::FILE_ATTRIBUTE_OWNER_USER_REAL; pub use self::constants::FILE_ATTRIBUTE_PREVIEW_ICON; #[cfg(any(feature = "v2_52", feature = "dox"))] pub use self::constants::FILE_ATTRIBUTE_RECENT_MODIFIED; pub use self::constants::FILE_ATTRIBUTE_SELINUX_CONTEXT; pub use self::constants::FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_COPY_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_DESCRIPTION; pub use self::constants::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_EDIT_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_ICON; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_BACKUP; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_HIDDEN; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_SYMLINK; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL; #[cfg(any(feature = "v2_46", feature = "dox"))] pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_VOLATILE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SIZE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SORT_ORDER; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET; pub use self::constants::FILE_ATTRIBUTE_STANDARD_TARGET_URI; pub use self::constants::FILE_ATTRIBUTE_STANDARD_TYPE; pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED; pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED_USEC; pub use self::constants::FILE_ATTRIBUTE_TRASH_DELETION_DATE; pub use self::constants::FILE_ATTRIBUTE_TRASH_ITEM_COUNT; pub use self::constants::FILE_ATTRIBUTE_TRASH_ORIG_PATH; pub use self::constants::FILE_ATTRIBUTE_UNIX_BLOCKS; pub use self::constants::FILE_ATTRIBUTE_UNIX_BLOCK_SIZE; pub use self::constants::FILE_ATTRIBUTE_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_UNIX_GID; pub use self::constants::FILE_ATTRIBUTE_UNIX_INODE; pub use self::constants::FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT; pub use self::constants::FILE_ATTRIBUTE_UNIX_MODE; pub use self::constants::FILE_ATTRIBUTE_UNIX_NLINK; pub use self::constants::FILE_ATTRIBUTE_UNIX_RDEV; pub use self::constants::FILE_ATTRIBUTE_UNIX_UID; pub use self::constants::MENU_ATTRIBUTE_ACTION; pub use self::constants::MENU_ATTRIBUTE_ACTION_NAMESPACE; pub use self::constants::MENU_ATTRIBUTE_ICON; pub use self::constants::MENU_ATTRIBUTE_LABEL; pub use self::constants::MENU_ATTRIBUTE_TARGET; pub use self::constants::MENU_LINK_SECTION; pub use self::constants::MENU_LINK_SUBMENU; pub use self::constants::NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME; pub use self::constants::NETWORK_MONITOR_EXTENSION_POINT_NAME; pub use self::constants::PROXY_EXTENSION_POINT_NAME; pub use self::constants::PROXY_RESOLVER_EXTENSION_POINT_NAME; pub use self::constants::SETTINGS_BACKEND_EXTENSION_POINT_NAME; pub use self::constants::TLS_BACKEND_EXTENSION_POINT_NAME; pub use self::constants::TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT; pub use self::constants::TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER; pub use self::constants::VFS_EXTENSION_POINT_NAME; pub use self::constants::VOLUME_IDENTIFIER_KIND_CLASS; pub use self::constants::VOLUME_IDENTIFIER_KIND_HAL_UDI; pub use self::constants::VOLUME_IDENTIFIER_KIND_LABEL; pub use self::constants::VOLUME_IDENTIFIER_KIND_NFS_MOUNT; pub use self::constants::VOLUME_IDENTIFIER_KIND_UNIX_DEVICE; pub use self::constants::VOLUME_IDENTIFIER_KIND_UUID; pub use self::constants::VOLUME_MONITOR_EXTENSION_POINT_NAME; #[doc(hidden)] pub mod traits { pub use super::ActionExt; pub use super::ActionGroupExt; pub use super::ActionMapExt; pub use super::AppInfoExt; pub use super::AppLaunchContextExt; pub use super::ApplicationCommandLineExt; pub use super::ApplicationExt; pub use super::BufferedInputStreamExt; pub use super::BufferedOutputStreamExt; pub use super::CancellableExt; pub use super::CharsetConverterExt; pub use super::ConverterExt; pub use super::ConverterInputStreamExt; pub use super::ConverterOutputStreamExt; pub use super::DataInputStreamExt; pub use super::DataOutputStreamExt; #[cfg(any(not(windows), feature = "dox"))] pub use super::DesktopAppInfoExt; pub use super::DriveExt; pub use super::EmblemedIconExt; pub use super::FileExt; pub use super::FileIOStreamExt; pub use super::FileInputStreamExt; pub use super::FileMonitorExt; pub use super::FileOutputStreamExt; pub use super::FilenameCompleterExt; pub use super::FilterInputStreamExt; pub use super::FilterOutputStreamExt; pub use super::IOStreamExt; pub use super::IconExt; pub use super::InetAddressExt; pub use super::InetAddressMaskExt; pub use super::InetSocketAddressExt; pub use super::InputStreamExt; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use super::ListModelExt; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use super::ListStoreExt; pub use super::LoadableIconExt; pub use super::MemoryInputStreamExt; pub use super::MemoryOutputStreamExt; pub use super::MenuAttributeIterExt; pub use super::MenuLinkIterExt; pub use super::MenuModelExt; pub use super::MountExt; pub use super::MountOperationExt; pub use super::NetworkAddressExt; pub use super::NetworkMonitorExt; pub use super::NetworkServiceExt; pub use super::OutputStreamExt; pub use super::PermissionExt; pub use super::PollableInputStreamExt; pub use super::PollableOutputStreamExt; pub use super::ProxyAddressExt; pub use super::ProxyExt; pub use super::ProxyResolverExt; pub use super::RemoteActionGroupExt; pub use super::ResolverExt; pub use super::SeekableExt; pub use super::SettingsBackendExt; pub use super::SettingsExt; pub use super::SocketAddressEnumeratorExt; pub use super::SocketAddressExt; pub use super::SocketClientExt; pub use super::SocketConnectableExt; pub use super::SocketConnectionExt; pub use super::SocketExt; pub use super::SocketListenerExt; pub use super::SocketServiceExt; pub use super::TcpConnectionExt; pub use super::ThreadedSocketServiceExt; pub use super::TlsCertificateExt; pub use super::TlsClientConnectionExt; pub use super::TlsConnectionExt; pub use super::TlsDatabaseExt; pub use super::TlsFileDatabaseExt; pub use super::TlsInteractionExt; pub use super::TlsPasswordExt; pub use super::TlsServerConnectionExt; #[cfg(any(unix, feature = "dox"))] pub use super::UnixInputStreamExt; #[cfg(any(unix, feature = "dox"))] pub use super::UnixOutputStreamExt; #[cfg(any(unix, feature = "dox"))] pub use super::UnixSocketAddressExt; pub use super::VfsExt; pub use super::VolumeExt; pub use super::VolumeMonitorExt; pub use super::ZlibCompressorExt; pub use super::ZlibDecompressorExt; } gio-0.7.0/src/auto/mount.rs010064400007650000024000000437411350341657000137770ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Drive; use Error; use File; use Icon; use MountMountFlags; use MountOperation; use MountUnmountFlags; use Volume; glib_wrapper! { pub struct Mount(Interface); match fn { get_type => || gio_sys::g_mount_get_type(), } } pub const NONE_MOUNT: Option<&Mount> = None; pub trait MountExt: 'static { fn can_eject(&self) -> bool; fn can_unmount(&self) -> bool; fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn get_default_location(&self) -> Option; fn get_drive(&self) -> Option; fn get_icon(&self) -> Option; fn get_name(&self) -> Option; fn get_root(&self) -> Option; fn get_sort_key(&self) -> Option; fn get_symbolic_icon(&self) -> Option; fn get_uuid(&self) -> Option; fn get_volume(&self) -> Option; fn guess_content_type< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, force_rescan: bool, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn guess_content_type_future( &self, force_rescan: bool, ) -> Box_, Error>> + std::marker::Unpin>; fn guess_content_type_sync>( &self, force_rescan: bool, cancellable: Option<&P>, ) -> Result, Error>; fn is_shadowed(&self) -> bool; fn remount< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn remount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn shadow(&self); fn unmount_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn unmount_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn unshadow(&self); fn connect_changed(&self, f: F) -> SignalHandlerId; fn connect_pre_unmount(&self, f: F) -> SignalHandlerId; fn connect_unmounted(&self, f: F) -> SignalHandlerId; } impl> MountExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_can_eject(self.as_ref().to_glib_none().0)) } } fn can_unmount(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_can_unmount(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_mount_eject_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = eject_with_operation_trampoline::; unsafe { gio_sys::g_mount_eject_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn get_default_location(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_default_location( self.as_ref().to_glib_none().0, )) } } fn get_drive(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_drive(self.as_ref().to_glib_none().0)) } } fn get_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_icon(self.as_ref().to_glib_none().0)) } } fn get_name(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_name(self.as_ref().to_glib_none().0)) } } fn get_root(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_root(self.as_ref().to_glib_none().0)) } } fn get_sort_key(&self) -> Option { unsafe { from_glib_none(gio_sys::g_mount_get_sort_key( self.as_ref().to_glib_none().0, )) } } fn get_symbolic_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn get_uuid(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_uuid(self.as_ref().to_glib_none().0)) } } fn get_volume(&self) -> Option { unsafe { from_glib_full(gio_sys::g_mount_get_volume(self.as_ref().to_glib_none().0)) } } fn guess_content_type< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, force_rescan: bool, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn guess_content_type_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_mount_guess_content_type_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = guess_content_type_trampoline::; unsafe { gio_sys::g_mount_guess_content_type( self.as_ref().to_glib_none().0, force_rescan.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn guess_content_type_future( &self, force_rescan: bool, ) -> Box_, Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.guess_content_type(force_rescan, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn guess_content_type_sync>( &self, force_rescan: bool, cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_mount_guess_content_type_sync( self.as_ref().to_glib_none().0, force_rescan.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn is_shadowed(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_is_shadowed(self.as_ref().to_glib_none().0)) } } fn remount< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn remount_trampoline) + Send + 'static>( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_mount_remount_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = remount_trampoline::; unsafe { gio_sys::g_mount_remount( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn remount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.remount( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn shadow(&self) { unsafe { gio_sys::g_mount_shadow(self.as_ref().to_glib_none().0); } } fn unmount_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn unmount_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_mount_unmount_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = unmount_with_operation_trampoline::; unsafe { gio_sys::g_mount_unmount_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn unmount_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.unmount_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn unshadow(&self) { unsafe { gio_sys::g_mount_unshadow(self.as_ref().to_glib_none().0); } } fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Mount::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_pre_unmount(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn pre_unmount_trampoline( this: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Mount::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pre-unmount\0".as_ptr() as *const _, Some(transmute(pre_unmount_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_unmounted(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn unmounted_trampoline( this: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Mount::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"unmounted\0".as_ptr() as *const _, Some(transmute(unmounted_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Mount { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Mount") } } gio-0.7.0/src/auto/mount_operation.rs010064400007650000024000000506111350341657000160510ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use libc; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use AskPasswordFlags; use MountOperationResult; use PasswordSave; glib_wrapper! { pub struct MountOperation(Object); match fn { get_type => || gio_sys::g_mount_operation_get_type(), } } impl MountOperation { pub fn new() -> MountOperation { unsafe { from_glib_full(gio_sys::g_mount_operation_new()) } } } impl Default for MountOperation { fn default() -> Self { Self::new() } } pub const NONE_MOUNT_OPERATION: Option<&MountOperation> = None; pub trait MountOperationExt: 'static { fn get_anonymous(&self) -> bool; fn get_choice(&self) -> i32; fn get_domain(&self) -> Option; #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_is_tcrypt_hidden_volume(&self) -> bool; #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_is_tcrypt_system_volume(&self) -> bool; fn get_password(&self) -> Option; fn get_password_save(&self) -> PasswordSave; #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_pim(&self) -> u32; fn get_username(&self) -> Option; fn reply(&self, result: MountOperationResult); fn set_anonymous(&self, anonymous: bool); fn set_choice(&self, choice: i32); fn set_domain(&self, domain: &str); #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool); #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_is_tcrypt_system_volume(&self, system_volume: bool); fn set_password(&self, password: &str); fn set_password_save(&self, save: PasswordSave); #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_pim(&self, pim: u32); fn set_username(&self, username: &str); fn connect_aborted(&self, f: F) -> SignalHandlerId; fn connect_ask_password( &self, f: F, ) -> SignalHandlerId; //fn connect_ask_question(&self, f: F) -> SignalHandlerId; fn connect_reply(&self, f: F) -> SignalHandlerId; //fn connect_show_processes(&self, f: F) -> SignalHandlerId; fn connect_show_unmount_progress( &self, f: F, ) -> SignalHandlerId; fn connect_property_anonymous_notify(&self, f: F) -> SignalHandlerId; fn connect_property_choice_notify(&self, f: F) -> SignalHandlerId; fn connect_property_domain_notify(&self, f: F) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_is_tcrypt_hidden_volume_notify( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_is_tcrypt_system_volume_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_password_notify(&self, f: F) -> SignalHandlerId; fn connect_property_password_save_notify( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_pim_notify(&self, f: F) -> SignalHandlerId; fn connect_property_username_notify(&self, f: F) -> SignalHandlerId; } impl> MountOperationExt for O { fn get_anonymous(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_operation_get_anonymous( self.as_ref().to_glib_none().0, )) } } fn get_choice(&self) -> i32 { unsafe { gio_sys::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) } } fn get_domain(&self) -> Option { unsafe { from_glib_none(gio_sys::g_mount_operation_get_domain( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_is_tcrypt_hidden_volume(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_operation_get_is_tcrypt_hidden_volume( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_is_tcrypt_system_volume(&self) -> bool { unsafe { from_glib(gio_sys::g_mount_operation_get_is_tcrypt_system_volume( self.as_ref().to_glib_none().0, )) } } fn get_password(&self) -> Option { unsafe { from_glib_none(gio_sys::g_mount_operation_get_password( self.as_ref().to_glib_none().0, )) } } fn get_password_save(&self) -> PasswordSave { unsafe { from_glib(gio_sys::g_mount_operation_get_password_save( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn get_pim(&self) -> u32 { unsafe { gio_sys::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) } } fn get_username(&self) -> Option { unsafe { from_glib_none(gio_sys::g_mount_operation_get_username( self.as_ref().to_glib_none().0, )) } } fn reply(&self, result: MountOperationResult) { unsafe { gio_sys::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.to_glib()); } } fn set_anonymous(&self, anonymous: bool) { unsafe { gio_sys::g_mount_operation_set_anonymous( self.as_ref().to_glib_none().0, anonymous.to_glib(), ); } } fn set_choice(&self, choice: i32) { unsafe { gio_sys::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice); } } fn set_domain(&self, domain: &str) { unsafe { gio_sys::g_mount_operation_set_domain( self.as_ref().to_glib_none().0, domain.to_glib_none().0, ); } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool) { unsafe { gio_sys::g_mount_operation_set_is_tcrypt_hidden_volume( self.as_ref().to_glib_none().0, hidden_volume.to_glib(), ); } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_is_tcrypt_system_volume(&self, system_volume: bool) { unsafe { gio_sys::g_mount_operation_set_is_tcrypt_system_volume( self.as_ref().to_glib_none().0, system_volume.to_glib(), ); } } fn set_password(&self, password: &str) { unsafe { gio_sys::g_mount_operation_set_password( self.as_ref().to_glib_none().0, password.to_glib_none().0, ); } } fn set_password_save(&self, save: PasswordSave) { unsafe { gio_sys::g_mount_operation_set_password_save( self.as_ref().to_glib_none().0, save.to_glib(), ); } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn set_pim(&self, pim: u32) { unsafe { gio_sys::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim); } } fn set_username(&self, username: &str) { unsafe { gio_sys::g_mount_operation_set_username( self.as_ref().to_glib_none().0, username.to_glib_none().0, ); } } fn connect_aborted(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn aborted_trampoline( this: *mut gio_sys::GMountOperation, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"aborted\0".as_ptr() as *const _, Some(transmute(aborted_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_ask_password( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn ask_password_trampoline< P, F: Fn(&P, &str, &str, &str, AskPasswordFlags) + 'static, >( this: *mut gio_sys::GMountOperation, message: *mut libc::c_char, default_user: *mut libc::c_char, default_domain: *mut libc::c_char, flags: gio_sys::GAskPasswordFlags, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &MountOperation::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(message), &GString::from_glib_borrow(default_user), &GString::from_glib_borrow(default_domain), from_glib(flags), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"ask-password\0".as_ptr() as *const _, Some(transmute(ask_password_trampoline:: as usize)), Box_::into_raw(f), ) } } //fn connect_ask_question(&self, f: F) -> SignalHandlerId { // Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 } //} fn connect_reply(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn reply_trampoline( this: *mut gio_sys::GMountOperation, result: gio_sys::GMountOperationResult, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &MountOperation::from_glib_borrow(this).unsafe_cast(), from_glib(result), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"reply\0".as_ptr() as *const _, Some(transmute(reply_trampoline:: as usize)), Box_::into_raw(f), ) } } //fn connect_show_processes(&self, f: F) -> SignalHandlerId { // Empty ctype processes: *.Array TypeId { ns_id: 2, id: 3 } // Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 } //} fn connect_show_unmount_progress( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn show_unmount_progress_trampoline< P, F: Fn(&P, &str, i64, i64) + 'static, >( this: *mut gio_sys::GMountOperation, message: *mut libc::c_char, time_left: i64, bytes_left: i64, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &MountOperation::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(message), time_left, bytes_left, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"show-unmount-progress\0".as_ptr() as *const _, Some(transmute( show_unmount_progress_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_anonymous_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_anonymous_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::anonymous\0".as_ptr() as *const _, Some(transmute(notify_anonymous_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_choice_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_choice_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::choice\0".as_ptr() as *const _, Some(transmute(notify_choice_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_domain_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_domain_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::domain\0".as_ptr() as *const _, Some(transmute(notify_domain_trampoline:: as usize)), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_is_tcrypt_hidden_volume_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_tcrypt_hidden_volume_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-tcrypt-hidden-volume\0".as_ptr() as *const _, Some(transmute( notify_is_tcrypt_hidden_volume_trampoline:: as usize, )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_is_tcrypt_system_volume_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_tcrypt_system_volume_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-tcrypt-system-volume\0".as_ptr() as *const _, Some(transmute( notify_is_tcrypt_system_volume_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_password_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_password_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::password\0".as_ptr() as *const _, Some(transmute(notify_password_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_password_save_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_password_save_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::password-save\0".as_ptr() as *const _, Some(transmute( notify_password_save_trampoline:: as usize, )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] fn connect_property_pim_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_pim_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::pim\0".as_ptr() as *const _, Some(transmute(notify_pim_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_username_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_username_trampoline( this: *mut gio_sys::GMountOperation, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&MountOperation::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::username\0".as_ptr() as *const _, Some(transmute(notify_username_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for MountOperation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MountOperation") } } gio-0.7.0/src/auto/network_address.rs010064400007650000024000000057241350341657000160320ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::fmt; use std::ptr; use Error; use SocketConnectable; glib_wrapper! { pub struct NetworkAddress(Object) @implements SocketConnectable; match fn { get_type => || gio_sys::g_network_address_get_type(), } } impl NetworkAddress { pub fn new(hostname: &str, port: u16) -> NetworkAddress { unsafe { from_glib_full(gio_sys::g_network_address_new( hostname.to_glib_none().0, port, )) } } #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn new_loopback(port: u16) -> NetworkAddress { unsafe { from_glib_full(gio_sys::g_network_address_new_loopback(port)) } } pub fn parse(host_and_port: &str, default_port: u16) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_network_address_parse( host_and_port.to_glib_none().0, default_port, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn parse_uri(uri: &str, default_port: u16) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_network_address_parse_uri( uri.to_glib_none().0, default_port, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl Send for NetworkAddress {} unsafe impl Sync for NetworkAddress {} pub const NONE_NETWORK_ADDRESS: Option<&NetworkAddress> = None; pub trait NetworkAddressExt: 'static { fn get_hostname(&self) -> Option; fn get_port(&self) -> u16; fn get_scheme(&self) -> Option; } impl> NetworkAddressExt for O { fn get_hostname(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_address_get_hostname( self.as_ref().to_glib_none().0, )) } } fn get_port(&self) -> u16 { unsafe { gio_sys::g_network_address_get_port(self.as_ref().to_glib_none().0) } } fn get_scheme(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_address_get_scheme( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for NetworkAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "NetworkAddress") } } gio-0.7.0/src/auto/network_monitor.rs010064400007650000024000000233721350341657000160730ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; #[cfg(any(feature = "v2_44", feature = "dox"))] use NetworkConnectivity; use SocketConnectable; glib_wrapper! { pub struct NetworkMonitor(Interface); match fn { get_type => || gio_sys::g_network_monitor_get_type(), } } impl NetworkMonitor { pub fn get_default() -> Option { unsafe { from_glib_none(gio_sys::g_network_monitor_get_default()) } } } pub const NONE_NETWORK_MONITOR: Option<&NetworkMonitor> = None; pub trait NetworkMonitorExt: 'static { fn can_reach, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result<(), Error>; fn can_reach_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn can_reach_async_future + Clone + 'static>( &self, connectable: &P, ) -> Box_> + std::marker::Unpin>; #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_connectivity(&self) -> NetworkConnectivity; fn get_network_available(&self) -> bool; #[cfg(any(feature = "v2_46", feature = "dox"))] fn get_network_metered(&self) -> bool; fn connect_network_changed(&self, f: F) -> SignalHandlerId; #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_property_connectivity_notify(&self, f: F) -> SignalHandlerId; fn connect_property_network_available_notify( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_property_network_metered_notify( &self, f: F, ) -> SignalHandlerId; } impl> NetworkMonitorExt for O { fn can_reach, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_network_monitor_can_reach( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn can_reach_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn can_reach_async_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_network_monitor_can_reach_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = can_reach_async_trampoline::; unsafe { gio_sys::g_network_monitor_can_reach_async( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn can_reach_async_future + Clone + 'static>( &self, connectable: &P, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let connectable = connectable.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.can_reach_async(&connectable, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } #[cfg(any(feature = "v2_44", feature = "dox"))] fn get_connectivity(&self) -> NetworkConnectivity { unsafe { from_glib(gio_sys::g_network_monitor_get_connectivity( self.as_ref().to_glib_none().0, )) } } fn get_network_available(&self) -> bool { unsafe { from_glib(gio_sys::g_network_monitor_get_network_available( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn get_network_metered(&self) -> bool { unsafe { from_glib(gio_sys::g_network_monitor_get_network_metered( self.as_ref().to_glib_none().0, )) } } fn connect_network_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn network_changed_trampoline( this: *mut gio_sys::GNetworkMonitor, network_available: glib_sys::gboolean, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &NetworkMonitor::from_glib_borrow(this).unsafe_cast(), from_glib(network_available), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"network-changed\0".as_ptr() as *const _, Some(transmute(network_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn connect_property_connectivity_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_connectivity_trampoline( this: *mut gio_sys::GNetworkMonitor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&NetworkMonitor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::connectivity\0".as_ptr() as *const _, Some(transmute( notify_connectivity_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_network_available_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_network_available_trampoline( this: *mut gio_sys::GNetworkMonitor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&NetworkMonitor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::network-available\0".as_ptr() as *const _, Some(transmute( notify_network_available_trampoline:: as usize, )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_property_network_metered_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_network_metered_trampoline( this: *mut gio_sys::GNetworkMonitor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&NetworkMonitor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::network-metered\0".as_ptr() as *const _, Some(transmute( notify_network_metered_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for NetworkMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "NetworkMonitor") } } gio-0.7.0/src/auto/network_service.rs010064400007650000024000000066771350341657000160550ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use SocketConnectable; glib_wrapper! { pub struct NetworkService(Object) @implements SocketConnectable; match fn { get_type => || gio_sys::g_network_service_get_type(), } } impl NetworkService { pub fn new(service: &str, protocol: &str, domain: &str) -> NetworkService { unsafe { from_glib_full(gio_sys::g_network_service_new( service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, )) } } } pub const NONE_NETWORK_SERVICE: Option<&NetworkService> = None; pub trait NetworkServiceExt: 'static { fn get_domain(&self) -> Option; fn get_protocol(&self) -> Option; fn get_scheme(&self) -> Option; fn get_service(&self) -> Option; fn set_scheme(&self, scheme: &str); fn connect_property_scheme_notify(&self, f: F) -> SignalHandlerId; } impl> NetworkServiceExt for O { fn get_domain(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_service_get_domain( self.as_ref().to_glib_none().0, )) } } fn get_protocol(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_service_get_protocol( self.as_ref().to_glib_none().0, )) } } fn get_scheme(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_service_get_scheme( self.as_ref().to_glib_none().0, )) } } fn get_service(&self) -> Option { unsafe { from_glib_none(gio_sys::g_network_service_get_service( self.as_ref().to_glib_none().0, )) } } fn set_scheme(&self, scheme: &str) { unsafe { gio_sys::g_network_service_set_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, ); } } fn connect_property_scheme_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_scheme_trampoline( this: *mut gio_sys::GNetworkService, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&NetworkService::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::scheme\0".as_ptr() as *const _, Some(transmute(notify_scheme_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for NetworkService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "NetworkService") } } gio-0.7.0/src/auto/notification.rs010064400007650000024000000063701350341657000153200ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use std::fmt; use Icon; use NotificationPriority; glib_wrapper! { pub struct Notification(Object); match fn { get_type => || gio_sys::g_notification_get_type(), } } impl Notification { pub fn new(title: &str) -> Notification { unsafe { from_glib_full(gio_sys::g_notification_new(title.to_glib_none().0)) } } pub fn add_button(&self, label: &str, detailed_action: &str) { unsafe { gio_sys::g_notification_add_button( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } //pub fn add_button_with_target(&self, label: &str, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_notification_add_button_with_target() } //} pub fn add_button_with_target_value( &self, label: &str, action: &str, target: Option<&glib::Variant>, ) { unsafe { gio_sys::g_notification_add_button_with_target_value( self.to_glib_none().0, label.to_glib_none().0, action.to_glib_none().0, target.to_glib_none().0, ); } } pub fn set_body(&self, body: Option<&str>) { unsafe { gio_sys::g_notification_set_body(self.to_glib_none().0, body.to_glib_none().0); } } pub fn set_default_action(&self, detailed_action: &str) { unsafe { gio_sys::g_notification_set_default_action( self.to_glib_none().0, detailed_action.to_glib_none().0, ); } } //pub fn set_default_action_and_target(&self, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_notification_set_default_action_and_target() } //} pub fn set_default_action_and_target_value( &self, action: &str, target: Option<&glib::Variant>, ) { unsafe { gio_sys::g_notification_set_default_action_and_target_value( self.to_glib_none().0, action.to_glib_none().0, target.to_glib_none().0, ); } } pub fn set_icon>(&self, icon: &P) { unsafe { gio_sys::g_notification_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } pub fn set_priority(&self, priority: NotificationPriority) { unsafe { gio_sys::g_notification_set_priority(self.to_glib_none().0, priority.to_glib()); } } pub fn set_title(&self, title: &str) { unsafe { gio_sys::g_notification_set_title(self.to_glib_none().0, title.to_glib_none().0); } } } impl fmt::Display for Notification { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Notification") } } gio-0.7.0/src/auto/output_stream.rs010064400007650000024000000412531350341657000155440ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use InputStream; use OutputStreamSpliceFlags; glib_wrapper! { pub struct OutputStream(Object); match fn { get_type => || gio_sys::g_output_stream_get_type(), } } pub const NONE_OUTPUT_STREAM: Option<&OutputStream> = None; pub trait OutputStreamExt: 'static { fn clear_pending(&self); fn close>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn flush>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn flush_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn flush_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn has_pending(&self) -> bool; fn is_closed(&self) -> bool; fn is_closing(&self) -> bool; //fn printf>(&self, cancellable: Option<&P>, error: &mut Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option; fn set_pending(&self) -> Result<(), Error>; fn splice, Q: IsA>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result; fn splice_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn splice_async_future + Clone + 'static>( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; //fn vprintf>(&self, cancellable: Option<&P>, error: &mut Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option; fn write>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result; fn write_bytes>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result; fn write_bytes_async, Q: FnOnce(Result) + Send + 'static>( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn write_bytes_async_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; } impl> OutputStreamExt for O { fn clear_pending(&self) { unsafe { gio_sys::g_output_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = close_async_trampoline::; unsafe { gio_sys::g_output_stream_close_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn close_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.close_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn flush>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_flush( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn flush_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn flush_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_flush_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = flush_async_trampoline::; unsafe { gio_sys::g_output_stream_flush_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn flush_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.flush_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn has_pending(&self) -> bool { unsafe { from_glib(gio_sys::g_output_stream_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(gio_sys::g_output_stream_is_closed( self.as_ref().to_glib_none().0, )) } } fn is_closing(&self) -> bool { unsafe { from_glib(gio_sys::g_output_stream_is_closing( self.as_ref().to_glib_none().0, )) } } //fn printf>(&self, cancellable: Option<&P>, error: &mut Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option { // unsafe { TODO: call gio_sys:g_output_stream_printf() } //} fn set_pending(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn splice, Q: IsA>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_splice( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn splice_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn splice_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_splice_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = splice_async_trampoline::; unsafe { gio_sys::g_output_stream_splice_async( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, flags.to_glib(), io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn splice_async_future + Clone + 'static>( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let source = source.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.splice_async( &source, flags, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } //fn vprintf>(&self, cancellable: Option<&P>, error: &mut Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option { // unsafe { TODO: call gio_sys:g_output_stream_vprintf() } //} fn write>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result { let count = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_write( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn write_bytes>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_write_bytes( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn write_bytes_async, Q: FnOnce(Result) + Send + 'static>( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn write_bytes_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_write_bytes_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = write_bytes_async_trampoline::; unsafe { gio_sys::g_output_stream_write_bytes_async( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn write_bytes_async_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let bytes = bytes.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.write_bytes_async(&bytes, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for OutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "OutputStream") } } gio-0.7.0/src/auto/permission.rs010064400007650000024000000240311350341657000150140ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; glib_wrapper! { pub struct Permission(Object); match fn { get_type => || gio_sys::g_permission_get_type(), } } pub const NONE_PERMISSION: Option<&Permission> = None; pub trait PermissionExt: 'static { fn acquire>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn acquire_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn acquire_async_future( &self, ) -> Box_> + std::marker::Unpin>; fn get_allowed(&self) -> bool; fn get_can_acquire(&self) -> bool; fn get_can_release(&self) -> bool; fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool); fn release>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn release_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn release_async_future( &self, ) -> Box_> + std::marker::Unpin>; fn connect_property_allowed_notify(&self, f: F) -> SignalHandlerId; fn connect_property_can_acquire_notify(&self, f: F) -> SignalHandlerId; fn connect_property_can_release_notify(&self, f: F) -> SignalHandlerId; } impl> PermissionExt for O { fn acquire>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_permission_acquire( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn acquire_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn acquire_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_permission_acquire_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = acquire_async_trampoline::; unsafe { gio_sys::g_permission_acquire_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn acquire_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.acquire_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn get_allowed(&self) -> bool { unsafe { from_glib(gio_sys::g_permission_get_allowed( self.as_ref().to_glib_none().0, )) } } fn get_can_acquire(&self) -> bool { unsafe { from_glib(gio_sys::g_permission_get_can_acquire( self.as_ref().to_glib_none().0, )) } } fn get_can_release(&self) -> bool { unsafe { from_glib(gio_sys::g_permission_get_can_release( self.as_ref().to_glib_none().0, )) } } fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool) { unsafe { gio_sys::g_permission_impl_update( self.as_ref().to_glib_none().0, allowed.to_glib(), can_acquire.to_glib(), can_release.to_glib(), ); } } fn release>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_permission_release( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn release_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn release_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_permission_release_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = release_async_trampoline::; unsafe { gio_sys::g_permission_release_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn release_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.release_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn connect_property_allowed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_allowed_trampoline( this: *mut gio_sys::GPermission, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Permission::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::allowed\0".as_ptr() as *const _, Some(transmute(notify_allowed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_can_acquire_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_can_acquire_trampoline( this: *mut gio_sys::GPermission, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Permission::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::can-acquire\0".as_ptr() as *const _, Some(transmute(notify_can_acquire_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_can_release_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_can_release_trampoline( this: *mut gio_sys::GPermission, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Permission::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::can-release\0".as_ptr() as *const _, Some(transmute(notify_can_release_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Permission { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Permission") } } gio-0.7.0/src/auto/pollable_input_stream.rs010064400007650000024000000023351350341657000172130ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use InputStream; glib_wrapper! { pub struct PollableInputStream(Interface) @requires InputStream; match fn { get_type => || gio_sys::g_pollable_input_stream_get_type(), } } pub const NONE_POLLABLE_INPUT_STREAM: Option<&PollableInputStream> = None; pub trait PollableInputStreamExt: 'static { fn can_poll(&self) -> bool; fn is_readable(&self) -> bool; } impl> PollableInputStreamExt for O { fn can_poll(&self) -> bool { unsafe { from_glib(gio_sys::g_pollable_input_stream_can_poll( self.as_ref().to_glib_none().0, )) } } fn is_readable(&self) -> bool { unsafe { from_glib(gio_sys::g_pollable_input_stream_is_readable( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for PollableInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PollableInputStream") } } gio-0.7.0/src/auto/pollable_output_stream.rs010064400007650000024000000041521350341657000174130ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; use Cancellable; use Error; use OutputStream; glib_wrapper! { pub struct PollableOutputStream(Interface) @requires OutputStream; match fn { get_type => || gio_sys::g_pollable_output_stream_get_type(), } } pub const NONE_POLLABLE_OUTPUT_STREAM: Option<&PollableOutputStream> = None; pub trait PollableOutputStreamExt: 'static { fn can_poll(&self) -> bool; fn is_writable(&self) -> bool; fn write_nonblocking>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result; } impl> PollableOutputStreamExt for O { fn can_poll(&self) -> bool { unsafe { from_glib(gio_sys::g_pollable_output_stream_can_poll( self.as_ref().to_glib_none().0, )) } } fn is_writable(&self) -> bool { unsafe { from_glib(gio_sys::g_pollable_output_stream_is_writable( self.as_ref().to_glib_none().0, )) } } fn write_nonblocking>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result { let count = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_pollable_output_stream_write_nonblocking( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } } impl fmt::Display for PollableOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PollableOutputStream") } } gio-0.7.0/src/auto/property_action.rs010064400007650000024000000116211350341657000160460ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; #[cfg(any(feature = "v2_46", feature = "dox"))] use glib::StaticType; #[cfg(any(feature = "v2_46", feature = "dox"))] use glib::Value; use glib_sys; #[cfg(any(feature = "v2_46", feature = "dox"))] use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Action; glib_wrapper! { pub struct PropertyAction(Object) @implements Action; match fn { get_type => || gio_sys::g_property_action_get_type(), } } impl PropertyAction { pub fn new>( name: &str, object: &P, property_name: &str, ) -> PropertyAction { unsafe { from_glib_full(gio_sys::g_property_action_new( name.to_glib_none().0, object.as_ref().to_glib_none().0, property_name.to_glib_none().0, )) } } #[cfg(any(feature = "v2_46", feature = "dox"))] pub fn get_property_invert_boolean(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.as_ptr() as *mut gobject_sys::GObject, b"invert-boolean\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } pub fn connect_property_enabled_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline( this: *mut gio_sys::GPropertyAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enabled\0".as_ptr() as *const _, Some(transmute(notify_enabled_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_property_parameter_type_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_parameter_type_trampoline( this: *mut gio_sys::GPropertyAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::parameter-type\0".as_ptr() as *const _, Some(transmute(notify_parameter_type_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_property_state_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline( this: *mut gio_sys::GPropertyAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _, Some(transmute(notify_state_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_property_state_type_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline( this: *mut gio_sys::GPropertyAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state-type\0".as_ptr() as *const _, Some(transmute(notify_state_type_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for PropertyAction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "PropertyAction") } } gio-0.7.0/src/auto/proxy.rs010064400007650000024000000122621350341657000140100ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use IOStream; use ProxyAddress; glib_wrapper! { pub struct Proxy(Interface); match fn { get_type => || gio_sys::g_proxy_get_type(), } } impl Proxy { pub fn get_default_for_protocol(protocol: &str) -> Option { unsafe { from_glib_full(gio_sys::g_proxy_get_default_for_protocol( protocol.to_glib_none().0, )) } } } pub const NONE_PROXY: Option<&Proxy> = None; pub trait ProxyExt: 'static { fn connect, Q: IsA, R: IsA>( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, ) -> Result; fn connect_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, callback: S, ); #[cfg(feature = "futures")] fn connect_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, connection: &P, proxy_address: &Q, ) -> Box_> + std::marker::Unpin>; fn supports_hostname(&self) -> bool; } impl> ProxyExt for O { fn connect, Q: IsA, R: IsA>( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_proxy_connect( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, proxy_address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn connect_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, callback: S, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_async_trampoline< S: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_proxy_connect_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_async_trampoline::; unsafe { gio_sys::g_proxy_connect_async( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, proxy_address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, connection: &P, proxy_address: &Q, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let connection = connection.clone(); let proxy_address = proxy_address.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_async( &connection, &proxy_address, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn supports_hostname(&self) -> bool { unsafe { from_glib(gio_sys::g_proxy_supports_hostname( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for Proxy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Proxy") } } gio-0.7.0/src/auto/proxy_address.rs010064400007650000024000000065711350341657000155230ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::fmt; use InetAddress; use InetSocketAddress; use SocketAddress; use SocketConnectable; glib_wrapper! { pub struct ProxyAddress(Object) @extends InetSocketAddress, SocketAddress, @implements SocketConnectable; match fn { get_type => || gio_sys::g_proxy_address_get_type(), } } impl ProxyAddress { pub fn new>( inetaddr: &P, port: u16, protocol: &str, dest_hostname: &str, dest_port: u16, username: Option<&str>, password: Option<&str>, ) -> ProxyAddress { unsafe { SocketAddress::from_glib_full(gio_sys::g_proxy_address_new( inetaddr.as_ref().to_glib_none().0, port, protocol.to_glib_none().0, dest_hostname.to_glib_none().0, dest_port, username.to_glib_none().0, password.to_glib_none().0, )) .unsafe_cast() } } } unsafe impl Send for ProxyAddress {} unsafe impl Sync for ProxyAddress {} pub const NONE_PROXY_ADDRESS: Option<&ProxyAddress> = None; pub trait ProxyAddressExt: 'static { fn get_destination_hostname(&self) -> GString; fn get_destination_port(&self) -> u16; fn get_destination_protocol(&self) -> Option; fn get_password(&self) -> Option; fn get_protocol(&self) -> GString; fn get_uri(&self) -> Option; fn get_username(&self) -> Option; } impl> ProxyAddressExt for O { fn get_destination_hostname(&self) -> GString { unsafe { from_glib_none(gio_sys::g_proxy_address_get_destination_hostname( self.as_ref().to_glib_none().0, )) } } fn get_destination_port(&self) -> u16 { unsafe { gio_sys::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) } } fn get_destination_protocol(&self) -> Option { unsafe { from_glib_none(gio_sys::g_proxy_address_get_destination_protocol( self.as_ref().to_glib_none().0, )) } } fn get_password(&self) -> Option { unsafe { from_glib_none(gio_sys::g_proxy_address_get_password( self.as_ref().to_glib_none().0, )) } } fn get_protocol(&self) -> GString { unsafe { from_glib_none(gio_sys::g_proxy_address_get_protocol( self.as_ref().to_glib_none().0, )) } } fn get_uri(&self) -> Option { unsafe { from_glib_none(gio_sys::g_proxy_address_get_uri( self.as_ref().to_glib_none().0, )) } } fn get_username(&self) -> Option { unsafe { from_glib_none(gio_sys::g_proxy_address_get_username( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ProxyAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ProxyAddress") } } gio-0.7.0/src/auto/proxy_resolver.rs010064400007650000024000000105451350341657000157330ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; glib_wrapper! { pub struct ProxyResolver(Interface); match fn { get_type => || gio_sys::g_proxy_resolver_get_type(), } } impl ProxyResolver { pub fn get_default() -> Option { unsafe { from_glib_none(gio_sys::g_proxy_resolver_get_default()) } } } pub const NONE_PROXY_RESOLVER: Option<&ProxyResolver> = None; pub trait ProxyResolverExt: 'static { fn is_supported(&self) -> bool; fn lookup>( &self, uri: &str, cancellable: Option<&P>, ) -> Result, Error>; fn lookup_async, Q: FnOnce(Result, Error>) + Send + 'static>( &self, uri: &str, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn lookup_async_future( &self, uri: &str, ) -> Box_, Error>> + std::marker::Unpin>; } impl> ProxyResolverExt for O { fn is_supported(&self) -> bool { unsafe { from_glib(gio_sys::g_proxy_resolver_is_supported( self.as_ref().to_glib_none().0, )) } } fn lookup>( &self, uri: &str, cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_proxy_resolver_lookup( self.as_ref().to_glib_none().0, uri.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, uri: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_async_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_proxy_resolver_lookup_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_async_trampoline::; unsafe { gio_sys::g_proxy_resolver_lookup_async( self.as_ref().to_glib_none().0, uri.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_async_future( &self, uri: &str, ) -> Box_, Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let uri = String::from(uri); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_async(&uri, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for ProxyResolver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ProxyResolver") } } gio-0.7.0/src/auto/remote_action_group.rs010064400007650000024000000037161350341657000166770ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use std::fmt; use ActionGroup; glib_wrapper! { pub struct RemoteActionGroup(Interface) @requires ActionGroup; match fn { get_type => || gio_sys::g_remote_action_group_get_type(), } } pub const NONE_REMOTE_ACTION_GROUP: Option<&RemoteActionGroup> = None; pub trait RemoteActionGroupExt: 'static { fn activate_action_full( &self, action_name: &str, parameter: Option<&glib::Variant>, platform_data: &glib::Variant, ); fn change_action_state_full( &self, action_name: &str, value: &glib::Variant, platform_data: &glib::Variant, ); } impl> RemoteActionGroupExt for O { fn activate_action_full( &self, action_name: &str, parameter: Option<&glib::Variant>, platform_data: &glib::Variant, ) { unsafe { gio_sys::g_remote_action_group_activate_action_full( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, parameter.to_glib_none().0, platform_data.to_glib_none().0, ); } } fn change_action_state_full( &self, action_name: &str, value: &glib::Variant, platform_data: &glib::Variant, ) { unsafe { gio_sys::g_remote_action_group_change_action_state_full( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, value.to_glib_none().0, platform_data.to_glib_none().0, ); } } } impl fmt::Display for RemoteActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "RemoteActionGroup") } } gio-0.7.0/src/auto/resolver.rs010064400007650000024000000414201350341657000144660ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use InetAddress; use ResolverRecordType; use SrvTarget; glib_wrapper! { pub struct Resolver(Object); match fn { get_type => || gio_sys::g_resolver_get_type(), } } impl Resolver { //pub fn free_addresses(addresses: /*Unimplemented*/&[&Fundamental: Pointer]) { // unsafe { TODO: call gio_sys:g_resolver_free_addresses() } //} //pub fn free_targets(targets: /*Unimplemented*/&[&Fundamental: Pointer]) { // unsafe { TODO: call gio_sys:g_resolver_free_targets() } //} pub fn get_default() -> Option { unsafe { from_glib_full(gio_sys::g_resolver_get_default()) } } } pub const NONE_RESOLVER: Option<&Resolver> = None; pub trait ResolverExt: 'static { fn lookup_by_address, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result; fn lookup_by_address_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn lookup_by_address_async_future + Clone + 'static>( &self, address: &P, ) -> Box_> + std::marker::Unpin>; fn lookup_by_name>( &self, hostname: &str, cancellable: Option<&P>, ) -> Result, Error>; fn lookup_by_name_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, hostname: &str, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn lookup_by_name_async_future( &self, hostname: &str, ) -> Box_, Error>> + std::marker::Unpin>; fn lookup_records>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, ) -> Result, Error>; fn lookup_records_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn lookup_records_async_future( &self, rrname: &str, record_type: ResolverRecordType, ) -> Box_, Error>> + std::marker::Unpin>; fn lookup_service>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, ) -> Result, Error>; fn lookup_service_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn lookup_service_async_future( &self, service: &str, protocol: &str, domain: &str, ) -> Box_, Error>> + std::marker::Unpin>; fn set_default(&self); fn connect_reload(&self, f: F) -> SignalHandlerId; } impl> ResolverExt for O { fn lookup_by_address, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_by_address( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_by_address_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_by_address_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_by_address_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_by_address_async_trampoline::; unsafe { gio_sys::g_resolver_lookup_by_address_async( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_by_address_async_future + Clone + 'static>( &self, address: &P, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let address = address.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_by_address_async(&address, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn lookup_by_name>( &self, hostname: &str, cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_by_name( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_by_name_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, hostname: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_by_name_async_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_by_name_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_by_name_async_trampoline::; unsafe { gio_sys::g_resolver_lookup_by_name_async( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_by_name_async_future( &self, hostname: &str, ) -> Box_, Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let hostname = String::from(hostname); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_by_name_async(&hostname, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn lookup_records>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_records( self.as_ref().to_glib_none().0, rrname.to_glib_none().0, record_type.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_records_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_records_async_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_records_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_records_async_trampoline::; unsafe { gio_sys::g_resolver_lookup_records_async( self.as_ref().to_glib_none().0, rrname.to_glib_none().0, record_type.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_records_async_future( &self, rrname: &str, record_type: ResolverRecordType, ) -> Box_, Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let rrname = String::from(rrname); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_records_async(&rrname, record_type, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn lookup_service>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_service( self.as_ref().to_glib_none().0, service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_service_async< P: IsA, Q: FnOnce(Result, Error>) + Send + 'static, >( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_service_async_trampoline< Q: FnOnce(Result, Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_resolver_lookup_service_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_service_async_trampoline::; unsafe { gio_sys::g_resolver_lookup_service_async( self.as_ref().to_glib_none().0, service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_service_async_future( &self, service: &str, protocol: &str, domain: &str, ) -> Box_, Error>> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let service = String::from(service); let protocol = String::from(protocol); let domain = String::from(domain); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_service_async( &service, &protocol, &domain, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn set_default(&self) { unsafe { gio_sys::g_resolver_set_default(self.as_ref().to_glib_none().0); } } fn connect_reload(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn reload_trampoline( this: *mut gio_sys::GResolver, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Resolver::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"reload\0".as_ptr() as *const _, Some(transmute(reload_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Resolver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Resolver") } } gio-0.7.0/src/auto/resource.rs010064400007650000024000000067471350341657000144710ustar0000000000000000// 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 gio_sys; use glib; use glib::translate::*; use glib::GString; use std; use std::mem; use std::ptr; use Error; use InputStream; use ResourceLookupFlags; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Resource(Shared); match fn { ref => |ptr| gio_sys::g_resource_ref(ptr), unref => |ptr| gio_sys::g_resource_unref(ptr), get_type => || gio_sys::g_resource_get_type(), } } impl Resource { pub fn enumerate_children( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resource_enumerate_children( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn get_info( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result<(usize, u32), Error> { unsafe { let mut size = mem::uninitialized(); let mut flags = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_resource_get_info( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.to_glib(), &mut size, &mut flags, &mut error, ); if error.is_null() { Ok((size, flags)) } else { Err(from_glib_full(error)) } } } pub fn lookup_data( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resource_lookup_data( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn open_stream( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resource_open_stream( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn load>(filename: P) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_resource_load(filename.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } gio-0.7.0/src/auto/seekable.rs010064400007650000024000000052441350341657000144040ustar0000000000000000// 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 gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; use Cancellable; use Error; glib_wrapper! { pub struct Seekable(Interface); match fn { get_type => || gio_sys::g_seekable_get_type(), } } pub const NONE_SEEKABLE: Option<&Seekable> = None; pub trait SeekableExt: 'static { fn can_seek(&self) -> bool; fn can_truncate(&self) -> bool; fn seek>( &self, offset: i64, type_: glib::SeekType, cancellable: Option<&P>, ) -> Result<(), Error>; fn tell(&self) -> i64; fn truncate>( &self, offset: i64, cancellable: Option<&P>, ) -> Result<(), Error>; } impl> SeekableExt for O { fn can_seek(&self) -> bool { unsafe { from_glib(gio_sys::g_seekable_can_seek(self.as_ref().to_glib_none().0)) } } fn can_truncate(&self) -> bool { unsafe { from_glib(gio_sys::g_seekable_can_truncate( self.as_ref().to_glib_none().0, )) } } fn seek>( &self, offset: i64, type_: glib::SeekType, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_seekable_seek( self.as_ref().to_glib_none().0, offset, type_.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn tell(&self) -> i64 { unsafe { gio_sys::g_seekable_tell(self.as_ref().to_glib_none().0) } } fn truncate>( &self, offset: i64, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_seekable_truncate( self.as_ref().to_glib_none().0, offset, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl fmt::Display for Seekable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Seekable") } } gio-0.7.0/src/auto/settings.rs010064400007650000024000000555411350341657000144760ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use libc; use signal::Inhibit; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Action; use SettingsBackend; use SettingsBindFlags; use SettingsSchema; glib_wrapper! { pub struct Settings(Object); match fn { get_type => || gio_sys::g_settings_get_type(), } } impl Settings { pub fn new(schema_id: &str) -> Settings { unsafe { from_glib_full(gio_sys::g_settings_new(schema_id.to_glib_none().0)) } } pub fn new_full>( schema: &SettingsSchema, backend: Option<&P>, path: Option<&str>, ) -> Settings { unsafe { from_glib_full(gio_sys::g_settings_new_full( schema.to_glib_none().0, backend.map(|p| p.as_ref()).to_glib_none().0, path.to_glib_none().0, )) } } pub fn new_with_backend>(schema_id: &str, backend: &P) -> Settings { unsafe { from_glib_full(gio_sys::g_settings_new_with_backend( schema_id.to_glib_none().0, backend.as_ref().to_glib_none().0, )) } } pub fn new_with_backend_and_path>( schema_id: &str, backend: &P, path: &str, ) -> Settings { unsafe { from_glib_full(gio_sys::g_settings_new_with_backend_and_path( schema_id.to_glib_none().0, backend.as_ref().to_glib_none().0, path.to_glib_none().0, )) } } pub fn new_with_path(schema_id: &str, path: &str) -> Settings { unsafe { from_glib_full(gio_sys::g_settings_new_with_path( schema_id.to_glib_none().0, path.to_glib_none().0, )) } } pub fn sync() { unsafe { gio_sys::g_settings_sync(); } } pub fn unbind>(object: &P, property: &str) { unsafe { gio_sys::g_settings_unbind(object.as_ref().to_glib_none().0, property.to_glib_none().0); } } } pub const NONE_SETTINGS: Option<&Settings> = None; pub trait SettingsExt: 'static { fn apply(&self); fn bind>( &self, key: &str, object: &P, property: &str, flags: SettingsBindFlags, ); //fn bind_with_mapping, Q: Fn(&glib::Value, &glib::Variant) -> bool + 'static, R: Fn(&glib::Value, &glib::VariantType) -> glib::Variant + 'static>(&self, key: &str, object: &P, property: &str, flags: SettingsBindFlags, get_mapping: Q, set_mapping: R); fn bind_writable>( &self, key: &str, object: &P, property: &str, inverted: bool, ); fn create_action(&self, key: &str) -> Option; fn delay(&self); //fn get(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); fn get_boolean(&self, key: &str) -> bool; fn get_child(&self, name: &str) -> Option; fn get_default_value(&self, key: &str) -> Option; fn get_double(&self, key: &str) -> f64; fn get_enum(&self, key: &str) -> i32; fn get_flags(&self, key: &str) -> u32; fn get_has_unapplied(&self) -> bool; fn get_int(&self, key: &str) -> i32; #[cfg(any(feature = "v2_50", feature = "dox"))] fn get_int64(&self, key: &str) -> i64; //fn get_mapped(&self, key: &str, mapping: /*Unimplemented*/FnMut(&glib::Variant, /*Unimplemented*/Option) -> bool, user_data: /*Unimplemented*/Option) -> /*Unimplemented*/Option; fn get_string(&self, key: &str) -> Option; fn get_strv(&self, key: &str) -> Vec; fn get_uint(&self, key: &str) -> u32; #[cfg(any(feature = "v2_50", feature = "dox"))] fn get_uint64(&self, key: &str) -> u64; fn get_user_value(&self, key: &str) -> Option; fn get_value(&self, key: &str) -> Option; fn is_writable(&self, name: &str) -> bool; fn list_children(&self) -> Vec; fn list_keys(&self) -> Vec; fn reset(&self, key: &str); fn revert(&self); //fn set(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; fn set_boolean(&self, key: &str, value: bool) -> bool; fn set_double(&self, key: &str, value: f64) -> bool; fn set_enum(&self, key: &str, value: i32) -> bool; fn set_flags(&self, key: &str, value: u32) -> bool; fn set_int(&self, key: &str, value: i32) -> bool; #[cfg(any(feature = "v2_50", feature = "dox"))] fn set_int64(&self, key: &str, value: i64) -> bool; fn set_string(&self, key: &str, value: &str) -> bool; fn set_strv(&self, key: &str, value: &[&str]) -> bool; fn set_uint(&self, key: &str, value: u32) -> bool; #[cfg(any(feature = "v2_50", feature = "dox"))] fn set_uint64(&self, key: &str, value: u64) -> bool; fn set_value(&self, key: &str, value: &glib::Variant) -> bool; fn get_property_backend(&self) -> Option; fn get_property_delay_apply(&self) -> bool; fn get_property_path(&self) -> Option; fn get_property_schema_id(&self) -> Option; fn get_property_settings_schema(&self) -> Option; //fn connect_change_event(&self, f: F) -> SignalHandlerId; fn connect_changed(&self, f: F) -> SignalHandlerId; fn connect_writable_change_event Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId; fn connect_writable_changed(&self, f: F) -> SignalHandlerId; fn connect_property_delay_apply_notify(&self, f: F) -> SignalHandlerId; fn connect_property_has_unapplied_notify( &self, f: F, ) -> SignalHandlerId; } impl> SettingsExt for O { fn apply(&self) { unsafe { gio_sys::g_settings_apply(self.as_ref().to_glib_none().0); } } fn bind>( &self, key: &str, object: &P, property: &str, flags: SettingsBindFlags, ) { unsafe { gio_sys::g_settings_bind( self.as_ref().to_glib_none().0, key.to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, flags.to_glib(), ); } } //fn bind_with_mapping, Q: Fn(&glib::Value, &glib::Variant) -> bool + 'static, R: Fn(&glib::Value, &glib::VariantType) -> glib::Variant + 'static>(&self, key: &str, object: &P, property: &str, flags: SettingsBindFlags, get_mapping: Q, set_mapping: R) { // unsafe { TODO: call gio_sys:g_settings_bind_with_mapping() } //} fn bind_writable>( &self, key: &str, object: &P, property: &str, inverted: bool, ) { unsafe { gio_sys::g_settings_bind_writable( self.as_ref().to_glib_none().0, key.to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, inverted.to_glib(), ); } } fn create_action(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_create_action( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn delay(&self) { unsafe { gio_sys::g_settings_delay(self.as_ref().to_glib_none().0); } } //fn get(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gio_sys:g_settings_get() } //} fn get_boolean(&self, key: &str) -> bool { unsafe { from_glib(gio_sys::g_settings_get_boolean( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_child(&self, name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_get_child( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn get_default_value(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_get_default_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_double(&self, key: &str) -> f64 { unsafe { gio_sys::g_settings_get_double(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn get_enum(&self, key: &str) -> i32 { unsafe { gio_sys::g_settings_get_enum(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn get_flags(&self, key: &str) -> u32 { unsafe { gio_sys::g_settings_get_flags(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn get_has_unapplied(&self) -> bool { unsafe { from_glib(gio_sys::g_settings_get_has_unapplied( self.as_ref().to_glib_none().0, )) } } fn get_int(&self, key: &str) -> i32 { unsafe { gio_sys::g_settings_get_int(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn get_int64(&self, key: &str) -> i64 { unsafe { gio_sys::g_settings_get_int64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } //fn get_mapped(&self, key: &str, mapping: /*Unimplemented*/FnMut(&glib::Variant, /*Unimplemented*/Option) -> bool, user_data: /*Unimplemented*/Option) -> /*Unimplemented*/Option { // unsafe { TODO: call gio_sys:g_settings_get_mapped() } //} fn get_string(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_get_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_strv(&self, key: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_settings_get_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_uint(&self, key: &str) -> u32 { unsafe { gio_sys::g_settings_get_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn get_uint64(&self, key: &str) -> u64 { unsafe { gio_sys::g_settings_get_uint64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn get_user_value(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_get_user_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn get_value(&self, key: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_get_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn is_writable(&self, name: &str) -> bool { unsafe { from_glib(gio_sys::g_settings_is_writable( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn list_children(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_settings_list_children( self.as_ref().to_glib_none().0, )) } } fn list_keys(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_settings_list_keys( self.as_ref().to_glib_none().0, )) } } fn reset(&self, key: &str) { unsafe { gio_sys::g_settings_reset(self.as_ref().to_glib_none().0, key.to_glib_none().0); } } fn revert(&self) { unsafe { gio_sys::g_settings_revert(self.as_ref().to_glib_none().0); } } //fn set(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gio_sys:g_settings_set() } //} fn set_boolean(&self, key: &str, value: bool) -> bool { unsafe { from_glib(gio_sys::g_settings_set_boolean( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib(), )) } } fn set_double(&self, key: &str, value: f64) -> bool { unsafe { from_glib(gio_sys::g_settings_set_double( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } fn set_enum(&self, key: &str, value: i32) -> bool { unsafe { from_glib(gio_sys::g_settings_set_enum( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } fn set_flags(&self, key: &str, value: u32) -> bool { unsafe { from_glib(gio_sys::g_settings_set_flags( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } fn set_int(&self, key: &str, value: i32) -> bool { unsafe { from_glib(gio_sys::g_settings_set_int( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn set_int64(&self, key: &str, value: i64) -> bool { unsafe { from_glib(gio_sys::g_settings_set_int64( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } fn set_string(&self, key: &str, value: &str) -> bool { unsafe { from_glib(gio_sys::g_settings_set_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0, )) } } fn set_strv(&self, key: &str, value: &[&str]) -> bool { unsafe { from_glib(gio_sys::g_settings_set_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0, )) } } fn set_uint(&self, key: &str, value: u32) -> bool { unsafe { from_glib(gio_sys::g_settings_set_uint( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn set_uint64(&self, key: &str, value: u64) -> bool { unsafe { from_glib(gio_sys::g_settings_set_uint64( self.as_ref().to_glib_none().0, key.to_glib_none().0, value, )) } } fn set_value(&self, key: &str, value: &glib::Variant) -> bool { unsafe { from_glib(gio_sys::g_settings_set_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0, )) } } fn get_property_backend(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"backend\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn get_property_delay_apply(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"delay-apply\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn get_property_path(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"path\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn get_property_schema_id(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"schema-id\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn get_property_settings_schema(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"settings-schema\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } //fn connect_change_event(&self, f: F) -> SignalHandlerId { // Unimplemented keys: *.CArray TypeId { ns_id: 2, id: 4 } //} fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut gio_sys::GSettings, key: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &Settings::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(key), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_writable_change_event Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn writable_change_event_trampoline< P, F: Fn(&P, u32) -> Inhibit + 'static, >( this: *mut gio_sys::GSettings, key: libc::c_uint, f: glib_sys::gpointer, ) -> glib_sys::gboolean where P: IsA, { let f: &F = &*(f as *const F); f(&Settings::from_glib_borrow(this).unsafe_cast(), key).to_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"writable-change-event\0".as_ptr() as *const _, Some(transmute( writable_change_event_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_writable_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn writable_changed_trampoline( this: *mut gio_sys::GSettings, key: *mut libc::c_char, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &Settings::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(key), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"writable-changed\0".as_ptr() as *const _, Some(transmute(writable_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_delay_apply_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_delay_apply_trampoline( this: *mut gio_sys::GSettings, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Settings::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::delay-apply\0".as_ptr() as *const _, Some(transmute(notify_delay_apply_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_has_unapplied_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_has_unapplied_trampoline( this: *mut gio_sys::GSettings, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Settings::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::has-unapplied\0".as_ptr() as *const _, Some(transmute( notify_has_unapplied_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for Settings { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Settings") } } gio-0.7.0/src/auto/settings_backend.rs010064400007650000024000000055001350341657000161330ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; glib_wrapper! { pub struct SettingsBackend(Object); match fn { get_type => || gio_sys::g_settings_backend_get_type(), } } impl SettingsBackend { //pub fn flatten_tree(tree: /*Ignored*/&glib::Tree) -> (GString, Vec, Vec) { // unsafe { TODO: call gio_sys:g_settings_backend_flatten_tree() } //} pub fn get_default() -> Option { unsafe { from_glib_full(gio_sys::g_settings_backend_get_default()) } } } pub const NONE_SETTINGS_BACKEND: Option<&SettingsBackend> = None; pub trait SettingsBackendExt: 'static { //fn changed(&self, key: &str, origin_tag: /*Unimplemented*/Option); //fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option); //fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option); //fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option); fn path_writable_changed(&self, path: &str); fn writable_changed(&self, key: &str); } impl> SettingsBackendExt for O { //fn changed(&self, key: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_settings_backend_changed() } //} //fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_settings_backend_changed_tree() } //} //fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_settings_backend_keys_changed() } //} //fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call gio_sys:g_settings_backend_path_changed() } //} fn path_writable_changed(&self, path: &str) { unsafe { gio_sys::g_settings_backend_path_writable_changed( self.as_ref().to_glib_none().0, path.to_glib_none().0, ); } } fn writable_changed(&self, key: &str) { unsafe { gio_sys::g_settings_backend_writable_changed( self.as_ref().to_glib_none().0, key.to_glib_none().0, ); } } } impl fmt::Display for SettingsBackend { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SettingsBackend") } } gio-0.7.0/src/auto/settings_schema.rs010064400007650000024000000036101350341657000160040ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::GString; use SettingsSchemaKey; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchema(Shared); match fn { ref => |ptr| gio_sys::g_settings_schema_ref(ptr), unref => |ptr| gio_sys::g_settings_schema_unref(ptr), get_type => || gio_sys::g_settings_schema_get_type(), } } impl SettingsSchema { pub fn get_id(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_get_id(self.to_glib_none().0)) } } pub fn get_key(&self, name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_settings_schema_get_key( self.to_glib_none().0, name.to_glib_none().0, )) } } pub fn get_path(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_get_path(self.to_glib_none().0)) } } pub fn has_key(&self, name: &str) -> bool { unsafe { from_glib(gio_sys::g_settings_schema_has_key( self.to_glib_none().0, name.to_glib_none().0, )) } } #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn list_children(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_settings_schema_list_children( self.to_glib_none().0, )) } } #[cfg(any(feature = "v2_46", feature = "dox"))] pub fn list_keys(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_settings_schema_list_keys( self.to_glib_none().0, )) } } } gio-0.7.0/src/auto/settings_schema_key.rs010064400007650000024000000042331350341657000166560ustar0000000000000000// 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 gio_sys; use glib; use glib::translate::*; use glib::GString; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchemaKey(Shared); match fn { ref => |ptr| gio_sys::g_settings_schema_key_ref(ptr), unref => |ptr| gio_sys::g_settings_schema_key_unref(ptr), get_type => || gio_sys::g_settings_schema_key_get_type(), } } impl SettingsSchemaKey { pub fn get_default_value(&self) -> Option { unsafe { from_glib_full(gio_sys::g_settings_schema_key_get_default_value( self.to_glib_none().0, )) } } pub fn get_description(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_key_get_description( self.to_glib_none().0, )) } } #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn get_name(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_key_get_name( self.to_glib_none().0, )) } } pub fn get_range(&self) -> Option { unsafe { from_glib_full(gio_sys::g_settings_schema_key_get_range( self.to_glib_none().0, )) } } pub fn get_summary(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_key_get_summary( self.to_glib_none().0, )) } } pub fn get_value_type(&self) -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_key_get_value_type( self.to_glib_none().0, )) } } pub fn range_check(&self, value: &glib::Variant) -> bool { unsafe { from_glib(gio_sys::g_settings_schema_key_range_check( self.to_glib_none().0, value.to_glib_none().0, )) } } } gio-0.7.0/src/auto/settings_schema_source.rs010064400007650000024000000045621350341657000173730ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::GString; use std; use std::ptr; use Error; use SettingsSchema; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchemaSource(Shared); match fn { ref => |ptr| gio_sys::g_settings_schema_source_ref(ptr), unref => |ptr| gio_sys::g_settings_schema_source_unref(ptr), get_type => || gio_sys::g_settings_schema_source_get_type(), } } impl SettingsSchemaSource { pub fn new_from_directory>( directory: P, parent: Option<&SettingsSchemaSource>, trusted: bool, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_settings_schema_source_new_from_directory( directory.as_ref().to_glib_none().0, parent.to_glib_none().0, trusted.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn list_schemas(&self, recursive: bool) -> (Vec, Vec) { unsafe { let mut non_relocatable = ptr::null_mut(); let mut relocatable = ptr::null_mut(); gio_sys::g_settings_schema_source_list_schemas( self.to_glib_none().0, recursive.to_glib(), &mut non_relocatable, &mut relocatable, ); ( FromGlibPtrContainer::from_glib_full(non_relocatable), FromGlibPtrContainer::from_glib_full(relocatable), ) } } pub fn lookup(&self, schema_id: &str, recursive: bool) -> Option { unsafe { from_glib_full(gio_sys::g_settings_schema_source_lookup( self.to_glib_none().0, schema_id.to_glib_none().0, recursive.to_glib(), )) } } pub fn get_default() -> Option { unsafe { from_glib_none(gio_sys::g_settings_schema_source_get_default()) } } } gio-0.7.0/src/auto/simple_action.rs010064400007650000024000000126111350341657000154530ustar0000000000000000// 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 gio_sys; use glib; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Action; glib_wrapper! { pub struct SimpleAction(Object) @implements Action; match fn { get_type => || gio_sys::g_simple_action_get_type(), } } impl SimpleAction { pub fn new(name: &str, parameter_type: Option<&glib::VariantTy>) -> SimpleAction { unsafe { from_glib_full(gio_sys::g_simple_action_new( name.to_glib_none().0, parameter_type.to_glib_none().0, )) } } pub fn new_stateful( name: &str, parameter_type: Option<&glib::VariantTy>, state: &glib::Variant, ) -> SimpleAction { unsafe { from_glib_full(gio_sys::g_simple_action_new_stateful( name.to_glib_none().0, parameter_type.to_glib_none().0, state.to_glib_none().0, )) } } pub fn set_enabled(&self, enabled: bool) { unsafe { gio_sys::g_simple_action_set_enabled(self.to_glib_none().0, enabled.to_glib()); } } pub fn set_state(&self, value: &glib::Variant) { unsafe { gio_sys::g_simple_action_set_state(self.to_glib_none().0, value.to_glib_none().0); } } #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn set_state_hint(&self, state_hint: Option<&glib::Variant>) { unsafe { gio_sys::g_simple_action_set_state_hint( self.to_glib_none().0, state_hint.to_glib_none().0, ); } } pub fn connect_activate) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn activate_trampoline< F: Fn(&SimpleAction, Option<&glib::Variant>) + 'static, >( this: *mut gio_sys::GSimpleAction, parameter: *mut glib_sys::GVariant, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), Option::::from_glib_borrow(parameter).as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"activate\0".as_ptr() as *const _, Some(transmute(activate_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_change_state) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn change_state_trampoline< F: Fn(&SimpleAction, Option<&glib::Variant>) + 'static, >( this: *mut gio_sys::GSimpleAction, value: *mut glib_sys::GVariant, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), Option::::from_glib_borrow(value).as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"change-state\0".as_ptr() as *const _, Some(transmute(change_state_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_property_enabled_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline( this: *mut gio_sys::GSimpleAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enabled\0".as_ptr() as *const _, Some(transmute(notify_enabled_trampoline:: as usize)), Box_::into_raw(f), ) } } pub fn connect_property_state_type_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline( this: *mut gio_sys::GSimpleAction, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state-type\0".as_ptr() as *const _, Some(transmute(notify_state_type_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for SimpleAction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SimpleAction") } } gio-0.7.0/src/auto/simple_action_group.rs010064400007650000024000000016701350341657000166720ustar0000000000000000// 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 gio_sys; use glib::translate::*; use std::fmt; use ActionGroup; use ActionMap; glib_wrapper! { pub struct SimpleActionGroup(Object) @implements ActionGroup, ActionMap; match fn { get_type => || gio_sys::g_simple_action_group_get_type(), } } impl SimpleActionGroup { pub fn new() -> SimpleActionGroup { unsafe { from_glib_full(gio_sys::g_simple_action_group_new()) } } } impl Default for SimpleActionGroup { fn default() -> Self { Self::new() } } pub const NONE_SIMPLE_ACTION_GROUP: Option<&SimpleActionGroup> = None; impl fmt::Display for SimpleActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SimpleActionGroup") } } gio-0.7.0/src/auto/simple_io_stream.rs010064400007650000024000000022651350341657000161640ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; use IOStream; #[cfg(any(feature = "v2_44", feature = "dox"))] use InputStream; #[cfg(any(feature = "v2_44", feature = "dox"))] use OutputStream; glib_wrapper! { pub struct SimpleIOStream(Object) @extends IOStream; match fn { get_type => || gio_sys::g_simple_io_stream_get_type(), } } impl SimpleIOStream { #[cfg(any(feature = "v2_44", feature = "dox"))] pub fn new, Q: IsA>( input_stream: &P, output_stream: &Q, ) -> SimpleIOStream { unsafe { IOStream::from_glib_full(gio_sys::g_simple_io_stream_new( input_stream.as_ref().to_glib_none().0, output_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } } impl fmt::Display for SimpleIOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SimpleIOStream") } } gio-0.7.0/src/auto/simple_permission.rs010064400007650000024000000014741350341657000163730ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::translate::*; use std::fmt; use Permission; glib_wrapper! { pub struct SimplePermission(Object) @extends Permission; match fn { get_type => || gio_sys::g_simple_permission_get_type(), } } impl SimplePermission { pub fn new(allowed: bool) -> SimplePermission { unsafe { Permission::from_glib_full(gio_sys::g_simple_permission_new(allowed.to_glib())) .unsafe_cast() } } } impl fmt::Display for SimplePermission { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SimplePermission") } } gio-0.7.0/src/auto/socket.rs010064400007650000024000000717541350341657000141320ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::ObjectExt; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; use Cancellable; use Credentials; use Error; use InetAddress; use SocketAddress; use SocketConnection; use SocketFamily; use SocketProtocol; use SocketType; glib_wrapper! { pub struct Socket(Object); match fn { get_type => || gio_sys::g_socket_get_type(), } } impl Socket { pub fn new( family: SocketFamily, type_: SocketType, protocol: SocketProtocol, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_new( family.to_glib(), type_.to_glib(), protocol.to_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl glib::SendUnique for Socket { fn is_unique(&self) -> bool { self.ref_count() == 1 } } pub const NONE_SOCKET: Option<&Socket> = None; pub trait SocketExt: 'static { fn accept>(&self, cancellable: Option<&P>) -> Result; fn bind>(&self, address: &P, allow_reuse: bool) -> Result<(), Error>; fn check_connect_result(&self) -> Result<(), Error>; fn close(&self) -> Result<(), Error>; fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition; fn condition_timed_wait>( &self, condition: glib::IOCondition, timeout: i64, cancellable: Option<&P>, ) -> Result<(), Error>; fn condition_wait>( &self, condition: glib::IOCondition, cancellable: Option<&P>, ) -> Result<(), Error>; fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), Error>; fn connection_factory_create_connection(&self) -> Option; fn get_available_bytes(&self) -> isize; fn get_blocking(&self) -> bool; fn get_broadcast(&self) -> bool; fn get_credentials(&self) -> Result; fn get_family(&self) -> SocketFamily; fn get_keepalive(&self) -> bool; fn get_listen_backlog(&self) -> i32; fn get_local_address(&self) -> Result; fn get_multicast_loopback(&self) -> bool; fn get_multicast_ttl(&self) -> u32; fn get_option(&self, level: i32, optname: i32) -> Result; fn get_protocol(&self) -> SocketProtocol; fn get_remote_address(&self) -> Result; fn get_socket_type(&self) -> SocketType; fn get_timeout(&self) -> u32; fn get_ttl(&self) -> u32; fn is_closed(&self) -> bool; fn is_connected(&self) -> bool; fn join_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] fn join_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), Error>; fn leave_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] fn leave_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), Error>; fn listen(&self) -> Result<(), Error>; fn set_blocking(&self, blocking: bool); fn set_broadcast(&self, broadcast: bool); fn set_keepalive(&self, keepalive: bool); fn set_listen_backlog(&self, backlog: i32); fn set_multicast_loopback(&self, loopback: bool); fn set_multicast_ttl(&self, ttl: u32); fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error>; fn set_timeout(&self, timeout: u32); fn set_ttl(&self, ttl: u32); fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), Error>; fn speaks_ipv4(&self) -> bool; fn get_property_type(&self) -> SocketType; fn connect_property_blocking_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_broadcast_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_keepalive_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_listen_backlog_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_local_address_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_multicast_loopback_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_multicast_ttl_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_remote_address_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_timeout_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_ttl_notify(&self, f: F) -> SignalHandlerId; } impl> SocketExt for O { fn accept>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_accept( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn bind>(&self, address: &P, allow_reuse: bool) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_bind( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, allow_reuse.to_glib(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn check_connect_result(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_check_connect_result(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_close(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition { unsafe { from_glib(gio_sys::g_socket_condition_check( self.as_ref().to_glib_none().0, condition.to_glib(), )) } } fn condition_timed_wait>( &self, condition: glib::IOCondition, timeout: i64, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_condition_timed_wait( self.as_ref().to_glib_none().0, condition.to_glib(), timeout, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn condition_wait>( &self, condition: glib::IOCondition, cancellable: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_condition_wait( self.as_ref().to_glib_none().0, condition.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_connect( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connection_factory_create_connection(&self) -> Option { unsafe { from_glib_full(gio_sys::g_socket_connection_factory_create_connection( self.as_ref().to_glib_none().0, )) } } fn get_available_bytes(&self) -> isize { unsafe { gio_sys::g_socket_get_available_bytes(self.as_ref().to_glib_none().0) } } fn get_blocking(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_get_blocking( self.as_ref().to_glib_none().0, )) } } fn get_broadcast(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_get_broadcast( self.as_ref().to_glib_none().0, )) } } fn get_credentials(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_get_credentials(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_family(&self) -> SocketFamily { unsafe { from_glib(gio_sys::g_socket_get_family(self.as_ref().to_glib_none().0)) } } fn get_keepalive(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_get_keepalive( self.as_ref().to_glib_none().0, )) } } fn get_listen_backlog(&self) -> i32 { unsafe { gio_sys::g_socket_get_listen_backlog(self.as_ref().to_glib_none().0) } } fn get_local_address(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_get_local_address(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_multicast_loopback(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_get_multicast_loopback( self.as_ref().to_glib_none().0, )) } } fn get_multicast_ttl(&self) -> u32 { unsafe { gio_sys::g_socket_get_multicast_ttl(self.as_ref().to_glib_none().0) } } fn get_option(&self, level: i32, optname: i32) -> Result { unsafe { let mut value = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_get_option( self.as_ref().to_glib_none().0, level, optname, &mut value, &mut error, ); if error.is_null() { Ok(value) } else { Err(from_glib_full(error)) } } } fn get_protocol(&self) -> SocketProtocol { unsafe { from_glib(gio_sys::g_socket_get_protocol( self.as_ref().to_glib_none().0, )) } } fn get_remote_address(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_get_remote_address(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_socket_type(&self) -> SocketType { unsafe { from_glib(gio_sys::g_socket_get_socket_type( self.as_ref().to_glib_none().0, )) } } fn get_timeout(&self) -> u32 { unsafe { gio_sys::g_socket_get_timeout(self.as_ref().to_glib_none().0) } } fn get_ttl(&self) -> u32 { unsafe { gio_sys::g_socket_get_ttl(self.as_ref().to_glib_none().0) } } fn is_closed(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_is_closed(self.as_ref().to_glib_none().0)) } } fn is_connected(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_is_connected( self.as_ref().to_glib_none().0, )) } } fn join_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_join_multicast_group( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.to_glib(), iface.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn join_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_join_multicast_group_ssm( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.map(|p| p.as_ref()).to_glib_none().0, iface.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn leave_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_leave_multicast_group( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.to_glib(), iface.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] fn leave_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_leave_multicast_group_ssm( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.map(|p| p.as_ref()).to_glib_none().0, iface.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn listen(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_listen(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_blocking(&self, blocking: bool) { unsafe { gio_sys::g_socket_set_blocking(self.as_ref().to_glib_none().0, blocking.to_glib()); } } fn set_broadcast(&self, broadcast: bool) { unsafe { gio_sys::g_socket_set_broadcast(self.as_ref().to_glib_none().0, broadcast.to_glib()); } } fn set_keepalive(&self, keepalive: bool) { unsafe { gio_sys::g_socket_set_keepalive(self.as_ref().to_glib_none().0, keepalive.to_glib()); } } fn set_listen_backlog(&self, backlog: i32) { unsafe { gio_sys::g_socket_set_listen_backlog(self.as_ref().to_glib_none().0, backlog); } } fn set_multicast_loopback(&self, loopback: bool) { unsafe { gio_sys::g_socket_set_multicast_loopback( self.as_ref().to_glib_none().0, loopback.to_glib(), ); } } fn set_multicast_ttl(&self, ttl: u32) { unsafe { gio_sys::g_socket_set_multicast_ttl(self.as_ref().to_glib_none().0, ttl); } } fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_set_option( self.as_ref().to_glib_none().0, level, optname, value, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_timeout(&self, timeout: u32) { unsafe { gio_sys::g_socket_set_timeout(self.as_ref().to_glib_none().0, timeout); } } fn set_ttl(&self, ttl: u32) { unsafe { gio_sys::g_socket_set_ttl(self.as_ref().to_glib_none().0, ttl); } } fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_shutdown( self.as_ref().to_glib_none().0, shutdown_read.to_glib(), shutdown_write.to_glib(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn speaks_ipv4(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_speaks_ipv4( self.as_ref().to_glib_none().0, )) } } fn get_property_type(&self) -> SocketType { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"type\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_property_blocking_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_blocking_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::blocking\0".as_ptr() as *const _, Some(transmute(notify_blocking_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_broadcast_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_broadcast_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::broadcast\0".as_ptr() as *const _, Some(transmute(notify_broadcast_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_keepalive_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_keepalive_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::keepalive\0".as_ptr() as *const _, Some(transmute(notify_keepalive_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_listen_backlog_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_listen_backlog_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::listen-backlog\0".as_ptr() as *const _, Some(transmute( notify_listen_backlog_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_local_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_local_address_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::local-address\0".as_ptr() as *const _, Some(transmute( notify_local_address_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_multicast_loopback_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_loopback_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::multicast-loopback\0".as_ptr() as *const _, Some(transmute( notify_multicast_loopback_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_multicast_ttl_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_ttl_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::multicast-ttl\0".as_ptr() as *const _, Some(transmute( notify_multicast_ttl_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_remote_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_remote_address_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::remote-address\0".as_ptr() as *const _, Some(transmute( notify_remote_address_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_timeout_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(transmute(notify_timeout_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_ttl_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ttl_trampoline( this: *mut gio_sys::GSocket, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Socket::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ttl\0".as_ptr() as *const _, Some(transmute(notify_ttl_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Socket { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Socket") } } gio-0.7.0/src/auto/socket_address.rs010064400007650000024000000056471350341657000156350ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use SocketConnectable; use SocketFamily; glib_wrapper! { pub struct SocketAddress(Object) @implements SocketConnectable; match fn { get_type => || gio_sys::g_socket_address_get_type(), } } impl SocketAddress { //pub fn new_from_native(native: /*Unimplemented*/Fundamental: Pointer, len: usize) -> SocketAddress { // unsafe { TODO: call gio_sys:g_socket_address_new_from_native() } //} } unsafe impl Send for SocketAddress {} unsafe impl Sync for SocketAddress {} pub const NONE_SOCKET_ADDRESS: Option<&SocketAddress> = None; pub trait SocketAddressExt: 'static { fn get_family(&self) -> SocketFamily; fn get_native_size(&self) -> isize; //fn to_native(&self, dest: /*Unimplemented*/Option, destlen: usize) -> Result<(), Error>; fn connect_property_family_notify( &self, f: F, ) -> SignalHandlerId; } impl> SocketAddressExt for O { fn get_family(&self) -> SocketFamily { unsafe { from_glib(gio_sys::g_socket_address_get_family( self.as_ref().to_glib_none().0, )) } } fn get_native_size(&self) -> isize { unsafe { gio_sys::g_socket_address_get_native_size(self.as_ref().to_glib_none().0) } } //fn to_native(&self, dest: /*Unimplemented*/Option, destlen: usize) -> Result<(), Error> { // unsafe { TODO: call gio_sys:g_socket_address_to_native() } //} fn connect_property_family_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline( this: *mut gio_sys::GSocketAddress, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketAddress::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(transmute(notify_family_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for SocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketAddress") } } gio-0.7.0/src/auto/socket_address_enumerator.rs010064400007650000024000000075551350341657000200760ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use SocketAddress; glib_wrapper! { pub struct SocketAddressEnumerator(Object); match fn { get_type => || gio_sys::g_socket_address_enumerator_get_type(), } } pub const NONE_SOCKET_ADDRESS_ENUMERATOR: Option<&SocketAddressEnumerator> = None; pub trait SocketAddressEnumeratorExt: 'static { fn next>(&self, cancellable: Option<&P>) -> Result; fn next_async, Q: FnOnce(Result) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn next_async_future( &self, ) -> Box_> + std::marker::Unpin>; } impl> SocketAddressEnumeratorExt for O { fn next>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_address_enumerator_next( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn next_async, Q: FnOnce(Result) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn next_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_address_enumerator_next_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = next_async_trampoline::; unsafe { gio_sys::g_socket_address_enumerator_next_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn next_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.next_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for SocketAddressEnumerator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketAddressEnumerator") } } gio-0.7.0/src/auto/socket_client.rs010064400007650000024000000765131350341657000154660ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use IOStream; use ProxyResolver; use SocketAddress; use SocketClientEvent; use SocketConnectable; use SocketConnection; use SocketFamily; use SocketProtocol; use SocketType; use TlsCertificateFlags; glib_wrapper! { pub struct SocketClient(Object); match fn { get_type => || gio_sys::g_socket_client_get_type(), } } impl SocketClient { pub fn new() -> SocketClient { unsafe { from_glib_full(gio_sys::g_socket_client_new()) } } } impl Default for SocketClient { fn default() -> Self { Self::new() } } pub const NONE_SOCKET_CLIENT: Option<&SocketClient> = None; pub trait SocketClientExt: 'static { fn add_application_proxy(&self, protocol: &str); fn connect, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result; fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn connect_async_future + Clone + 'static>( &self, connectable: &P, ) -> Box_> + std::marker::Unpin>; fn connect_to_host>( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, ) -> Result; fn connect_to_host_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn connect_to_host_async_future( &self, host_and_port: &str, default_port: u16, ) -> Box_> + std::marker::Unpin>; fn connect_to_service>( &self, domain: &str, service: &str, cancellable: Option<&P>, ) -> Result; fn connect_to_service_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, domain: &str, service: &str, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn connect_to_service_async_future( &self, domain: &str, service: &str, ) -> Box_> + std::marker::Unpin>; fn connect_to_uri>( &self, uri: &str, default_port: u16, cancellable: Option<&P>, ) -> Result; fn connect_to_uri_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, uri: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn connect_to_uri_async_future( &self, uri: &str, default_port: u16, ) -> Box_> + std::marker::Unpin>; fn get_enable_proxy(&self) -> bool; fn get_family(&self) -> SocketFamily; fn get_local_address(&self) -> Option; fn get_protocol(&self) -> SocketProtocol; fn get_proxy_resolver(&self) -> Option; fn get_socket_type(&self) -> SocketType; fn get_timeout(&self) -> u32; fn get_tls(&self) -> bool; fn get_tls_validation_flags(&self) -> TlsCertificateFlags; fn set_enable_proxy(&self, enable: bool); fn set_family(&self, family: SocketFamily); fn set_local_address>(&self, address: Option<&P>); fn set_protocol(&self, protocol: SocketProtocol); fn set_proxy_resolver>(&self, proxy_resolver: Option<&P>); fn set_socket_type(&self, type_: SocketType); fn set_timeout(&self, timeout: u32); fn set_tls(&self, tls: bool); fn set_tls_validation_flags(&self, flags: TlsCertificateFlags); fn get_property_type(&self) -> SocketType; fn set_property_type(&self, type_: SocketType); fn connect_event< F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( &self, f: F, ) -> SignalHandlerId; fn connect_property_enable_proxy_notify(&self, f: F) -> SignalHandlerId; fn connect_property_family_notify(&self, f: F) -> SignalHandlerId; fn connect_property_local_address_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_protocol_notify(&self, f: F) -> SignalHandlerId; fn connect_property_proxy_resolver_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_timeout_notify(&self, f: F) -> SignalHandlerId; fn connect_property_tls_notify(&self, f: F) -> SignalHandlerId; fn connect_property_tls_validation_flags_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_type_notify(&self, f: F) -> SignalHandlerId; } impl> SocketClientExt for O { fn add_application_proxy(&self, protocol: &str) { unsafe { gio_sys::g_socket_client_add_application_proxy( self.as_ref().to_glib_none().0, protocol.to_glib_none().0, ); } } fn connect, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_async_trampoline::; unsafe { gio_sys::g_socket_client_connect_async( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_async_future + Clone + 'static>( &self, connectable: &P, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let connectable = connectable.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_async(&connectable, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn connect_to_host>( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_host( self.as_ref().to_glib_none().0, host_and_port.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn connect_to_host_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_to_host_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_host_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_to_host_async_trampoline::; unsafe { gio_sys::g_socket_client_connect_to_host_async( self.as_ref().to_glib_none().0, host_and_port.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_to_host_async_future( &self, host_and_port: &str, default_port: u16, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let host_and_port = String::from(host_and_port); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_to_host_async( &host_and_port, default_port, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn connect_to_service>( &self, domain: &str, service: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_service( self.as_ref().to_glib_none().0, domain.to_glib_none().0, service.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn connect_to_service_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, domain: &str, service: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_to_service_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_service_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_to_service_async_trampoline::; unsafe { gio_sys::g_socket_client_connect_to_service_async( self.as_ref().to_glib_none().0, domain.to_glib_none().0, service.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_to_service_async_future( &self, domain: &str, service: &str, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let domain = String::from(domain); let service = String::from(service); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_to_service_async(&domain, &service, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn connect_to_uri>( &self, uri: &str, default_port: u16, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_uri( self.as_ref().to_glib_none().0, uri.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn connect_to_uri_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, uri: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_to_uri_async_trampoline< Q: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_client_connect_to_uri_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_to_uri_async_trampoline::; unsafe { gio_sys::g_socket_client_connect_to_uri_async( self.as_ref().to_glib_none().0, uri.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_to_uri_async_future( &self, uri: &str, default_port: u16, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let uri = String::from(uri); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_to_uri_async(&uri, default_port, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn get_enable_proxy(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_client_get_enable_proxy( self.as_ref().to_glib_none().0, )) } } fn get_family(&self) -> SocketFamily { unsafe { from_glib(gio_sys::g_socket_client_get_family( self.as_ref().to_glib_none().0, )) } } fn get_local_address(&self) -> Option { unsafe { from_glib_none(gio_sys::g_socket_client_get_local_address( self.as_ref().to_glib_none().0, )) } } fn get_protocol(&self) -> SocketProtocol { unsafe { from_glib(gio_sys::g_socket_client_get_protocol( self.as_ref().to_glib_none().0, )) } } fn get_proxy_resolver(&self) -> Option { unsafe { from_glib_none(gio_sys::g_socket_client_get_proxy_resolver( self.as_ref().to_glib_none().0, )) } } fn get_socket_type(&self) -> SocketType { unsafe { from_glib(gio_sys::g_socket_client_get_socket_type( self.as_ref().to_glib_none().0, )) } } fn get_timeout(&self) -> u32 { unsafe { gio_sys::g_socket_client_get_timeout(self.as_ref().to_glib_none().0) } } fn get_tls(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_client_get_tls( self.as_ref().to_glib_none().0, )) } } fn get_tls_validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(gio_sys::g_socket_client_get_tls_validation_flags( self.as_ref().to_glib_none().0, )) } } fn set_enable_proxy(&self, enable: bool) { unsafe { gio_sys::g_socket_client_set_enable_proxy( self.as_ref().to_glib_none().0, enable.to_glib(), ); } } fn set_family(&self, family: SocketFamily) { unsafe { gio_sys::g_socket_client_set_family(self.as_ref().to_glib_none().0, family.to_glib()); } } fn set_local_address>(&self, address: Option<&P>) { unsafe { gio_sys::g_socket_client_set_local_address( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, ); } } fn set_protocol(&self, protocol: SocketProtocol) { unsafe { gio_sys::g_socket_client_set_protocol( self.as_ref().to_glib_none().0, protocol.to_glib(), ); } } fn set_proxy_resolver>(&self, proxy_resolver: Option<&P>) { unsafe { gio_sys::g_socket_client_set_proxy_resolver( self.as_ref().to_glib_none().0, proxy_resolver.map(|p| p.as_ref()).to_glib_none().0, ); } } fn set_socket_type(&self, type_: SocketType) { unsafe { gio_sys::g_socket_client_set_socket_type( self.as_ref().to_glib_none().0, type_.to_glib(), ); } } fn set_timeout(&self, timeout: u32) { unsafe { gio_sys::g_socket_client_set_timeout(self.as_ref().to_glib_none().0, timeout); } } fn set_tls(&self, tls: bool) { unsafe { gio_sys::g_socket_client_set_tls(self.as_ref().to_glib_none().0, tls.to_glib()); } } fn set_tls_validation_flags(&self, flags: TlsCertificateFlags) { unsafe { gio_sys::g_socket_client_set_tls_validation_flags( self.as_ref().to_glib_none().0, flags.to_glib(), ); } } fn get_property_type(&self) -> SocketType { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"type\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn set_property_type(&self, type_: SocketType) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"type\0".as_ptr() as *const _, Value::from(&type_).to_glib_none().0, ); } } fn connect_event< F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn event_trampoline< P, F: Fn(&P, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( this: *mut gio_sys::GSocketClient, event: gio_sys::GSocketClientEvent, connectable: *mut gio_sys::GSocketConnectable, connection: *mut gio_sys::GIOStream, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &SocketClient::from_glib_borrow(this).unsafe_cast(), from_glib(event), &from_glib_borrow(connectable), Option::::from_glib_borrow(connection).as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"event\0".as_ptr() as *const _, Some(transmute(event_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_enable_proxy_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_enable_proxy_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enable-proxy\0".as_ptr() as *const _, Some(transmute( notify_enable_proxy_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_family_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(transmute(notify_family_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_local_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_local_address_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::local-address\0".as_ptr() as *const _, Some(transmute( notify_local_address_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_protocol_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_protocol_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::protocol\0".as_ptr() as *const _, Some(transmute(notify_protocol_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_proxy_resolver_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_proxy_resolver_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::proxy-resolver\0".as_ptr() as *const _, Some(transmute( notify_proxy_resolver_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(transmute(notify_timeout_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_tls_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_tls_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::tls\0".as_ptr() as *const _, Some(transmute(notify_tls_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_tls_validation_flags_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_tls_validation_flags_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::tls-validation-flags\0".as_ptr() as *const _, Some(transmute( notify_tls_validation_flags_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_type_trampoline( this: *mut gio_sys::GSocketClient, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketClient::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::type\0".as_ptr() as *const _, Some(transmute(notify_type_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for SocketClient { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketClient") } } gio-0.7.0/src/auto/socket_connectable.rs010064400007650000024000000033461350341657000164570ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; #[cfg(any(feature = "v2_48", feature = "dox"))] use glib::GString; use std::fmt; use SocketAddressEnumerator; glib_wrapper! { pub struct SocketConnectable(Interface); match fn { get_type => || gio_sys::g_socket_connectable_get_type(), } } pub const NONE_SOCKET_CONNECTABLE: Option<&SocketConnectable> = None; pub trait SocketConnectableExt: 'static { fn enumerate(&self) -> Option; fn proxy_enumerate(&self) -> Option; #[cfg(any(feature = "v2_48", feature = "dox"))] fn to_string(&self) -> Option; } impl> SocketConnectableExt for O { fn enumerate(&self) -> Option { unsafe { from_glib_full(gio_sys::g_socket_connectable_enumerate( self.as_ref().to_glib_none().0, )) } } fn proxy_enumerate(&self) -> Option { unsafe { from_glib_full(gio_sys::g_socket_connectable_proxy_enumerate( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_48", feature = "dox"))] fn to_string(&self) -> Option { unsafe { from_glib_full(gio_sys::g_socket_connectable_to_string( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for SocketConnectable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketConnectable") } } gio-0.7.0/src/auto/socket_connection.rs010064400007650000024000000151131350341657000163340ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use IOStream; use Socket; use SocketAddress; use SocketFamily; use SocketType; glib_wrapper! { pub struct SocketConnection(Object) @extends IOStream; match fn { get_type => || gio_sys::g_socket_connection_get_type(), } } impl SocketConnection { pub fn factory_lookup_type( family: SocketFamily, type_: SocketType, protocol_id: i32, ) -> glib::types::Type { unsafe { from_glib(gio_sys::g_socket_connection_factory_lookup_type( family.to_glib(), type_.to_glib(), protocol_id, )) } } pub fn factory_register_type( g_type: glib::types::Type, family: SocketFamily, type_: SocketType, protocol: i32, ) { unsafe { gio_sys::g_socket_connection_factory_register_type( g_type.to_glib(), family.to_glib(), type_.to_glib(), protocol, ); } } } pub const NONE_SOCKET_CONNECTION: Option<&SocketConnection> = None; pub trait SocketConnectionExt: 'static { fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), Error>; fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn connect_async_future + Clone + 'static>( &self, address: &P, ) -> Box_> + std::marker::Unpin>; fn get_local_address(&self) -> Result; fn get_remote_address(&self) -> Result; fn get_socket(&self) -> Option; fn is_connected(&self) -> bool; } impl> SocketConnectionExt for O { fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_connection_connect( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn connect_async_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_connection_connect_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = connect_async_trampoline::; unsafe { gio_sys::g_socket_connection_connect_async( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn connect_async_future + Clone + 'static>( &self, address: &P, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let address = address.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.connect_async(&address, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn get_local_address(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_connection_get_local_address( self.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_remote_address(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_connection_get_remote_address( self.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn get_socket(&self) -> Option { unsafe { from_glib_none(gio_sys::g_socket_connection_get_socket( self.as_ref().to_glib_none().0, )) } } fn is_connected(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_connection_is_connected( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for SocketConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketConnection") } } gio-0.7.0/src/auto/socket_listener.rs010064400007650000024000000236141350341657000160270ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use Socket; use SocketAddress; use SocketConnection; #[cfg(any(feature = "v2_46", feature = "dox"))] use SocketListenerEvent; use SocketProtocol; use SocketType; glib_wrapper! { pub struct SocketListener(Object); match fn { get_type => || gio_sys::g_socket_listener_get_type(), } } impl SocketListener { pub fn new() -> SocketListener { unsafe { from_glib_full(gio_sys::g_socket_listener_new()) } } } impl Default for SocketListener { fn default() -> Self { Self::new() } } pub const NONE_SOCKET_LISTENER: Option<&SocketListener> = None; pub trait SocketListenerExt: 'static { fn accept>( &self, cancellable: Option<&P>, ) -> Result<(SocketConnection, Option), Error>; fn accept_socket>( &self, cancellable: Option<&P>, ) -> Result<(Socket, Option), Error>; fn add_address, Q: IsA>( &self, address: &P, type_: SocketType, protocol: SocketProtocol, source_object: Option<&Q>, ) -> Result; fn add_any_inet_port>( &self, source_object: Option<&P>, ) -> Result; fn add_inet_port>( &self, port: u16, source_object: Option<&P>, ) -> Result<(), Error>; fn add_socket, Q: IsA>( &self, socket: &P, source_object: Option<&Q>, ) -> Result<(), Error>; fn close(&self); fn set_backlog(&self, listen_backlog: i32); fn get_property_listen_backlog(&self) -> i32; fn set_property_listen_backlog(&self, listen_backlog: i32); #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_event( &self, f: F, ) -> SignalHandlerId; fn connect_property_listen_backlog_notify( &self, f: F, ) -> SignalHandlerId; } impl> SocketListenerExt for O { fn accept>( &self, cancellable: Option<&P>, ) -> Result<(SocketConnection, Option), Error> { unsafe { let mut source_object = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_listener_accept( self.as_ref().to_glib_none().0, &mut source_object, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) } } } fn accept_socket>( &self, cancellable: Option<&P>, ) -> Result<(Socket, Option), Error> { unsafe { let mut source_object = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_listener_accept_socket( self.as_ref().to_glib_none().0, &mut source_object, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) } } } fn add_address, Q: IsA>( &self, address: &P, type_: SocketType, protocol: SocketProtocol, source_object: Option<&Q>, ) -> Result { unsafe { let mut effective_address = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_listener_add_address( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, type_.to_glib(), protocol.to_glib(), source_object.map(|p| p.as_ref()).to_glib_none().0, &mut effective_address, &mut error, ); if error.is_null() { Ok(from_glib_full(effective_address)) } else { Err(from_glib_full(error)) } } } fn add_any_inet_port>( &self, source_object: Option<&P>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_listener_add_any_inet_port( self.as_ref().to_glib_none().0, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn add_inet_port>( &self, port: u16, source_object: Option<&P>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_listener_add_inet_port( self.as_ref().to_glib_none().0, port, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn add_socket, Q: IsA>( &self, socket: &P, source_object: Option<&Q>, ) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_socket_listener_add_socket( self.as_ref().to_glib_none().0, socket.as_ref().to_glib_none().0, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close(&self) { unsafe { gio_sys::g_socket_listener_close(self.as_ref().to_glib_none().0); } } fn set_backlog(&self, listen_backlog: i32) { unsafe { gio_sys::g_socket_listener_set_backlog(self.as_ref().to_glib_none().0, listen_backlog); } } fn get_property_listen_backlog(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"listen-backlog\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn set_property_listen_backlog(&self, listen_backlog: i32) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"listen-backlog\0".as_ptr() as *const _, Value::from(&listen_backlog).to_glib_none().0, ); } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_event( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn event_trampoline< P, F: Fn(&P, SocketListenerEvent, &Socket) + 'static, >( this: *mut gio_sys::GSocketListener, event: gio_sys::GSocketListenerEvent, socket: *mut gio_sys::GSocket, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &SocketListener::from_glib_borrow(this).unsafe_cast(), from_glib(event), &from_glib_borrow(socket), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"event\0".as_ptr() as *const _, Some(transmute(event_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_listen_backlog_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_listen_backlog_trampoline( this: *mut gio_sys::GSocketListener, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketListener::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::listen-backlog\0".as_ptr() as *const _, Some(transmute( notify_listen_backlog_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for SocketListener { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketListener") } } gio-0.7.0/src/auto/socket_service.rs010064400007650000024000000122771350341657000156450ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; #[cfg(any(feature = "v2_46", feature = "dox"))] use glib::StaticType; #[cfg(any(feature = "v2_46", feature = "dox"))] use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use SocketConnection; use SocketListener; glib_wrapper! { pub struct SocketService(Object) @extends SocketListener; match fn { get_type => || gio_sys::g_socket_service_get_type(), } } impl SocketService { pub fn new() -> SocketService { unsafe { from_glib_full(gio_sys::g_socket_service_new()) } } } impl Default for SocketService { fn default() -> Self { Self::new() } } pub const NONE_SOCKET_SERVICE: Option<&SocketService> = None; pub trait SocketServiceExt: 'static { fn is_active(&self) -> bool; fn start(&self); fn stop(&self); #[cfg(any(feature = "v2_46", feature = "dox"))] fn get_property_active(&self) -> bool; #[cfg(any(feature = "v2_46", feature = "dox"))] fn set_property_active(&self, active: bool); fn connect_incoming) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_property_active_notify(&self, f: F) -> SignalHandlerId; } impl> SocketServiceExt for O { fn is_active(&self) -> bool { unsafe { from_glib(gio_sys::g_socket_service_is_active( self.as_ref().to_glib_none().0, )) } } fn start(&self) { unsafe { gio_sys::g_socket_service_start(self.as_ref().to_glib_none().0); } } fn stop(&self) { unsafe { gio_sys::g_socket_service_stop(self.as_ref().to_glib_none().0); } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn get_property_active(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"active\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn set_property_active(&self, active: bool) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"active\0".as_ptr() as *const _, Value::from(&active).to_glib_none().0, ); } } fn connect_incoming< F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn incoming_trampoline< P, F: Fn(&P, &SocketConnection, Option<&glib::Object>) -> bool + 'static, >( this: *mut gio_sys::GSocketService, connection: *mut gio_sys::GSocketConnection, source_object: *mut gobject_sys::GObject, f: glib_sys::gpointer, ) -> glib_sys::gboolean where P: IsA, { let f: &F = &*(f as *const F); f( &SocketService::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(connection), Option::::from_glib_borrow(source_object).as_ref(), ) .to_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"incoming\0".as_ptr() as *const _, Some(transmute(incoming_trampoline:: as usize)), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn connect_property_active_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_active_trampoline( this: *mut gio_sys::GSocketService, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&SocketService::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::active\0".as_ptr() as *const _, Some(transmute(notify_active_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for SocketService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SocketService") } } gio-0.7.0/src/auto/srv_target.rs010064400007650000024000000031531350341657000150060ustar0000000000000000// 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 gio_sys; use glib::translate::*; use glib::GString; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SrvTarget(Boxed); match fn { copy => |ptr| gio_sys::g_srv_target_copy(mut_override(ptr)), free => |ptr| gio_sys::g_srv_target_free(ptr), get_type => || gio_sys::g_srv_target_get_type(), } } impl SrvTarget { pub fn new(hostname: &str, port: u16, priority: u16, weight: u16) -> SrvTarget { unsafe { from_glib_full(gio_sys::g_srv_target_new( hostname.to_glib_none().0, port, priority, weight, )) } } pub fn get_hostname(&mut self) -> Option { unsafe { from_glib_none(gio_sys::g_srv_target_get_hostname( self.to_glib_none_mut().0, )) } } pub fn get_port(&mut self) -> u16 { unsafe { gio_sys::g_srv_target_get_port(self.to_glib_none_mut().0) } } pub fn get_priority(&mut self) -> u16 { unsafe { gio_sys::g_srv_target_get_priority(self.to_glib_none_mut().0) } } pub fn get_weight(&mut self) -> u16 { unsafe { gio_sys::g_srv_target_get_weight(self.to_glib_none_mut().0) } } //pub fn list_sort(targets: /*Unimplemented*/&[&Fundamental: Pointer]) -> /*Unimplemented*/Vec { // unsafe { TODO: call gio_sys:g_srv_target_list_sort() } //} } gio-0.7.0/src/auto/subprocess.rs010064400007650000024000000275541350341657000150310ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use InputStream; use OutputStream; use SubprocessFlags; glib_wrapper! { pub struct Subprocess(Object); match fn { get_type => || gio_sys::g_subprocess_get_type(), } } impl Subprocess { //pub fn new(flags: SubprocessFlags, error: Option<&mut Error>, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Subprocess { // unsafe { TODO: call gio_sys:g_subprocess_new() } //} pub fn newv(argv: &[&std::ffi::OsStr], flags: SubprocessFlags) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_subprocess_newv(argv.to_glib_none().0, flags.to_glib(), &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn communicate>( &self, stdin_buf: Option<&glib::Bytes>, cancellable: Option<&P>, ) -> Result<(Option, Option), Error> { unsafe { let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_communicate( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut stdout_buf, &mut stderr_buf, &mut error, ); if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) } } } pub fn communicate_async< P: IsA, Q: FnOnce(Result<(glib::Bytes, glib::Bytes), Error>) + Send + 'static, >( &self, stdin_buf: Option<&glib::Bytes>, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn communicate_async_trampoline< Q: FnOnce(Result<(glib::Bytes, glib::Bytes), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let _ = gio_sys::g_subprocess_communicate_finish( _source_object as *mut _, res, &mut stdout_buf, &mut stderr_buf, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = communicate_async_trampoline::; unsafe { gio_sys::g_subprocess_communicate_async( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn communicate_async_future( &self, stdin_buf: Option<&glib::Bytes>, ) -> Box_< dyn future::Future> + std::marker::Unpin, > { use fragile::Fragile; use GioFuture; let stdin_buf = stdin_buf.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.communicate_async( stdin_buf.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } pub fn communicate_utf8>( &self, stdin_buf: Option<&str>, cancellable: Option<&P>, ) -> Result<(Option, Option), Error> { unsafe { let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_communicate_utf8( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut stdout_buf, &mut stderr_buf, &mut error, ); if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) } } } pub fn force_exit(&self) { unsafe { gio_sys::g_subprocess_force_exit(self.to_glib_none().0); } } pub fn get_exit_status(&self) -> i32 { unsafe { gio_sys::g_subprocess_get_exit_status(self.to_glib_none().0) } } pub fn get_identifier(&self) -> Option { unsafe { from_glib_none(gio_sys::g_subprocess_get_identifier(self.to_glib_none().0)) } } pub fn get_if_exited(&self) -> bool { unsafe { from_glib(gio_sys::g_subprocess_get_if_exited(self.to_glib_none().0)) } } pub fn get_if_signaled(&self) -> bool { unsafe { from_glib(gio_sys::g_subprocess_get_if_signaled(self.to_glib_none().0)) } } pub fn get_status(&self) -> i32 { unsafe { gio_sys::g_subprocess_get_status(self.to_glib_none().0) } } pub fn get_stderr_pipe(&self) -> Option { unsafe { from_glib_none(gio_sys::g_subprocess_get_stderr_pipe(self.to_glib_none().0)) } } pub fn get_stdin_pipe(&self) -> Option { unsafe { from_glib_none(gio_sys::g_subprocess_get_stdin_pipe(self.to_glib_none().0)) } } pub fn get_stdout_pipe(&self) -> Option { unsafe { from_glib_none(gio_sys::g_subprocess_get_stdout_pipe(self.to_glib_none().0)) } } pub fn get_successful(&self) -> bool { unsafe { from_glib(gio_sys::g_subprocess_get_successful(self.to_glib_none().0)) } } pub fn get_term_sig(&self) -> i32 { unsafe { gio_sys::g_subprocess_get_term_sig(self.to_glib_none().0) } } #[cfg(any(not(windows), feature = "dox"))] pub fn send_signal(&self, signal_num: i32) { unsafe { gio_sys::g_subprocess_send_signal(self.to_glib_none().0, signal_num); } } pub fn wait>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_wait( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } pub fn wait_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn wait_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_wait_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = wait_async_trampoline::; unsafe { gio_sys::g_subprocess_wait_async( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn wait_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.wait_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } pub fn wait_check>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_wait_check( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } pub fn wait_check_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn wait_check_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_subprocess_wait_check_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = wait_check_async_trampoline::; unsafe { gio_sys::g_subprocess_wait_check_async( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn wait_check_async_future( &self, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.wait_check_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for Subprocess { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Subprocess") } } gio-0.7.0/src/auto/subprocess_launcher.rs010064400007650000024000000117271350341657000167050ustar0000000000000000// 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 gio_sys; use glib::translate::*; use std; use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Error; use Subprocess; use SubprocessFlags; glib_wrapper! { pub struct SubprocessLauncher(Object); match fn { get_type => || gio_sys::g_subprocess_launcher_get_type(), } } impl SubprocessLauncher { pub fn new(flags: SubprocessFlags) -> SubprocessLauncher { unsafe { from_glib_full(gio_sys::g_subprocess_launcher_new(flags.to_glib())) } } pub fn getenv>(&self, variable: P) -> Option { unsafe { from_glib_none(gio_sys::g_subprocess_launcher_getenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] pub fn set_child_setup(&self, child_setup: P) { let child_setup_data: Box_

= Box::new(child_setup); unsafe extern "C" fn child_setup_func(user_data: glib_sys::gpointer) { let callback: &P = &*(user_data as *mut _); (*callback)(); } let child_setup = Some(child_setup_func::

as _); unsafe extern "C" fn destroy_notify_func(data: glib_sys::gpointer) { let _callback: Box_

= Box_::from_raw(data as *mut _); } let destroy_call3 = Some(destroy_notify_func::

as _); let super_callback0: Box_

= child_setup_data; unsafe { gio_sys::g_subprocess_launcher_set_child_setup( self.to_glib_none().0, child_setup, Box::into_raw(super_callback0) as *mut _, destroy_call3, ); } } pub fn set_cwd>(&self, cwd: P) { unsafe { gio_sys::g_subprocess_launcher_set_cwd( self.to_glib_none().0, cwd.as_ref().to_glib_none().0, ); } } pub fn set_environ(&self, env: &[&std::path::Path]) { unsafe { gio_sys::g_subprocess_launcher_set_environ(self.to_glib_none().0, env.to_glib_none().0); } } pub fn set_flags(&self, flags: SubprocessFlags) { unsafe { gio_sys::g_subprocess_launcher_set_flags(self.to_glib_none().0, flags.to_glib()); } } #[cfg(any(unix, feature = "dox"))] pub fn set_stderr_file_path>(&self, path: P) { unsafe { gio_sys::g_subprocess_launcher_set_stderr_file_path( self.to_glib_none().0, path.as_ref().to_glib_none().0, ); } } #[cfg(any(unix, feature = "dox"))] pub fn set_stdin_file_path(&self, path: &str) { unsafe { gio_sys::g_subprocess_launcher_set_stdin_file_path( self.to_glib_none().0, path.to_glib_none().0, ); } } #[cfg(any(unix, feature = "dox"))] pub fn set_stdout_file_path>(&self, path: P) { unsafe { gio_sys::g_subprocess_launcher_set_stdout_file_path( self.to_glib_none().0, path.as_ref().to_glib_none().0, ); } } pub fn setenv, Q: AsRef>( &self, variable: P, value: Q, overwrite: bool, ) { unsafe { gio_sys::g_subprocess_launcher_setenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, value.as_ref().to_glib_none().0, overwrite.to_glib(), ); } } //pub fn spawn(&self, error: &mut Error, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option { // unsafe { TODO: call gio_sys:g_subprocess_launcher_spawn() } //} pub fn spawnv(&self, argv: &[&std::ffi::OsStr]) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_subprocess_launcher_spawnv( self.to_glib_none().0, argv.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn unsetenv>(&self, variable: P) { unsafe { gio_sys::g_subprocess_launcher_unsetenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } } impl fmt::Display for SubprocessLauncher { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "SubprocessLauncher") } } gio-0.7.0/src/auto/tcp_connection.rs010064400007650000024000000050771350341657000156420ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use IOStream; use SocketConnection; glib_wrapper! { pub struct TcpConnection(Object) @extends SocketConnection, IOStream; match fn { get_type => || gio_sys::g_tcp_connection_get_type(), } } pub const NONE_TCP_CONNECTION: Option<&TcpConnection> = None; pub trait TcpConnectionExt: 'static { fn get_graceful_disconnect(&self) -> bool; fn set_graceful_disconnect(&self, graceful_disconnect: bool); fn connect_property_graceful_disconnect_notify( &self, f: F, ) -> SignalHandlerId; } impl> TcpConnectionExt for O { fn get_graceful_disconnect(&self) -> bool { unsafe { from_glib(gio_sys::g_tcp_connection_get_graceful_disconnect( self.as_ref().to_glib_none().0, )) } } fn set_graceful_disconnect(&self, graceful_disconnect: bool) { unsafe { gio_sys::g_tcp_connection_set_graceful_disconnect( self.as_ref().to_glib_none().0, graceful_disconnect.to_glib(), ); } } fn connect_property_graceful_disconnect_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_graceful_disconnect_trampoline( this: *mut gio_sys::GTcpConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TcpConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::graceful-disconnect\0".as_ptr() as *const _, Some(transmute( notify_graceful_disconnect_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for TcpConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TcpConnection") } } gio-0.7.0/src/auto/themed_icon.rs010064400007650000024000000063161350341657000151100ustar0000000000000000// 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 gio_sys; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Icon; glib_wrapper! { pub struct ThemedIcon(Object) @implements Icon; match fn { get_type => || gio_sys::g_themed_icon_get_type(), } } impl ThemedIcon { pub fn new(iconname: &str) -> ThemedIcon { unsafe { from_glib_full(gio_sys::g_themed_icon_new(iconname.to_glib_none().0)) } } pub fn new_from_names(iconnames: &[&str]) -> ThemedIcon { let len = iconnames.len() as i32; unsafe { from_glib_full(gio_sys::g_themed_icon_new_from_names( iconnames.to_glib_none().0, len, )) } } pub fn new_with_default_fallbacks(iconname: &str) -> ThemedIcon { unsafe { from_glib_full(gio_sys::g_themed_icon_new_with_default_fallbacks( iconname.to_glib_none().0, )) } } pub fn append_name(&self, iconname: &str) { unsafe { gio_sys::g_themed_icon_append_name(self.to_glib_none().0, iconname.to_glib_none().0); } } pub fn get_names(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_themed_icon_get_names( self.to_glib_none().0, )) } } pub fn prepend_name(&self, iconname: &str) { unsafe { gio_sys::g_themed_icon_prepend_name(self.to_glib_none().0, iconname.to_glib_none().0); } } pub fn get_property_use_default_fallbacks(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.as_ptr() as *mut gobject_sys::GObject, b"use-default-fallbacks\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } pub fn connect_property_names_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_names_trampoline( this: *mut gio_sys::GThemedIcon, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::names\0".as_ptr() as *const _, Some(transmute(notify_names_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ThemedIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ThemedIcon") } } gio-0.7.0/src/auto/threaded_socket_service.rs010064400007650000024000000061711350341657000175010ustar0000000000000000// 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 gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use SocketConnection; use SocketListener; use SocketService; glib_wrapper! { pub struct ThreadedSocketService(Object) @extends SocketService, SocketListener; match fn { get_type => || gio_sys::g_threaded_socket_service_get_type(), } } impl ThreadedSocketService { pub fn new(max_threads: i32) -> ThreadedSocketService { unsafe { SocketService::from_glib_full(gio_sys::g_threaded_socket_service_new(max_threads)) .unsafe_cast() } } } pub const NONE_THREADED_SOCKET_SERVICE: Option<&ThreadedSocketService> = None; pub trait ThreadedSocketServiceExt: 'static { fn get_property_max_threads(&self) -> i32; fn connect_run bool + 'static>( &self, f: F, ) -> SignalHandlerId; } impl> ThreadedSocketServiceExt for O { fn get_property_max_threads(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"max-threads\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_run bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn run_trampoline< P, F: Fn(&P, &SocketConnection, &glib::Object) -> bool + 'static, >( this: *mut gio_sys::GThreadedSocketService, connection: *mut gio_sys::GSocketConnection, source_object: *mut gobject_sys::GObject, f: glib_sys::gpointer, ) -> glib_sys::gboolean where P: IsA, { let f: &F = &*(f as *const F); f( &ThreadedSocketService::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(connection), &from_glib_borrow(source_object), ) .to_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"run\0".as_ptr() as *const _, Some(transmute(run_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ThreadedSocketService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ThreadedSocketService") } } gio-0.7.0/src/auto/tls_certificate.rs010064400007650000024000000122041350341657000157670ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::Value; use gobject_sys; use std; use std::fmt; use std::ptr; use Error; use SocketConnectable; use TlsCertificateFlags; glib_wrapper! { pub struct TlsCertificate(Object); match fn { get_type => || gio_sys::g_tls_certificate_get_type(), } } impl TlsCertificate { pub fn new_from_file>(file: P) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_certificate_new_from_file( file.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_files, Q: AsRef>( cert_file: P, key_file: Q, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_certificate_new_from_files( cert_file.as_ref().to_glib_none().0, key_file.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn new_from_pem(data: &str) -> Result { let length = data.len() as isize; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_certificate_new_from_pem(data.to_glib_none().0, length, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } pub fn list_new_from_file>( file: P, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_certificate_list_new_from_file( file.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub const NONE_TLS_CERTIFICATE: Option<&TlsCertificate> = None; pub trait TlsCertificateExt: 'static { fn get_issuer(&self) -> Option; fn is_same>(&self, cert_two: &P) -> bool; fn verify, Q: IsA>( &self, identity: Option<&P>, trusted_ca: Option<&Q>, ) -> TlsCertificateFlags; //fn get_property_certificate(&self) -> /*Ignored*/Option; fn get_property_certificate_pem(&self) -> Option; } impl> TlsCertificateExt for O { fn get_issuer(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_certificate_get_issuer( self.as_ref().to_glib_none().0, )) } } fn is_same>(&self, cert_two: &P) -> bool { unsafe { from_glib(gio_sys::g_tls_certificate_is_same( self.as_ref().to_glib_none().0, cert_two.as_ref().to_glib_none().0, )) } } fn verify, Q: IsA>( &self, identity: Option<&P>, trusted_ca: Option<&Q>, ) -> TlsCertificateFlags { unsafe { from_glib(gio_sys::g_tls_certificate_verify( self.as_ref().to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, trusted_ca.map(|p| p.as_ref()).to_glib_none().0, )) } } //fn get_property_certificate(&self) -> /*Ignored*/Option { // unsafe { // let mut value = Value::from_type(::static_type()); // gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"certificate\0".as_ptr() as *const _, value.to_glib_none_mut().0); // value.get() // } //} fn get_property_certificate_pem(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"certificate-pem\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } } impl fmt::Display for TlsCertificate { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsCertificate") } } gio-0.7.0/src/auto/tls_client_connection.rs010064400007650000024000000204011350341657000172000ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; use IOStream; use SocketConnectable; use TlsCertificateFlags; use TlsConnection; glib_wrapper! { pub struct TlsClientConnection(Interface) @requires TlsConnection, IOStream; match fn { get_type => || gio_sys::g_tls_client_connection_get_type(), } } impl TlsClientConnection { pub fn new, Q: IsA>( base_io_stream: &P, server_identity: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_client_connection_new( base_io_stream.as_ref().to_glib_none().0, server_identity.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub const NONE_TLS_CLIENT_CONNECTION: Option<&TlsClientConnection> = None; pub trait TlsClientConnectionExt: 'static { #[cfg(any(feature = "v2_46", feature = "dox"))] fn copy_session_state>(&self, source: &P); //fn get_accepted_cas(&self) -> /*Ignored*/Vec; fn get_server_identity(&self) -> Option; #[cfg_attr(feature = "v2_56", deprecated)] fn get_use_ssl3(&self) -> bool; fn get_validation_flags(&self) -> TlsCertificateFlags; fn set_server_identity>(&self, identity: &P); #[cfg_attr(feature = "v2_56", deprecated)] fn set_use_ssl3(&self, use_ssl3: bool); fn set_validation_flags(&self, flags: TlsCertificateFlags); fn connect_property_accepted_cas_notify(&self, f: F) -> SignalHandlerId; fn connect_property_server_identity_notify( &self, f: F, ) -> SignalHandlerId; #[cfg_attr(feature = "v2_56", deprecated)] fn connect_property_use_ssl3_notify(&self, f: F) -> SignalHandlerId; fn connect_property_validation_flags_notify( &self, f: F, ) -> SignalHandlerId; } impl> TlsClientConnectionExt for O { #[cfg(any(feature = "v2_46", feature = "dox"))] fn copy_session_state>(&self, source: &P) { unsafe { gio_sys::g_tls_client_connection_copy_session_state( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, ); } } //fn get_accepted_cas(&self) -> /*Ignored*/Vec { // unsafe { TODO: call gio_sys:g_tls_client_connection_get_accepted_cas() } //} fn get_server_identity(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_client_connection_get_server_identity( self.as_ref().to_glib_none().0, )) } } fn get_use_ssl3(&self) -> bool { unsafe { from_glib(gio_sys::g_tls_client_connection_get_use_ssl3( self.as_ref().to_glib_none().0, )) } } fn get_validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(gio_sys::g_tls_client_connection_get_validation_flags( self.as_ref().to_glib_none().0, )) } } fn set_server_identity>(&self, identity: &P) { unsafe { gio_sys::g_tls_client_connection_set_server_identity( self.as_ref().to_glib_none().0, identity.as_ref().to_glib_none().0, ); } } fn set_use_ssl3(&self, use_ssl3: bool) { unsafe { gio_sys::g_tls_client_connection_set_use_ssl3( self.as_ref().to_glib_none().0, use_ssl3.to_glib(), ); } } fn set_validation_flags(&self, flags: TlsCertificateFlags) { unsafe { gio_sys::g_tls_client_connection_set_validation_flags( self.as_ref().to_glib_none().0, flags.to_glib(), ); } } fn connect_property_accepted_cas_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_accepted_cas_trampoline( this: *mut gio_sys::GTlsClientConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::accepted-cas\0".as_ptr() as *const _, Some(transmute( notify_accepted_cas_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_server_identity_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_server_identity_trampoline( this: *mut gio_sys::GTlsClientConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::server-identity\0".as_ptr() as *const _, Some(transmute( notify_server_identity_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_use_ssl3_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_use_ssl3_trampoline( this: *mut gio_sys::GTlsClientConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::use-ssl3\0".as_ptr() as *const _, Some(transmute(notify_use_ssl3_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_validation_flags_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_validation_flags_trampoline( this: *mut gio_sys::GTlsClientConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsClientConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::validation-flags\0".as_ptr() as *const _, Some(transmute( notify_validation_flags_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsClientConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsClientConnection") } } gio-0.7.0/src/auto/tls_connection.rs010064400007650000024000000417501350341657000156540ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use IOStream; use TlsCertificate; use TlsCertificateFlags; use TlsDatabase; use TlsInteraction; use TlsRehandshakeMode; glib_wrapper! { pub struct TlsConnection(Object) @extends IOStream; match fn { get_type => || gio_sys::g_tls_connection_get_type(), } } pub const NONE_TLS_CONNECTION: Option<&TlsConnection> = None; pub trait TlsConnectionExt: 'static { fn emit_accept_certificate>( &self, peer_cert: &P, errors: TlsCertificateFlags, ) -> bool; fn get_certificate(&self) -> Option; fn get_database(&self) -> Option; fn get_interaction(&self) -> Option; fn get_peer_certificate(&self) -> Option; fn get_peer_certificate_errors(&self) -> TlsCertificateFlags; fn get_rehandshake_mode(&self) -> TlsRehandshakeMode; fn get_require_close_notify(&self) -> bool; fn handshake>(&self, cancellable: Option<&P>) -> Result<(), Error>; fn handshake_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn handshake_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin>; fn set_certificate>(&self, certificate: &P); fn set_database>(&self, database: &P); fn set_interaction>(&self, interaction: Option<&P>); fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode); fn set_require_close_notify(&self, require_close_notify: bool); fn get_property_base_io_stream(&self) -> Option; fn connect_accept_certificate< F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId; fn connect_property_certificate_notify(&self, f: F) -> SignalHandlerId; fn connect_property_database_notify(&self, f: F) -> SignalHandlerId; fn connect_property_interaction_notify(&self, f: F) -> SignalHandlerId; fn connect_property_peer_certificate_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_peer_certificate_errors_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_rehandshake_mode_notify( &self, f: F, ) -> SignalHandlerId; fn connect_property_require_close_notify_notify( &self, f: F, ) -> SignalHandlerId; } impl> TlsConnectionExt for O { fn emit_accept_certificate>( &self, peer_cert: &P, errors: TlsCertificateFlags, ) -> bool { unsafe { from_glib(gio_sys::g_tls_connection_emit_accept_certificate( self.as_ref().to_glib_none().0, peer_cert.as_ref().to_glib_none().0, errors.to_glib(), )) } } fn get_certificate(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_connection_get_certificate( self.as_ref().to_glib_none().0, )) } } fn get_database(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_connection_get_database( self.as_ref().to_glib_none().0, )) } } fn get_interaction(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_connection_get_interaction( self.as_ref().to_glib_none().0, )) } } fn get_peer_certificate(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_connection_get_peer_certificate( self.as_ref().to_glib_none().0, )) } } fn get_peer_certificate_errors(&self) -> TlsCertificateFlags { unsafe { from_glib(gio_sys::g_tls_connection_get_peer_certificate_errors( self.as_ref().to_glib_none().0, )) } } fn get_rehandshake_mode(&self) -> TlsRehandshakeMode { unsafe { from_glib(gio_sys::g_tls_connection_get_rehandshake_mode( self.as_ref().to_glib_none().0, )) } } fn get_require_close_notify(&self) -> bool { unsafe { from_glib(gio_sys::g_tls_connection_get_require_close_notify( self.as_ref().to_glib_none().0, )) } } fn handshake>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); let _ = gio_sys::g_tls_connection_handshake( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn handshake_async, Q: FnOnce(Result<(), Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn handshake_async_trampoline< Q: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_tls_connection_handshake_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = handshake_async_trampoline::; unsafe { gio_sys::g_tls_connection_handshake_async( self.as_ref().to_glib_none().0, io_priority.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn handshake_async_future( &self, io_priority: glib::Priority, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.handshake_async(io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn set_certificate>(&self, certificate: &P) { unsafe { gio_sys::g_tls_connection_set_certificate( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, ); } } fn set_database>(&self, database: &P) { unsafe { gio_sys::g_tls_connection_set_database( self.as_ref().to_glib_none().0, database.as_ref().to_glib_none().0, ); } } fn set_interaction>(&self, interaction: Option<&P>) { unsafe { gio_sys::g_tls_connection_set_interaction( self.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, ); } } fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode) { unsafe { gio_sys::g_tls_connection_set_rehandshake_mode( self.as_ref().to_glib_none().0, mode.to_glib(), ); } } fn set_require_close_notify(&self, require_close_notify: bool) { unsafe { gio_sys::g_tls_connection_set_require_close_notify( self.as_ref().to_glib_none().0, require_close_notify.to_glib(), ); } } fn get_property_base_io_stream(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"base-io-stream\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn connect_accept_certificate< F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn accept_certificate_trampoline< P, F: Fn(&P, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( this: *mut gio_sys::GTlsConnection, peer_cert: *mut gio_sys::GTlsCertificate, errors: gio_sys::GTlsCertificateFlags, f: glib_sys::gpointer, ) -> glib_sys::gboolean where P: IsA, { let f: &F = &*(f as *const F); f( &TlsConnection::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(peer_cert), from_glib(errors), ) .to_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"accept-certificate\0".as_ptr() as *const _, Some(transmute(accept_certificate_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_certificate_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_certificate_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::certificate\0".as_ptr() as *const _, Some(transmute(notify_certificate_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_database_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_database_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::database\0".as_ptr() as *const _, Some(transmute(notify_database_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_interaction_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_interaction_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::interaction\0".as_ptr() as *const _, Some(transmute(notify_interaction_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_peer_certificate_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_peer_certificate_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::peer-certificate\0".as_ptr() as *const _, Some(transmute( notify_peer_certificate_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_peer_certificate_errors_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_peer_certificate_errors_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::peer-certificate-errors\0".as_ptr() as *const _, Some(transmute( notify_peer_certificate_errors_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_rehandshake_mode_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_rehandshake_mode_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::rehandshake-mode\0".as_ptr() as *const _, Some(transmute( notify_rehandshake_mode_trampoline:: as usize, )), Box_::into_raw(f), ) } } fn connect_property_require_close_notify_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_require_close_notify_trampoline( this: *mut gio_sys::GTlsConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::require-close-notify\0".as_ptr() as *const _, Some(transmute( notify_require_close_notify_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsConnection") } } gio-0.7.0/src/auto/tls_database.rs010064400007650000024000000455511350341657000152640ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use SocketConnectable; use TlsCertificate; use TlsCertificateFlags; use TlsDatabaseLookupFlags; use TlsDatabaseVerifyFlags; use TlsInteraction; glib_wrapper! { pub struct TlsDatabase(Object); match fn { get_type => || gio_sys::g_tls_database_get_type(), } } pub const NONE_TLS_DATABASE: Option<&TlsDatabase> = None; pub trait TlsDatabaseExt: 'static { fn create_certificate_handle>(&self, certificate: &P) -> Option; fn lookup_certificate_for_handle, Q: IsA>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, Error>; fn lookup_certificate_for_handle_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn lookup_certificate_for_handle_async_future + Clone + 'static>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, ) -> Box_> + std::marker::Unpin>; fn lookup_certificate_issuer< P: IsA, Q: IsA, R: IsA, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, ) -> Result; fn lookup_certificate_issuer_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, callback: S, ); #[cfg(feature = "futures")] fn lookup_certificate_issuer_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, ) -> Box_> + std::marker::Unpin>; //fn lookup_certificates_issued_by, Q: IsA>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>) -> Result, Error>; //fn lookup_certificates_issued_by_async, Q: IsA, R: FnOnce(Result, Error>) + Send + 'static>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R); //#[cfg(feature = "futures")] //fn lookup_certificates_issued_by_async_future + Clone + 'static>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags) -> Box_, Error>> + std::marker::Unpin>; fn verify_chain< P: IsA, Q: IsA, R: IsA, S: IsA, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, ) -> Result; fn verify_chain_async< P: IsA, Q: IsA, R: IsA, S: IsA, T: FnOnce(Result) + Send + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, callback: T, ); #[cfg(feature = "futures")] fn verify_chain_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, R: IsA + Clone + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, ) -> Box_> + std::marker::Unpin>; } impl> TlsDatabaseExt for O { fn create_certificate_handle>( &self, certificate: &P, ) -> Option { unsafe { from_glib_full(gio_sys::g_tls_database_create_certificate_handle( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, )) } } fn lookup_certificate_for_handle, Q: IsA>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_lookup_certificate_for_handle( self.as_ref().to_glib_none().0, handle.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_certificate_for_handle_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_certificate_for_handle_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_lookup_certificate_for_handle_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_certificate_for_handle_async_trampoline::; unsafe { gio_sys::g_tls_database_lookup_certificate_for_handle_async( self.as_ref().to_glib_none().0, handle.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_certificate_for_handle_async_future + Clone + 'static>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let handle = String::from(handle); let interaction = interaction.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_certificate_for_handle_async( &handle, interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn lookup_certificate_issuer< P: IsA, Q: IsA, R: IsA, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_lookup_certificate_issuer( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn lookup_certificate_issuer_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, callback: S, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn lookup_certificate_issuer_async_trampoline< S: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_lookup_certificate_issuer_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lookup_certificate_issuer_async_trampoline::; unsafe { gio_sys::g_tls_database_lookup_certificate_issuer_async( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn lookup_certificate_issuer_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let certificate = certificate.clone(); let interaction = interaction.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.lookup_certificate_issuer_async( &certificate, interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } //fn lookup_certificates_issued_by, Q: IsA>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>) -> Result, Error> { // unsafe { TODO: call gio_sys:g_tls_database_lookup_certificates_issued_by() } //} //fn lookup_certificates_issued_by_async, Q: IsA, R: FnOnce(Result, Error>) + Send + 'static>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R) { // unsafe { TODO: call gio_sys:g_tls_database_lookup_certificates_issued_by_async() } //} //#[cfg(feature = "futures")] //fn lookup_certificates_issued_by_async_future + Clone + 'static>(&self, issuer_raw_dn: /*Ignored*/&glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags) -> Box_, Error>> + std::marker::Unpin> { //use GioFuture; //use fragile::Fragile; //let issuer_raw_dn = issuer_raw_dn.clone(); //let interaction = interaction.map(ToOwned::to_owned); //GioFuture::new(self, move |obj, send| { // let cancellable = Cancellable::new(); // let send = Fragile::new(send); // obj.lookup_certificates_issued_by_async( // &issuer_raw_dn, // interaction.as_ref().map(::std::borrow::Borrow::borrow), // flags, // Some(&cancellable), // move |res| { // let _ = send.into_inner().send(res); // }, // ); // cancellable //}) //} fn verify_chain< P: IsA, Q: IsA, R: IsA, S: IsA, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_verify_chain( self.as_ref().to_glib_none().0, chain.as_ref().to_glib_none().0, purpose.to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } fn verify_chain_async< P: IsA, Q: IsA, R: IsA, S: IsA, T: FnOnce(Result) + Send + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, callback: T, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn verify_chain_async_trampoline< T: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_database_verify_chain_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = verify_chain_async_trampoline::; unsafe { gio_sys::g_tls_database_verify_chain_async( self.as_ref().to_glib_none().0, chain.as_ref().to_glib_none().0, purpose.to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn verify_chain_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, R: IsA + Clone + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let chain = chain.clone(); let purpose = String::from(purpose); let identity = identity.map(ToOwned::to_owned); let interaction = interaction.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.verify_chain_async( &chain, &purpose, identity.as_ref().map(::std::borrow::Borrow::borrow), interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } } impl fmt::Display for TlsDatabase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsDatabase") } } gio-0.7.0/src/auto/tls_file_database.rs010064400007650000024000000063011350341657000162510ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; use TlsDatabase; glib_wrapper! { pub struct TlsFileDatabase(Interface) @requires TlsDatabase; match fn { get_type => || gio_sys::g_tls_file_database_get_type(), } } impl TlsFileDatabase { pub fn new>(anchors: P) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_file_database_new(anchors.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub const NONE_TLS_FILE_DATABASE: Option<&TlsFileDatabase> = None; pub trait TlsFileDatabaseExt: 'static { fn get_property_anchors(&self) -> Option; fn set_property_anchors(&self, anchors: Option<&str>); fn connect_property_anchors_notify(&self, f: F) -> SignalHandlerId; } impl> TlsFileDatabaseExt for O { fn get_property_anchors(&self) -> Option { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"anchors\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get() } } fn set_property_anchors(&self, anchors: Option<&str>) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"anchors\0".as_ptr() as *const _, Value::from(anchors).to_glib_none().0, ); } } fn connect_property_anchors_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_anchors_trampoline( this: *mut gio_sys::GTlsFileDatabase, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsFileDatabase::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::anchors\0".as_ptr() as *const _, Some(transmute(notify_anchors_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for TlsFileDatabase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsFileDatabase") } } gio-0.7.0/src/auto/tls_interaction.rs010064400007650000024000000244121350341657000160300ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; #[cfg(feature = "futures")] use std::boxed::Box as Box_; use std::fmt; use std::ptr; use Cancellable; use Error; use TlsCertificateRequestFlags; use TlsConnection; use TlsInteractionResult; use TlsPassword; glib_wrapper! { pub struct TlsInteraction(Object); match fn { get_type => || gio_sys::g_tls_interaction_get_type(), } } pub const NONE_TLS_INTERACTION: Option<&TlsInteraction> = None; pub trait TlsInteractionExt: 'static { fn ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result; fn ask_password_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, password: &P, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn ask_password_async_future + Clone + 'static>( &self, password: &P, ) -> Box_> + std::marker::Unpin>; fn invoke_ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result; fn invoke_request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result; fn request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result; fn request_certificate_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn request_certificate_async_future + Clone + 'static>( &self, connection: &P, flags: TlsCertificateRequestFlags, ) -> Box_> + std::marker::Unpin>; } impl> TlsInteractionExt for O { fn ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_ask_password( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } fn ask_password_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, password: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn ask_password_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_ask_password_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = ask_password_async_trampoline::; unsafe { gio_sys::g_tls_interaction_ask_password_async( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn ask_password_async_future + Clone + 'static>( &self, password: &P, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let password = password.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.ask_password_async(&password, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn invoke_ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_invoke_ask_password( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } fn invoke_request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_invoke_request_certificate( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } fn request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_request_certificate( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } fn request_certificate_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn request_certificate_async_trampoline< R: FnOnce(Result) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_interaction_request_certificate_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = request_certificate_async_trampoline::; unsafe { gio_sys::g_tls_interaction_request_certificate_async( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn request_certificate_async_future + Clone + 'static>( &self, connection: &P, flags: TlsCertificateRequestFlags, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let connection = connection.clone(); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.request_certificate_async(&connection, flags, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } impl fmt::Display for TlsInteraction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsInteraction") } } gio-0.7.0/src/auto/tls_password.rs010064400007650000024000000130421350341657000153500ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use TlsPasswordFlags; glib_wrapper! { pub struct TlsPassword(Object); match fn { get_type => || gio_sys::g_tls_password_get_type(), } } impl TlsPassword { pub fn new(flags: TlsPasswordFlags, description: &str) -> TlsPassword { unsafe { from_glib_full(gio_sys::g_tls_password_new( flags.to_glib(), description.to_glib_none().0, )) } } } pub const NONE_TLS_PASSWORD: Option<&TlsPassword> = None; pub trait TlsPasswordExt: 'static { fn get_description(&self) -> Option; fn get_flags(&self) -> TlsPasswordFlags; fn get_warning(&self) -> Option; fn set_description(&self, description: &str); fn set_flags(&self, flags: TlsPasswordFlags); //fn set_value_full(&self, value: &[u8]); fn set_warning(&self, warning: &str); fn connect_property_description_notify(&self, f: F) -> SignalHandlerId; fn connect_property_flags_notify(&self, f: F) -> SignalHandlerId; fn connect_property_warning_notify(&self, f: F) -> SignalHandlerId; } impl> TlsPasswordExt for O { fn get_description(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_password_get_description( self.as_ref().to_glib_none().0, )) } } fn get_flags(&self) -> TlsPasswordFlags { unsafe { from_glib(gio_sys::g_tls_password_get_flags( self.as_ref().to_glib_none().0, )) } } fn get_warning(&self) -> Option { unsafe { from_glib_none(gio_sys::g_tls_password_get_warning( self.as_ref().to_glib_none().0, )) } } fn set_description(&self, description: &str) { unsafe { gio_sys::g_tls_password_set_description( self.as_ref().to_glib_none().0, description.to_glib_none().0, ); } } fn set_flags(&self, flags: TlsPasswordFlags) { unsafe { gio_sys::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.to_glib()); } } //fn set_value_full(&self, value: &[u8]) { // unsafe { TODO: call gio_sys:g_tls_password_set_value_full() } //} fn set_warning(&self, warning: &str) { unsafe { gio_sys::g_tls_password_set_warning( self.as_ref().to_glib_none().0, warning.to_glib_none().0, ); } } fn connect_property_description_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_description_trampoline( this: *mut gio_sys::GTlsPassword, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsPassword::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::description\0".as_ptr() as *const _, Some(transmute(notify_description_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_flags_trampoline( this: *mut gio_sys::GTlsPassword, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsPassword::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::flags\0".as_ptr() as *const _, Some(transmute(notify_flags_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_property_warning_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_warning_trampoline( this: *mut gio_sys::GTlsPassword, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsPassword::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::warning\0".as_ptr() as *const _, Some(transmute(notify_warning_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for TlsPassword { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsPassword") } } gio-0.7.0/src/auto/tls_server_connection.rs010064400007650000024000000074221350341657000172400ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Error; use IOStream; use TlsAuthenticationMode; use TlsCertificate; use TlsConnection; glib_wrapper! { pub struct TlsServerConnection(Interface) @requires TlsConnection, IOStream; match fn { get_type => || gio_sys::g_tls_server_connection_get_type(), } } impl TlsServerConnection { pub fn new, Q: IsA>( base_io_stream: &P, certificate: Option<&Q>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_tls_server_connection_new( base_io_stream.as_ref().to_glib_none().0, certificate.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } pub const NONE_TLS_SERVER_CONNECTION: Option<&TlsServerConnection> = None; pub trait TlsServerConnectionExt: 'static { fn get_property_authentication_mode(&self) -> TlsAuthenticationMode; fn set_property_authentication_mode(&self, authentication_mode: TlsAuthenticationMode); fn connect_property_authentication_mode_notify( &self, f: F, ) -> SignalHandlerId; } impl> TlsServerConnectionExt for O { fn get_property_authentication_mode(&self) -> TlsAuthenticationMode { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"authentication-mode\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn set_property_authentication_mode(&self, authentication_mode: TlsAuthenticationMode) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"authentication-mode\0".as_ptr() as *const _, Value::from(&authentication_mode).to_glib_none().0, ); } } fn connect_property_authentication_mode_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_authentication_mode_trampoline( this: *mut gio_sys::GTlsServerConnection, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&TlsServerConnection::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::authentication-mode\0".as_ptr() as *const _, Some(transmute( notify_authentication_mode_trampoline:: as usize, )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsServerConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "TlsServerConnection") } } gio-0.7.0/src/auto/unix_input_stream.rs010064400007650000024000000020741350341657000164040ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use InputStream; use PollableInputStream; glib_wrapper! { pub struct UnixInputStream(Object) @extends InputStream, @implements PollableInputStream; match fn { get_type => || gio_sys::g_unix_input_stream_get_type(), } } pub const NONE_UNIX_INPUT_STREAM: Option<&UnixInputStream> = None; pub trait UnixInputStreamExt: 'static { fn get_close_fd(&self) -> bool; } impl> UnixInputStreamExt for O { fn get_close_fd(&self) -> bool { unsafe { from_glib(gio_sys::g_unix_input_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for UnixInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UnixInputStream") } } gio-0.7.0/src/auto/unix_output_stream.rs010064400007650000024000000021151350341657000166010ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use std::fmt; use OutputStream; use PollableOutputStream; glib_wrapper! { pub struct UnixOutputStream(Object) @extends OutputStream, @implements PollableOutputStream; match fn { get_type => || gio_sys::g_unix_output_stream_get_type(), } } pub const NONE_UNIX_OUTPUT_STREAM: Option<&UnixOutputStream> = None; pub trait UnixOutputStreamExt: 'static { fn get_close_fd(&self) -> bool; } impl> UnixOutputStreamExt for O { fn get_close_fd(&self) -> bool { unsafe { from_glib(gio_sys::g_unix_output_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for UnixOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UnixOutputStream") } } gio-0.7.0/src/auto/unix_socket_address.rs010064400007650000024000000063561350341657000166760ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::Value; use gobject_sys; use std::fmt; use SocketAddress; use SocketConnectable; use UnixSocketAddressType; glib_wrapper! { pub struct UnixSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; match fn { get_type => || gio_sys::g_unix_socket_address_get_type(), } } impl UnixSocketAddress { //pub fn new_abstract(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }) -> UnixSocketAddress { // unsafe { TODO: call gio_sys:g_unix_socket_address_new_abstract() } //} //pub fn new_with_type(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }, type_: UnixSocketAddressType) -> UnixSocketAddress { // unsafe { TODO: call gio_sys:g_unix_socket_address_new_with_type() } //} pub fn abstract_names_supported() -> bool { unsafe { from_glib(gio_sys::g_unix_socket_address_abstract_names_supported()) } } } unsafe impl Send for UnixSocketAddress {} unsafe impl Sync for UnixSocketAddress {} pub const NONE_UNIX_SOCKET_ADDRESS: Option<&UnixSocketAddress> = None; pub trait UnixSocketAddressExt: 'static { fn get_address_type(&self) -> UnixSocketAddressType; fn get_is_abstract(&self) -> bool; fn get_path_len(&self) -> usize; fn get_property_abstract(&self) -> bool; //fn get_property_path_as_array(&self) -> /*Ignored*/Option; } impl> UnixSocketAddressExt for O { fn get_address_type(&self) -> UnixSocketAddressType { unsafe { from_glib(gio_sys::g_unix_socket_address_get_address_type( self.as_ref().to_glib_none().0, )) } } fn get_is_abstract(&self) -> bool { unsafe { from_glib(gio_sys::g_unix_socket_address_get_is_abstract( self.as_ref().to_glib_none().0, )) } } fn get_path_len(&self) -> usize { unsafe { gio_sys::g_unix_socket_address_get_path_len(self.as_ref().to_glib_none().0) } } fn get_property_abstract(&self) -> bool { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"abstract\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } //fn get_property_path_as_array(&self) -> /*Ignored*/Option { // unsafe { // let mut value = Value::from_type(::static_type()); // gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"path-as-array\0".as_ptr() as *const _, value.to_glib_none_mut().0); // value.get() // } //} } impl fmt::Display for UnixSocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "UnixSocketAddress") } } gio-0.7.0/src/auto/versions.txt010064400007650000024000000001721350341657000146670ustar0000000000000000Generated by gir (https://github.com/gtk-rs/gir @ 1dbb0ee) from gir-files (https://github.com/gtk-rs/gir-files @ 617a344) gio-0.7.0/src/auto/vfs.rs010064400007650000024000000145161350341657000134310ustar0000000000000000// 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 gio_sys; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::boxed::Box as Box_; use std::fmt; use File; glib_wrapper! { pub struct Vfs(Object); match fn { get_type => || gio_sys::g_vfs_get_type(), } } impl Vfs { pub fn get_default() -> Option { unsafe { from_glib_none(gio_sys::g_vfs_get_default()) } } pub fn get_local() -> Option { unsafe { from_glib_none(gio_sys::g_vfs_get_local()) } } } unsafe impl Send for Vfs {} unsafe impl Sync for Vfs {} pub const NONE_VFS: Option<&Vfs> = None; pub trait VfsExt: 'static { fn get_file_for_path(&self, path: &str) -> Option; fn get_file_for_uri(&self, uri: &str) -> Option; fn get_supported_uri_schemes(&self) -> Vec; fn is_active(&self) -> bool; fn parse_name(&self, parse_name: &str) -> Option; #[cfg(any(feature = "v2_50", feature = "dox"))] fn register_uri_scheme( &self, scheme: &str, uri_func: Option File + 'static>>, parse_name_func: Option File + 'static>>, ) -> bool; #[cfg(any(feature = "v2_50", feature = "dox"))] fn unregister_uri_scheme(&self, scheme: &str) -> bool; } impl> VfsExt for O { fn get_file_for_path(&self, path: &str) -> Option { unsafe { from_glib_full(gio_sys::g_vfs_get_file_for_path( self.as_ref().to_glib_none().0, path.to_glib_none().0, )) } } fn get_file_for_uri(&self, uri: &str) -> Option { unsafe { from_glib_full(gio_sys::g_vfs_get_file_for_uri( self.as_ref().to_glib_none().0, uri.to_glib_none().0, )) } } fn get_supported_uri_schemes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(gio_sys::g_vfs_get_supported_uri_schemes( self.as_ref().to_glib_none().0, )) } } fn is_active(&self) -> bool { unsafe { from_glib(gio_sys::g_vfs_is_active(self.as_ref().to_glib_none().0)) } } fn parse_name(&self, parse_name: &str) -> Option { unsafe { from_glib_full(gio_sys::g_vfs_parse_name( self.as_ref().to_glib_none().0, parse_name.to_glib_none().0, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn register_uri_scheme( &self, scheme: &str, uri_func: Option File + 'static>>, parse_name_func: Option File + 'static>>, ) -> bool { let uri_func_data: Box_ File + 'static>>> = Box::new(uri_func); unsafe extern "C" fn uri_func_func( vfs: *mut gio_sys::GVfs, identifier: *const libc::c_char, user_data: glib_sys::gpointer, ) -> *mut gio_sys::GFile { let vfs = from_glib_borrow(vfs); let identifier: GString = from_glib_borrow(identifier); let callback: &Option File + 'static>> = &*(user_data as *mut _); let res = if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") }; res.to_glib_full() } let uri_func = if uri_func_data.is_some() { Some(uri_func_func as _) } else { None }; let parse_name_func_data: Box_ File + 'static>>> = Box::new(parse_name_func); unsafe extern "C" fn parse_name_func_func( vfs: *mut gio_sys::GVfs, identifier: *const libc::c_char, user_data: glib_sys::gpointer, ) -> *mut gio_sys::GFile { let vfs = from_glib_borrow(vfs); let identifier: GString = from_glib_borrow(identifier); let callback: &Option File + 'static>> = &*(user_data as *mut _); let res = if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") }; res.to_glib_full() } let parse_name_func = if parse_name_func_data.is_some() { Some(parse_name_func_func as _) } else { None }; unsafe extern "C" fn uri_destroy_func(data: glib_sys::gpointer) { let _callback: Box_ File + 'static>>> = Box_::from_raw(data as *mut _); } let destroy_call4 = Some(uri_destroy_func as _); unsafe extern "C" fn parse_name_destroy_func(data: glib_sys::gpointer) { let _callback: Box_ File + 'static>>> = Box_::from_raw(data as *mut _); } let destroy_call7 = Some(parse_name_destroy_func as _); let super_callback0: Box_ File + 'static>>> = uri_func_data; let super_callback1: Box_ File + 'static>>> = parse_name_func_data; unsafe { from_glib(gio_sys::g_vfs_register_uri_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, uri_func, Box::into_raw(super_callback0) as *mut _, destroy_call4, parse_name_func, Box::into_raw(super_callback1) as *mut _, destroy_call7, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] fn unregister_uri_scheme(&self, scheme: &str) -> bool { unsafe { from_glib(gio_sys::g_vfs_unregister_uri_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, )) } } } impl fmt::Display for Vfs { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Vfs") } } gio-0.7.0/src/auto/volume.rs010064400007650000024000000261211350341657000141350ustar0000000000000000// 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 #[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; use Cancellable; use Drive; use Error; use File; use Icon; use Mount; use MountMountFlags; use MountOperation; use MountUnmountFlags; glib_wrapper! { pub struct Volume(Interface); match fn { get_type => || gio_sys::g_volume_get_type(), } } pub const NONE_VOLUME: Option<&Volume> = None; pub trait VolumeExt: 'static { fn can_eject(&self) -> bool; fn can_mount(&self) -> bool; fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn enumerate_identifiers(&self) -> Vec; fn get_activation_root(&self) -> Option; fn get_drive(&self) -> Option; fn get_icon(&self) -> Option; fn get_identifier(&self, kind: &str) -> Option; fn get_mount(&self) -> Option; fn get_name(&self) -> Option; fn get_sort_key(&self) -> Option; fn get_symbolic_icon(&self) -> Option; fn get_uuid(&self) -> Option; fn mount< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(feature = "futures")] fn mount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin>; fn should_automount(&self) -> bool; fn connect_changed(&self, f: F) -> SignalHandlerId; fn connect_removed(&self, f: F) -> SignalHandlerId; } impl> VolumeExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(gio_sys::g_volume_can_eject(self.as_ref().to_glib_none().0)) } } fn can_mount(&self) -> bool { unsafe { from_glib(gio_sys::g_volume_can_mount(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_volume_eject_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = eject_with_operation_trampoline::; unsafe { gio_sys::g_volume_eject_with_operation( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_volume_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } fn get_activation_root(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_activation_root( self.as_ref().to_glib_none().0, )) } } fn get_drive(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_drive(self.as_ref().to_glib_none().0)) } } fn get_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_icon(self.as_ref().to_glib_none().0)) } } fn get_identifier(&self, kind: &str) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_identifier( self.as_ref().to_glib_none().0, kind.to_glib_none().0, )) } } fn get_mount(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_mount(self.as_ref().to_glib_none().0)) } } fn get_name(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_name(self.as_ref().to_glib_none().0)) } } fn get_sort_key(&self) -> Option { unsafe { from_glib_none(gio_sys::g_volume_get_sort_key( self.as_ref().to_glib_none().0, )) } } fn get_symbolic_icon(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn get_uuid(&self) -> Option { unsafe { from_glib_full(gio_sys::g_volume_get_uuid(self.as_ref().to_glib_none().0)) } } fn mount< P: IsA, Q: IsA, R: FnOnce(Result<(), Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn mount_trampoline) + Send + 'static>( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let _ = gio_sys::g_volume_mount_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = mount_trampoline::; unsafe { gio_sys::g_volume_mount( self.as_ref().to_glib_none().0, flags.to_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn mount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Box_> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let mount_operation = mount_operation.map(ToOwned::to_owned); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.mount( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } fn should_automount(&self) -> bool { unsafe { from_glib(gio_sys::g_volume_should_automount( self.as_ref().to_glib_none().0, )) } } fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut gio_sys::GVolume, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Volume::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn removed_trampoline( this: *mut gio_sys::GVolume, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&Volume::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"removed\0".as_ptr() as *const _, Some(transmute(removed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for Volume { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Volume") } } gio-0.7.0/src/auto/volume_monitor.rs010064400007650000024000000342241350341657000157070ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Drive; use Mount; use Volume; glib_wrapper! { pub struct VolumeMonitor(Object); match fn { get_type => || gio_sys::g_volume_monitor_get_type(), } } impl VolumeMonitor { pub fn get() -> VolumeMonitor { unsafe { from_glib_full(gio_sys::g_volume_monitor_get()) } } } pub const NONE_VOLUME_MONITOR: Option<&VolumeMonitor> = None; pub trait VolumeMonitorExt: 'static { fn get_connected_drives(&self) -> Vec; fn get_mount_for_uuid(&self, uuid: &str) -> Option; fn get_mounts(&self) -> Vec; fn get_volume_for_uuid(&self, uuid: &str) -> Option; fn get_volumes(&self) -> Vec; fn connect_drive_changed(&self, f: F) -> SignalHandlerId; fn connect_drive_connected(&self, f: F) -> SignalHandlerId; fn connect_drive_disconnected(&self, f: F) -> SignalHandlerId; fn connect_drive_eject_button(&self, f: F) -> SignalHandlerId; fn connect_drive_stop_button(&self, f: F) -> SignalHandlerId; fn connect_mount_added(&self, f: F) -> SignalHandlerId; fn connect_mount_changed(&self, f: F) -> SignalHandlerId; fn connect_mount_pre_unmount(&self, f: F) -> SignalHandlerId; fn connect_mount_removed(&self, f: F) -> SignalHandlerId; fn connect_volume_added(&self, f: F) -> SignalHandlerId; fn connect_volume_changed(&self, f: F) -> SignalHandlerId; fn connect_volume_removed(&self, f: F) -> SignalHandlerId; } impl> VolumeMonitorExt for O { fn get_connected_drives(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_volume_monitor_get_connected_drives( self.as_ref().to_glib_none().0, )) } } fn get_mount_for_uuid(&self, uuid: &str) -> Option { unsafe { from_glib_full(gio_sys::g_volume_monitor_get_mount_for_uuid( self.as_ref().to_glib_none().0, uuid.to_glib_none().0, )) } } fn get_mounts(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_volume_monitor_get_mounts( self.as_ref().to_glib_none().0, )) } } fn get_volume_for_uuid(&self, uuid: &str) -> Option { unsafe { from_glib_full(gio_sys::g_volume_monitor_get_volume_for_uuid( self.as_ref().to_glib_none().0, uuid.to_glib_none().0, )) } } fn get_volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(gio_sys::g_volume_monitor_get_volumes( self.as_ref().to_glib_none().0, )) } } fn connect_drive_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_changed_trampoline( this: *mut gio_sys::GVolumeMonitor, drive: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-changed\0".as_ptr() as *const _, Some(transmute(drive_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_drive_connected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_connected_trampoline( this: *mut gio_sys::GVolumeMonitor, drive: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-connected\0".as_ptr() as *const _, Some(transmute(drive_connected_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_drive_disconnected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_disconnected_trampoline( this: *mut gio_sys::GVolumeMonitor, drive: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-disconnected\0".as_ptr() as *const _, Some(transmute(drive_disconnected_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_drive_eject_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_eject_button_trampoline( this: *mut gio_sys::GVolumeMonitor, drive: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-eject-button\0".as_ptr() as *const _, Some(transmute(drive_eject_button_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_drive_stop_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_stop_button_trampoline( this: *mut gio_sys::GVolumeMonitor, drive: *mut gio_sys::GDrive, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-stop-button\0".as_ptr() as *const _, Some(transmute(drive_stop_button_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_mount_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_added_trampoline( this: *mut gio_sys::GVolumeMonitor, mount: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-added\0".as_ptr() as *const _, Some(transmute(mount_added_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_mount_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_changed_trampoline( this: *mut gio_sys::GVolumeMonitor, mount: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-changed\0".as_ptr() as *const _, Some(transmute(mount_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_mount_pre_unmount(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_pre_unmount_trampoline( this: *mut gio_sys::GVolumeMonitor, mount: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-pre-unmount\0".as_ptr() as *const _, Some(transmute(mount_pre_unmount_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_mount_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_removed_trampoline( this: *mut gio_sys::GVolumeMonitor, mount: *mut gio_sys::GMount, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-removed\0".as_ptr() as *const _, Some(transmute(mount_removed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_volume_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_added_trampoline( this: *mut gio_sys::GVolumeMonitor, volume: *mut gio_sys::GVolume, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-added\0".as_ptr() as *const _, Some(transmute(volume_added_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_volume_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_changed_trampoline( this: *mut gio_sys::GVolumeMonitor, volume: *mut gio_sys::GVolume, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-changed\0".as_ptr() as *const _, Some(transmute(volume_changed_trampoline:: as usize)), Box_::into_raw(f), ) } } fn connect_volume_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_removed_trampoline( this: *mut gio_sys::GVolumeMonitor, volume: *mut gio_sys::GVolume, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( &VolumeMonitor::from_glib_borrow(this).unsafe_cast(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-removed\0".as_ptr() as *const _, Some(transmute(volume_removed_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for VolumeMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "VolumeMonitor") } } gio-0.7.0/src/auto/zlib_compressor.rs010064400007650000024000000071711350341657000160460ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Converter; use FileInfo; use ZlibCompressorFormat; glib_wrapper! { pub struct ZlibCompressor(Object) @implements Converter; match fn { get_type => || gio_sys::g_zlib_compressor_get_type(), } } impl ZlibCompressor { pub fn new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor { unsafe { from_glib_full(gio_sys::g_zlib_compressor_new(format.to_glib(), level)) } } } pub const NONE_ZLIB_COMPRESSOR: Option<&ZlibCompressor> = None; pub trait ZlibCompressorExt: 'static { fn get_file_info(&self) -> Option; fn set_file_info(&self, file_info: Option<&FileInfo>); fn get_property_format(&self) -> ZlibCompressorFormat; fn get_property_level(&self) -> i32; fn connect_property_file_info_notify(&self, f: F) -> SignalHandlerId; } impl> ZlibCompressorExt for O { fn get_file_info(&self) -> Option { unsafe { from_glib_none(gio_sys::g_zlib_compressor_get_file_info( self.as_ref().to_glib_none().0, )) } } fn set_file_info(&self, file_info: Option<&FileInfo>) { unsafe { gio_sys::g_zlib_compressor_set_file_info( self.as_ref().to_glib_none().0, file_info.to_glib_none().0, ); } } fn get_property_format(&self) -> ZlibCompressorFormat { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"format\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn get_property_level(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"level\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_property_file_info_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_file_info_trampoline( this: *mut gio_sys::GZlibCompressor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&ZlibCompressor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::file-info\0".as_ptr() as *const _, Some(transmute(notify_file_info_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ZlibCompressor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ZlibCompressor") } } gio-0.7.0/src/auto/zlib_decompressor.rs010064400007650000024000000056101350341657000163530ustar0000000000000000// 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 gio_sys; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use Converter; use FileInfo; use ZlibCompressorFormat; glib_wrapper! { pub struct ZlibDecompressor(Object) @implements Converter; match fn { get_type => || gio_sys::g_zlib_decompressor_get_type(), } } impl ZlibDecompressor { pub fn new(format: ZlibCompressorFormat) -> ZlibDecompressor { unsafe { from_glib_full(gio_sys::g_zlib_decompressor_new(format.to_glib())) } } } pub const NONE_ZLIB_DECOMPRESSOR: Option<&ZlibDecompressor> = None; pub trait ZlibDecompressorExt: 'static { fn get_file_info(&self) -> Option; fn get_property_format(&self) -> ZlibCompressorFormat; fn connect_property_file_info_notify(&self, f: F) -> SignalHandlerId; } impl> ZlibDecompressorExt for O { fn get_file_info(&self) -> Option { unsafe { from_glib_none(gio_sys::g_zlib_decompressor_get_file_info( self.as_ref().to_glib_none().0, )) } } fn get_property_format(&self) -> ZlibCompressorFormat { unsafe { let mut value = Value::from_type(::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"format\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().unwrap() } } fn connect_property_file_info_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_file_info_trampoline( this: *mut gio_sys::GZlibDecompressor, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(&ZlibDecompressor::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::file-info\0".as_ptr() as *const _, Some(transmute(notify_file_info_trampoline:: as usize)), Box_::into_raw(f), ) } } } impl fmt::Display for ZlibDecompressor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "ZlibDecompressor") } } gio-0.7.0/src/converter.rs010064400007650000024000000033031350341657000136620ustar0000000000000000use gio_sys; use glib::object::IsA; use glib::translate::*; use std::mem; use std::ptr; use Converter; use ConverterFlags; use ConverterResult; use Error; pub trait ConverterExtManual { fn convert, OUT: AsMut<[u8]>>( &self, inbuf: IN, outbuf: OUT, flags: ConverterFlags, ) -> Result<(ConverterResult, usize, usize), Error>; } impl> ConverterExtManual for O { fn convert, OUT: AsMut<[u8]>>( &self, inbuf: IN, outbuf: OUT, flags: ConverterFlags, ) -> Result<(ConverterResult, usize, usize), Error> { let inbuf: Box = Box::new(inbuf); let (inbuf_size, inbuf) = { let slice = (*inbuf).as_ref(); (slice.len(), slice.as_ptr()) }; let mut outbuf: Box = Box::new(outbuf); let (outbuf_size, outbuf) = { let slice = (*outbuf).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe { let mut bytes_read = mem::uninitialized(); let mut bytes_written = mem::uninitialized(); let mut error = ptr::null_mut(); let ret = gio_sys::g_converter_convert( self.as_ref().to_glib_none().0, mut_override(inbuf), inbuf_size, outbuf, 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)) } } } } gio-0.7.0/src/desktop_app_info.rs010064400007650000024000000020551350341657000152020ustar0000000000000000// Copyright 2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib::translate::*; use glib::GString; use glib_sys; use libc; use DesktopAppInfo; impl DesktopAppInfo { pub fn search(search_string: &str) -> Vec> { unsafe { let out = gio_sys::g_desktop_app_info_search(search_string.to_glib_none().0); if out.is_null() { return Vec::new(); } let mut ret = Vec::new(); let mut it = 0; loop { let tmp: *mut *mut libc::c_char = *out.offset(it); if tmp.is_null() { break; } let v: Vec = FromGlibPtrContainer::from_glib_full(tmp); ret.push(v); it += 1; } glib_sys::g_free(out as *mut libc::c_void); ret } } } gio-0.7.0/src/error.rs010064400007650000024000000030211350341657000130010ustar0000000000000000// Copyright 2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use std::io; use Error; use IOErrorEnum; impl From for io::ErrorKind { fn from(kind: IOErrorEnum) -> Self { match kind { IOErrorEnum::NotFound => io::ErrorKind::NotFound, IOErrorEnum::Exists => io::ErrorKind::AlreadyExists, IOErrorEnum::InvalidFilename => io::ErrorKind::InvalidInput, IOErrorEnum::InvalidArgument => io::ErrorKind::InvalidInput, IOErrorEnum::PermissionDenied => io::ErrorKind::PermissionDenied, IOErrorEnum::AddressInUse => io::ErrorKind::AddrInUse, IOErrorEnum::TimedOut => io::ErrorKind::TimedOut, IOErrorEnum::WouldBlock => io::ErrorKind::WouldBlock, IOErrorEnum::InvalidData => io::ErrorKind::InvalidData, IOErrorEnum::ConnectionRefused => io::ErrorKind::ConnectionRefused, IOErrorEnum::BrokenPipe => io::ErrorKind::BrokenPipe, IOErrorEnum::NotConnected => io::ErrorKind::NotConnected, _ => io::ErrorKind::Other, } } } pub(crate) fn to_std_io_result(result: Result) -> io::Result { result.map_err(|g_error| match g_error.kind::() { Some(io_error_enum) => io::Error::new(io_error_enum.into(), g_error), None => io::Error::new(io::ErrorKind::Other, g_error), }) } gio-0.7.0/src/file.rs010064400007650000024000000106421350341657000125760ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; use std::ptr; use Cancellable; use Error; use File; use FileCreateFlags; #[cfg(feature = "futures")] use futures::future; pub trait FileExtManual: Sized { fn replace_contents_async< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, Error)>) + Send + 'static, >( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&Cancellable>, callback: R, ); #[cfg(feature = "futures")] fn replace_contents_async_future<'a, B: AsRef<[u8]> + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Box> + std::marker::Unpin>; } impl> FileExtManual for O { fn replace_contents_async< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, Error)>) + Send + 'static, >( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&Cancellable>, callback: R, ) { let etag = etag.to_glib_none(); let cancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((callback, contents))); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, contents_ptr) = { let contents = &(*user_data).as_ref().unwrap().1; let slice = contents.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn replace_contents_async_trampoline< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, Error)>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, contents) = user_data.take().unwrap(); let mut error = ptr::null_mut(); let mut new_etag = ptr::null_mut(); let _ = gio_sys::g_file_replace_contents_finish( _source_object as *mut _, res, &mut new_etag, &mut error, ); let result = if error.is_null() { Ok((contents, from_glib_full(new_etag))) } else { Err((contents, from_glib_full(error))) }; callback(result); } let callback = replace_contents_async_trampoline::; unsafe { gio_sys::g_file_replace_contents_async( self.as_ref().to_glib_none().0, mut_override(contents_ptr), count, etag.0, make_backup.to_glib(), flags.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn replace_contents_async_future + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Box> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; let etag = etag.map(glib::GString::from); GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.replace_contents_async( contents, etag.as_ref().map(|s| s.as_str()), make_backup, flags, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }, ); cancellable }) } } gio-0.7.0/src/file_attribute_matcher.rs010064400007650000024000000012151350341657000163600ustar0000000000000000use gio_sys; use glib::translate::*; use glib::GString; use std::iter::{IntoIterator, Iterator}; pub struct FileAttributematcherIter(::FileAttributeMatcher); impl Iterator for FileAttributematcherIter { type Item = GString; fn next(&mut self) -> Option { unsafe { from_glib_none(gio_sys::g_file_attribute_matcher_enumerate_next( self.0.to_glib_none().0, )) } } } impl IntoIterator for ::FileAttributeMatcher { type Item = GString; type IntoIter = FileAttributematcherIter; fn into_iter(self) -> Self::IntoIter { FileAttributematcherIter(self) } } gio-0.7.0/src/flags.rs010064400007650000024000000005521350341527700127550ustar0000000000000000// Copyright 2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use ApplicationFlags; impl Default for ApplicationFlags { fn default() -> ApplicationFlags { ApplicationFlags::empty() } } gio-0.7.0/src/gio_future.rs010064400007650000024000000057561350341657000140410ustar0000000000000000// Copyright 2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use futures::channel::oneshot; use futures::prelude::*; use futures::task::{Context, Poll}; use std::marker::Unpin; use std::pin; use glib; use Cancellable; use CancellableExt; pub struct GioFuture { obj: O, schedule_operation: Option, cancellable: Option<(Cancellable, oneshot::Receiver>)>, } impl GioFuture where O: Clone + 'static, F: FnOnce(&O, oneshot::Sender>) -> Cancellable + 'static, { pub fn new(obj: &O, schedule_operation: F) -> Box> + Unpin> { Box::new(GioFuture { obj: obj.clone(), schedule_operation: Some(schedule_operation), cancellable: None, }) } } impl Future for GioFuture where O: Clone + 'static, F: FnOnce(&O, oneshot::Sender>) -> Cancellable + 'static, { type Output = Result; fn poll(mut self: pin::Pin<&mut Self>, ctx: &mut Context) -> Poll> { let GioFuture { ref obj, ref mut schedule_operation, ref mut cancellable, .. } = *self; if let Some(schedule_operation) = schedule_operation.take() { let main_context = glib::MainContext::ref_thread_default(); assert!( main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext" ); // Channel for sending back the GIO async operation // result to our future here. // // In theory we could directly continue polling the // corresponding task from the GIO async operation // callback, however this would break at the very // least the g_main_current_source() API. let (send, recv) = oneshot::channel(); let c = schedule_operation(obj, send); *cancellable = Some((c, recv)); } // At this point we must have a receiver let res = { let &mut (_, ref mut receiver) = cancellable.as_mut().unwrap(); receiver.poll_unpin(ctx) }; match res { Poll::Pending => Poll::Pending, Poll::Ready(Err(_)) => panic!("Async operation sender was unexpectedly closed"), Poll::Ready(Ok(v)) => { // Get rid of the reference to the cancellable let _ = cancellable.take(); Poll::Ready(v) } } } } impl Drop for GioFuture { fn drop(&mut self) { if let Some((cancellable, _)) = self.cancellable.take() { cancellable.cancel(); } } } impl Unpin for GioFuture {} gio-0.7.0/src/inet_address.rs010064400007650000024000000015721350341657000143250ustar0000000000000000use gio_sys; use glib::translate::*; use InetAddress; use SocketFamily; #[derive(Debug)] pub enum InetAddressBytes<'a> { V4(&'a [u8; 4]), V6(&'a [u8; 16]), } impl<'a> InetAddressBytes<'a> { fn deref(&self) -> &[u8] { use self::InetAddressBytes::*; match *self { V4(bytes) => bytes, V6(bytes) => bytes, } } } impl InetAddress { pub fn new_from_bytes(inet_address_bytes: InetAddressBytes) -> Self { use self::InetAddressBytes::*; let bytes = inet_address_bytes.deref(); let family = match inet_address_bytes { V4(_) => SocketFamily::Ipv4, V6(_) => SocketFamily::Ipv6, }; unsafe { from_glib_full(gio_sys::g_inet_address_new_from_bytes( bytes.to_glib_none().0, family.to_glib(), )) } } } gio-0.7.0/src/input_stream.rs010064400007650000024000000330171350341657000143720ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use error::to_std_io_result; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::Priority; use glib_sys; use gobject_sys; use std::io; use std::mem; use std::ptr; use Cancellable; use Error; use InputStream; #[cfg(feature = "futures")] use futures::future; pub trait InputStreamExtManual: Sized { fn read>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result; fn read_all>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result<(usize, Option), Error>; #[cfg(any(feature = "v2_44", feature = "dox"))] fn read_all_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ); fn read_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ); #[cfg(feature = "futures")] #[cfg(any(feature = "v2_44", feature = "dox"))] fn read_all_async_future<'a, B: AsMut<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box< dyn future::Future), (B, Error)>> + std::marker::Unpin, >; #[cfg(feature = "futures")] fn read_async_future<'a, B: AsMut<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box> + std::marker::Unpin>; fn into_read(self) -> InputStreamRead { InputStreamRead(self) } } impl> InputStreamExtManual for O { fn read>( &self, mut buffer: B, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_read( self.as_ref().to_glib_none().0, buffer_ptr, count, cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } fn read_all>( &self, mut buffer: B, cancellable: Option<&Cancellable>, ) -> Result<(usize, Option), Error> { let cancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut bytes_read = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_input_stream_read_all( self.as_ref().to_glib_none().0, buffer_ptr, count, &mut bytes_read, cancellable.0, &mut error, ); if error.is_null() { Ok((bytes_read, None)) } else if bytes_read != 0 { Ok((bytes_read, Some(from_glib_full(error)))) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn read_all_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ) { let cancellable = cancellable.to_glib_none(); let mut user_data: Box> = Box::new(Some((callback, buffer))); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &mut (*user_data).as_mut().unwrap().1; let slice = (*buffer).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe extern "C" fn read_all_async_trampoline< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); let mut error = ptr::null_mut(); let mut bytes_read = mem::uninitialized(); let _ = gio_sys::g_input_stream_read_all_finish( _source_object as *mut _, res, &mut bytes_read, &mut error, ); let result = if error.is_null() { Ok((buffer, bytes_read, None)) } else if bytes_read != 0 { Ok((buffer, bytes_read, Some(from_glib_full(error)))) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = read_all_async_trampoline::; unsafe { gio_sys::g_input_stream_read_all_async( self.as_ref().to_glib_none().0, buffer_ptr, count, io_priority.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn read_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ) { let cancellable = cancellable.to_glib_none(); let mut user_data: Box> = Box::new(Some((callback, buffer))); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &mut (*user_data).as_mut().unwrap().1; let slice = (*buffer).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe extern "C" fn read_async_trampoline< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); let mut error = ptr::null_mut(); let ret = gio_sys::g_input_stream_read_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok((buffer, ret as usize)) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = read_async_trampoline::; unsafe { gio_sys::g_input_stream_read_async( self.as_ref().to_glib_none().0, buffer_ptr, count, io_priority.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_44", feature = "dox"))] fn read_all_async_future<'a, B: AsMut<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box< dyn future::Future), (B, Error)>> + std::marker::Unpin, > { use GioFuture; GioFuture::new(self, move |obj, send| { use fragile::Fragile; let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_all_async(buffer, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } #[cfg(feature = "futures")] fn read_async_future<'a, B: AsMut<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box> + std::marker::Unpin> { use GioFuture; GioFuture::new(self, move |obj, send| { use fragile::Fragile; let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.read_async(buffer, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct InputStreamRead(T); impl InputStreamRead { pub fn into_input_stream(self) -> T { self.0 } pub fn input_stream(&self) -> &T { &self.0 } } impl io::Read for InputStreamRead { fn read(&mut self, buf: &mut [u8]) -> io::Result { let gio_result = self.0.read(buf, None); to_std_io_result(gio_result) } } #[cfg(test)] mod tests { use glib::*; use std::io::Read; use test_util::run_async; use *; #[test] #[cfg(feature = "v2_44")] fn read_all_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let buf = vec![0; 10]; strm.read_all_async(buf, PRIORITY_DEFAULT_IDLE, None, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let (buf, count, err) = ret.unwrap(); assert_eq!(count, 3); assert!(err.is_none()); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_all() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read_all(&mut buf, None).unwrap(); assert_eq!(ret.0, 3); assert!(ret.1.is_none()); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, None); assert_eq!(ret.unwrap(), 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let buf = vec![0; 10]; strm.read_async(buf, PRIORITY_DEFAULT_IDLE, None, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let (buf, count) = ret.unwrap(); assert_eq!(count, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_bytes_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); strm.read_bytes_async(10, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let bytes = ret.unwrap(); assert_eq!(bytes, vec![1, 2, 3]); } #[test] fn skip_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); strm.skip_async(10, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let skipped = ret.unwrap(); assert_eq!(skipped, 3); } #[test] fn std_io_read() { let b = Bytes::from_owned(vec![1, 2, 3]); let mut read = MemoryInputStream::new_from_bytes(&b).into_read(); let mut buf = [0u8; 10]; let ret = read.read(&mut buf); assert_eq!(ret.unwrap(), 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn into_input_stream() { let b = Bytes::from_owned(vec![1, 2, 3]); let stream = MemoryInputStream::new_from_bytes(&b); let stream_clone = stream.clone(); let stream = stream.into_read().into_input_stream(); assert_eq!(stream, stream_clone); } } gio-0.7.0/src/lib.rs010064400007650000024000000035501350341657000124250ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or #![allow(deprecated)] #![cfg_attr(feature = "cargo-clippy", allow(let_and_return))] #![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] #[macro_use] extern crate bitflags; #[macro_use] extern crate lazy_static; #[macro_use] extern crate glib; extern crate fragile; extern crate gio_sys; extern crate glib_sys; extern crate gobject_sys; extern crate libc; #[cfg(feature = "futures")] extern crate futures; mod application; mod converter; #[cfg(any(not(windows), feature = "dox"))] mod desktop_app_info; mod error; mod file; mod file_attribute_matcher; pub use file_attribute_matcher::FileAttributematcherIter; mod flags; mod inet_address; mod input_stream; #[cfg(any(feature = "v2_44", feature = "dox"))] mod list_store; mod memory_input_stream; mod memory_output_stream; mod output_stream; mod pollable_input_stream; mod pollable_output_stream; mod resource; mod socket; mod socket_listener; mod subprocess; mod subprocess_launcher; #[cfg(any(unix, feature = "dox"))] mod unix_input_stream; #[cfg(any(unix, feature = "dox"))] mod unix_output_stream; #[cfg(any(unix, feature = "dox"))] mod unix_socket_address; pub use inet_address::InetAddressBytes; #[cfg(test)] mod test_util; pub use glib::{Error, Object}; pub use auto::functions::*; pub use auto::*; pub mod signal { pub use glib::signal::Inhibit; } pub mod prelude; pub use prelude::*; #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] mod auto; #[cfg(feature = "futures")] mod gio_future; #[cfg(feature = "futures")] pub use gio_future::*; #[macro_use] #[cfg(feature = "subclassing")] pub mod subclass; gio-0.7.0/src/list_store.rs010064400007650000024000000047071350341657000140530ustar0000000000000000// Copyright 2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib; use glib::translate::*; use glib::{IsA, Object}; use glib_sys; use gobject_sys; use std::cmp::Ordering; use ListStore; pub trait ListStoreExtManual { fn insert_sorted, F: FnMut(&Object, &Object) -> Ordering>( &self, item: &P, compare_func: F, ) -> u32; #[cfg(any(feature = "v2_46", feature = "dox"))] fn sort Ordering>(&self, compare_func: F); } impl> ListStoreExtManual for O { fn insert_sorted, F: FnMut(&Object, &Object) -> Ordering>( &self, item: &P, compare_func: F, ) -> u32 { unsafe { let mut func = compare_func; let func_obj: &mut (dyn FnMut(&Object, &Object) -> Ordering) = &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(&Object, &Object) -> Ordering) as glib_sys::gpointer; gio_sys::g_list_store_insert_sorted( self.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } #[cfg(any(feature = "v2_46", feature = "dox"))] fn sort Ordering>(&self, compare_func: F) { unsafe { let mut func = compare_func; let func_obj: &mut (dyn FnMut(&Object, &Object) -> Ordering) = &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(&Object, &Object) -> Ordering) as glib_sys::gpointer; gio_sys::g_list_store_sort( self.as_ref().to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } } unsafe extern "C" fn compare_func_trampoline( a: glib_sys::gconstpointer, b: glib_sys::gconstpointer, func: glib_sys::gpointer, ) -> i32 { let func = func as *mut &mut (dyn FnMut(&Object, &Object) -> Ordering); let a = from_glib_borrow(a as *mut gobject_sys::GObject); let b = from_glib_borrow(b as *mut gobject_sys::GObject); match (*func)(&a, &b) { Ordering::Less => -1, Ordering::Equal => 0, Ordering::Greater => 1, } } gio-0.7.0/src/memory_input_stream.rs010064400007650000024000000043131350341657000157570ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or #[cfg(test)] mod tests { use glib::Bytes; use *; #[test] fn new() { let strm = MemoryInputStream::new(); let ret = strm.skip(1, ::NONE_CANCELLABLE); assert!(!ret.is_err()); assert_eq!(ret.unwrap(), 0); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, ::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 0); } #[test] fn new_from_bytes() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, ::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); let ret = strm.skip(10, ::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 0); } #[test] fn add_bytes() { let strm = MemoryInputStream::new(); let b = Bytes::from_owned(vec![1, 2, 3]); strm.add_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, ::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); let ret = strm.skip(10, ::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 0); } #[test] #[cfg(feature = "futures")] fn read_async_future() { use futures::prelude::*; let c = glib::MainContext::new(); let buf = vec![0; 10]; let b = glib::Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::new_from_bytes(&b); let res = c .block_on( strm.read_async_future(buf, glib::PRIORITY_DEFAULT) .map_err(|(_buf, err)| err) .map_ok(move |(mut buf, len)| { buf.truncate(len); buf }), ) .unwrap(); assert_eq!(res, vec![1, 2, 3]); } } gio-0.7.0/src/memory_output_stream.rs010064400007650000024000000017321350341657000161620ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or #[cfg(test)] mod tests { use *; #[test] fn steal_empty() { let strm = MemoryOutputStream::new_resizable(); assert_eq!(strm.get_data_size(), 0); assert!(strm.close(::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.steal_as_bytes().unwrap(), [].as_ref()); } #[test] fn steal() { let strm = MemoryOutputStream::new_resizable(); assert!(strm.write(&[1, 2, 3], ::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.get_data_size(), 3); assert!(strm.write(&[4, 5], ::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.get_data_size(), 5); assert!(strm.close(::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.steal_as_bytes().unwrap(), [1, 2, 3, 4, 5].as_ref()); } } gio-0.7.0/src/output_stream.rs010064400007650000024000000301671350341657000145760ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use error::to_std_io_result; use gio_sys; use glib::object::IsA; use glib::translate::*; use glib::Priority; use glib_sys; use gobject_sys; use std::io; use std::mem; use std::ptr; use Cancellable; use Error; use OutputStream; use OutputStreamExt; #[cfg(feature = "futures")] use futures::future; pub trait OutputStreamExtManual: Sized + OutputStreamExt { fn write_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ); fn write_all( &self, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result<(usize, Option), Error>; #[cfg(any(feature = "v2_44", feature = "dox"))] fn write_all_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ); #[cfg(feature = "futures")] fn write_async_future<'a, B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box> + std::marker::Unpin>; #[cfg(feature = "futures")] #[cfg(any(feature = "v2_44", feature = "dox"))] fn write_all_async_future<'a, B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box< dyn future::Future), (B, Error)>> + std::marker::Unpin, >; fn into_write(self) -> OutputStreamWrite { OutputStreamWrite(self) } } impl> OutputStreamExtManual for O { fn write_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ) { let cancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((callback, buffer))); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &(*user_data).as_ref().unwrap().1; let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn write_async_trampoline< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, Error)>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); let mut error = ptr::null_mut(); let ret = gio_sys::g_output_stream_write_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok((buffer, ret as usize)) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = write_async_trampoline::; unsafe { gio_sys::g_output_stream_write_async( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, io_priority.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn write_all( &self, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result<(usize, Option), Error> { let cancellable = cancellable.to_glib_none(); let count = buffer.len() as usize; unsafe { let mut bytes_written = mem::uninitialized(); let mut error = ptr::null_mut(); let _ = gio_sys::g_output_stream_write_all( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, &mut bytes_written, cancellable.0, &mut error, ); if error.is_null() { Ok((bytes_written, None)) } else if bytes_written != 0 { Ok((bytes_written, Some(from_glib_full(error)))) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_44", feature = "dox"))] fn write_all_async< 'a, B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&Cancellable>, callback: Q, ) { let cancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((callback, buffer))); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &(*user_data).as_ref().unwrap().1; let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn write_all_async_trampoline< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, Error)>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); let mut error = ptr::null_mut(); let mut bytes_written = mem::uninitialized(); let _ = gio_sys::g_output_stream_write_all_finish( _source_object as *mut _, res, &mut bytes_written, &mut error, ); let result = if error.is_null() { Ok((buffer, bytes_written, None)) } else if bytes_written != 0 { Ok((buffer, bytes_written, from_glib_full(error))) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = write_all_async_trampoline::; unsafe { gio_sys::g_output_stream_write_all_async( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, io_priority.to_glib(), cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn write_async_future<'a, B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box> + std::marker::Unpin> { use GioFuture; GioFuture::new(self, move |obj, send| { use fragile::Fragile; let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.write_async(buffer, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } #[cfg(feature = "futures")] #[cfg(any(feature = "v2_44", feature = "dox"))] fn write_all_async_future<'a, B: AsRef<[u8]> + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Box< dyn future::Future), (B, Error)>> + std::marker::Unpin, > { use GioFuture; GioFuture::new(self, move |obj, send| { use fragile::Fragile; let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.write_all_async(buffer, io_priority, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } #[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct OutputStreamWrite(T); impl OutputStreamWrite { pub fn into_output_stream(self) -> T { self.0 } pub fn output_stream(&self) -> &T { &self.0 } } impl io::Write for OutputStreamWrite { fn write(&mut self, buf: &[u8]) -> io::Result { let result = self .0 .write(buf, ::NONE_CANCELLABLE) .map(|size| size as usize); to_std_io_result(result) } fn flush(&mut self) -> io::Result<()> { let gio_result = self.0.flush(::NONE_CANCELLABLE); to_std_io_result(gio_result) } } #[cfg(test)] mod tests { use glib::*; use std::io::Write; use test_util::run_async; use *; #[test] fn splice_async() { let ret = run_async(|tx, l| { let input = MemoryInputStream::new(); let b = Bytes::from_owned(vec![1, 2, 3]); input.add_bytes(&b); let strm = MemoryOutputStream::new_resizable(); strm.splice_async( &input, OutputStreamSpliceFlags::CLOSE_SOURCE, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); assert_eq!(ret.unwrap(), 3); } #[test] fn write_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let buf = vec![1, 2, 3]; strm.write_async(buf, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let (buf, size) = ret.unwrap(); assert_eq!(buf, vec![1, 2, 3]); assert_eq!(size, 3); } #[test] #[cfg(any(feature = "v2_44", feature = "dox"))] fn write_all_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let buf = vec![1, 2, 3]; strm.write_all_async(buf, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); let (buf, size, err) = ret.unwrap(); assert_eq!(buf, vec![1, 2, 3]); assert_eq!(size, 3); assert!(err.is_none()); } #[test] fn write_bytes_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let b = Bytes::from_owned(vec![1, 2, 3]); strm.write_bytes_async(&b, PRIORITY_DEFAULT_IDLE, ::NONE_CANCELLABLE, move |ret| { tx.send(ret).unwrap(); l.quit(); }); }); assert_eq!(ret.unwrap(), 3); } #[test] fn std_io_write() { let b = Bytes::from_owned(vec![1, 2, 3]); let mut write = MemoryOutputStream::new_resizable().into_write(); let ret = write.write(&b); let stream = write.into_output_stream(); stream.close(::NONE_CANCELLABLE).unwrap(); assert_eq!(ret.unwrap(), 3); assert_eq!(stream.steal_as_bytes().unwrap(), [1, 2, 3].as_ref()); } #[test] fn into_output_stream() { let stream = MemoryOutputStream::new_resizable(); let stream_clone = stream.clone(); let stream = stream.into_write().into_output_stream(); assert_eq!(stream, stream_clone); } } gio-0.7.0/src/pollable_input_stream.rs010064400007650000024000000131471350341657000162460ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use fragile::Fragile; use gio_sys; use glib; use glib::object::{Cast, IsA}; use glib::translate::*; use glib_sys; use std::cell::RefCell; use std::mem::transmute; use std::ptr; use Cancellable; use Error; use PollableInputStream; #[cfg(feature = "futures")] use futures::future::Future; #[cfg(feature = "futures")] use futures::stream::Stream; pub trait PollableInputStreamExtManual: Sized { fn create_source( &self, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static; #[cfg(feature = "futures")] fn create_source_future( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; #[cfg(feature = "futures")] fn create_source_stream( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; fn read_nonblocking( &self, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result; } impl> PollableInputStreamExtManual for O { fn create_source( &self, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static, { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline>( stream: *mut gio_sys::GPollableInputStream, func: glib_sys::gpointer, ) -> glib_sys::gboolean { let func: &Fragile glib::Continue + 'static>>> = transmute(func); let func = func.get(); let mut func = func.borrow_mut(); (&mut *func)(&PollableInputStream::from_glib_borrow(stream).unsafe_cast()).to_glib() } unsafe extern "C" fn destroy_closure(ptr: glib_sys::gpointer) { Box:: glib::Continue + 'static>>>>::from_raw( ptr as *mut _, ); } let cancellable = cancellable.to_glib_none(); unsafe { let source = gio_sys::g_pollable_input_stream_create_source( self.as_ref().to_glib_none().0, cancellable.0, ); let trampoline = trampoline:: as glib_sys::gpointer; glib_sys::g_source_set_callback( source, Some(transmute(trampoline)), into_raw(func), Some(destroy_closure::), ); glib_sys::g_source_set_priority(source, priority.to_glib()); if let Some(name) = name { glib_sys::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } fn read_nonblocking( &self, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let count = buffer.len() as usize; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_pollable_input_stream_read_nonblocking( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, cancellable.0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "futures")] fn create_source_future( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.get() .create_source(cancellable.as_ref(), None, priority, move |_| { let _ = send.take().unwrap().send(()); glib::Continue(false) }) })) } #[cfg(feature = "futures")] fn create_source_stream( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceStream::new(move |send| { obj.get() .create_source(cancellable.as_ref(), None, priority, move |_| { if send.unbounded_send(()).is_err() { glib::Continue(false) } else { glib::Continue(true) } }) })) } } fn into_raw glib::Continue + 'static>(func: F) -> glib_sys::gpointer { let func: Box glib::Continue + 'static>>>> = Box::new(Fragile::new(RefCell::new(Box::new(func)))); Box::into_raw(func) as glib_sys::gpointer } gio-0.7.0/src/pollable_output_stream.rs010064400007650000024000000114561350341657000164500ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use fragile::Fragile; use gio_sys; use glib; use glib::object::{Cast, IsA}; use glib::translate::*; use glib_sys; use std::cell::RefCell; use std::mem::transmute; use Cancellable; use PollableOutputStream; #[cfg(feature = "futures")] use futures::future::Future; #[cfg(feature = "futures")] use futures::stream::Stream; pub trait PollableOutputStreamExtManual { fn create_source( &self, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static; #[cfg(feature = "futures")] fn create_source_future( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; #[cfg(feature = "futures")] fn create_source_stream( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; } impl> PollableOutputStreamExtManual for O { fn create_source( &self, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static, { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline>( stream: *mut gio_sys::GPollableOutputStream, func: glib_sys::gpointer, ) -> glib_sys::gboolean { let func: &Fragile glib::Continue + 'static>>> = transmute(func); let func = func.get(); let mut func = func.borrow_mut(); (&mut *func)(&PollableOutputStream::from_glib_borrow(stream).unsafe_cast()).to_glib() } unsafe extern "C" fn destroy_closure(ptr: glib_sys::gpointer) { Box:: glib::Continue + 'static>>>>::from_raw( ptr as *mut _, ); } let cancellable = cancellable.to_glib_none(); unsafe { let source = gio_sys::g_pollable_output_stream_create_source( self.as_ref().to_glib_none().0, cancellable.0, ); let trampoline = trampoline:: as glib_sys::gpointer; glib_sys::g_source_set_callback( source, Some(transmute(trampoline)), into_raw(func), Some(destroy_closure::), ); glib_sys::g_source_set_priority(source, priority.to_glib()); if let Some(name) = name { glib_sys::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } #[cfg(feature = "futures")] fn create_source_future( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.get() .create_source(cancellable.as_ref(), None, priority, move |_| { let _ = send.take().unwrap().send(()); glib::Continue(false) }) })) } #[cfg(feature = "futures")] fn create_source_stream( &self, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceStream::new(move |send| { let send = Some(send); obj.get() .create_source(cancellable.as_ref(), None, priority, move |_| { if send.as_ref().unwrap().unbounded_send(()).is_err() { glib::Continue(false) } else { glib::Continue(true) } }) })) } } fn into_raw glib::Continue + 'static>(func: F) -> glib_sys::gpointer { let func: Box glib::Continue + 'static>>>> = Box::new(Fragile::new(RefCell::new(Box::new(func)))); Box::into_raw(func) as glib_sys::gpointer } gio-0.7.0/src/prelude.rs010064400007650000024000000020401350341657000133100ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or //! Traits and essential types intended for blanket imports. pub use auto::traits::*; pub use application::*; pub use converter::*; pub use file::FileExtManual; pub use input_stream::InputStreamExtManual; #[cfg(any(feature = "v2_44", feature = "dox"))] pub use list_store::ListStoreExtManual; pub use output_stream::OutputStreamExtManual; pub use pollable_input_stream::PollableInputStreamExtManual; pub use pollable_output_stream::PollableOutputStreamExtManual; pub use socket::*; pub use socket_listener::SocketListenerExtManual; #[cfg(any(unix, feature = "dox"))] pub use unix_input_stream::UnixInputStreamExtManual; #[cfg(any(unix, feature = "dox"))] pub use unix_output_stream::UnixOutputStreamExtManual; #[cfg(any(unix, feature = "dox"))] pub use unix_socket_address::{UnixSocketAddressExtManual, UnixSocketAddressPath}; gio-0.7.0/src/resource.rs010064400007650000024000000021751350341657000135100ustar0000000000000000// Copyright 2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib; use glib::translate::*; use glib_sys; use std::mem; use std::ptr; use Resource; impl Resource { pub fn new_from_data(data: &glib::Bytes) -> Result { unsafe { let mut error = ptr::null_mut(); // Create a copy of data if it is not pointer-aligned // https://bugzilla.gnome.org/show_bug.cgi?id=790030 let mut data = data.clone(); let data_ptr = glib_sys::g_bytes_get_data(data.to_glib_none().0, ptr::null_mut()); if data_ptr as usize % mem::align_of::<*const u8>() != 0 { data = glib::Bytes::from(&*data); } let ret = gio_sys::g_resource_new_from_data(data.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } gio-0.7.0/src/socket.rs010064400007650000024000000344461350341657000131570ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use fragile::Fragile; use gio_sys; use glib; use glib::object::{Cast, IsA}; use glib::translate::*; use glib_sys; use std::cell::RefCell; use std::mem::transmute; #[cfg(all(not(unix), feature = "dox"))] use std::os::raw::c_int; #[cfg(all(not(windows), feature = "dox"))] use std::os::raw::c_void; use std::ptr; use Cancellable; use Error; use Socket; use SocketAddress; #[cfg(feature = "futures")] use futures::future::Future; #[cfg(feature = "futures")] use futures::stream::Stream; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; impl Socket { #[cfg(any(unix, feature = "dox"))] pub unsafe fn new_from_fd(fd: T) -> Result { let fd = fd.into_raw_fd(); let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_new_from_fd(fd, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } #[cfg(any(windows, feature = "dox"))] pub unsafe fn new_from_socket(socket: T) -> Result { let socket = socket.into_raw_socket(); let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_new_from_fd(socket as i32, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(any(unix, feature = "dox"))] impl AsRawFd for Socket { fn as_raw_fd(&self) -> RawFd { unsafe { gio_sys::g_socket_get_fd(self.to_glib_none().0) as _ } } } #[cfg(any(windows, feature = "dox"))] impl AsRawSocket for Socket { fn as_raw_socket(&self) -> RawSocket { unsafe { gio_sys::g_socket_get_fd(self.to_glib_none().0) as _ } } } pub trait SocketExtManual: Sized { fn receive>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result; fn receive_from>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result<(usize, SocketAddress), Error>; fn receive_with_blocking>( &self, buffer: B, blocking: bool, cancellable: Option<&Cancellable>, ) -> Result; fn send>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result; fn send_to, P: IsA>( &self, address: Option<&P>, buffer: B, cancellable: Option<&Cancellable>, ) -> Result; fn send_with_blocking>( &self, buffer: B, blocking: bool, cancellable: Option<&Cancellable>, ) -> Result; #[cfg(any(unix, feature = "dox"))] fn get_fd(&self) -> T; #[cfg(any(windows, feature = "dox"))] fn get_socket(&self) -> T; fn create_source( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self, glib::IOCondition) -> glib::Continue + 'static; #[cfg(feature = "futures")] fn create_source_future( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; #[cfg(feature = "futures")] fn create_source_stream( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin>; } impl> SocketExtManual for O { fn receive>( &self, mut buffer: B, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_receive( self.as_ref().to_glib_none().0, buffer_ptr, count, cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } fn receive_from>( &self, mut buffer: B, cancellable: Option<&Cancellable>, ) -> Result<(usize, SocketAddress), Error> { let cancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let mut addr_ptr = ptr::null_mut(); let ret = gio_sys::g_socket_receive_from( self.as_ref().to_glib_none().0, &mut addr_ptr, buffer_ptr, count, cancellable.0, &mut error, ); if error.is_null() { Ok((ret as usize, from_glib_full(addr_ptr))) } else { Err(from_glib_full(error)) } } } fn receive_with_blocking>( &self, mut buffer: B, blocking: bool, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_receive_with_blocking( self.as_ref().to_glib_none().0, buffer_ptr, count, blocking.to_glib(), cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } fn send>( &self, buffer: B, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_send( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } fn send_to, P: IsA>( &self, address: Option<&P>, buffer: B, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_send_to( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, mut_override(buffer_ptr), count, cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } fn send_with_blocking>( &self, buffer: B, blocking: bool, cancellable: Option<&Cancellable>, ) -> Result { let cancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = gio_sys::g_socket_send_with_blocking( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, blocking.to_glib(), cancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[cfg(any(unix, feature = "dox"))] fn get_fd(&self) -> T { unsafe { FromRawFd::from_raw_fd(gio_sys::g_socket_get_fd(self.as_ref().to_glib_none().0)) } } #[cfg(any(windows, feature = "dox"))] fn get_socket(&self) -> T { unsafe { FromRawSocket::from_raw_socket( gio_sys::g_socket_get_fd(self.as_ref().to_glib_none().0) as _ ) } } fn create_source( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self, glib::IOCondition) -> glib::Continue + 'static, { #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] unsafe extern "C" fn trampoline>( socket: *mut gio_sys::GSocket, condition: glib_sys::GIOCondition, func: glib_sys::gpointer, ) -> glib_sys::gboolean { let func: &Fragile< RefCell glib::Continue + 'static>>, > = transmute(func); let func = func.get(); let mut func = func.borrow_mut(); (&mut *func)( &Socket::from_glib_borrow(socket).unsafe_cast(), from_glib(condition), ) .to_glib() } unsafe extern "C" fn destroy_closure(ptr: glib_sys::gpointer) { Box::< Fragile glib::Continue + 'static>>>, >::from_raw(ptr as *mut _); } let cancellable = cancellable.to_glib_none(); unsafe { let source = gio_sys::g_socket_create_source( self.as_ref().to_glib_none().0, condition.to_glib(), cancellable.0, ); let trampoline = trampoline:: as glib_sys::gpointer; glib_sys::g_source_set_callback( source, Some(transmute(trampoline)), into_raw(func), Some(destroy_closure::), ); glib_sys::g_source_set_priority(source, priority.to_glib()); if let Some(name) = name { glib_sys::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } #[cfg(feature = "futures")] fn create_source_future( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.get().create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { let _ = send.take().unwrap().send(condition); glib::Continue(false) }, ) })) } #[cfg(feature = "futures")] fn create_source_stream( &self, condition: glib::IOCondition, cancellable: Option<&Cancellable>, priority: glib::Priority, ) -> Box + std::marker::Unpin> { let cancellable: Option = cancellable.cloned(); let obj = Fragile::new(self.clone()); Box::new(glib::SourceStream::new(move |send| { let send = Some(send); obj.get().create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { if send.as_ref().unwrap().unbounded_send(condition).is_err() { glib::Continue(false) } else { glib::Continue(true) } }, ) })) } } fn into_raw glib::Continue + 'static>( func: F, ) -> glib_sys::gpointer { let func: Box< Fragile glib::Continue + 'static>>>, > = Box::new(Fragile::new(RefCell::new(Box::new(func)))); Box::into_raw(func) as glib_sys::gpointer } #[cfg(all(not(unix), feature = "dox"))] pub trait IntoRawFd { fn into_raw_fd(self) -> c_int; } #[cfg(all(not(unix), feature = "dox"))] pub trait FromRawFd { unsafe fn from_raw_fd(fd: c_int) -> Self; } #[cfg(all(not(unix), feature = "dox"))] pub trait AsRawFd { fn as_raw_fd(&self) -> RawFd; } #[cfg(all(not(unix), feature = "dox"))] pub type RawFd = c_int; #[cfg(all(not(windows), feature = "dox"))] pub trait IntoRawSocket { fn into_raw_socket(self) -> u64; } #[cfg(all(not(windows), feature = "dox"))] pub trait FromRawSocket { unsafe fn from_raw_socket(sock: u64) -> Self; } #[cfg(all(not(windows), feature = "dox"))] pub trait AsRawSocket { fn as_raw_socket(&self) -> RawSocket; } #[cfg(all(not(windows), feature = "dox"))] pub type RawSocket = *mut c_void; gio-0.7.0/src/socket_listener.rs010064400007650000024000000133001350341657000150460ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib; use glib::object::IsA; use glib::translate::*; use glib_sys; use gobject_sys; use std::boxed::Box as Box_; use std::ptr; use Cancellable; use Error; use Socket; use SocketConnection; use SocketListener; #[cfg(feature = "futures")] use futures::future; pub trait SocketListenerExtManual: Sized { fn accept_socket_async< Q: FnOnce(Result<(Socket, Option), Error>) + Send + 'static, >( &self, cancellable: Option<&Cancellable>, callback: Q, ); #[cfg(feature = "futures")] fn accept_socket_async_future( &self, ) -> Box< dyn future::Future), Error>> + std::marker::Unpin, >; fn accept_async< P: IsA, Q: FnOnce(Result<(SocketConnection, Option), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(feature = "futures")] fn accept_async_future( &self, ) -> Box_< dyn future::Future), Error>> + std::marker::Unpin, >; } impl> SocketListenerExtManual for O { fn accept_socket_async< Q: FnOnce(Result<(Socket, Option), Error>) + Send + 'static, >( &self, cancellable: Option<&Cancellable>, callback: Q, ) { let cancellable = cancellable.to_glib_none(); let user_data: Box = Box::new(callback); unsafe extern "C" fn accept_socket_async_trampoline< Q: FnOnce(Result<(Socket, Option), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut source_object = ptr::null_mut(); let res = gio_sys::g_socket_listener_accept_socket_finish( _source_object as *mut _, res, &mut source_object, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(res), from_glib_none(source_object))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = accept_socket_async_trampoline::; unsafe { gio_sys::g_socket_listener_accept_socket_async( self.as_ref().to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn accept_socket_async_future( &self, ) -> Box< dyn future::Future), Error>> + std::marker::Unpin, > { use GioFuture; GioFuture::new(self, move |obj, send| { use fragile::Fragile; let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.accept_socket_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } fn accept_async< P: IsA, Q: FnOnce(Result<(SocketConnection, Option), Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn accept_async_trampoline< Q: FnOnce(Result<(SocketConnection, Option), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut source_object = ptr::null_mut(); let ret = gio_sys::g_socket_listener_accept_finish( _source_object as *mut _, res, &mut source_object, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) }; let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = accept_async_trampoline::; unsafe { gio_sys::g_socket_listener_accept_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] fn accept_async_future( &self, ) -> Box_< dyn future::Future), Error>> + std::marker::Unpin, > { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.accept_async(Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } gio-0.7.0/src/subclass/application.rs010064400007650000024000000403721350341657000160040ustar0000000000000000// Copyright 2019, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib_sys; use glib::translate::*; use glib::subclass::prelude::*; use Application; use ApplicationClass; use libc::{c_char, c_void}; use std::convert; use std::ffi::OsString; use std::fmt; use std::ops::Deref; use std::ptr; pub struct ArgumentList { pub(crate) ptr: *mut *mut *mut c_char, items: Vec, } impl ArgumentList { pub(crate) fn new(arguments: *mut *mut *mut c_char) -> Self { Self { ptr: arguments, items: unsafe { FromGlibPtrContainer::from_glib_none(ptr::read(arguments)) }, } } pub(crate) fn refresh(&mut self) { self.items = unsafe { FromGlibPtrContainer::from_glib_none(ptr::read(self.ptr)) }; } // remove the item at index `idx` and shift the raw array pub fn remove(&mut self, idx: usize) { unsafe { let n_args = glib_sys::g_strv_length(*self.ptr); assert!((n_args as usize) == self.items.len()); assert!((idx as u32) < n_args); self.items.remove(idx); glib_sys::g_free(((*self.ptr).offset(idx as isize)) as *mut c_void); for i in (idx as u32)..n_args - 1 { ptr::write( (*self.ptr).offset(i as isize), *(*self.ptr).offset((i + 1) as isize), ) } ptr::write((*self.ptr).offset((n_args - 1) as isize), ptr::null_mut()); } } } impl Deref for ArgumentList { type Target = [OsString]; fn deref(&self) -> &Self::Target { self.items.as_slice() } } impl fmt::Debug for ArgumentList { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.items.fmt(formatter) } } impl convert::Into> for ArgumentList { fn into(self) -> Vec { self.items } } pub trait ApplicationImpl: ApplicationImplExt + 'static { fn activate(&self, application: &Application) { self.parent_activate(application) } fn after_emit(&self, application: &Application, platform_data: &glib::Variant) { self.parent_after_emit(application, platform_data) } fn before_emit(&self, application: &Application, platform_data: &glib::Variant) { self.parent_before_emit(application, platform_data) } fn command_line( &self, application: &Application, command_line: &::ApplicationCommandLine, ) -> i32 { self.parent_command_line(application, command_line) } fn local_command_line( &self, application: &Application, arguments: &mut ArgumentList, ) -> Option { self.parent_local_command_line(application, arguments) } fn open(&self, application: &Application, files: &[::File], hint: &str) { self.parent_open(application, files, hint) } fn quit_mainloop(&self, application: &Application) { self.parent_quit_mainloop(application) } fn run_mainloop(&self, application: &Application) { self.parent_run_mainloop(application) } fn shutdown(&self, application: &Application) { self.parent_shutdown(application) } fn startup(&self, application: &Application) { self.parent_startup(application) } } pub trait ApplicationImplExt { fn parent_activate(&self, application: &Application); fn parent_after_emit(&self, application: &Application, platform_data: &glib::Variant); fn parent_before_emit(&self, application: &Application, platform_data: &glib::Variant); fn parent_command_line( &self, application: &Application, command_line: &::ApplicationCommandLine, ) -> i32; fn parent_local_command_line( &self, application: &Application, arguments: &mut ArgumentList, ) -> Option; fn parent_open(&self, application: &Application, files: &[::File], hint: &str); fn parent_quit_mainloop(&self, application: &Application); fn parent_run_mainloop(&self, application: &Application); fn parent_shutdown(&self, application: &Application); fn parent_startup(&self, application: &Application); } impl ApplicationImplExt for T { fn parent_activate(&self, application: &Application) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .activate .expect("No parent class implementation for \"activate\""); f(application.to_glib_none().0) } } fn parent_after_emit(&self, application: &Application, platform_data: &glib::Variant) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .after_emit .expect("No parent class implementation for \"after_emit\""); f(application.to_glib_none().0, platform_data.to_glib_none().0) } } fn parent_before_emit(&self, application: &Application, platform_data: &glib::Variant) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .before_emit .expect("No parent class implementation for \"before_emit\""); f(application.to_glib_none().0, platform_data.to_glib_none().0) } } fn parent_command_line( &self, application: &Application, command_line: &::ApplicationCommandLine, ) -> i32 { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .command_line .expect("No parent class implementation for \"command_line\""); f(application.to_glib_none().0, command_line.to_glib_none().0) } } fn parent_local_command_line( &self, application: &Application, arguments: &mut ArgumentList, ) -> Option { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .local_command_line .expect("No parent class implementation for \"local_command_line\""); let mut exit_status = 0; let res = f( application.to_glib_none().0, arguments.ptr, &mut exit_status, ); arguments.refresh(); match res { glib_sys::GFALSE => None, _ => Some(exit_status), } } } fn parent_open(&self, application: &Application, files: &[::File], hint: &str) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .open .expect("No parent class implementation for \"open\""); f( application.to_glib_none().0, files.to_glib_none().0, files.len() as i32, hint.to_glib_none().0, ) } } fn parent_quit_mainloop(&self, application: &Application) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .quit_mainloop .expect("No parent class implementation for \"quit_mainloop\""); f(application.to_glib_none().0) } } fn parent_run_mainloop(&self, application: &Application) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .run_mainloop .expect("No parent class implementation for \"run_mainloop\""); f(application.to_glib_none().0) } } fn parent_shutdown(&self, application: &Application) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .shutdown .expect("No parent class implementation for \"shutdown\""); f(application.to_glib_none().0) } } fn parent_startup(&self, application: &Application) { unsafe { let data = self.get_type_data(); let parent_class = data.as_ref().get_parent_class() as *mut gio_sys::GApplicationClass; let f = (*parent_class) .startup .expect("No parent class implementation for \"startup\""); f(application.to_glib_none().0) } } } unsafe impl IsSubclassable for ApplicationClass { fn override_vfuncs(&mut self) { >::override_vfuncs(self); unsafe { let klass = &mut *(self as *mut Self as *mut gio_sys::GApplicationClass); klass.activate = Some(application_activate::); klass.after_emit = Some(application_after_emit::); klass.before_emit = Some(application_before_emit::); klass.command_line = Some(application_command_line::); klass.local_command_line = Some(application_local_command_line::); klass.open = Some(application_open::); klass.quit_mainloop = Some(application_quit_mainloop::); klass.run_mainloop = Some(application_run_mainloop::); klass.shutdown = Some(application_shutdown::); klass.startup = Some(application_startup::); } } } unsafe extern "C" fn application_activate(ptr: *mut gio_sys::GApplication) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.activate(&wrap) } unsafe extern "C" fn application_after_emit( ptr: *mut gio_sys::GApplication, platform_data: *mut glib_sys::GVariant, ) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.after_emit(&wrap, &from_glib_borrow(platform_data)) } unsafe extern "C" fn application_before_emit( ptr: *mut gio_sys::GApplication, platform_data: *mut glib_sys::GVariant, ) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.before_emit(&wrap, &from_glib_borrow(platform_data)) } unsafe extern "C" fn application_command_line( ptr: *mut gio_sys::GApplication, command_line: *mut gio_sys::GApplicationCommandLine, ) -> i32 where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.command_line(&wrap, &from_glib_borrow(command_line)) } unsafe extern "C" fn application_local_command_line( ptr: *mut gio_sys::GApplication, arguments: *mut *mut *mut c_char, exit_status: *mut i32, ) -> glib_sys::gboolean where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); let mut args = ArgumentList::new(arguments); let res = imp.local_command_line(&wrap, &mut args); args.refresh(); match res { Some(ret) => { ptr::write(exit_status, ret); glib_sys::GTRUE } None => glib_sys::GFALSE, } } unsafe extern "C" fn application_open( ptr: *mut gio_sys::GApplication, files: *mut *mut gio_sys::GFile, num_files: i32, hint: *const c_char, ) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); let files: Vec<::File> = FromGlibContainer::from_glib_none_num(files, num_files as usize); imp.open( &wrap, files.as_slice(), &glib::GString::from_glib_borrow(hint), ) } unsafe extern "C" fn application_quit_mainloop(ptr: *mut gio_sys::GApplication) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.quit_mainloop(&wrap) } unsafe extern "C" fn application_run_mainloop(ptr: *mut gio_sys::GApplication) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.run_mainloop(&wrap) } unsafe extern "C" fn application_shutdown(ptr: *mut gio_sys::GApplication) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.shutdown(&wrap) } unsafe extern "C" fn application_startup(ptr: *mut gio_sys::GApplication) where T: ApplicationImpl, { let instance = &*(ptr as *mut T::Instance); let imp = instance.get_impl(); let wrap: Application = from_glib_borrow(ptr); imp.startup(&wrap) } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; use glib; use glib::prelude::*; use glib::subclass; const EXIT_STATUS: i32 = 20; struct SimpleApplication; impl ObjectSubclass for SimpleApplication { const NAME: &'static str = "SimpleApplication"; type ParentType = Application; type Instance = subclass::simple::InstanceStruct; type Class = subclass::simple::ClassStruct; glib_object_subclass!(); fn new() -> Self { Self } } impl ObjectImpl for SimpleApplication { glib_object_impl!(); } impl ApplicationImpl for SimpleApplication { fn local_command_line( &self, _application: &Application, arguments: &mut ArgumentList, ) -> Option { let mut rm = Vec::new(); for (i, line) in arguments.iter().enumerate() { // TODO: we need https://github.com/rust-lang/rust/issues/49802 let l = line.clone().into_string().unwrap(); if l.starts_with("--local-") { rm.push(i) } } rm.reverse(); for i in rm.iter() { arguments.remove(*i); } None } fn command_line( &self, _application: &Application, cmd_line: &::ApplicationCommandLine, ) -> i32 { let arguments = cmd_line.get_arguments(); for arg in arguments { // TODO: we need https://github.com/rust-lang/rust/issues/49802 let a = arg.into_string().unwrap(); assert!(!a.starts_with("--local-")) } return EXIT_STATUS; } } #[test] fn test_simple_application() { let app = glib::Object::new( SimpleApplication::get_type(), &[ ("application-id", &"org.gtk-rs.SimpleApplication"), ("flags", &::ApplicationFlags::empty()), ], ) .unwrap() .downcast::<::Application>() .unwrap(); app.set_inactivity_timeout(10000); assert!(app.run(&["--local".to_string()]) == EXIT_STATUS); } } gio-0.7.0/src/subclass/mod.rs010064400007650000024000000005611350341657000142540ustar0000000000000000// Copyright 2019, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or pub mod application; pub mod prelude { pub use super::application::{ApplicationImpl, ArgumentList}; pub use glib::subclass::prelude::*; } gio-0.7.0/src/subprocess.rs010064400007650000024000000051231350341657000140450ustar0000000000000000#[cfg(feature = "futures")] use futures::future; use gio_sys; use glib::translate::*; use glib::GString; use glib_sys; use gobject_sys; use libc::c_char; use std::ptr; use Cancellable; use Error; use Subprocess; impl Subprocess { pub fn communicate_utf8_async) + Send + 'static>( &self, stdin_buf: Option, cancellable: Option<&Cancellable>, callback: R, ) { let stdin_buf = stdin_buf.to_glib_full(); let cancellable = cancellable.to_glib_none(); let user_data: Box<(R, *mut c_char)> = Box::new((callback, stdin_buf)); unsafe extern "C" fn communicate_utf8_async_trampoline< R: FnOnce(Result<(GString, GString), Error>) + Send + 'static, >( _source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer, ) { let mut error = ptr::null_mut(); let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let _ = gio_sys::g_subprocess_communicate_utf8_finish( _source_object as *mut _, res, &mut stdout_buf, &mut stderr_buf, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) }; let callback: Box<(R, *mut c_char)> = Box::from_raw(user_data as *mut _); glib_sys::g_free(callback.1 as *mut _); callback.0(result); } unsafe { gio_sys::g_subprocess_communicate_utf8_async( self.to_glib_none().0, stdin_buf, cancellable.0, Some(communicate_utf8_async_trampoline::), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "futures")] pub fn communicate_utf8_async_future( &self, stdin_buf: Option, ) -> Box> + std::marker::Unpin> { use fragile::Fragile; use GioFuture; GioFuture::new(self, move |obj, send| { let cancellable = Cancellable::new(); let send = Fragile::new(send); obj.communicate_utf8_async(stdin_buf, Some(&cancellable), move |res| { let _ = send.into_inner().send(res); }); cancellable }) } } gio-0.7.0/src/subprocess_launcher.rs010064400007650000024000000025571350341657000157360ustar0000000000000000#[cfg(any(unix, feature = "dox"))] use gio_sys; #[cfg(any(unix, feature = "dox"))] use glib::translate::*; #[cfg(any(unix, all(feature = "dox", unix)))] use std::os::unix::io::IntoRawFd; use SubprocessLauncher; #[cfg(all(feature = "dox", not(unix)))] pub trait IntoRawFd: Sized { fn into_raw_fd(self) -> i32 { 0 } } impl SubprocessLauncher { #[cfg(any(unix, feature = "dox"))] pub fn take_fd(&self, source_fd: F, target_fd: G) { unsafe { gio_sys::g_subprocess_launcher_take_fd( self.to_glib_none().0, source_fd.into_raw_fd(), target_fd.into_raw_fd(), ); } } #[cfg(any(unix, feature = "dox"))] pub fn take_stderr_fd(&self, fd: F) { unsafe { gio_sys::g_subprocess_launcher_take_stderr_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(any(unix, feature = "dox"))] pub fn take_stdin_fd(&self, fd: F) { unsafe { gio_sys::g_subprocess_launcher_take_stdin_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(any(unix, feature = "dox"))] pub fn take_stdout_fd(&self, fd: F) { unsafe { gio_sys::g_subprocess_launcher_take_stdout_fd(self.to_glib_none().0, fd.into_raw_fd()); } } } gio-0.7.0/src/test_util.rs010064400007650000024000000013221350341657000136660ustar0000000000000000// Copyright 2013-2017, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use glib::*; use std::sync::mpsc::{channel, Sender}; #[allow(dead_code)] pub fn run_async, MainLoop) + Send + 'static>( start: Q, ) -> T { let c = MainContext::new(); let l = MainLoop::new(Some(&c), false); let l_clone = l.clone(); let (tx, rx) = channel(); c.push_thread_default(); c.invoke(move || { start(tx, l_clone); }); l.run(); c.pop_thread_default(); let ret = rx.recv().unwrap(); ret } gio-0.7.0/src/unix_input_stream.rs010064400007650000024000000027641350341657000154420ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use glib::object::{Cast, IsA}; use glib::translate::*; use InputStream; use UnixInputStream; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(all(not(unix), feature = "dox"))] use socket::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; impl UnixInputStream { pub unsafe fn new(fd: T) -> UnixInputStream { let fd = fd.into_raw_fd(); let close_fd = true.to_glib(); InputStream::from_glib_full(gio_sys::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() } } impl AsRawFd for UnixInputStream { fn as_raw_fd(&self) -> RawFd { unsafe { gio_sys::g_unix_input_stream_get_fd(self.to_glib_none().0) as _ } } } pub trait UnixInputStreamExtManual: Sized { fn get_fd(&self) -> T; unsafe fn set_close_fd(&self, close_fd: bool); } impl> UnixInputStreamExtManual for O { fn get_fd(&self) -> T { unsafe { T::from_raw_fd(gio_sys::g_unix_input_stream_get_fd( self.as_ref().to_glib_none().0, )) } } unsafe fn set_close_fd(&self, close_fd: bool) { gio_sys::g_unix_input_stream_set_close_fd( self.as_ref().to_glib_none().0, close_fd.to_glib(), ); } } gio-0.7.0/src/unix_output_stream.rs010064400007650000024000000030011350341657000156240ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use glib::object::{Cast, IsA}; use glib::translate::*; use OutputStream; use UnixOutputStream; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(all(not(unix), feature = "dox"))] use socket::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; impl UnixOutputStream { pub unsafe fn new(fd: T) -> UnixOutputStream { let fd = fd.into_raw_fd(); let close_fd = true.to_glib(); OutputStream::from_glib_full(gio_sys::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() } } impl AsRawFd for UnixOutputStream { fn as_raw_fd(&self) -> RawFd { unsafe { gio_sys::g_unix_output_stream_get_fd(self.to_glib_none().0) as _ } } } pub trait UnixOutputStreamExtManual: Sized { fn get_fd(&self) -> T; unsafe fn set_close_fd(&self, close_fd: bool); } impl> UnixOutputStreamExtManual for O { fn get_fd(&self) -> T { unsafe { T::from_raw_fd(gio_sys::g_unix_output_stream_get_fd( self.as_ref().to_glib_none().0, )) } } unsafe fn set_close_fd(&self, close_fd: bool) { gio_sys::g_unix_output_stream_set_close_fd( self.as_ref().to_glib_none().0, close_fd.to_glib(), ); } } gio-0.7.0/src/unix_socket_address.rs010064400007650000024000000062321350341657000157170ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or use gio_sys; use glib::object::{Cast, IsA}; use glib::translate::*; use libc; use std::ffi::OsStr; #[cfg(unix)] use std::os::unix::ffi::OsStrExt; use std::path; use std::ptr; use std::slice; use SocketAddress; use UnixSocketAddress; use UnixSocketAddressExt; use UnixSocketAddressType; #[derive(Debug)] pub enum UnixSocketAddressPath<'a> { Path(&'a path::Path), Anonymous, Abstract(&'a [u8]), AbstractPadded(&'a [u8]), } impl<'a> UnixSocketAddressPath<'a> { fn to_type(&self) -> UnixSocketAddressType { use self::UnixSocketAddressPath::*; match *self { Path(_) => UnixSocketAddressType::Path, Anonymous => UnixSocketAddressType::Anonymous, Abstract(_) => UnixSocketAddressType::Abstract, AbstractPadded(_) => UnixSocketAddressType::AbstractPadded, } } } impl UnixSocketAddress { pub fn new(path: &path::Path) -> UnixSocketAddress { unsafe { SocketAddress::from_glib_full(gio_sys::g_unix_socket_address_new(path.to_glib_none().0)) .unsafe_cast() } } pub fn new_with_type(address_type: UnixSocketAddressPath) -> Self { use self::UnixSocketAddressPath::*; let type_ = address_type.to_type(); let (path, len) = match address_type { Path(path) => (path.to_glib_none().0, path.as_os_str().len()), Abstract(path) | AbstractPadded(path) => { (path.to_glib_none().0 as *mut libc::c_char, path.len()) } Anonymous => (ptr::null_mut(), 0), }; unsafe { SocketAddress::from_glib_full(gio_sys::g_unix_socket_address_new_with_type( path, len as i32, type_.to_glib(), )) .unsafe_cast() } } } pub trait UnixSocketAddressExtManual { fn get_path(&self) -> Option; } impl> UnixSocketAddressExtManual for O { fn get_path(&self) -> Option { use self::UnixSocketAddressPath::*; let path = unsafe { let path = gio_sys::g_unix_socket_address_get_path(self.as_ref().to_glib_none().0); if path.is_null() { &[] } else { slice::from_raw_parts(path as *const u8, self.get_path_len()) } }; match self.get_address_type() { UnixSocketAddressType::Anonymous => Some(Anonymous), #[cfg(not(feature = "dox"))] UnixSocketAddressType::Path => Some(Path(path::Path::new(OsStr::from_bytes(path)))), #[cfg(feature = "dox")] UnixSocketAddressType::Path => unreachable!(), UnixSocketAddressType::Abstract => Some(Abstract(path)), UnixSocketAddressType::AbstractPadded => Some(AbstractPadded(path)), UnixSocketAddressType::Invalid | UnixSocketAddressType::__Unknown(_) => None, } } } gio-0.7.0/tests/check_gir.rs010064400007650000024000000006461350341527700141560ustar0000000000000000// Copyright 2013-2018, The Gtk-rs Project Developers. // See the COPYRIGHT file at the top-level directory of this distribution. // Licensed under the MIT license, see the LICENSE file or extern crate gir_format_check; #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{}", res.to_string()); assert_eq!(res.nb_errors, 0); } gio-0.7.0/tests/std_io_copy.rs010064400007650000024000000011571350341657000145460ustar0000000000000000#![cfg(feature = "v2_36")] extern crate gio; extern crate glib; use gio::prelude::*; use std::io; #[test] #[cfg(feature = "v2_36")] fn std_io_copy_with_gio() { let bytes = glib::Bytes::from_owned([1, 2, 3]); let mut read = gio::MemoryInputStream::new_from_bytes(&bytes).into_read(); let mut write = gio::MemoryOutputStream::new_resizable().into_write(); let result = io::copy(&mut read, &mut write); let out_stream = write.into_output_stream(); out_stream.close(gio::NONE_CANCELLABLE).unwrap(); assert_eq!(result.unwrap(), 3); assert_eq!(out_stream.steal_as_bytes().unwrap(), bytes); } gio-0.7.0/.cargo_vcs_info.json0000644000000001120000000000000116470ustar00{ "git": { "sha1": "9202280d530bd22ba0035705cfa6261eacfd9623" } }