├── cairo ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── build.rs │ └── Cargo.toml ├── src │ ├── font │ │ ├── text_cluster.rs │ │ ├── glyph.rs │ │ └── mod.rs │ ├── quartz_surface.rs │ └── constants.rs └── Cargo.toml ├── gio ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── versions.txt │ ├── build.rs │ ├── tests │ │ └── manual.h │ └── Gir.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── dbus_arg_info.rs │ │ ├── dbus_method_info.rs │ │ ├── dbus_signal_info.rs │ │ ├── dbus_property_info.rs │ │ ├── native_volume_monitor.rs │ │ ├── simple_permission.rs │ │ ├── native_socket_address.rs │ │ ├── bytes_icon.rs │ │ ├── file_icon.rs │ │ ├── simple_action_group.rs │ │ ├── dbus_menu_model.rs │ │ ├── simple_io_stream.rs │ │ ├── dbus_action_group.rs │ │ ├── datagram_based.rs │ │ ├── property_action.rs │ │ ├── unix_fd_list.rs │ │ ├── unix_input_stream.rs │ │ ├── unix_output_stream.rs │ │ ├── initable.rs │ │ ├── menu_link_iter.rs │ │ ├── pollable_input_stream.rs │ │ ├── menu_attribute_iter.rs │ │ ├── emblem.rs │ │ ├── converter.rs │ │ ├── app_info_monitor.rs │ │ ├── action_map.rs │ │ ├── socket_connectable.rs │ │ ├── file_attribute_info_list.rs │ │ ├── dbus_interface.rs │ │ ├── dbus_node_info.rs │ │ ├── tcp_wrapper_connection.rs │ │ └── dbus_object_proxy.rs │ ├── flags.rs │ ├── dbus_message.rs │ ├── debug_controller_dbus.rs │ ├── inet_socket_address.rs │ ├── threaded_socket_service.rs │ ├── socket_control_message.rs │ ├── content_type.rs │ ├── unix_mount_point.rs │ ├── file_attribute_matcher.rs │ ├── memory_output_stream.rs │ ├── file_attribute_info_list.rs │ ├── test_util.rs │ ├── subclass │ │ └── mod.rs │ ├── dbus_node_info.rs │ ├── simple_proxy_resolver.rs │ ├── file_descriptor_based.rs │ ├── unix_fd_message.rs │ └── action_map.rs ├── build.rs ├── tests │ ├── check_gir.rs │ ├── com.github.gtk-rs.test.gschema.xml │ ├── std_io_copy.rs │ └── content_type.rs └── README.md ├── glib ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── versions.txt │ ├── build.rs │ └── tests │ │ └── manual.h ├── gobject-sys │ ├── LICENSE │ ├── versions.txt │ ├── tests │ │ └── manual.h │ ├── Gir.toml │ └── build.rs ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── alias.rs │ │ ├── checksum.rs │ │ └── main_loop.rs │ ├── collections │ │ └── mod.rs │ ├── date_time.rs │ ├── time_zone.rs │ ├── prelude.rs │ └── gobject │ │ ├── auto │ │ ├── mod.rs │ │ └── binding.rs │ │ ├── mod.rs │ │ ├── interface_info.rs │ │ ├── type_info.rs │ │ └── type_value_table.rs ├── tests │ ├── subclass_compiletest │ │ ├── 03-object-no-auto-send-sync.rs │ │ ├── 01-auto-send-sync.rs │ │ ├── 02-no-auto-send-sync.rs │ │ ├── 02-no-auto-send-sync.stderr │ │ └── 06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs │ ├── check_gir.rs │ ├── regex_compiletest │ │ ├── 05-variance.rs │ │ ├── 05-variance.stderr │ │ ├── 02-dangling.rs │ │ ├── 04-nonstatic-value.rs │ │ ├── 03-static-value.rs │ │ ├── 01-not-dangling.rs │ │ └── 06-property.rs │ ├── subclass_compiletest.rs │ ├── derive.rs │ └── regex_compiletest.rs └── benches │ └── gstring.rs ├── pango ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── versions.txt │ ├── tests │ │ └── manual.h │ ├── build.rs │ └── Gir.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── alias.rs │ │ ├── color.rs │ │ ├── fontset_simple.rs │ │ ├── attribute.rs │ │ └── glyph_item.rs │ ├── prelude.rs │ ├── attr_string.rs │ ├── item.rs │ ├── attr_font_desc.rs │ ├── attr_font_features.rs │ ├── attr_language.rs │ ├── attr_size.rs │ ├── attr_shape.rs │ ├── attr_float.rs │ ├── glyph_item.rs │ ├── glyph_info.rs │ ├── language.rs │ ├── glyph_geometry.rs │ ├── analysis.rs │ └── rectangle.rs ├── tests │ └── check_gir.rs ├── Cargo.toml └── README.md ├── gdk-pixbuf ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── versions.txt │ ├── tests │ │ └── manual.h │ ├── Gir.toml │ ├── build.rs │ └── Cargo.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── pixbuf_non_anim.rs │ │ ├── mod.rs │ │ └── flags.rs │ ├── prelude.rs │ ├── lib.rs │ ├── subclass │ │ └── mod.rs │ └── pixbuf_animation.rs ├── tests │ └── check_gir.rs ├── Cargo.toml └── README.md ├── generator.py ├── graphene ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── tests │ │ └── manual.h │ ├── versions.txt │ ├── build.rs │ ├── Gir.toml │ └── Cargo.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── quad.rs │ │ └── mod.rs │ ├── prelude.rs │ ├── lib.rs │ ├── size.rs │ ├── ray.rs │ └── point.rs ├── tests │ └── check_gir.rs ├── Cargo.toml └── README.md ├── pangocairo ├── LICENSE ├── COPYRIGHT ├── sys │ ├── LICENSE │ ├── versions.txt │ ├── Gir.toml │ ├── build.rs │ └── Cargo.toml ├── src │ ├── auto │ │ ├── versions.txt │ │ ├── mod.rs │ │ ├── font.rs │ │ └── font_map.rs │ ├── prelude.rs │ ├── lib.rs │ └── font_map.rs ├── tests │ ├── check_gir.rs │ └── iterators.rs ├── Cargo.toml └── README.md ├── glib-macros ├── COPYRIGHT ├── LICENSE ├── src │ ├── downgrade_derive │ │ └── mod.rs │ └── async_test.rs └── Cargo.toml ├── rustfmt.toml ├── glib-build-tools ├── COPYRIGHT ├── LICENSE ├── README.md └── Cargo.toml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── blank-issue.md │ ├── feature-request-or-missing-binding.md │ ├── bug_report.md │ └── asking-for-help.md ├── workflows │ ├── typos.yml │ └── image.yml └── dependabot.yml ├── .gitattributes ├── tests └── two-levels-glib-dependent │ ├── gtk │ ├── src │ │ └── lib.rs │ └── Cargo.toml │ ├── gstreamer │ ├── src │ │ └── lib.rs │ └── Cargo.toml │ ├── Cargo.toml │ ├── README.md │ └── glib-dependent-dependent │ ├── Cargo.toml │ └── src │ └── lib.rs ├── examples ├── resources │ ├── eye.png │ ├── file.png │ ├── menu.png │ └── resources.gresource.xml ├── build.rs ├── gio_futures │ └── README.md ├── gio_cancellable_future │ ├── README.md │ └── main.rs ├── gio_async_tls │ └── README.md ├── gio_futures_await │ └── README.md ├── object_subclass │ ├── main.rs │ └── author.rs ├── gio_task │ ├── README.md │ └── file_size │ │ └── imp.rs ├── README.md ├── Cargo.toml └── virtual_methods │ ├── main.rs │ └── tabby_cat.rs ├── .gitignore ├── .gitmodules ├── .typos.toml ├── deny.toml ├── COPYRIGHT ├── LICENSE └── Cargo.toml /cairo/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /gio/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /glib/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /pango/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /cairo/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gdk-pixbuf/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /generator.py: -------------------------------------------------------------------------------- 1 | gir/generator.py -------------------------------------------------------------------------------- /gio/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /gio/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /glib/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /graphene/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /pango/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /pangocairo/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /cairo/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /gdk-pixbuf/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /glib-macros/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /glib-macros/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /glib/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /graphene/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /graphene/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /pango/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /pangocairo/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | -------------------------------------------------------------------------------- /gdk-pixbuf/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /glib-build-tools/COPYRIGHT: -------------------------------------------------------------------------------- 1 | ../COPYRIGHT -------------------------------------------------------------------------------- /glib-build-tools/LICENSE: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /glib/gobject-sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /pangocairo/sys/LICENSE: -------------------------------------------------------------------------------- 1 | ../../LICENSE -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: gtk-rs 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | Cargo.* eol=lf 2 | *.sh eol=lf 3 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/gtk/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use glib; 2 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/gstreamer/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub use glib; 2 | -------------------------------------------------------------------------------- /examples/resources/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shahradelahi/gtk-rs-core/main/examples/resources/eye.png -------------------------------------------------------------------------------- /examples/resources/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shahradelahi/gtk-rs-core/main/examples/resources/file.png -------------------------------------------------------------------------------- /examples/resources/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shahradelahi/gtk-rs-core/main/examples/resources/menu.png -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "gstreamer", 5 | "gtk", 6 | "glib-dependent-dependent" 7 | ] 8 | -------------------------------------------------------------------------------- /gio/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /glib/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /graphene/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /pango/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /gdk-pixbuf/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /gio/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /glib/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /graphene/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /pango/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /pangocairo/sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /glib/gobject-sys/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /graphene/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /pangocairo/src/auto/versions.txt: -------------------------------------------------------------------------------- 1 | Generated by gir (https://github.com/gtk-rs/gir @ 19e8a2f15e0e) 2 | from gir-files (https://github.com/gtk-rs/gir-files @ be4559caec2b) 3 | -------------------------------------------------------------------------------- /gio/build.rs: -------------------------------------------------------------------------------- 1 | // This whole build.rs file is required because of the `OUT_DIR` environment variable 2 | // provided by cargo when a build file is present. 3 | fn main() {} 4 | -------------------------------------------------------------------------------- /glib/gobject-sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/blank-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Blank issue 3 | about: None of the above templates match your issue 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **test/bin/ 2 | **target/ 3 | **doc/ 4 | configure.in 5 | config.log 6 | config.status 7 | *.dylib 8 | .rust 9 | *.so 10 | *.o 11 | *.swp 12 | gtk/tests/* 13 | **~ 14 | **/docs.md 15 | -------------------------------------------------------------------------------- /examples/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | glib_build_tools::compile_resources( 3 | &["resources"], 4 | "resources/resources.gresource.xml", 5 | "compiled.gresource", 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /glib/tests/subclass_compiletest/03-object-no-auto-send-sync.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | fn check(_obj: &T) {} 3 | 4 | let obj = glib::Object::new::(); 5 | check(&obj); 6 | } 7 | -------------------------------------------------------------------------------- /examples/gio_futures/README.md: -------------------------------------------------------------------------------- 1 | # GIO Futures 2 | 3 | This example reads our `Cargo.toml` by executing GIO futures. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gio_futures 9 | ``` 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gir"] 2 | path = gir 3 | url = https://github.com/gtk-rs/gir 4 | update = none 5 | [submodule "gir-files"] 6 | path = gir-files 7 | url = https://github.com/gtk-rs/gir-files 8 | update = none 9 | -------------------------------------------------------------------------------- /examples/gio_cancellable_future/README.md: -------------------------------------------------------------------------------- 1 | # GIO Futures 2 | 3 | This example reads our `Cargo.toml` by executing GIO futures. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gio_cancellable_future 9 | ``` 10 | -------------------------------------------------------------------------------- /graphene/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Traits intended for blanket imports. 5 | 6 | #[doc(hidden)] 7 | pub use glib::prelude::*; 8 | -------------------------------------------------------------------------------- /pango/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #define PANGO_ENABLE_BACKEND 4 | #define PANGO_ENABLE_ENGINE 5 | #include 6 | #include 7 | -------------------------------------------------------------------------------- /gio/src/flags.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ApplicationFlags; 4 | 5 | impl Default for ApplicationFlags { 6 | fn default() -> Self { 7 | Self::empty() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/gio_async_tls/README.md: -------------------------------------------------------------------------------- 1 | # GIO Async TLS 2 | 3 | This example demonstrates the usage of GIO async TLS by downloading the Rust's homepage. 4 | 5 | Run it by executing: 6 | 7 | ```bash 8 | cargo run --bin gio_async_tls --features="async-tls" 9 | ``` 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request-or-missing-binding.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request or missing binding 3 | about: A missing binding or something that could be improved 4 | title: "[FEATURE REQUEST]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /gio/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /glib/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /pango/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /examples/gio_futures_await/README.md: -------------------------------------------------------------------------------- 1 | # GIO Futures Await 2 | 3 | This example reads our `Cargo.toml` by executing GIO futures. 4 | It does that by using the convenient `await` syntax. 5 | 6 | Run it by executing: 7 | 8 | ```bash 9 | cargo run --bin gio_futures_await 10 | ``` 11 | -------------------------------------------------------------------------------- /examples/resources/resources.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eye.png 5 | file.png 6 | menu.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /gdk-pixbuf/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /graphene/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /pangocairo/tests/check_gir.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[test] 4 | fn check_gir_file() { 5 | let res = gir_format_check::check_gir_file("Gir.toml"); 6 | println!("{res}"); 7 | assert_eq!(res.nb_errors, 0); 8 | } 9 | -------------------------------------------------------------------------------- /pangocairo/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[doc(hidden)] 4 | pub use glib::prelude::*; 5 | #[doc(hidden)] 6 | pub use pango::prelude::*; 7 | 8 | pub use crate::{auto::traits::*, font_map::PangoCairoFontMapExtManual}; 9 | -------------------------------------------------------------------------------- /gdk-pixbuf/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | // The bindings include the pixbuf loader API 4 | #define GDK_PIXBUF_ENABLE_BACKEND 5 | 6 | #include 7 | #include 8 | -------------------------------------------------------------------------------- /pangocairo/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "PangoCairo" 4 | version = "1.0" 5 | min_cfg_version = "1.40" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "Pango", 12 | "Cairo", 13 | ] 14 | -------------------------------------------------------------------------------- /pango/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Traits and essential types intended for blanket imports. 5 | 6 | #[doc(hidden)] 7 | pub use glib::prelude::*; 8 | 9 | pub use crate::{attribute::IsAttribute, auto::traits::*}; 10 | -------------------------------------------------------------------------------- /gio/src/dbus_message.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::fmt; 4 | 5 | use crate::DBusMessage; 6 | 7 | impl fmt::Display for DBusMessage { 8 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 9 | write!(f, "{}", self.print(0)) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/05-variance.rs: -------------------------------------------------------------------------------- 1 | use glib::MatchInfo; 2 | 3 | // pass 4 | fn covariance_check<'short>(input: MatchInfo<'static>) -> MatchInfo<'short> { 5 | input 6 | } 7 | 8 | // fail 9 | fn contravariance_check<'short>(input: MatchInfo<'short>) -> MatchInfo<'static> { 10 | input 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /cairo/sys/build.rs: -------------------------------------------------------------------------------- 1 | #[cfg(not(docsrs))] 2 | use std::process; 3 | 4 | #[cfg(docsrs)] 5 | fn main() {} // prevent linking libraries to avoid documentation failure 6 | 7 | #[cfg(not(docsrs))] 8 | fn main() { 9 | if let Err(s) = system_deps::Config::new().probe() { 10 | println!("cargo:warning={s}"); 11 | process::exit(1); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /glib/src/collections/mod.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | pub mod ptr_slice; 4 | pub use ptr_slice::PtrSlice; 5 | 6 | pub mod slice; 7 | pub use slice::Slice; 8 | 9 | pub mod list; 10 | pub use list::List; 11 | 12 | pub mod slist; 13 | pub use slist::SList; 14 | 15 | pub mod strv; 16 | pub use strv::StrV; 17 | -------------------------------------------------------------------------------- /.github/workflows/typos.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - "main" 7 | jobs: 8 | typos: 9 | name: Spell Check with Typos 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout Actions Repository 13 | uses: actions/checkout@v4 14 | - name: Check spelling 15 | uses: crate-ci/typos@master 16 | -------------------------------------------------------------------------------- /.typos.toml: -------------------------------------------------------------------------------- 1 | [files] 2 | extend-exclude = ["auto", "sys", "gobject-sys", "*.svg", "glib/Gir.toml"] 3 | 4 | [default.extend-words] 5 | # Ignore false-positives 6 | gir = "gir" 7 | mak = "mak" 8 | anid = "anid" 9 | lamda = "lamda" 10 | inout = "inout" 11 | relm = "relm" 12 | ba = "ba" 13 | ue = "ue" 14 | ot = "ot" 15 | siz = "siz" 16 | vai = "vai" 17 | guid = "guid" 18 | typ = "typ" 19 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Traits intended for blanket imports. 5 | 6 | #[doc(hidden)] 7 | pub use glib::prelude::*; 8 | 9 | #[doc(hidden)] 10 | pub use gio::prelude::*; 11 | 12 | pub use crate::{auto::traits::*, pixbuf_animation::PixbufAnimationExtManual}; 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" # Location of package manifests 6 | schedule: 7 | interval: "weekly" 8 | - package-ecosystem: "cargo" 9 | directory: "/" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /examples/object_subclass/main.rs: -------------------------------------------------------------------------------- 1 | mod author; 2 | 3 | use glib::prelude::*; 4 | 5 | fn main() { 6 | let author = author::Author::new("John", "Doe"); 7 | author.set_name("Jane"); 8 | author.connect("awarded", true, |_author| { 9 | println!("Author received a new award!"); 10 | None 11 | }); 12 | 13 | println!("Author: {} {}", author.name(), author.surname()); 14 | } 15 | -------------------------------------------------------------------------------- /glib/gobject-sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "GObject" 4 | version = "2.0" 5 | min_cfg_version = "2.56" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | ] 12 | extra_versions = [ 13 | "2.82" 14 | ] 15 | ignore = [ 16 | "GObject.VaClosureMarshal", 17 | "GObject.SignalCVaMarshaller", 18 | ] 19 | -------------------------------------------------------------------------------- /glib/src/auto/alias.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[allow(unused_imports)] 6 | use crate::auto::*; 7 | 8 | #[doc(alias = "GDateDay")] 9 | pub type DateDay = u8; 10 | #[doc(alias = "GDateYear")] 11 | pub type DateYear = u16; 12 | #[doc(alias = "GTime")] 13 | pub type Time = i32; 14 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/05-variance.stderr: -------------------------------------------------------------------------------- 1 | error: lifetime may not live long enough 2 | --> tests/regex_compiletest/05-variance.rs:10:5 3 | | 4 | 9 | fn contravariance_check<'short>(input: MatchInfo<'short>) -> MatchInfo<'static> { 5 | | ------ lifetime `'short` defined here 6 | 10 | input 7 | | ^^^^^ returning this value requires that `'short` must outlive `'static` 8 | -------------------------------------------------------------------------------- /examples/gio_task/README.md: -------------------------------------------------------------------------------- 1 | # GTask example 2 | 3 | This example demonstrates how to implement a GIO async/finish API based on GTask (see 4 | https://developer.gnome.org/gio/stable/GTask.html) in Rust using the GTask generated bindings. 5 | This can be useful, for example, when porting to Rust some existing C code exposing such an API. 6 | 7 | Run it by executing: 8 | 9 | ```bash 10 | cargo run --bin gio_task 11 | ``` 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Bug description** 11 | 12 | Please provide a code sample as small as possible which reproduces the bug. 13 | 14 | **Backtrace** 15 | 16 | You can get the backtrace running your program with the environment variable `RUST_BACKTRACE=full`. 17 | -------------------------------------------------------------------------------- /pango/src/auto/alias.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[allow(unused_imports)] 6 | use crate::auto::*; 7 | 8 | #[doc(alias = "PangoGlyph")] 9 | pub type Glyph = u32; 10 | #[doc(alias = "PangoGlyphUnit")] 11 | pub type GlyphUnit = i32; 12 | #[doc(alias = "PangoLayoutRun")] 13 | pub type LayoutRun = GlyphItem; 14 | -------------------------------------------------------------------------------- /glib/src/date_time.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[cfg(test)] 4 | mod tests { 5 | use crate::{prelude::*, DateTime}; 6 | 7 | #[test] 8 | fn test_value() { 9 | let dt1 = DateTime::now_utc().unwrap(); 10 | let v = dt1.to_value(); 11 | let dt2 = v.get::<&DateTime>().unwrap(); 12 | 13 | assert_eq!(dt1.as_ptr(), dt2.as_ptr()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /gio/tests/com.github.gtk-rs.test.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | "Good" 9 | 10 | 11 | 12 | true 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pangocairo/src/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod font; 6 | pub use self::font::Font; 7 | 8 | mod font_map; 9 | pub use self::font_map::FontMap; 10 | 11 | pub(crate) mod functions; 12 | 13 | pub(crate) mod traits { 14 | pub use super::font::PangoCairoFontExt; 15 | pub use super::font_map::PangoCairoFontMapExt; 16 | } 17 | -------------------------------------------------------------------------------- /pangocairo/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg))] 4 | #![doc = include_str!("../README.md")] 5 | 6 | pub use cairo; 7 | pub use glib; 8 | pub use pango; 9 | pub use pango_cairo_sys as ffi; 10 | 11 | mod auto; 12 | 13 | pub use crate::auto::*; 14 | pub mod prelude; 15 | pub mod functions { 16 | pub use super::auto::functions::*; 17 | } 18 | 19 | mod font_map; 20 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/02-dangling.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let r = glib::Regex::new( 3 | "hello", 4 | glib::RegexCompileFlags::DEFAULT, 5 | glib::RegexMatchFlags::DEFAULT, 6 | ) 7 | .unwrap() 8 | .unwrap(); 9 | let s = glib::GString::from("hello"); 10 | let match_info = r 11 | .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT) 12 | .expect("should match"); 13 | dbg!(match_info.fetch_all()); 14 | drop(s); 15 | } 16 | -------------------------------------------------------------------------------- /gio/src/debug_controller_dbus.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::prelude::*; 4 | 5 | use crate::{DBusConnection, DebugControllerDBus}; 6 | 7 | pub trait DebugControllerDBusExtManual: IsA + Sized { 8 | fn connection(&self) -> DBusConnection { 9 | ObjectExt::property(self.as_ref(), "connection") 10 | } 11 | } 12 | 13 | impl> DebugControllerDBusExtManual for O {} 14 | -------------------------------------------------------------------------------- /gdk-pixbuf/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "GdkPixbuf" 4 | version = "2.0" 5 | min_cfg_version = "2.36.8" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "GObject", 12 | "Gio", 13 | ] 14 | 15 | ignore = [ 16 | "GdkPixbuf.PIXBUF_FEATURES_H", 17 | "GdkPixbuf.PIXBUF_MAJOR", 18 | "GdkPixbuf.PIXBUF_MICRO", 19 | "GdkPixbuf.PIXBUF_MINOR", 20 | "GdkPixbuf.PIXBUF_VERSION", 21 | ] 22 | -------------------------------------------------------------------------------- /glib-build-tools/README.md: -------------------------------------------------------------------------------- 1 | # GIO build helpers 2 | 3 | Crate containing helpers for building GIO-based applications. 4 | 5 | ## Minimum supported Rust version 6 | 7 | Currently, the minimum supported Rust version is `1.83.0`. 8 | 9 | ## Documentation 10 | 11 | * [Stable API](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib-build-tools) 12 | * [Development API](https://gtk-rs.org/gtk-rs-core/git/latest/docs/glib-build-tools) 13 | 14 | ### See Also 15 | 16 | * [gio](http://crates.io/crates/gio) 17 | -------------------------------------------------------------------------------- /gio/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /glib/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pango/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gdk-pixbuf/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /graphene/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pangocairo/sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/asking-for-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Asking for help 3 | about: You have a question on how to use gtk-rs-core 4 | title: "[HELP]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | If you need help to use the libraries and not the Rust API specifically, better go to instead. 11 | 12 | In case you need help with the Rust API, please provide as much information as possible and a sample of code as small as possible which reproduces your issue so we can help you better. 13 | -------------------------------------------------------------------------------- /glib/gobject-sys/build.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | #[cfg(not(docsrs))] 6 | use std::process; 7 | 8 | #[cfg(docsrs)] 9 | fn main() {} // prevent linking libraries to avoid documentation failure 10 | 11 | #[cfg(not(docsrs))] 12 | fn main() { 13 | if let Err(s) = system_deps::Config::new().probe() { 14 | println!("cargo:warning={s}"); 15 | process::exit(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/gtk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | # This crate is named `gtk` so that we can check that `glib` re-export detection succeeds. 3 | name = "gtk" 4 | version = "0.1.0" 5 | authors = ["François Laignel "] 6 | description = "gtk simulator as a glib dependent crate for validation of glib re-exports in proc-macros" 7 | keywords = ["gtk-rs-core", "integration"] 8 | license = "MIT/Apache-2.0" 9 | edition = "2021" 10 | rust-version = "1.83" 11 | 12 | [dependencies] 13 | glib = { path = "../../../glib" } 14 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/README.md: -------------------------------------------------------------------------------- 1 | # glib-rs Two Levels Dependent Test 2 | 3 | This repository is intended at checking `glib` macro 4 | re-export detection in two levels dependencies. 5 | 6 | The detection mechanism used to stop at the first identified crate known 7 | to re-export `glib` and which was found in `Cargo.toml`. When used in a crate 8 | that depends both on `gstreamer` and `gtk` and `gtk` is optional, the detection 9 | mechanism stopped at `gtk` and prepended `gtk` to `glib`, leading to errors 10 | compiling `glib` proc-macros. -------------------------------------------------------------------------------- /gio/src/auto/dbus_arg_info.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct DBusArgInfo(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::g_dbus_arg_info_ref(ptr), 13 | unref => |ptr| ffi::g_dbus_arg_info_unref(ptr), 14 | type_ => || ffi::g_dbus_arg_info_get_type(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/gstreamer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | # This crate is named `gstreamer` so that we can check that `glib` re-export detection succeeds. 3 | name = "gstreamer" 4 | version = "0.1.0" 5 | authors = ["François Laignel "] 6 | description = "gstreamer simulator as a glib dependent crate for validation of glib re-exports in proc-macros" 7 | keywords = ["gtk-rs-core", "integration"] 8 | license = "MIT/Apache-2.0" 9 | edition = "2021" 10 | rust-version = "1.83" 11 | 12 | [dependencies] 13 | glib = { path = "../../../glib" } 14 | -------------------------------------------------------------------------------- /deny.toml: -------------------------------------------------------------------------------- 1 | [graph] 2 | exclude = [ 3 | "gtk-rs-examples", 4 | ] 5 | 6 | [advisories] 7 | version = 2 8 | db-path = "~/.cargo/advisory-db" 9 | db-urls = ["https://github.com/rustsec/advisory-db"] 10 | ignore = [] 11 | 12 | [licenses] 13 | version = 2 14 | allow = [ 15 | "MIT", 16 | "Apache-2.0", 17 | "Apache-2.0 WITH LLVM-exception", 18 | "Unicode-3.0", 19 | ] 20 | confidence-threshold = 0.8 21 | 22 | [bans] 23 | multiple-versions = "deny" 24 | wildcards = "allow" 25 | highlight = "all" 26 | 27 | [sources] 28 | unknown-registry = "deny" 29 | unknown-git = "deny" 30 | -------------------------------------------------------------------------------- /gio/src/inet_socket_address.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::net::SocketAddr; 4 | 5 | use crate::{prelude::*, InetAddress, InetSocketAddress}; 6 | 7 | impl From for InetSocketAddress { 8 | fn from(addr: SocketAddr) -> Self { 9 | Self::new(&InetAddress::from(addr.ip()), addr.port()) 10 | } 11 | } 12 | 13 | impl From for SocketAddr { 14 | fn from(addr: InetSocketAddress) -> Self { 15 | Self::new(addr.address().into(), addr.port()) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gio/src/auto/dbus_method_info.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct DBusMethodInfo(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::g_dbus_method_info_ref(ptr), 13 | unref => |ptr| ffi::g_dbus_method_info_unref(ptr), 14 | type_ => || ffi::g_dbus_method_info_get_type(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gio/src/auto/dbus_signal_info.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct DBusSignalInfo(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::g_dbus_signal_info_ref(ptr), 13 | unref => |ptr| ffi::g_dbus_signal_info_unref(ptr), 14 | type_ => || ffi::g_dbus_signal_info_get_type(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gio/src/auto/dbus_property_info.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | 7 | glib::wrapper! { 8 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 9 | pub struct DBusPropertyInfo(Shared); 10 | 11 | match fn { 12 | ref => |ptr| ffi::g_dbus_property_info_ref(ptr), 13 | unref => |ptr| ffi::g_dbus_property_info_unref(ptr), 14 | type_ => || ffi::g_dbus_property_info_get_type(), 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /gio/tests/std_io_copy.rs: -------------------------------------------------------------------------------- 1 | use gio::prelude::*; 2 | 3 | #[test] 4 | fn std_io_copy_with_gio() { 5 | let bytes = glib::Bytes::from_owned([1, 2, 3]); 6 | let mut read = gio::MemoryInputStream::from_bytes(&bytes).into_read(); 7 | let mut write = gio::MemoryOutputStream::new_resizable().into_write(); 8 | 9 | let result = std::io::copy(&mut read, &mut write); 10 | 11 | let out_stream = write.into_output_stream(); 12 | out_stream.close(gio::Cancellable::NONE).unwrap(); 13 | assert_eq!(result.unwrap(), 3); 14 | assert_eq!(out_stream.steal_as_bytes(), bytes); 15 | } 16 | -------------------------------------------------------------------------------- /gio/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #define G_SETTINGS_ENABLE_BACKEND 1 15 | #include 16 | -------------------------------------------------------------------------------- /glib/src/time_zone.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::translate::*; 4 | use crate::{TimeType, TimeZone}; 5 | 6 | impl TimeZone { 7 | #[doc(alias = "g_time_zone_adjust_time")] 8 | pub fn adjust_time(&self, type_: TimeType, mut time: i64) -> (i32, i64) { 9 | unsafe { 10 | let res = crate::ffi::g_time_zone_adjust_time( 11 | self.to_glib_none().0, 12 | type_.into_glib(), 13 | &mut time, 14 | ); 15 | (res, time) 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pango/src/attr_string.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType}; 6 | 7 | define_attribute_struct!(AttrString, ffi::PangoAttrString, &[AttrType::Family]); 8 | 9 | impl AttrString { 10 | #[doc(alias = "pango_attr_family_new")] 11 | pub fn new_family(family: &str) -> Self { 12 | unsafe { from_glib_full(ffi::pango_attr_family_new(family.to_glib_none().0)) } 13 | } 14 | 15 | pub fn value(&self) -> glib::GString { 16 | unsafe { from_glib_none(self.inner.value) } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pango/src/item.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::{Analysis, Item}; 4 | 5 | impl Item { 6 | pub fn offset(&self) -> i32 { 7 | unsafe { (*self.as_ptr()).offset } 8 | } 9 | 10 | pub fn length(&self) -> i32 { 11 | unsafe { (*self.as_ptr()).length } 12 | } 13 | 14 | pub fn num_chars(&self) -> i32 { 15 | unsafe { (*self.as_ptr()).num_chars } 16 | } 17 | 18 | pub fn analysis(&self) -> &Analysis { 19 | unsafe { &*(&((*self.as_ptr()).analysis) as *const _ as *const Analysis) } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /glib-build-tools/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "glib-build-tools" 3 | keywords = ["glib", "gio", "gtk-rs", "gnome", "build-dependencies"] 4 | readme = "README.md" 5 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib_build_tools" 6 | description = "Rust bindings for the Gio library, build script utils crate" 7 | authors.workspace = true 8 | edition.workspace = true 9 | exclude.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | repository.workspace = true 13 | rust-version.workspace = true 14 | version.workspace = true 15 | 16 | [dependencies] 17 | gio.workspace = true -------------------------------------------------------------------------------- /gdk-pixbuf/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![allow(clippy::manual_c_str_literals)] 4 | #![cfg_attr(docsrs, feature(doc_cfg))] 5 | #![doc = include_str!("../README.md")] 6 | 7 | pub use gdk_pixbuf_sys as ffi; 8 | pub use gio; 9 | pub use glib; 10 | 11 | #[allow(clippy::too_many_arguments)] 12 | #[allow(unused_imports)] 13 | mod auto; 14 | 15 | pub mod subclass; 16 | 17 | mod pixbuf; 18 | mod pixbuf_animation; 19 | mod pixbuf_animation_iter; 20 | pub mod prelude; 21 | 22 | pub use self::pixbuf_animation_iter::PixbufAnimationIter; 23 | pub use crate::auto::*; 24 | -------------------------------------------------------------------------------- /examples/gio_task/file_size/imp.rs: -------------------------------------------------------------------------------- 1 | use glib::subclass::prelude::*; 2 | 3 | // FileSize is a simple object that will just contain the read file size. 4 | // Initially the optional size field will be initialized to None. 5 | // It uses a Mutex rather than a plain RefCell since we also want to 6 | // use it for tasks that run in threads. 7 | #[derive(Default)] 8 | pub struct FileSize { 9 | pub size: std::sync::Mutex>, 10 | } 11 | 12 | #[glib::object_subclass] 13 | impl ObjectSubclass for FileSize { 14 | const NAME: &'static str = "FileSize"; 15 | type Type = super::FileSize; 16 | } 17 | 18 | impl ObjectImpl for FileSize {} 19 | -------------------------------------------------------------------------------- /gio/src/auto/native_volume_monitor.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, VolumeMonitor}; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "GNativeVolumeMonitor")] 9 | pub struct NativeVolumeMonitor(Object) @extends VolumeMonitor; 10 | 11 | match fn { 12 | type_ => || ffi::g_native_volume_monitor_get_type(), 13 | } 14 | } 15 | 16 | impl NativeVolumeMonitor { 17 | pub const NONE: Option<&'static NativeVolumeMonitor> = None; 18 | } 19 | -------------------------------------------------------------------------------- /gio/src/threaded_socket_service.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::{prelude::*, translate::*}; 4 | 5 | use crate::{SocketService, ThreadedSocketService}; 6 | 7 | impl ThreadedSocketService { 8 | #[doc(alias = "g_threaded_socket_service_new")] 9 | pub fn new(max_threads: Option) -> ThreadedSocketService { 10 | let max_threads = max_threads.map(|x| x as i32).unwrap_or(-1); 11 | unsafe { 12 | SocketService::from_glib_full(crate::ffi::g_threaded_socket_service_new(max_threads)) 13 | .unsafe_cast() 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pango/src/attr_font_desc.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType, FontDescription}; 6 | 7 | define_attribute_struct!(AttrFontDesc, ffi::PangoAttrFontDesc, &[AttrType::FontDesc]); 8 | 9 | impl AttrFontDesc { 10 | #[doc(alias = "pango_attr_font_desc_new")] 11 | pub fn new(desc: &FontDescription) -> Self { 12 | unsafe { from_glib_full(ffi::pango_attr_font_desc_new(desc.to_glib_none().0)) } 13 | } 14 | 15 | pub fn desc(&self) -> FontDescription { 16 | unsafe { from_glib_none(self.inner.desc) } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /glib/tests/subclass_compiletest.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | pub fn test() { 3 | let t = trybuild2::TestCases::new(); 4 | 5 | t.pass("tests/subclass_compiletest/01-auto-send-sync.rs"); 6 | t.compile_fail("tests/subclass_compiletest/02-no-auto-send-sync.rs"); 7 | t.compile_fail("tests/subclass_compiletest/03-object-no-auto-send-sync.rs"); 8 | t.pass("tests/subclass_compiletest/04-auto-send-sync-with-send-sync-parent.rs"); 9 | t.compile_fail("tests/subclass_compiletest/05-no-auto-send-sync-with-non-send-sync-parent.rs"); 10 | t.compile_fail( 11 | "tests/subclass_compiletest/06-no-auto-send-sync-with-non-send-sync-ffi-parent.rs", 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /glib/src/prelude.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Traits and essential types intended for blanket imports. 5 | 6 | pub use crate::{ 7 | error::ErrorDomain, 8 | gobject::traits::{DynamicObjectRegisterExt, TypeModuleExt, TypePluginExt}, 9 | object::{Cast, CastNone, IsA, ObjectClassExt, ObjectExt, ObjectType}, 10 | param_spec::{HasParamSpec, ParamSpecBuilderExt, ParamSpecType}, 11 | types::{StaticType, StaticTypeExt}, 12 | value::{ToSendValue, ToValue, ValueType}, 13 | variant::{FixedSizeVariantType, FromVariant, StaticVariantType, ToVariant}, 14 | }; 15 | -------------------------------------------------------------------------------- /gio/tests/content_type.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[cfg(unix)] 4 | #[test] 5 | fn test_content_type_guess() { 6 | // We only test for directory and file without extension here as we can't guarantee the 7 | // CI runners will have any mimetypes installed. 8 | let ret: (glib::GString, bool) = 9 | gio::functions::content_type_guess(Some(std::path::Path::new("test/")), None); 10 | assert_eq!(ret.0, "inode/directory"); 11 | 12 | let ret: (glib::GString, bool) = 13 | gio::functions::content_type_guess(Some(std::path::Path::new("test")), None); 14 | assert_eq!(ret.0, "application/octet-stream"); 15 | } 16 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/04-nonstatic-value.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use glib::prelude::*; 4 | 5 | fn main() { 6 | let r = glib::Regex::new( 7 | "hello", 8 | glib::RegexCompileFlags::DEFAULT, 9 | glib::RegexMatchFlags::DEFAULT, 10 | ) 11 | .unwrap() 12 | .unwrap(); 13 | let s = glib::GString::from("hello"); 14 | let match_info = r 15 | .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT) 16 | .expect("should match"); 17 | dbg!(match_info.fetch_all()); 18 | let v: glib::Value = match_info.to_value(); 19 | drop(match_info); 20 | drop(s); 21 | let match_info = v.get::>().unwrap(); 22 | } 23 | -------------------------------------------------------------------------------- /pango/src/attr_font_features.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType}; 6 | 7 | define_attribute_struct!( 8 | AttrFontFeatures, 9 | ffi::PangoAttrFontFeatures, 10 | &[AttrType::FontFeatures] 11 | ); 12 | 13 | impl AttrFontFeatures { 14 | #[doc(alias = "pango_attr_font_features_new")] 15 | pub fn new(features: &str) -> Self { 16 | unsafe { from_glib_full(ffi::pango_attr_font_features_new(features.to_glib_none().0)) } 17 | } 18 | 19 | pub fn features(&self) -> glib::GString { 20 | unsafe { from_glib_none(self.inner.features) } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/subclass/mod.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! Traits intended for creating custom types. 5 | 6 | pub mod pixbuf_animation; 7 | pub mod pixbuf_animation_iter; 8 | pub mod pixbuf_loader; 9 | 10 | pub mod prelude { 11 | pub use glib::subclass::prelude::*; 12 | 13 | pub use gio::subclass::prelude::*; 14 | 15 | pub use super::{ 16 | pixbuf_animation::{PixbufAnimationImpl, PixbufAnimationImplExt}, 17 | pixbuf_animation_iter::{PixbufAnimationIterImpl, PixbufAnimationIterImplExt}, 18 | pixbuf_loader::{PixbufLoaderImpl, PixbufLoaderImplExt}, 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | The gtk-rs Project is licensed under the MIT license, see the LICENSE file or 2 | . 3 | 4 | Copyrights in the gtk-rs Project project are retained by their contributors. 5 | No copyright assignment is required to contribute to the gtk-rs Project 6 | project. 7 | 8 | For full authorship information, see the version control history. 9 | 10 | This project provides interoperability with various GNOME libraries but 11 | doesn't distribute any parts of them. Distributing compiled libraries and 12 | executables that link to those libraries may be subject to terms of the GNU 13 | LGPL or other licenses. For more information check the license of each GNOME 14 | library. 15 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/03-static-value.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | use glib::prelude::*; 4 | 5 | fn main() { 6 | let r = glib::Regex::new( 7 | "hello", 8 | glib::RegexCompileFlags::DEFAULT, 9 | glib::RegexMatchFlags::DEFAULT, 10 | ) 11 | .unwrap() 12 | .unwrap(); 13 | let s = glib::GStr::from_str_until_nul("hello\0").unwrap(); 14 | let match_info = r 15 | .match_(s, glib::RegexMatchFlags::DEFAULT) 16 | .expect("should match"); 17 | assert_eq!(match_info.fetch_all(), vec!["hello"]); 18 | let v: glib::Value = match_info.to_value(); 19 | drop(match_info); 20 | let match_info = v.get::>().unwrap(); 21 | } 22 | -------------------------------------------------------------------------------- /pango/src/attr_language.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType, Language}; 6 | 7 | define_attribute_struct!(AttrLanguage, ffi::PangoAttrLanguage, &[AttrType::Language]); 8 | 9 | impl AttrLanguage { 10 | #[doc(alias = "pango_attr_language_new")] 11 | pub fn new(language: &Language) -> Self { 12 | unsafe { 13 | from_glib_full(ffi::pango_attr_language_new(mut_override( 14 | language.to_glib_none().0, 15 | ))) 16 | } 17 | } 18 | 19 | pub fn value(&self) -> Language { 20 | unsafe { from_glib_none(self.inner.value) } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/glib-dependent-dependent/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "glib-dependent-dependent" 3 | version = "0.1.0" 4 | authors = ["François Laignel "] 5 | description = "crate that depends on a glib-rs dependent crate for validation of glib re-exports in proc-macros" 6 | keywords = ["gtk-rs-core", "integration"] 7 | license = "MIT/Apache-2.0" 8 | edition = "2021" 9 | rust-version = "1.83" 10 | 11 | [dependencies] 12 | # Use `gstreamer` as a simulation of an identified crate re-exporting `glib`. 13 | gst = { package = "gstreamer", path = "../gstreamer" } 14 | # Use `gtk` optionally so that it is part of the declared dependencies. 15 | gtk = { path = "../gtk", optional = true } 16 | -------------------------------------------------------------------------------- /gio/src/socket_control_message.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::{prelude::*, translate::*}; 4 | 5 | use crate::{prelude::*, SocketControlMessage}; 6 | 7 | pub trait SocketControlMessageExtManual: IsA + Sized { 8 | #[doc(alias = "g_socket_control_message_serialize")] 9 | fn serialize(&self, data: &mut [u8]) { 10 | assert!(data.len() >= self.size()); 11 | unsafe { 12 | crate::ffi::g_socket_control_message_serialize( 13 | self.as_ref().to_glib_none().0, 14 | data.as_mut_ptr() as *mut _, 15 | ); 16 | } 17 | } 18 | } 19 | 20 | impl> SocketControlMessageExtManual for O {} 21 | -------------------------------------------------------------------------------- /glib-macros/src/downgrade_derive/mod.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | mod enums; 4 | mod fields; 5 | mod structs; 6 | 7 | use proc_macro::TokenStream; 8 | use syn::{Data, DeriveInput}; 9 | 10 | pub fn impl_downgrade(input: DeriveInput) -> TokenStream { 11 | match input.data { 12 | Data::Struct(data_struct) => { 13 | structs::derive_downgrade_for_struct(input.ident, input.generics, data_struct) 14 | } 15 | Data::Enum(data_enum) => { 16 | enums::derive_downgrade_for_enum(input.ident, input.generics, data_enum) 17 | } 18 | Data::Union(..) => { 19 | panic!("#[derive(Downgrade)] is not available for unions."); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /glib/sys/tests/manual.h: -------------------------------------------------------------------------------- 1 | // Feel free to edit this file, it won't be regenerated by gir generator unless removed. 2 | 3 | #include 4 | #include 5 | 6 | #ifndef G_PLATFORM_WIN32 7 | // glib-unix.h is not included automatically 8 | #include 9 | // polyfill the WIN32 constants on non-Win32 platforms 10 | typedef enum 11 | { 12 | G_WIN32_OS_ANY, 13 | G_WIN32_OS_WORKSTATION, 14 | G_WIN32_OS_SERVER, 15 | } GWin32OSType; 16 | #endif 17 | 18 | // polyfill when the platform doesn't define tracing macros 19 | #ifndef G_TRACE_CURRENT_TIME 20 | #define G_TRACE_CURRENT_TIME 0 21 | #endif 22 | 23 | // included in Gir on all platforms even though it is only present on windows 24 | #ifndef G_WIN32_MSG_HANDLE 25 | #define G_WIN32_MSG_HANDLE 19981206 26 | #endif 27 | -------------------------------------------------------------------------------- /glib-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "glib-macros" 3 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/glib_macros/" 4 | description = "Rust bindings for the GLib library, proc macros crate" 5 | keywords = ["glib", "gtk-rs", "gnome", "GUI"] 6 | authors.workspace = true 7 | edition.workspace = true 8 | exclude.workspace = true 9 | homepage.workspace = true 10 | license.workspace = true 11 | repository.workspace = true 12 | rust-version.workspace = true 13 | version.workspace = true 14 | 15 | [dependencies] 16 | heck = "0.5" 17 | proc-macro2 = "1.0" 18 | quote = "1.0" 19 | syn = { version = "2.0.101", features = ["full"] } 20 | proc-macro-crate = "3.3" 21 | 22 | [lib] 23 | proc-macro = true 24 | 25 | [dev-dependencies] 26 | glib.workspace = true 27 | trybuild2 = "1.2" 28 | -------------------------------------------------------------------------------- /glib/tests/subclass_compiletest/01-auto-send-sync.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use glib::subclass::prelude::*; 3 | 4 | #[derive(Default)] 5 | pub struct TestObject { 6 | s: String, 7 | } 8 | 9 | #[glib::object_subclass] 10 | impl ObjectSubclass for TestObject { 11 | const NAME: &'static str = "TestObject"; 12 | type Type = super::TestObject; 13 | } 14 | 15 | impl ObjectImpl for TestObject {} 16 | } 17 | 18 | glib::wrapper! { 19 | pub struct TestObject(ObjectSubclass); 20 | } 21 | 22 | impl Default for TestObject { 23 | fn default() -> Self { 24 | glib::Object::new() 25 | } 26 | } 27 | 28 | fn main() { 29 | fn check(_obj: &T) {} 30 | 31 | let obj = TestObject::default(); 32 | check(&obj); 33 | } 34 | -------------------------------------------------------------------------------- /tests/two-levels-glib-dependent/glib-dependent-dependent/src/lib.rs: -------------------------------------------------------------------------------- 1 | use gst::glib; 2 | use gst::glib::prelude::*; 3 | use gst::glib::subclass::prelude::*; 4 | 5 | pub mod imp { 6 | use super::*; 7 | 8 | #[derive(Default)] 9 | pub struct Foo {} 10 | 11 | #[glib::object_subclass] 12 | impl ObjectSubclass for Foo { 13 | const NAME: &'static str = "MyFoo"; 14 | type Type = super::Foo; 15 | } 16 | 17 | impl ObjectImpl for Foo {} 18 | } 19 | 20 | pub trait FooExt: IsA + 'static { 21 | fn test(&self) { 22 | let _self = self.as_ref().downcast_ref::().unwrap().imp(); 23 | unimplemented!(); 24 | } 25 | } 26 | 27 | impl> FooExt for O {} 28 | 29 | glib::wrapper! { 30 | pub struct Foo(ObjectSubclass); 31 | } 32 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | Consists of various examples of how to use the `gtk-rs-core` libraries. Note that there are other examples in [gtk3-rs](https://github.com/gtk-rs/gtk3-rs/tree/master/examples) & [gtk4-rs](https://github.com/gtk-rs/gtk4-rs/tree/main/examples) if you want GTK specific ones. 4 | 5 | - [GIO Async TLS](./gio_async_tls/) 6 | - [GIO Futures](./gio_futures/) 7 | - [GIO Futures Await](./gio_futures_await/) 8 | - [GIO DBus Register Object](./gio_dbus_register_object/) 9 | - [GIO Task](./gio_task/) 10 | - [GIO Resources](./resources) 11 | - [Object Subclassing](./object_subclass) 12 | - [Interfaces and Virtual Methods](./virtual_methods) 13 | 14 | ## License 15 | 16 | The examples are licensed under the MIT license, please refer to the LICENSE and COPYRIGHT files for more information. 17 | -------------------------------------------------------------------------------- /graphene/src/lib.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #![cfg_attr(docsrs, feature(doc_cfg))] 4 | #![doc = include_str!("../README.md")] 5 | 6 | pub use glib; 7 | pub use graphene_sys as ffi; 8 | 9 | // Graphene has no runtime to initialize 10 | macro_rules! assert_initialized_main_thread { 11 | () => {}; 12 | } 13 | 14 | // No-op 15 | macro_rules! skip_assert_initialized { 16 | () => {}; 17 | } 18 | 19 | mod auto; 20 | 21 | pub mod prelude; 22 | 23 | pub use crate::auto::*; 24 | 25 | mod box_; 26 | mod euler; 27 | mod frustum; 28 | mod matrix; 29 | mod plane; 30 | mod point; 31 | mod point3_d; 32 | mod quad; 33 | mod quaternion; 34 | mod ray; 35 | mod rect; 36 | mod size; 37 | mod sphere; 38 | mod triangle; 39 | mod vec2; 40 | mod vec3; 41 | mod vec4; 42 | -------------------------------------------------------------------------------- /gio/src/auto/simple_permission.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Permission}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GSimplePermission")] 10 | pub struct SimplePermission(Object) @extends Permission; 11 | 12 | match fn { 13 | type_ => || ffi::g_simple_permission_get_type(), 14 | } 15 | } 16 | 17 | impl SimplePermission { 18 | #[doc(alias = "g_simple_permission_new")] 19 | pub fn new(allowed: bool) -> SimplePermission { 20 | unsafe { 21 | Permission::from_glib_full(ffi::g_simple_permission_new(allowed.into_glib())) 22 | .unsafe_cast() 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /glib/tests/derive.rs: -------------------------------------------------------------------------------- 1 | use std::marker::PhantomData; 2 | 3 | use glib::{Downgrade, Object}; 4 | 5 | #[test] 6 | fn derive_downgrade() { 7 | #[derive(Downgrade)] 8 | pub struct NewType(Object); 9 | 10 | #[derive(Downgrade)] 11 | pub struct Struct { 12 | o1: Object, 13 | o2: std::rc::Rc, 14 | } 15 | 16 | #[derive(Downgrade)] 17 | pub enum Enum { 18 | None, 19 | Pair { x: Object, y: Object }, 20 | Unit(), 21 | SingleUnnamed(Object), 22 | MultipleUnnamed(Object, Object, Object), 23 | } 24 | 25 | #[derive(Downgrade)] 26 | pub struct TypedWrapper(Object, PhantomData); 27 | 28 | #[derive(Downgrade)] 29 | pub enum TypedEnum { 30 | This(Object, PhantomData), 31 | That(Object, PhantomData), 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /glib/src/gobject/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod binding; 6 | pub use self::binding::Binding; 7 | 8 | #[cfg(feature = "v2_72")] 9 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] 10 | mod binding_group; 11 | #[cfg(feature = "v2_72")] 12 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] 13 | pub use self::binding_group::BindingGroup; 14 | 15 | #[cfg(feature = "v2_74")] 16 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] 17 | mod signal_group; 18 | #[cfg(feature = "v2_74")] 19 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] 20 | pub use self::signal_group::SignalGroup; 21 | 22 | mod flags; 23 | pub use self::flags::BindingFlags; 24 | pub use self::flags::SignalFlags; 25 | pub use self::flags::TypeFlags; 26 | -------------------------------------------------------------------------------- /glib/tests/subclass_compiletest/02-no-auto-send-sync.rs: -------------------------------------------------------------------------------- 1 | mod imp { 2 | use glib::subclass::prelude::*; 3 | use std::cell::RefCell; 4 | 5 | #[derive(Default)] 6 | pub struct TestObject { 7 | s: RefCell, 8 | } 9 | 10 | #[glib::object_subclass] 11 | impl ObjectSubclass for TestObject { 12 | const NAME: &'static str = "TestObject"; 13 | type Type = super::TestObject; 14 | } 15 | 16 | impl ObjectImpl for TestObject {} 17 | } 18 | 19 | glib::wrapper! { 20 | pub struct TestObject(ObjectSubclass); 21 | } 22 | 23 | impl Default for TestObject { 24 | fn default() -> Self { 25 | glib::Object::new() 26 | } 27 | } 28 | 29 | fn main() { 30 | fn check(_obj: &T) {} 31 | 32 | let obj = TestObject::default(); 33 | check(&obj); 34 | } 35 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/auto/pixbuf_non_anim.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Pixbuf, PixbufAnimation}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GdkPixbufNonAnim")] 10 | pub struct PixbufNonAnim(Object) @extends PixbufAnimation; 11 | 12 | match fn { 13 | type_ => || ffi::gdk_pixbuf_non_anim_get_type(), 14 | } 15 | } 16 | 17 | impl PixbufNonAnim { 18 | #[doc(alias = "gdk_pixbuf_non_anim_new")] 19 | pub fn new(pixbuf: &Pixbuf) -> PixbufNonAnim { 20 | unsafe { 21 | PixbufAnimation::from_glib_full(ffi::gdk_pixbuf_non_anim_new(pixbuf.to_glib_none().0)) 22 | .unsafe_cast() 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/workflows/image.yml: -------------------------------------------------------------------------------- 1 | name: github packages 2 | 3 | on: 4 | # Rebuild the container once every week 5 | schedule: 6 | - cron: '0 0 * * 1' 7 | push: 8 | branches: 9 | - "main" 10 | paths: 11 | - "Dockerfile" 12 | pull_request: 13 | paths: 14 | - "Dockerfile" 15 | workflow_dispatch: 16 | 17 | jobs: 18 | docker: 19 | runs-on: ubuntu-24.04 20 | steps: 21 | - name: Login to GitHub Container Registry 22 | uses: docker/login-action@v3 23 | with: 24 | username: ${{ github.actor }} 25 | password: ${{ secrets.GITHUB_TOKEN }} 26 | registry: ghcr.io 27 | - name: Push to GitHub Packages 28 | uses: docker/build-push-action@v6 29 | with: 30 | push: ${{ github.event_name != 'pull_request' }} 31 | tags: ghcr.io/${{ github.repository }}/core:latest 32 | -------------------------------------------------------------------------------- /pango/src/attr_size.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType}; 6 | 7 | define_attribute_struct!( 8 | AttrSize, 9 | ffi::PangoAttrSize, 10 | &[AttrType::Size, AttrType::AbsoluteSize] 11 | ); 12 | 13 | impl AttrSize { 14 | #[doc(alias = "pango_attr_size_new")] 15 | pub fn new(size: i32) -> Self { 16 | unsafe { from_glib_full(ffi::pango_attr_size_new(size)) } 17 | } 18 | 19 | #[doc(alias = "pango_attr_size_new_absolute")] 20 | pub fn new_size_absolute(size: i32) -> Self { 21 | unsafe { from_glib_full(ffi::pango_attr_size_new_absolute(size)) } 22 | } 23 | 24 | pub fn size(&self) -> i32 { 25 | self.inner.size 26 | } 27 | 28 | pub fn absolute(&self) -> bool { 29 | unsafe { from_glib(self.inner.absolute as i32) } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pango/src/attr_shape.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType, Rectangle}; 6 | 7 | define_attribute_struct!(AttrShape, ffi::PangoAttrShape, &[AttrType::Shape]); 8 | 9 | impl AttrShape { 10 | #[doc(alias = "pango_attr_shape_new")] 11 | pub fn new(ink_rect: &Rectangle, logical_rect: &Rectangle) -> Self { 12 | unsafe { 13 | from_glib_full(ffi::pango_attr_shape_new( 14 | ink_rect.to_glib_none().0, 15 | logical_rect.to_glib_none().0, 16 | )) 17 | } 18 | } 19 | 20 | pub fn ink_rect(&self) -> Rectangle { 21 | unsafe { from_glib_none(&self.inner.ink_rect as *const _) } 22 | } 23 | 24 | pub fn logical_rect(&self) -> Rectangle { 25 | unsafe { from_glib_none(&self.inner.logical_rect as *const _) } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pangocairo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pangocairo" 3 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/pangocairo/" 4 | keywords = ["pango", "cairo", "gtk-rs", "gnome"] 5 | readme = "README.md" 6 | description = "Rust bindings for the PangoCairo library" 7 | authors.workspace = true 8 | edition.workspace = true 9 | exclude.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | repository.workspace = true 13 | rust-version.workspace = true 14 | version.workspace = true 15 | 16 | [dependencies] 17 | pangocairo-sys.workspace = true 18 | libc.workspace = true 19 | glib.workspace = true 20 | pango.workspace = true 21 | cairo-rs.workspace = true 22 | 23 | [dev-dependencies] 24 | gir-format-check.workspace = true 25 | 26 | [package.metadata.docs.rs] 27 | all-features = true 28 | rustc-args = ["--cfg", "docsrs"] 29 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 30 | -------------------------------------------------------------------------------- /gio/src/auto/native_socket_address.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, SocketAddress, SocketConnectable}; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "GNativeSocketAddress")] 9 | pub struct NativeSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; 10 | 11 | match fn { 12 | type_ => || ffi::g_native_socket_address_get_type(), 13 | } 14 | } 15 | 16 | impl NativeSocketAddress { 17 | pub const NONE: Option<&'static NativeSocketAddress> = None; 18 | 19 | //#[doc(alias = "g_native_socket_address_new")] 20 | //pub fn new(native: /*Unimplemented*/Option, len: usize) -> NativeSocketAddress { 21 | // unsafe { TODO: call ffi:g_native_socket_address_new() } 22 | //} 23 | } 24 | -------------------------------------------------------------------------------- /gio/src/content_type.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::ptr; 4 | 5 | use glib::translate::*; 6 | 7 | use crate::ffi; 8 | 9 | #[doc(alias = "g_content_type_guess")] 10 | pub fn content_type_guess<'a>( 11 | filename: Option>, 12 | data: impl Into>, 13 | ) -> (glib::GString, bool) { 14 | let data = data.into(); 15 | let data_size = data.map_or(0, |d| d.len()); 16 | unsafe { 17 | let mut result_uncertain = std::mem::MaybeUninit::uninit(); 18 | let ret = from_glib_full(ffi::g_content_type_guess( 19 | filename.as_ref().map(|p| p.as_ref()).to_glib_none().0, 20 | data.map_or(ptr::null(), |d| d.to_glib_none().0), 21 | data_size, 22 | result_uncertain.as_mut_ptr(), 23 | )); 24 | (ret, from_glib(result_uncertain.assume_init())) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /graphene/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "graphene-rs" 3 | keywords = ["graphene", "graphene-rs", "gtk-rs", "gnome", "GUI"] 4 | readme = "README.md" 5 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/graphene/" 6 | description = "Rust bindings for the Graphene library" 7 | authors.workspace = true 8 | edition.workspace = true 9 | exclude.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | repository.workspace = true 13 | rust-version.workspace = true 14 | version.workspace = true 15 | 16 | [lib] 17 | name = "graphene" 18 | 19 | [features] 20 | 21 | [dependencies] 22 | graphene-sys.workspace = true 23 | libc.workspace = true 24 | glib.workspace = true 25 | 26 | [dev-dependencies] 27 | gir-format-check.workspace = true 28 | 29 | [package.metadata.docs.rs] 30 | all-features = true 31 | rustc-args = ["--cfg", "docsrs"] 32 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 33 | -------------------------------------------------------------------------------- /gio/src/auto/bytes_icon.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Icon, LoadableIcon}; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GBytesIcon")] 10 | pub struct BytesIcon(Object) @implements Icon, LoadableIcon; 11 | 12 | match fn { 13 | type_ => || ffi::g_bytes_icon_get_type(), 14 | } 15 | } 16 | 17 | impl BytesIcon { 18 | #[doc(alias = "g_bytes_icon_new")] 19 | pub fn new(bytes: &glib::Bytes) -> BytesIcon { 20 | unsafe { from_glib_full(ffi::g_bytes_icon_new(bytes.to_glib_none().0)) } 21 | } 22 | 23 | #[doc(alias = "g_bytes_icon_get_bytes")] 24 | #[doc(alias = "get_bytes")] 25 | pub fn bytes(&self) -> glib::Bytes { 26 | unsafe { from_glib_none(ffi::g_bytes_icon_get_bytes(self.to_glib_none().0)) } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pango/src/auto/color.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | pub struct Color(BoxedInline); 10 | 11 | match fn { 12 | copy => |ptr| ffi::pango_color_copy(ptr), 13 | free => |ptr| ffi::pango_color_free(ptr), 14 | type_ => || ffi::pango_color_get_type(), 15 | } 16 | } 17 | 18 | impl Color { 19 | #[doc(alias = "pango_color_to_string")] 20 | #[doc(alias = "to_string")] 21 | pub fn to_str(&self) -> glib::GString { 22 | unsafe { from_glib_full(ffi::pango_color_to_string(self.to_glib_none().0)) } 23 | } 24 | } 25 | 26 | impl std::fmt::Display for Color { 27 | #[inline] 28 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 29 | f.write_str(&self.to_str()) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest/01-not-dangling.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let r = glib::Regex::new( 3 | "hello", 4 | glib::RegexCompileFlags::DEFAULT, 5 | glib::RegexMatchFlags::DEFAULT, 6 | ) 7 | .unwrap() 8 | .unwrap(); 9 | // implicit drop 10 | { 11 | let s = glib::GString::from("hello"); 12 | let match_info = r 13 | .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT) 14 | .expect("should match"); 15 | assert_eq!(match_info.fetch_all(), vec!["hello"]); 16 | // match_info is dropped 17 | // s is dropped 18 | } 19 | // explicit drop 20 | { 21 | let s = glib::GString::from("hello"); 22 | let match_info = r 23 | .match_(s.as_gstr(), glib::RegexMatchFlags::DEFAULT) 24 | .expect("should match"); 25 | assert_eq!(match_info.fetch_all(), vec!["hello"]); 26 | drop(match_info); 27 | drop(s); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gio/src/auto/file_icon.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, File, Icon, LoadableIcon}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GFileIcon")] 10 | pub struct FileIcon(Object) @implements Icon, LoadableIcon; 11 | 12 | match fn { 13 | type_ => || ffi::g_file_icon_get_type(), 14 | } 15 | } 16 | 17 | impl FileIcon { 18 | #[doc(alias = "g_file_icon_new")] 19 | pub fn new(file: &impl IsA) -> FileIcon { 20 | unsafe { from_glib_full(ffi::g_file_icon_new(file.as_ref().to_glib_none().0)) } 21 | } 22 | 23 | #[doc(alias = "g_file_icon_get_file")] 24 | #[doc(alias = "get_file")] 25 | pub fn file(&self) -> File { 26 | unsafe { from_glib_none(ffi::g_file_icon_get_file(self.to_glib_none().0)) } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gio/src/auto/simple_action_group.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, ActionGroup, ActionMap}; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GSimpleActionGroup")] 10 | pub struct SimpleActionGroup(Object) @implements ActionGroup, ActionMap; 11 | 12 | match fn { 13 | type_ => || ffi::g_simple_action_group_get_type(), 14 | } 15 | } 16 | 17 | impl SimpleActionGroup { 18 | pub const NONE: Option<&'static SimpleActionGroup> = None; 19 | 20 | #[doc(alias = "g_simple_action_group_new")] 21 | pub fn new() -> SimpleActionGroup { 22 | unsafe { from_glib_full(ffi::g_simple_action_group_new()) } 23 | } 24 | } 25 | 26 | impl Default for SimpleActionGroup { 27 | fn default() -> Self { 28 | Self::new() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gio/src/unix_mount_point.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::mem; 4 | 5 | use glib::translate::*; 6 | 7 | use crate::{ffi, UnixMountPoint}; 8 | 9 | impl UnixMountPoint { 10 | #[cfg(unix)] 11 | #[doc(alias = "g_unix_mount_points_get")] 12 | #[doc(alias = "get_mount_points")] 13 | pub fn mount_points() -> (Vec, u64) { 14 | unsafe { 15 | let mut time_read = mem::MaybeUninit::uninit(); 16 | let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mount_points_get( 17 | time_read.as_mut_ptr(), 18 | )); 19 | let time_read = time_read.assume_init(); 20 | (ret, time_read) 21 | } 22 | } 23 | 24 | #[doc(alias = "g_unix_mount_points_changed_since")] 25 | pub fn is_changed_since(time: u64) -> bool { 26 | unsafe { from_glib(ffi::g_unix_mount_points_changed_since(time)) } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pango/src/attr_float.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, AttrType}; 6 | 7 | define_attribute_struct!( 8 | AttrFloat, 9 | ffi::PangoAttrFloat, 10 | &[ 11 | AttrType::Scale, 12 | #[cfg(feature = "v1_50")] 13 | AttrType::LineHeight 14 | ] 15 | ); 16 | 17 | impl AttrFloat { 18 | #[doc(alias = "pango_attr_scale_new")] 19 | pub fn new_scale(scale_factor: f64) -> Self { 20 | unsafe { from_glib_full(ffi::pango_attr_scale_new(scale_factor)) } 21 | } 22 | 23 | #[cfg(feature = "v1_50")] 24 | #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))] 25 | #[doc(alias = "pango_attr_line_height_new")] 26 | pub fn new_line_height(factor: f64) -> Self { 27 | unsafe { from_glib_full(ffi::pango_attr_line_height_new(factor)) } 28 | } 29 | 30 | pub fn value(&self) -> f64 { 31 | self.inner.value 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gio/src/file_attribute_matcher.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::iter::FusedIterator; 4 | 5 | use crate::ffi; 6 | use glib::{translate::*, GString}; 7 | 8 | pub struct FileAttributematcherIter(crate::FileAttributeMatcher); 9 | 10 | impl Iterator for FileAttributematcherIter { 11 | type Item = GString; 12 | 13 | #[doc(alias = "g_file_attribute_matcher_enumerate_next")] 14 | fn next(&mut self) -> Option { 15 | unsafe { 16 | from_glib_none(ffi::g_file_attribute_matcher_enumerate_next( 17 | self.0.to_glib_none().0, 18 | )) 19 | } 20 | } 21 | } 22 | 23 | impl FusedIterator for FileAttributematcherIter {} 24 | 25 | impl IntoIterator for crate::FileAttributeMatcher { 26 | type Item = GString; 27 | type IntoIter = FileAttributematcherIter; 28 | 29 | fn into_iter(self) -> Self::IntoIter { 30 | FileAttributematcherIter(self) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gio/src/auto/dbus_menu_model.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, DBusConnection, MenuModel}; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GDBusMenuModel")] 10 | pub struct DBusMenuModel(Object) @extends MenuModel; 11 | 12 | match fn { 13 | type_ => || ffi::g_dbus_menu_model_get_type(), 14 | } 15 | } 16 | 17 | impl DBusMenuModel { 18 | #[doc(alias = "g_dbus_menu_model_get")] 19 | pub fn get( 20 | connection: &DBusConnection, 21 | bus_name: Option<&str>, 22 | object_path: &str, 23 | ) -> DBusMenuModel { 24 | unsafe { 25 | from_glib_full(ffi::g_dbus_menu_model_get( 26 | connection.to_glib_none().0, 27 | bus_name.to_glib_none().0, 28 | object_path.to_glib_none().0, 29 | )) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gio/src/memory_output_stream.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[cfg(test)] 4 | mod tests { 5 | use crate::{prelude::*, MemoryOutputStream}; 6 | 7 | #[test] 8 | fn steal_empty() { 9 | let strm = MemoryOutputStream::new_resizable(); 10 | assert_eq!(strm.data_size(), 0); 11 | 12 | assert!(strm.close(crate::Cancellable::NONE).is_ok()); 13 | assert_eq!(strm.steal_as_bytes(), [].as_ref()); 14 | } 15 | 16 | #[test] 17 | fn steal() { 18 | let strm = MemoryOutputStream::new_resizable(); 19 | 20 | assert!(strm.write(&[1, 2, 3], crate::Cancellable::NONE).is_ok()); 21 | assert_eq!(strm.data_size(), 3); 22 | 23 | assert!(strm.write(&[4, 5], crate::Cancellable::NONE).is_ok()); 24 | assert_eq!(strm.data_size(), 5); 25 | 26 | assert!(strm.close(crate::Cancellable::NONE).is_ok()); 27 | assert_eq!(strm.steal_as_bytes(), [1, 2, 3, 4, 5].as_ref()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gio/src/file_attribute_info_list.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, FileAttributeInfo, FileAttributeInfoList}; 6 | 7 | impl FileAttributeInfoList { 8 | #[doc(alias = "g_file_attribute_info_list_lookup")] 9 | pub fn lookup(&self, name: &str) -> Option { 10 | unsafe { 11 | let res = ffi::g_file_attribute_info_list_lookup( 12 | self.to_glib_none().0, 13 | name.to_glib_none().0, 14 | ); 15 | if res.is_null() { 16 | None 17 | } else { 18 | Some(from_glib_none(res)) 19 | } 20 | } 21 | } 22 | 23 | pub fn attributes(&self) -> Vec { 24 | unsafe { 25 | let ptr: *const _ = self.to_glib_none().0; 26 | FromGlibContainer::from_glib_none_num((*ptr).infos, (*ptr).n_infos as usize) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /gdk-pixbuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gdk-pixbuf" 3 | keywords = ["gdk-pixbuf", "gtk-rs", "gnome"] 4 | readme = "README.md" 5 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gdk_pixbuf/" 6 | description = "Rust bindings for the GdkPixbuf library" 7 | authors.workspace = true 8 | edition.workspace = true 9 | exclude.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | repository.workspace = true 13 | rust-version.workspace = true 14 | version.workspace = true 15 | 16 | [lib] 17 | name = "gdk_pixbuf" 18 | 19 | [features] 20 | v2_40 = ["gdk-pixbuf-sys/v2_40"] 21 | v2_42 = ["v2_40", "gdk-pixbuf-sys/v2_42"] 22 | 23 | [dependencies] 24 | gdk-pixbuf-sys.workspace = true 25 | libc.workspace = true 26 | glib.workspace = true 27 | gio.workspace = true 28 | 29 | [dev-dependencies] 30 | gir-format-check.workspace = true 31 | 32 | [package.metadata.docs.rs] 33 | all-features = true 34 | rustc-args = ["--cfg", "docsrs"] 35 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 36 | -------------------------------------------------------------------------------- /pangocairo/src/auto/font.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "PangoCairoFont")] 10 | pub struct Font(Interface) @requires pango::Font; 11 | 12 | match fn { 13 | type_ => || ffi::pango_cairo_font_get_type(), 14 | } 15 | } 16 | 17 | impl Font { 18 | pub const NONE: Option<&'static Font> = None; 19 | } 20 | 21 | pub trait PangoCairoFontExt: IsA + 'static { 22 | #[doc(alias = "pango_cairo_font_get_scaled_font")] 23 | #[doc(alias = "get_scaled_font")] 24 | fn scaled_font(&self) -> Option { 25 | unsafe { 26 | from_glib_none(ffi::pango_cairo_font_get_scaled_font( 27 | self.as_ref().to_glib_none().0, 28 | )) 29 | } 30 | } 31 | } 32 | 33 | impl> PangoCairoFontExt for O {} 34 | -------------------------------------------------------------------------------- /pango/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "Pango" 4 | version = "1.0" 5 | min_cfg_version = "1.40" 6 | single_version_file = "." 7 | girs_directories = ["../../gir-files"] 8 | 9 | external_libraries = [ 10 | "GLib", 11 | "GObject", 12 | ] 13 | 14 | ignore = [ 15 | "Pango.VERSION_MAJOR", 16 | "Pango.VERSION_MICRO", 17 | "Pango.VERSION_MINOR", 18 | "Pango.VERSION_STRING", 19 | ] 20 | 21 | [[object]] 22 | name = "Pango.Attribute" 23 | status = "generate" 24 | [[object.function]] 25 | name = "get_type" 26 | version = "1.44" 27 | 28 | [[object]] 29 | name = "Pango.AttrIterator" 30 | status = "generate" 31 | [[object.function]] 32 | name = "get_type" 33 | version = "1.44" 34 | 35 | [[object]] 36 | name = "Pango.Coverage" 37 | status = "generate" 38 | [[object.function]] 39 | name = "get_type" 40 | version = "1.44" 41 | 42 | [[object]] 43 | name = "Pango.ScriptIter" 44 | status = "generate" 45 | [[object.function]] 46 | name = "get_type" 47 | version = "1.44" 48 | -------------------------------------------------------------------------------- /gio/src/auto/simple_io_stream.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, IOStream, InputStream, OutputStream}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GSimpleIOStream")] 10 | pub struct SimpleIOStream(Object) @extends IOStream; 11 | 12 | match fn { 13 | type_ => || ffi::g_simple_io_stream_get_type(), 14 | } 15 | } 16 | 17 | impl SimpleIOStream { 18 | #[doc(alias = "g_simple_io_stream_new")] 19 | pub fn new( 20 | input_stream: &impl IsA, 21 | output_stream: &impl IsA, 22 | ) -> SimpleIOStream { 23 | unsafe { 24 | IOStream::from_glib_full(ffi::g_simple_io_stream_new( 25 | input_stream.as_ref().to_glib_none().0, 26 | output_stream.as_ref().to_glib_none().0, 27 | )) 28 | .unsafe_cast() 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gio/src/auto/dbus_action_group.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, ActionGroup, DBusConnection, RemoteActionGroup}; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GDBusActionGroup")] 10 | pub struct DBusActionGroup(Object) @implements ActionGroup, RemoteActionGroup; 11 | 12 | match fn { 13 | type_ => || ffi::g_dbus_action_group_get_type(), 14 | } 15 | } 16 | 17 | impl DBusActionGroup { 18 | #[doc(alias = "g_dbus_action_group_get")] 19 | pub fn get( 20 | connection: &DBusConnection, 21 | bus_name: Option<&str>, 22 | object_path: &str, 23 | ) -> DBusActionGroup { 24 | unsafe { 25 | from_glib_full(ffi::g_dbus_action_group_get( 26 | connection.to_glib_none().0, 27 | bus_name.to_glib_none().0, 28 | object_path.to_glib_none().0, 29 | )) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person obtaining a copy 2 | of this software and associated documentation files (the "Software"), to deal 3 | in the Software without restriction, including without limitation the rights 4 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5 | copies of the Software, and to permit persons to whom the Software is 6 | furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all 9 | copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 17 | SOFTWARE. 18 | 19 | -------------------------------------------------------------------------------- /glib/tests/regex_compiletest.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | pub fn test() { 3 | let t = trybuild2::TestCases::new(); 4 | 5 | t.pass("tests/regex_compiletest/01-not-dangling.rs"); 6 | // The exact error message format changed sometime between 1.70.0 and 1.73.0, 7 | // so the .stderr file would be incorrect for at least one CI run, 8 | // so use compile_fail_check_sub instead of compile_fail. 9 | t.compile_fail_check_sub( 10 | "tests/regex_compiletest/02-dangling.rs", 11 | "error[E0505]: cannot move out of `s` because it is borrowed", 12 | ); 13 | 14 | t.pass("tests/regex_compiletest/03-static-value.rs"); 15 | // See above about 02 16 | t.compile_fail_check_sub( 17 | "tests/regex_compiletest/04-nonstatic-value.rs", 18 | "argument requires that `s` is borrowed for `'static`", 19 | ); 20 | 21 | // Don't use check_sub: Check the exact error message to ensure that only the contravariance check fails. 22 | t.compile_fail("tests/regex_compiletest/05-variance.rs"); 23 | 24 | t.pass("tests/regex_compiletest/06-property.rs"); 25 | } 26 | -------------------------------------------------------------------------------- /graphene/sys/Gir.toml: -------------------------------------------------------------------------------- 1 | [options] 2 | work_mode = "sys" 3 | library = "Graphene" 4 | version = "1.0" 5 | min_cfg_version = "1.10" 6 | girs_dir = "../gir-files" 7 | target_path = "." 8 | single_version_file = "." 9 | girs_directories = ["../../gir-files"] 10 | 11 | external_libraries = [ 12 | "GLib", 13 | ] 14 | 15 | ignore = [ 16 | "Graphene.true", 17 | "Graphene.false", 18 | "Graphene.HAS_GCC", 19 | "Graphene.HAS_SCALAR", 20 | "Graphene.HAS_SSE", 21 | "Graphene.SIMD_S", 22 | "Graphene.PI", 23 | "Graphene.PI_2", 24 | ] 25 | 26 | [[object]] 27 | name = "Graphene.Matrix" 28 | status = "generate" 29 | align = 16 30 | 31 | [[object]] 32 | name = "Graphene.Simd4F" 33 | status = "generate" 34 | align = 16 35 | 36 | [[object]] 37 | name = "Graphene.Simd4X4F" 38 | status = "generate" 39 | align = 16 40 | 41 | [[object]] 42 | name = "Graphene.Vec2" 43 | status = "generate" 44 | align = 16 45 | 46 | [[object]] 47 | name = "Graphene.Vec3" 48 | status = "generate" 49 | align = 16 50 | 51 | [[object]] 52 | name = "Graphene.Vec4" 53 | status = "generate" 54 | align = 16 55 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod pixbuf; 6 | pub use self::pixbuf::Pixbuf; 7 | 8 | mod pixbuf_animation; 9 | pub use self::pixbuf_animation::PixbufAnimation; 10 | 11 | mod pixbuf_loader; 12 | pub use self::pixbuf_loader::PixbufLoader; 13 | 14 | mod pixbuf_non_anim; 15 | pub use self::pixbuf_non_anim::PixbufNonAnim; 16 | 17 | mod pixbuf_simple_anim; 18 | pub use self::pixbuf_simple_anim::PixbufSimpleAnim; 19 | 20 | mod pixbuf_format; 21 | pub use self::pixbuf_format::PixbufFormat; 22 | 23 | mod enums; 24 | pub use self::enums::Colorspace; 25 | pub use self::enums::InterpType; 26 | #[allow(deprecated)] 27 | pub use self::enums::PixbufAlphaMode; 28 | pub use self::enums::PixbufError; 29 | pub use self::enums::PixbufRotation; 30 | 31 | mod flags; 32 | pub use self::flags::PixbufFormatFlags; 33 | 34 | pub(crate) mod traits { 35 | pub use super::pixbuf_animation::PixbufAnimationExt; 36 | pub use super::pixbuf_loader::PixbufLoaderExt; 37 | } 38 | -------------------------------------------------------------------------------- /pango/src/glyph_item.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::translate::*; 4 | 5 | use crate::{ffi, GlyphItem, GlyphString, Item}; 6 | 7 | impl GlyphItem { 8 | pub fn item(&self) -> Item { 9 | unsafe { from_glib_none((*self.as_ptr()).item) } 10 | } 11 | 12 | pub fn glyph_string(&self) -> GlyphString { 13 | unsafe { from_glib_none((*self.as_ptr()).glyphs) } 14 | } 15 | 16 | #[doc(alias = "pango_glyph_item_get_logical_widths")] 17 | #[doc(alias = "get_logical_widths")] 18 | pub fn logical_widths(&self, text: &str) -> Vec { 19 | let count = text.chars().count(); 20 | unsafe { 21 | let mut logical_widths = Vec::with_capacity(count); 22 | ffi::pango_glyph_item_get_logical_widths( 23 | mut_override(self.to_glib_none().0), 24 | text.to_glib_none().0, 25 | logical_widths.as_mut_ptr(), 26 | ); 27 | logical_widths.set_len(count); 28 | logical_widths 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /gio/src/test_util.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | #[cfg(test)] 4 | use std::sync::mpsc::{channel, Sender}; 5 | 6 | #[cfg(test)] 7 | use glib::{MainContext, MainLoop}; 8 | 9 | #[cfg(test)] 10 | pub fn run_async, MainLoop) + Send + 'static>( 11 | start: Q, 12 | ) -> T { 13 | let c = MainContext::new(); 14 | let l = MainLoop::new(Some(&c), false); 15 | let l_clone = l.clone(); 16 | 17 | let (tx, rx) = channel(); 18 | 19 | c.spawn(async move { 20 | start(tx, l_clone); 21 | }); 22 | 23 | l.run(); 24 | 25 | rx.recv().unwrap() 26 | } 27 | 28 | #[cfg(test)] 29 | pub fn run_async_local, MainLoop) + Send + 'static>(start: Q) -> T { 30 | let c = MainContext::new(); 31 | let l = MainLoop::new(Some(&c), false); 32 | let l_clone = l.clone(); 33 | 34 | let (tx, rx) = channel(); 35 | 36 | c.spawn_local(async move { 37 | start(tx, l_clone); 38 | }); 39 | 40 | l.run(); 41 | 42 | rx.recv().unwrap() 43 | } 44 | -------------------------------------------------------------------------------- /gio/src/auto/datagram_based.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GDatagramBased")] 10 | pub struct DatagramBased(Interface); 11 | 12 | match fn { 13 | type_ => || ffi::g_datagram_based_get_type(), 14 | } 15 | } 16 | 17 | impl DatagramBased { 18 | pub const NONE: Option<&'static DatagramBased> = None; 19 | } 20 | 21 | pub trait DatagramBasedExt: IsA + 'static { 22 | #[doc(alias = "g_datagram_based_condition_check")] 23 | fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition { 24 | unsafe { 25 | from_glib(ffi::g_datagram_based_condition_check( 26 | self.as_ref().to_glib_none().0, 27 | condition.into_glib(), 28 | )) 29 | } 30 | } 31 | } 32 | 33 | impl> DatagramBasedExt for O {} 34 | -------------------------------------------------------------------------------- /gio/src/auto/property_action.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Action}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GPropertyAction")] 10 | pub struct PropertyAction(Object) @implements Action; 11 | 12 | match fn { 13 | type_ => || ffi::g_property_action_get_type(), 14 | } 15 | } 16 | 17 | impl PropertyAction { 18 | #[doc(alias = "g_property_action_new")] 19 | pub fn new(name: &str, object: &impl IsA, property_name: &str) -> PropertyAction { 20 | unsafe { 21 | from_glib_full(ffi::g_property_action_new( 22 | name.to_glib_none().0, 23 | object.as_ref().to_glib_none().0, 24 | property_name.to_glib_none().0, 25 | )) 26 | } 27 | } 28 | 29 | #[doc(alias = "invert-boolean")] 30 | pub fn inverts_boolean(&self) -> bool { 31 | ObjectExt::property(self, "invert-boolean") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /graphene/src/auto/quad.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Point, Rect}; 6 | use glib::translate::*; 7 | 8 | glib::wrapper! { 9 | pub struct Quad(BoxedInline); 10 | 11 | match fn { 12 | copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_quad_get_type(), ptr as *mut _) as *mut ffi::graphene_quad_t, 13 | free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_quad_get_type(), ptr as *mut _), 14 | type_ => || ffi::graphene_quad_get_type(), 15 | } 16 | } 17 | 18 | impl Quad { 19 | #[doc(alias = "graphene_quad_bounds")] 20 | pub fn bounds(&self) -> Rect { 21 | unsafe { 22 | let mut r = Rect::uninitialized(); 23 | ffi::graphene_quad_bounds(self.to_glib_none().0, r.to_glib_none_mut().0); 24 | r 25 | } 26 | } 27 | 28 | #[doc(alias = "graphene_quad_contains")] 29 | pub fn contains(&self, p: &Point) -> bool { 30 | unsafe { ffi::graphene_quad_contains(self.to_glib_none().0, p.to_glib_none().0) } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /gio/src/auto/unix_fd_list.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GUnixFDList")] 10 | pub struct UnixFDList(Object); 11 | 12 | match fn { 13 | type_ => || ffi::g_unix_fd_list_get_type(), 14 | } 15 | } 16 | 17 | impl UnixFDList { 18 | pub const NONE: Option<&'static UnixFDList> = None; 19 | 20 | #[doc(alias = "g_unix_fd_list_new")] 21 | pub fn new() -> UnixFDList { 22 | unsafe { from_glib_full(ffi::g_unix_fd_list_new()) } 23 | } 24 | } 25 | 26 | impl Default for UnixFDList { 27 | fn default() -> Self { 28 | Self::new() 29 | } 30 | } 31 | 32 | pub trait UnixFDListExt: IsA + 'static { 33 | #[doc(alias = "g_unix_fd_list_get_length")] 34 | #[doc(alias = "get_length")] 35 | fn length(&self) -> i32 { 36 | unsafe { ffi::g_unix_fd_list_get_length(self.as_ref().to_glib_none().0) } 37 | } 38 | } 39 | 40 | impl> UnixFDListExt for O {} 41 | -------------------------------------------------------------------------------- /graphene/src/auto/mod.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | mod box_; 6 | pub use self::box_::Box; 7 | 8 | mod euler; 9 | pub use self::euler::Euler; 10 | 11 | mod frustum; 12 | pub use self::frustum::Frustum; 13 | 14 | mod matrix; 15 | pub use self::matrix::Matrix; 16 | 17 | mod plane; 18 | pub use self::plane::Plane; 19 | 20 | mod point; 21 | pub use self::point::Point; 22 | 23 | mod point3_d; 24 | pub use self::point3_d::Point3D; 25 | 26 | mod quad; 27 | pub use self::quad::Quad; 28 | 29 | mod quaternion; 30 | pub use self::quaternion::Quaternion; 31 | 32 | mod ray; 33 | pub use self::ray::Ray; 34 | 35 | mod rect; 36 | pub use self::rect::Rect; 37 | 38 | mod size; 39 | pub use self::size::Size; 40 | 41 | mod sphere; 42 | pub use self::sphere::Sphere; 43 | 44 | mod triangle; 45 | pub use self::triangle::Triangle; 46 | 47 | mod vec2; 48 | pub use self::vec2::Vec2; 49 | 50 | mod vec3; 51 | pub use self::vec3::Vec3; 52 | 53 | mod vec4; 54 | pub use self::vec4::Vec4; 55 | 56 | mod enums; 57 | pub use self::enums::EulerOrder; 58 | pub use self::enums::RayIntersectionKind; 59 | -------------------------------------------------------------------------------- /graphene/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies] 2 | pkg-config = "0.3.31" 3 | system-deps = "7" 4 | 5 | [dependencies] 6 | libc = "0.2" 7 | 8 | [dependencies.glib-sys] 9 | workspace = true 10 | 11 | [dev-dependencies] 12 | shell-words = "1.0.0" 13 | tempfile = "3" 14 | 15 | [lib] 16 | name = "graphene_sys" 17 | 18 | [package] 19 | build = "build.rs" 20 | description = "FFI bindings to libgraphene-1.0" 21 | keywords = ["graphene", "ffi", "gtk-rs", "gnome"] 22 | name = "graphene-sys" 23 | 24 | [package.authors] 25 | workspace = true 26 | 27 | [package.edition] 28 | workspace = true 29 | 30 | [package.exclude] 31 | workspace = true 32 | 33 | [package.homepage] 34 | workspace = true 35 | 36 | [package.license] 37 | workspace = true 38 | 39 | [package.repository] 40 | workspace = true 41 | 42 | [package.rust-version] 43 | workspace = true 44 | 45 | [package.version] 46 | workspace = true 47 | 48 | [package.metadata.system-deps.graphene_gobject_1_0] 49 | name = "graphene-gobject-1.0" 50 | version = "1.10" 51 | 52 | [package.metadata.docs.rs] 53 | rustc-args = ["--cfg", "docsrs"] 54 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 55 | all-features = true 56 | 57 | [features] 58 | -------------------------------------------------------------------------------- /pango/src/glyph_info.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::fmt; 4 | 5 | use crate::GlyphGeometry; 6 | 7 | glib::wrapper! { 8 | #[doc(alias = "PangoGlyphInfo")] 9 | pub struct GlyphInfo(BoxedInline); 10 | } 11 | 12 | impl GlyphInfo { 13 | #[inline] 14 | pub fn glyph(&self) -> u32 { 15 | self.inner.glyph 16 | } 17 | 18 | #[inline] 19 | pub fn set_glyph(&mut self, glyph: u32) { 20 | self.inner.glyph = glyph 21 | } 22 | 23 | #[inline] 24 | pub fn geometry(&self) -> &GlyphGeometry { 25 | unsafe { &*(&self.inner.geometry as *const _ as *const GlyphGeometry) } 26 | } 27 | 28 | #[inline] 29 | pub fn geometry_mut(&mut self) -> &mut GlyphGeometry { 30 | unsafe { &mut *(&mut self.inner.geometry as *mut _ as *mut GlyphGeometry) } 31 | } 32 | } 33 | 34 | impl fmt::Debug for GlyphInfo { 35 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 36 | f.debug_struct("GlyphInfo") 37 | .field("glyph", &self.glyph()) 38 | .field("geometry", &self.geometry()) 39 | .finish() 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pango/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pango" 3 | documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/pango/" 4 | keywords = ["pango", "gtk-rs", "gnome"] 5 | readme = "README.md" 6 | description = "Rust bindings for the Pango library" 7 | authors.workspace = true 8 | edition.workspace = true 9 | exclude.workspace = true 10 | homepage.workspace = true 11 | license.workspace = true 12 | repository.workspace = true 13 | rust-version.workspace = true 14 | version.workspace = true 15 | 16 | [features] 17 | v1_42 = ["pango-sys/v1_42"] 18 | v1_44 = ["v1_42", "pango-sys/v1_44"] 19 | v1_46 = ["v1_44", "pango-sys/v1_46"] 20 | v1_48 = ["v1_46", "pango-sys/v1_48"] 21 | v1_50 = ["v1_48", "pango-sys/v1_50"] 22 | v1_52 = ["v1_50", "pango-sys/v1_52"] 23 | v1_54 = ["v1_52", "pango-sys/v1_54"] 24 | v1_56 = ["v1_54", "pango-sys/v1_56"] 25 | 26 | [dependencies] 27 | pango-sys.workspace = true 28 | libc.workspace = true 29 | glib.workspace = true 30 | gio.workspace = true 31 | 32 | [dev-dependencies] 33 | gir-format-check.workspace = true 34 | 35 | [package.metadata.docs.rs] 36 | all-features = true 37 | rustc-args = ["--cfg", "docsrs"] 38 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 39 | -------------------------------------------------------------------------------- /examples/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "gtk-rs-examples" 3 | authors.workspace = true 4 | edition.workspace = true 5 | rust-version.workspace = true 6 | version.workspace = true 7 | 8 | [dependencies] 9 | futures = "0.3" 10 | futures-channel = "0.3" 11 | futures-util = "0.3" 12 | glib.workspace = true 13 | gio.workspace = true 14 | 15 | [dependencies.async-tls] 16 | version = "0.13" 17 | optional = true 18 | 19 | [build-dependencies.glib-build-tools] 20 | path = "../glib-build-tools" 21 | 22 | [[bin]] 23 | name = "gio_async_tls" 24 | path = "gio_async_tls/main.rs" 25 | required-features = ["async-tls"] 26 | 27 | [[bin]] 28 | name = "gio_cancellable_future" 29 | path = "gio_cancellable_future/main.rs" 30 | 31 | [[bin]] 32 | name = "gio_futures" 33 | path = "gio_futures/main.rs" 34 | 35 | [[bin]] 36 | name = "gio_futures_await" 37 | path = "gio_futures_await/main.rs" 38 | 39 | [[bin]] 40 | name = "gio_dbus_register_object" 41 | path = "gio_dbus_register_object/main.rs" 42 | 43 | [[bin]] 44 | name = "gio_task" 45 | path = "gio_task/main.rs" 46 | 47 | [[bin]] 48 | name = "object_subclass" 49 | path = "object_subclass/main.rs" 50 | 51 | [[bin]] 52 | name = "virtual_methods" 53 | path = "virtual_methods/main.rs" 54 | -------------------------------------------------------------------------------- /gio/src/auto/unix_input_stream.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, FileDescriptorBased, InputStream, PollableInputStream}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GUnixInputStream")] 10 | pub struct UnixInputStream(Object) @extends InputStream, @implements FileDescriptorBased, PollableInputStream; 11 | 12 | match fn { 13 | type_ => || ffi::g_unix_input_stream_get_type(), 14 | } 15 | } 16 | 17 | impl UnixInputStream { 18 | pub const NONE: Option<&'static UnixInputStream> = None; 19 | } 20 | 21 | pub trait UnixInputStreamExt: IsA + 'static { 22 | #[doc(alias = "g_unix_input_stream_get_close_fd")] 23 | #[doc(alias = "get_close_fd")] 24 | #[doc(alias = "close-fd")] 25 | fn closes_fd(&self) -> bool { 26 | unsafe { 27 | from_glib(ffi::g_unix_input_stream_get_close_fd( 28 | self.as_ref().to_glib_none().0, 29 | )) 30 | } 31 | } 32 | } 33 | 34 | impl> UnixInputStreamExt for O {} 35 | -------------------------------------------------------------------------------- /gio/src/subclass/mod.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | mod action_group; 4 | mod action_map; 5 | mod application; 6 | mod async_initable; 7 | mod initable; 8 | mod input_stream; 9 | mod io_stream; 10 | mod list_model; 11 | mod output_stream; 12 | mod seekable; 13 | mod socket_control_message; 14 | 15 | pub use self::application::ArgumentList; 16 | 17 | pub mod prelude { 18 | #[doc(hidden)] 19 | pub use glib::subclass::prelude::*; 20 | 21 | pub use super::{ 22 | action_group::{ActionGroupImpl, ActionGroupImplExt}, 23 | action_map::{ActionMapImpl, ActionMapImplExt}, 24 | application::{ApplicationImpl, ApplicationImplExt}, 25 | async_initable::{AsyncInitableImpl, AsyncInitableImplExt}, 26 | initable::{InitableImpl, InitableImplExt}, 27 | input_stream::{InputStreamImpl, InputStreamImplExt}, 28 | io_stream::{IOStreamImpl, IOStreamImplExt}, 29 | list_model::{ListModelImpl, ListModelImplExt}, 30 | output_stream::{OutputStreamImpl, OutputStreamImplExt}, 31 | seekable::{SeekableImpl, SeekableImplExt}, 32 | socket_control_message::{SocketControlMessageImpl, SocketControlMessageImplExt}, 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /cairo/src/font/text_cluster.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ffi; 4 | use std::fmt; 5 | 6 | #[derive(Clone, Copy)] 7 | #[repr(transparent)] 8 | #[doc(alias = "cairo_text_cluster_t")] 9 | pub struct TextCluster(ffi::cairo_text_cluster_t); 10 | 11 | impl TextCluster { 12 | pub fn new(num_bytes: i32, num_glyphs: i32) -> Self { 13 | Self(ffi::cairo_text_cluster_t { 14 | num_bytes, 15 | num_glyphs, 16 | }) 17 | } 18 | 19 | pub fn num_bytes(&self) -> i32 { 20 | self.0.num_bytes 21 | } 22 | 23 | pub fn num_glyphs(&self) -> i32 { 24 | self.0.num_glyphs 25 | } 26 | 27 | pub fn set_num_bytes(&mut self, num_bytes: i32) { 28 | self.0.num_bytes = num_bytes; 29 | } 30 | 31 | pub fn set_num_glyphs(&mut self, num_glyphs: i32) { 32 | self.0.num_glyphs = num_glyphs; 33 | } 34 | } 35 | 36 | impl fmt::Debug for TextCluster { 37 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 38 | f.debug_struct("TextCluster") 39 | .field("num_bytes", &self.num_bytes()) 40 | .field("num_glyphs", &self.num_glyphs()) 41 | .finish() 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pango/src/auto/fontset_simple.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, Font, Fontset, Language}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "PangoFontsetSimple")] 10 | pub struct FontsetSimple(Object) @extends Fontset; 11 | 12 | match fn { 13 | type_ => || ffi::pango_fontset_simple_get_type(), 14 | } 15 | } 16 | 17 | impl FontsetSimple { 18 | #[doc(alias = "pango_fontset_simple_new")] 19 | pub fn new(language: &mut Language) -> FontsetSimple { 20 | unsafe { from_glib_full(ffi::pango_fontset_simple_new(language.to_glib_none_mut().0)) } 21 | } 22 | 23 | #[doc(alias = "pango_fontset_simple_append")] 24 | pub fn append(&self, font: impl IsA) { 25 | unsafe { 26 | ffi::pango_fontset_simple_append(self.to_glib_none().0, font.upcast().into_glib_ptr()); 27 | } 28 | } 29 | 30 | #[doc(alias = "pango_fontset_simple_size")] 31 | pub fn size(&self) -> i32 { 32 | unsafe { ffi::pango_fontset_simple_size(self.to_glib_none().0) } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /pangocairo/tests/iterators.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use glib::GStr; 4 | use pango::prelude::*; 5 | 6 | const TEXT: &GStr = glib::gstr!("AAAA BBBB CCCC DDDD EEEE FFFF gggg hhhh iiii jjjj kkkk llll"); 7 | 8 | #[test] 9 | fn glyph_item_iter() { 10 | let item = { 11 | let map = pangocairo::FontMap::default(); 12 | let pc = map.create_context(); 13 | let layout = pango::Layout::new(&pc); 14 | layout.set_width(256 * pango::SCALE); 15 | layout.set_height(256 * pango::SCALE); 16 | layout.set_text(TEXT); 17 | let mut layout_iter = layout.iter(); 18 | layout_iter.run().unwrap() 19 | }; 20 | let iter = pango::GlyphItemIter::new_start(&item, TEXT).unwrap(); 21 | assert_eq!(iter.glyph_item(), &item); 22 | assert_eq!(iter.text(), TEXT); 23 | for (i, (sg, si, sc, eg, ei, ec)) in iter.into_iter().enumerate() { 24 | let i = i as i32; 25 | // ensure these are all single-byte ASCII characters 26 | assert_eq!(sg, i); 27 | assert_eq!(si, i); 28 | assert_eq!(sc, i); 29 | assert_eq!(eg, i + 1); 30 | assert_eq!(ei, i + 1); 31 | assert_eq!(ec, i + 1); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cairo/src/font/glyph.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use crate::ffi; 4 | use std::fmt; 5 | 6 | #[derive(Clone, Copy)] 7 | #[repr(transparent)] 8 | #[doc(alias = "cairo_glyph_t")] 9 | pub struct Glyph(ffi::cairo_glyph_t); 10 | 11 | impl Glyph { 12 | pub fn new(index: libc::c_ulong, x: f64, y: f64) -> Self { 13 | Self(ffi::cairo_glyph_t { index, x, y }) 14 | } 15 | 16 | pub fn index(&self) -> libc::c_ulong { 17 | self.0.index 18 | } 19 | 20 | pub fn x(&self) -> f64 { 21 | self.0.x 22 | } 23 | 24 | pub fn y(&self) -> f64 { 25 | self.0.y 26 | } 27 | 28 | pub fn set_index(&mut self, index: libc::c_ulong) { 29 | self.0.index = index; 30 | } 31 | 32 | pub fn set_x(&mut self, x: f64) { 33 | self.0.x = x; 34 | } 35 | 36 | pub fn set_y(&mut self, y: f64) { 37 | self.0.y = y; 38 | } 39 | } 40 | 41 | impl fmt::Debug for Glyph { 42 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 43 | f.debug_struct("Glyph") 44 | .field("index", &self.index()) 45 | .field("x", &self.x()) 46 | .field("y", &self.y()) 47 | .finish() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /gio/src/auto/unix_output_stream.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::{ffi, FileDescriptorBased, OutputStream, PollableOutputStream}; 6 | use glib::{prelude::*, translate::*}; 7 | 8 | glib::wrapper! { 9 | #[doc(alias = "GUnixOutputStream")] 10 | pub struct UnixOutputStream(Object) @extends OutputStream, @implements FileDescriptorBased, PollableOutputStream; 11 | 12 | match fn { 13 | type_ => || ffi::g_unix_output_stream_get_type(), 14 | } 15 | } 16 | 17 | impl UnixOutputStream { 18 | pub const NONE: Option<&'static UnixOutputStream> = None; 19 | } 20 | 21 | pub trait UnixOutputStreamExt: IsA + 'static { 22 | #[doc(alias = "g_unix_output_stream_get_close_fd")] 23 | #[doc(alias = "get_close_fd")] 24 | #[doc(alias = "close-fd")] 25 | fn closes_fd(&self) -> bool { 26 | unsafe { 27 | from_glib(ffi::g_unix_output_stream_get_close_fd( 28 | self.as_ref().to_glib_none().0, 29 | )) 30 | } 31 | } 32 | } 33 | 34 | impl> UnixOutputStreamExt for O {} 35 | -------------------------------------------------------------------------------- /pangocairo/sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [build-dependencies] 2 | system-deps = "7" 3 | 4 | [dependencies] 5 | libc = "0.2" 6 | 7 | [dependencies.cairo-sys-rs] 8 | workspace = true 9 | 10 | [dependencies.glib-sys] 11 | workspace = true 12 | 13 | [dependencies.pango-sys] 14 | workspace = true 15 | 16 | [dev-dependencies] 17 | shell-words = "1.0.0" 18 | tempfile = "3" 19 | 20 | [lib] 21 | name = "pango_cairo_sys" 22 | 23 | [package] 24 | build = "build.rs" 25 | description = "FFI bindings to PangoCairo" 26 | keywords = ["gtk", "ffi", "gtk-rs", "gnome"] 27 | name = "pangocairo-sys" 28 | 29 | [package.authors] 30 | workspace = true 31 | 32 | [package.edition] 33 | workspace = true 34 | 35 | [package.exclude] 36 | workspace = true 37 | 38 | [package.homepage] 39 | workspace = true 40 | 41 | [package.license] 42 | workspace = true 43 | 44 | [package.repository] 45 | workspace = true 46 | 47 | [package.rust-version] 48 | workspace = true 49 | 50 | [package.version] 51 | workspace = true 52 | 53 | [package.metadata.system-deps.pangocairo] 54 | name = "pangocairo" 55 | version = "1.40" 56 | 57 | [package.metadata.docs.rs] 58 | rustc-args = ["--cfg", "docsrs"] 59 | rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] 60 | all-features = true 61 | 62 | [features] 63 | -------------------------------------------------------------------------------- /glib/src/gobject/mod.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | // rustdoc-stripper-ignore-next 4 | //! GObject bindings 5 | 6 | #[allow(unused_imports)] 7 | mod auto; 8 | mod binding; 9 | #[cfg(feature = "v2_72")] 10 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] 11 | mod binding_group; 12 | mod flags; 13 | #[cfg(feature = "v2_74")] 14 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] 15 | mod signal_group; 16 | 17 | #[cfg(feature = "v2_72")] 18 | #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] 19 | pub use binding_group::BindingGroupBuilder; 20 | 21 | pub use self::{auto::*, flags::*}; 22 | //pub use self::auto::functions::*; 23 | 24 | mod interface_info; 25 | pub use interface_info::InterfaceInfo; 26 | 27 | mod type_info; 28 | pub use type_info::TypeInfo; 29 | 30 | mod type_value_table; 31 | pub use type_value_table::TypeValueTable; 32 | 33 | mod type_module; 34 | pub use self::type_module::TypeModule; 35 | 36 | mod type_plugin; 37 | pub use self::type_plugin::TypePlugin; 38 | 39 | mod dynamic_object; 40 | 41 | #[doc(hidden)] 42 | pub mod traits { 43 | pub use super::dynamic_object::DynamicObjectRegisterExt; 44 | pub use super::type_module::TypeModuleExt; 45 | pub use super::type_plugin::TypePluginExt; 46 | } 47 | -------------------------------------------------------------------------------- /gio/src/dbus_node_info.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::ffi::CStr; 4 | 5 | use crate::{DBusInterfaceInfo, DBusNodeInfo}; 6 | 7 | impl DBusNodeInfo { 8 | pub fn path(&self) -> Option<&str> { 9 | unsafe { 10 | let c_obj = self.as_ptr(); 11 | let path = (*c_obj).path; 12 | if path.is_null() { 13 | return None; 14 | } 15 | let c_str = CStr::from_ptr(path); 16 | Some(c_str.to_str().unwrap()) 17 | } 18 | } 19 | 20 | pub fn interfaces(&self) -> &[DBusInterfaceInfo] { 21 | unsafe { 22 | let c_obj = self.as_ptr(); 23 | let c_ii = (*c_obj).interfaces; 24 | if c_ii.is_null() { 25 | return &[]; 26 | } 27 | 28 | glib::collections::PtrSlice::from_glib_borrow(c_ii) 29 | } 30 | } 31 | 32 | pub fn nodes(&self) -> &[DBusNodeInfo] { 33 | unsafe { 34 | let c_obj = self.as_ptr(); 35 | let c_ni = (*c_obj).nodes; 36 | if c_ni.is_null() { 37 | return &[]; 38 | } 39 | glib::collections::PtrSlice::from_glib_borrow(c_ni) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gdk-pixbuf/src/auto/flags.rs: -------------------------------------------------------------------------------- 1 | // This file was generated by gir (https://github.com/gtk-rs/gir) 2 | // from gir-files (https://github.com/gtk-rs/gir-files) 3 | // DO NOT EDIT 4 | 5 | use crate::ffi; 6 | use glib::{bitflags::bitflags, translate::*}; 7 | 8 | bitflags! { 9 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 10 | #[doc(alias = "GdkPixbufFormatFlags")] 11 | pub struct PixbufFormatFlags: u32 { 12 | #[doc(alias = "GDK_PIXBUF_FORMAT_WRITABLE")] 13 | const WRITABLE = ffi::GDK_PIXBUF_FORMAT_WRITABLE as _; 14 | #[doc(alias = "GDK_PIXBUF_FORMAT_SCALABLE")] 15 | const SCALABLE = ffi::GDK_PIXBUF_FORMAT_SCALABLE as _; 16 | #[doc(alias = "GDK_PIXBUF_FORMAT_THREADSAFE")] 17 | const THREADSAFE = ffi::GDK_PIXBUF_FORMAT_THREADSAFE as _; 18 | } 19 | } 20 | 21 | #[doc(hidden)] 22 | impl IntoGlib for PixbufFormatFlags { 23 | type GlibType = ffi::GdkPixbufFormatFlags; 24 | 25 | #[inline] 26 | fn into_glib(self) -> ffi::GdkPixbufFormatFlags { 27 | self.bits() 28 | } 29 | } 30 | 31 | #[doc(hidden)] 32 | impl FromGlib for PixbufFormatFlags { 33 | #[inline] 34 | unsafe fn from_glib(value: ffi::GdkPixbufFormatFlags) -> Self { 35 | Self::from_bits_truncate(value) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /graphene/src/size.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::fmt; 4 | 5 | use glib::translate::*; 6 | 7 | use crate::{ffi, Size}; 8 | 9 | impl Size { 10 | #[doc(alias = "graphene_size_init")] 11 | pub fn new(width: f32, height: f32) -> Self { 12 | assert_initialized_main_thread!(); 13 | unsafe { 14 | let mut siz = Self::uninitialized(); 15 | ffi::graphene_size_init(siz.to_glib_none_mut().0, width, height); 16 | siz 17 | } 18 | } 19 | 20 | #[inline] 21 | pub fn width(&self) -> f32 { 22 | self.inner.width 23 | } 24 | 25 | #[inline] 26 | pub fn set_width(&mut self, width: f32) { 27 | self.inner.width = width; 28 | } 29 | 30 | #[inline] 31 | pub fn height(&self) -> f32 { 32 | self.inner.height 33 | } 34 | 35 | #[inline] 36 | pub fn set_height(&mut self, height: f32) { 37 | self.inner.height = height; 38 | } 39 | } 40 | 41 | impl fmt::Debug for Size { 42 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 43 | f.debug_struct("Size") 44 | .field("width", &self.width()) 45 | .field("height", &self.height()) 46 | .finish() 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /pango/src/language.rs: -------------------------------------------------------------------------------- 1 | // Take a look at the license at the top of the repository in the LICENSE file. 2 | 3 | use std::str::FromStr; 4 | 5 | use glib::translate::*; 6 | 7 | use crate::{ffi, Language, Script}; 8 | 9 | unsafe impl Send for Language {} 10 | unsafe impl Sync for Language {} 11 | 12 | impl Language { 13 | #[doc(alias = "get_scripts")] 14 | #[doc(alias = "pango_language_get_scripts")] 15 | pub fn scripts(&self) -> Vec