libshumate-0.6.0/.cargo_vcs_info.json0000644000000001500000000000100131700ustar { "git": { "sha1": "843060b7f8dd7daae45def581251076fb98a8495" }, "path_in_vcs": "libshumate" }libshumate-0.6.0/Cargo.toml0000644000000031270000000000100111750ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "libshumate" version = "0.6.0" authors = ["Corentin Noël "] description = "Rust bindings for libshumate" homepage = "https://world.pages.gitlab.gnome.org/Rust/libshumate-rs/" documentation = "https://world.pages.gitlab.gnome.org/Rust/libshumate-rs/stable/latest/docs/libshumate" readme = "README.md" keywords = [ "gtk4-rs", "gnome", "Map", "GUI", ] categories = [ "api-bindings", "gui", ] license = "MIT" repository = "https://gitlab.gnome.org/World/Rust/libshumate-rs" [package.metadata.docs.rs] all-features = true rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [lib] name = "libshumate" [dependencies.ffi] version = "0.6" package = "libshumate-sys" [dependencies.gdk] version = "0.9" package = "gdk4" [dependencies.gdk-pixbuf] version = "0.20" [dependencies.gio] version = "0.20" [dependencies.glib] version = "0.20" [dependencies.gtk] version = "0.9" package = "gtk4" [dependencies.libc] version = "0.2" [features] v1_1 = ["ffi/v1_1"] v1_2 = [ "v1_1", "ffi/v1_2", ] libshumate-0.6.0/Cargo.toml.orig000064400000000000000000000025671046102023000146650ustar 00000000000000[package] name = "libshumate" version = "0.6.0" authors = ["Corentin Noël "] edition = "2021" readme = "../README.md" homepage = "https://world.pages.gitlab.gnome.org/Rust/libshumate-rs/" description = "Rust bindings for libshumate" license = "MIT" repository = "https://gitlab.gnome.org/World/Rust/libshumate-rs" documentation = "https://world.pages.gitlab.gnome.org/Rust/libshumate-rs/stable/latest/docs/libshumate" categories = ["api-bindings", "gui"] keywords = ["gtk4-rs", "gnome", "Map", "GUI"] [lib] name = "libshumate" [features] v1_1 = ["ffi/v1_1"] v1_2 = ["v1_1", "ffi/v1_2"] [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [dependencies] libc = '0.2' [dependencies.glib] git = "https://github.com/gtk-rs/gtk-rs-core" branch = "0.20" version = "0.20" [dependencies.gio] git = "https://github.com/gtk-rs/gtk-rs-core" branch = "0.20" version = "0.20" [dependencies.gdk] package = "gdk4" git = "https://github.com/gtk-rs/gtk4-rs" branch = "0.9" version = "0.9" [dependencies.gdk-pixbuf] git = "https://github.com/gtk-rs/gtk-rs-core" branch = "0.20" version = "0.20" [dependencies.gtk] package = "gtk4" git = "https://github.com/gtk-rs/gtk4-rs" branch = "0.9" version = "0.9" [dependencies.ffi] package = "libshumate-sys" path = './sys' version = "0.6" libshumate-0.6.0/Gir.toml000064400000000000000000000050331046102023000134030ustar 00000000000000[external_libraries] Gio = {min_version = "2.66"} [options] girs_directories = ["../gir-files", "../"] library = "Shumate" version = "1.0" min_cfg_version = "1" target_path = "." work_mode = "normal" generate_safety_asserts = true deprecate_by_min_version = true # with this option enabled, versions for gir and gir-files saved only to one file to minimize noise single_version_file = true generate_builder = true use_gi_docgen = true external_libraries = [ "GLib", "GObject", "Gdk", "Gtk", ] generate = [ "Shumate.*", "Shumate.Compass", "Shumate.Coordinate", "Shumate.DataSource", "Shumate.DataSourceRequest", "Shumate.FileCache", "Shumate.GeometryType", "Shumate.Layer", "Shumate.License", "Shumate.Map", "Shumate.MapLayer", "Shumate.MapSource", "Shumate.MapSourceRegistry", "Shumate.Marker", "Shumate.MarkerLayer", "Shumate.PathLayer", "Shumate.Point", "Shumate.RasterRenderer", "Shumate.Scale", "Shumate.StyleError", "Shumate.Location", "Shumate.MapProjection", "Shumate.SimpleMap", "Shumate.State", "Shumate.Unit", "Shumate.FileCacheError", "Shumate.Tile", "Shumate.TileDownloaderError", "Shumate.VectorReader", "Shumate.VectorRenderer", "Shumate.VectorSpriteSheet", "Shumate.Viewport", ] manual = [ "GLib.Bytes", "GLib.DateTime", "GLib.Error", "GLib.Variant", "GObject.Object", "GObject.Value", "Gdk.Cursor", "Gdk.Display", "Gdk.DragAction", "Gdk.Paintable", "Gdk.RGBA", "Gdk.Rectangle", "Gdk.Texture", "GdkPixbuf.Pixbuf", "Gio.Initable", "Gio.Cancellable", "Gio.Icon", "Gio.ListModel", "Gtk.Accessible", "Gtk.AccessibleRole", "Gtk.Actionable", "Gtk.Align", "Gtk.Buildable", "Gtk.ConstraintTarget", "Gtk.LayoutManager", "Gtk.Orientable", "Gtk.Orientation", "Gtk.Overflow", "Gtk.SelectionMode", "Gtk.SymbolicPaintable", "Gtk.Widget" ] [[object]] name = "Shumate.VectorSprite" status = "generate" [[object.function]] name = "new_full" [[object.function.parameter]] name = "source_rect" const = true [[object]] name = "Shumate.VectorReaderIter" status = "generate" generate_builder = false [[object.property]] name = "reader" generate = [] [[object]] name = "Shumate.TileDownloader" status = "generate" generate_builder = false [[object]] name = "Shumate.SymbolEvent" status = "generate" [[object.function]] name = "get_keys" ignore = true # todo for later libshumate-0.6.0/README.md000064400000000000000000000006111046102023000132410ustar 00000000000000# libshumate-rs The Rust bindings of [libshumate](https://gitlab.gnome.org/GNOME/libshumate) Website: ## Documentation - libshumate: - libshumate-sys: libshumate-0.6.0/src/auto/compass.rs000064400000000000000000000206331046102023000155420ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateCompass")] pub struct Compass(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_compass_get_type(), } } impl Compass { #[doc(alias = "shumate_compass_new")] pub fn new(viewport: Option<&Viewport>) -> Compass { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_compass_new(viewport.to_glib_none().0)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Compass`] objects. /// /// This method returns an instance of [`CompassBuilder`](crate::builders::CompassBuilder) which can be used to create [`Compass`] objects. pub fn builder() -> CompassBuilder { CompassBuilder::new() } #[doc(alias = "shumate_compass_get_viewport")] #[doc(alias = "get_viewport")] pub fn viewport(&self) -> Option { unsafe { from_glib_none(ffi::shumate_compass_get_viewport(self.to_glib_none().0)) } } #[doc(alias = "shumate_compass_set_viewport")] #[doc(alias = "viewport")] pub fn set_viewport(&self, viewport: Option<&Viewport>) { unsafe { ffi::shumate_compass_set_viewport(self.to_glib_none().0, viewport.to_glib_none().0); } } #[doc(alias = "viewport")] pub fn connect_viewport_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_viewport_trampoline( this: *mut ffi::ShumateCompass, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::viewport\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_viewport_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for Compass { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Compass`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct CompassBuilder { builder: glib::object::ObjectBuilder<'static, Compass>, } impl CompassBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn viewport(self, viewport: &Viewport) -> Self { Self { builder: self.builder.property("viewport", viewport.clone()), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`Compass`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Compass { self.builder.build() } } libshumate-0.6.0/src/auto/constants.rs000064400000000000000000000034621046102023000161120ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::GStr; #[doc(alias = "SHUMATE_MAP_SOURCE_MFF_RELIEF")] pub static MAP_SOURCE_MFF_RELIEF: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_MFF_RELIEF) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OSM_CYCLE_MAP")] pub static MAP_SOURCE_OSM_CYCLE_MAP: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OSM_CYCLE_MAP) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OSM_MAPNIK")] pub static MAP_SOURCE_OSM_MAPNIK: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OSM_MAPNIK) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OSM_TRANSPORT_MAP")] pub static MAP_SOURCE_OSM_TRANSPORT_MAP: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OSM_TRANSPORT_MAP) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OWM_CLOUDS")] pub static MAP_SOURCE_OWM_CLOUDS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OWM_CLOUDS) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OWM_PRECIPITATION")] pub static MAP_SOURCE_OWM_PRECIPITATION: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OWM_PRECIPITATION) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OWM_PRESSURE")] pub static MAP_SOURCE_OWM_PRESSURE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OWM_PRESSURE) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OWM_TEMPERATURE")] pub static MAP_SOURCE_OWM_TEMPERATURE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OWM_TEMPERATURE) }; #[doc(alias = "SHUMATE_MAP_SOURCE_OWM_WIND")] pub static MAP_SOURCE_OWM_WIND: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::SHUMATE_MAP_SOURCE_OWM_WIND) }; libshumate-0.6.0/src/auto/coordinate.rs000064400000000000000000000046661046102023000162340ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Location}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumateCoordinate")] pub struct Coordinate(Object) @implements Location; match fn { type_ => || ffi::shumate_coordinate_get_type(), } } impl Coordinate { pub const NONE: Option<&'static Coordinate> = None; #[doc(alias = "shumate_coordinate_new")] pub fn new() -> Coordinate { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_coordinate_new()) } } #[doc(alias = "shumate_coordinate_new_full")] pub fn new_full(latitude: f64, longitude: f64) -> Coordinate { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_coordinate_new_full(latitude, longitude)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Coordinate`] objects. /// /// This method returns an instance of [`CoordinateBuilder`](crate::builders::CoordinateBuilder) which can be used to create [`Coordinate`] objects. pub fn builder() -> CoordinateBuilder { CoordinateBuilder::new() } } impl Default for Coordinate { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Coordinate`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct CoordinateBuilder { builder: glib::object::ObjectBuilder<'static, Coordinate>, } impl CoordinateBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn latitude(self, latitude: f64) -> Self { Self { builder: self.builder.property("latitude", latitude), } } pub fn longitude(self, longitude: f64) -> Self { Self { builder: self.builder.property("longitude", longitude), } } // rustdoc-stripper-ignore-next /// Build the [`Coordinate`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Coordinate { self.builder.build() } } libshumate-0.6.0/src/auto/data_source.rs000064400000000000000000000216531046102023000163710ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use crate::DataSourceRequest; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "ShumateDataSource")] pub struct DataSource(Object); match fn { type_ => || ffi::shumate_data_source_get_type(), } } impl DataSource { pub const NONE: Option<&'static DataSource> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DataSourceExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_data_source_get_max_zoom_level")] #[doc(alias = "get_max_zoom_level")] #[doc(alias = "max-zoom-level")] fn max_zoom_level(&self) -> u32 { unsafe { ffi::shumate_data_source_get_max_zoom_level(self.as_ref().to_glib_none().0) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_data_source_get_min_zoom_level")] #[doc(alias = "get_min_zoom_level")] #[doc(alias = "min-zoom-level")] fn min_zoom_level(&self) -> u32 { unsafe { ffi::shumate_data_source_get_min_zoom_level(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_data_source_get_tile_data_async")] #[doc(alias = "get_tile_data_async")] fn tile_data_async, glib::Error>) + 'static>( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn tile_data_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::shumate_data_source_get_tile_data_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = tile_data_async_trampoline::

; unsafe { ffi::shumate_data_source_get_tile_data_async( self.as_ref().to_glib_none().0, x, y, zoom_level, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn tile_data_future( &self, x: i32, y: i32, zoom_level: i32, ) -> Pin< Box_, glib::Error>> + 'static>, > { Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.tile_data_async(x, y, zoom_level, Some(cancellable), move |res| { send.resolve(res); }); })) } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_data_source_set_max_zoom_level")] #[doc(alias = "max-zoom-level")] fn set_max_zoom_level(&self, zoom_level: u32) { unsafe { ffi::shumate_data_source_set_max_zoom_level(self.as_ref().to_glib_none().0, zoom_level); } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_data_source_set_min_zoom_level")] #[doc(alias = "min-zoom-level")] fn set_min_zoom_level(&self, zoom_level: u32) { unsafe { ffi::shumate_data_source_set_min_zoom_level(self.as_ref().to_glib_none().0, zoom_level); } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_data_source_start_request")] fn start_request( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option<&impl IsA>, ) -> Option { unsafe { from_glib_full(ffi::shumate_data_source_start_request( self.as_ref().to_glib_none().0, x, y, zoom_level, cancellable.map(|p| p.as_ref()).to_glib_none().0, )) } } #[cfg_attr(feature = "v1_1", deprecated = "Since 1.1")] #[doc(alias = "received-data")] fn connect_received_data( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn received_data_trampoline< P: IsA, F: Fn(&P, i32, i32, i32, &glib::Bytes) + 'static, >( this: *mut ffi::ShumateDataSource, x: libc::c_int, y: libc::c_int, zoom_level: libc::c_int, bytes: *mut glib::ffi::GBytes, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DataSource::from_glib_borrow(this).unsafe_cast_ref(), x, y, zoom_level, &from_glib_borrow(bytes), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"received-data\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( received_data_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "max-zoom-level")] fn connect_max_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_max_zoom_level_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateDataSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::max-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "min-zoom-level")] fn connect_min_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_min_zoom_level_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateDataSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::min-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_min_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DataSourceExt for O {} libshumate-0.6.0/src/auto/data_source_request.rs000064400000000000000000000210301046102023000201260ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateDataSourceRequest")] pub struct DataSourceRequest(Object); match fn { type_ => || ffi::shumate_data_source_request_get_type(), } } impl DataSourceRequest { pub const NONE: Option<&'static DataSourceRequest> = None; #[doc(alias = "shumate_data_source_request_new")] pub fn new(x: i32, y: i32, zoom_level: i32) -> DataSourceRequest { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_data_source_request_new(x, y, zoom_level)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`DataSourceRequest`] objects. /// /// This method returns an instance of [`DataSourceRequestBuilder`](crate::builders::DataSourceRequestBuilder) which can be used to create [`DataSourceRequest`] objects. pub fn builder() -> DataSourceRequestBuilder { DataSourceRequestBuilder::new() } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] impl Default for DataSourceRequest { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`DataSourceRequest`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct DataSourceRequestBuilder { builder: glib::object::ObjectBuilder<'static, DataSourceRequest>, } impl DataSourceRequestBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn x(self, x: i32) -> Self { Self { builder: self.builder.property("x", x), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn y(self, y: i32) -> Self { Self { builder: self.builder.property("y", y), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn zoom_level(self, zoom_level: i32) -> Self { Self { builder: self.builder.property("zoom-level", zoom_level), } } // rustdoc-stripper-ignore-next /// Build the [`DataSourceRequest`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> DataSourceRequest { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DataSourceRequestExt: IsA + sealed::Sealed + 'static { #[doc(alias = "shumate_data_source_request_complete")] fn complete(&self) { unsafe { ffi::shumate_data_source_request_complete(self.as_ref().to_glib_none().0); } } #[doc(alias = "shumate_data_source_request_emit_data")] fn emit_data(&self, data: &glib::Bytes, complete: bool) { unsafe { ffi::shumate_data_source_request_emit_data( self.as_ref().to_glib_none().0, data.to_glib_none().0, complete.into_glib(), ); } } #[doc(alias = "shumate_data_source_request_emit_error")] fn emit_error(&self, error: &glib::Error) { unsafe { ffi::shumate_data_source_request_emit_error( self.as_ref().to_glib_none().0, error.to_glib_none().0, ); } } #[doc(alias = "shumate_data_source_request_get_data")] #[doc(alias = "get_data")] fn data(&self) -> Option { unsafe { from_glib_none(ffi::shumate_data_source_request_get_data( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_data_source_request_get_error")] #[doc(alias = "get_error")] fn error(&self) -> Option { unsafe { from_glib_none(ffi::shumate_data_source_request_get_error( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_data_source_request_get_x")] #[doc(alias = "get_x")] fn x(&self) -> i32 { unsafe { ffi::shumate_data_source_request_get_x(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_data_source_request_get_y")] #[doc(alias = "get_y")] fn y(&self) -> i32 { unsafe { ffi::shumate_data_source_request_get_y(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_data_source_request_get_zoom_level")] #[doc(alias = "get_zoom_level")] #[doc(alias = "zoom-level")] fn zoom_level(&self) -> i32 { unsafe { ffi::shumate_data_source_request_get_zoom_level(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_data_source_request_is_completed")] #[doc(alias = "completed")] fn is_completed(&self) -> bool { unsafe { from_glib(ffi::shumate_data_source_request_is_completed( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "completed")] fn connect_completed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_completed_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateDataSourceRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataSourceRequest::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::completed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_completed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "data")] fn connect_data_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_data_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateDataSourceRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataSourceRequest::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::data\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_data_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "error")] fn connect_error_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_error_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateDataSourceRequest, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataSourceRequest::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::error\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_error_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DataSourceRequestExt for O {} libshumate-0.6.0/src/auto/enums.rs000064400000000000000000000552251046102023000152310ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::{prelude::*, translate::*}; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateFileCacheError")] pub enum FileCacheError { #[doc(alias = "SHUMATE_FILE_CACHE_ERROR_FAILED")] Failed, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for FileCacheError { type GlibType = ffi::ShumateFileCacheError; #[inline] fn into_glib(self) -> ffi::ShumateFileCacheError { match self { Self::Failed => ffi::SHUMATE_FILE_CACHE_ERROR_FAILED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileCacheError { #[inline] unsafe fn from_glib(value: ffi::ShumateFileCacheError) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_FILE_CACHE_ERROR_FAILED => Self::Failed, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for FileCacheError { #[inline] fn domain() -> glib::Quark { skip_assert_initialized!(); unsafe { from_glib(ffi::shumate_file_cache_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { skip_assert_initialized!(); match unsafe { from_glib(code) } { Self::__Unknown(_) => Some(Self::Failed), value => Some(value), } } } impl StaticType for FileCacheError { #[inline] #[doc(alias = "shumate_file_cache_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_file_cache_error_get_type()) } } } impl glib::HasParamSpec for FileCacheError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for FileCacheError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileCacheError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for FileCacheError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileCacheError) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateGeometryType")] pub enum GeometryType { #[doc(alias = "SHUMATE_GEOMETRY_TYPE_UNKNOWN")] Unknown, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_POINT")] Point, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTIPOINT")] Multipoint, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_LINESTRING")] Linestring, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTILINESTRING")] Multilinestring, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_POLYGON")] Polygon, #[doc(alias = "SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON")] Multipolygon, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] #[doc(hidden)] impl IntoGlib for GeometryType { type GlibType = ffi::ShumateGeometryType; #[inline] fn into_glib(self) -> ffi::ShumateGeometryType { match self { Self::Unknown => ffi::SHUMATE_GEOMETRY_TYPE_UNKNOWN, Self::Point => ffi::SHUMATE_GEOMETRY_TYPE_POINT, Self::Multipoint => ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOINT, Self::Linestring => ffi::SHUMATE_GEOMETRY_TYPE_LINESTRING, Self::Multilinestring => ffi::SHUMATE_GEOMETRY_TYPE_MULTILINESTRING, Self::Polygon => ffi::SHUMATE_GEOMETRY_TYPE_POLYGON, Self::Multipolygon => ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON, Self::__Unknown(value) => value, } } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] #[doc(hidden)] impl FromGlib for GeometryType { #[inline] unsafe fn from_glib(value: ffi::ShumateGeometryType) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_GEOMETRY_TYPE_UNKNOWN => Self::Unknown, ffi::SHUMATE_GEOMETRY_TYPE_POINT => Self::Point, ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOINT => Self::Multipoint, ffi::SHUMATE_GEOMETRY_TYPE_LINESTRING => Self::Linestring, ffi::SHUMATE_GEOMETRY_TYPE_MULTILINESTRING => Self::Multilinestring, ffi::SHUMATE_GEOMETRY_TYPE_POLYGON => Self::Polygon, ffi::SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON => Self::Multipolygon, value => Self::__Unknown(value), } } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] impl StaticType for GeometryType { #[inline] #[doc(alias = "shumate_geometry_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_geometry_type_get_type()) } } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] impl glib::HasParamSpec for GeometryType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] impl glib::value::ValueType for GeometryType { type Type = Self; } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] unsafe impl<'a> glib::value::FromValue<'a> for GeometryType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] impl ToValue for GeometryType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] impl From for glib::Value { #[inline] fn from(v: GeometryType) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateMapProjection")] pub enum MapProjection { #[doc(alias = "SHUMATE_MAP_PROJECTION_MERCATOR")] Mercator, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for MapProjection { type GlibType = ffi::ShumateMapProjection; #[inline] fn into_glib(self) -> ffi::ShumateMapProjection { match self { Self::Mercator => ffi::SHUMATE_MAP_PROJECTION_MERCATOR, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for MapProjection { #[inline] unsafe fn from_glib(value: ffi::ShumateMapProjection) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_MAP_PROJECTION_MERCATOR => Self::Mercator, value => Self::__Unknown(value), } } } impl StaticType for MapProjection { #[inline] #[doc(alias = "shumate_map_projection_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_map_projection_get_type()) } } } impl glib::HasParamSpec for MapProjection { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for MapProjection { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for MapProjection { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for MapProjection { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: MapProjection) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateState")] pub enum State { #[doc(alias = "SHUMATE_STATE_NONE")] None, #[doc(alias = "SHUMATE_STATE_LOADING")] Loading, #[doc(alias = "SHUMATE_STATE_LOADED")] Loaded, #[doc(alias = "SHUMATE_STATE_DONE")] Done, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for State { type GlibType = ffi::ShumateState; #[inline] fn into_glib(self) -> ffi::ShumateState { match self { Self::None => ffi::SHUMATE_STATE_NONE, Self::Loading => ffi::SHUMATE_STATE_LOADING, Self::Loaded => ffi::SHUMATE_STATE_LOADED, Self::Done => ffi::SHUMATE_STATE_DONE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for State { #[inline] unsafe fn from_glib(value: ffi::ShumateState) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_STATE_NONE => Self::None, ffi::SHUMATE_STATE_LOADING => Self::Loading, ffi::SHUMATE_STATE_LOADED => Self::Loaded, ffi::SHUMATE_STATE_DONE => Self::Done, value => Self::__Unknown(value), } } } impl StaticType for State { #[inline] #[doc(alias = "shumate_state_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_state_get_type()) } } } impl glib::HasParamSpec for State { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for State { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for State { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for State { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: State) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateStyleError")] pub enum StyleError { #[doc(alias = "SHUMATE_STYLE_ERROR_FAILED")] Failed, #[doc(alias = "SHUMATE_STYLE_ERROR_MALFORMED_STYLE")] MalformedStyle, #[doc(alias = "SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER")] UnsupportedLayer, #[doc(alias = "SHUMATE_STYLE_ERROR_INVALID_EXPRESSION")] InvalidExpression, #[doc(alias = "SHUMATE_STYLE_ERROR_SUPPORT_OMITTED")] SupportOmitted, #[doc(alias = "SHUMATE_STYLE_ERROR_UNSUPPORTED")] Unsupported, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for StyleError { type GlibType = ffi::ShumateStyleError; #[inline] fn into_glib(self) -> ffi::ShumateStyleError { match self { Self::Failed => ffi::SHUMATE_STYLE_ERROR_FAILED, Self::MalformedStyle => ffi::SHUMATE_STYLE_ERROR_MALFORMED_STYLE, Self::UnsupportedLayer => ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER, Self::InvalidExpression => ffi::SHUMATE_STYLE_ERROR_INVALID_EXPRESSION, Self::SupportOmitted => ffi::SHUMATE_STYLE_ERROR_SUPPORT_OMITTED, Self::Unsupported => ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for StyleError { #[inline] unsafe fn from_glib(value: ffi::ShumateStyleError) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_STYLE_ERROR_FAILED => Self::Failed, ffi::SHUMATE_STYLE_ERROR_MALFORMED_STYLE => Self::MalformedStyle, ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED_LAYER => Self::UnsupportedLayer, ffi::SHUMATE_STYLE_ERROR_INVALID_EXPRESSION => Self::InvalidExpression, ffi::SHUMATE_STYLE_ERROR_SUPPORT_OMITTED => Self::SupportOmitted, ffi::SHUMATE_STYLE_ERROR_UNSUPPORTED => Self::Unsupported, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for StyleError { #[inline] fn domain() -> glib::Quark { skip_assert_initialized!(); unsafe { from_glib(ffi::shumate_style_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { skip_assert_initialized!(); match unsafe { from_glib(code) } { Self::__Unknown(_) => Some(Self::Failed), value => Some(value), } } } impl StaticType for StyleError { #[inline] #[doc(alias = "shumate_style_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_style_error_get_type()) } } } impl glib::HasParamSpec for StyleError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for StyleError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for StyleError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for StyleError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: StyleError) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateTileDownloaderError")] pub enum TileDownloaderError { #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_FAILED")] Failed, #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE")] BadResponse, #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT")] CouldNotConnect, #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL")] MalformedUrl, #[doc(alias = "SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE")] Offline, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TileDownloaderError { type GlibType = ffi::ShumateTileDownloaderError; #[inline] fn into_glib(self) -> ffi::ShumateTileDownloaderError { match self { Self::Failed => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_FAILED, Self::BadResponse => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE, Self::CouldNotConnect => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT, Self::MalformedUrl => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL, Self::Offline => ffi::SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TileDownloaderError { #[inline] unsafe fn from_glib(value: ffi::ShumateTileDownloaderError) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_TILE_DOWNLOADER_ERROR_FAILED => Self::Failed, ffi::SHUMATE_TILE_DOWNLOADER_ERROR_BAD_RESPONSE => Self::BadResponse, ffi::SHUMATE_TILE_DOWNLOADER_ERROR_COULD_NOT_CONNECT => Self::CouldNotConnect, ffi::SHUMATE_TILE_DOWNLOADER_ERROR_MALFORMED_URL => Self::MalformedUrl, ffi::SHUMATE_TILE_DOWNLOADER_ERROR_OFFLINE => Self::Offline, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for TileDownloaderError { #[inline] fn domain() -> glib::Quark { skip_assert_initialized!(); unsafe { from_glib(ffi::shumate_tile_downloader_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { skip_assert_initialized!(); match unsafe { from_glib(code) } { Self::__Unknown(_) => Some(Self::Failed), value => Some(value), } } } impl StaticType for TileDownloaderError { #[inline] #[doc(alias = "shumate_tile_downloader_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_tile_downloader_error_get_type()) } } } impl glib::HasParamSpec for TileDownloaderError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TileDownloaderError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TileDownloaderError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TileDownloaderError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TileDownloaderError) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "ShumateUnit")] pub enum Unit { #[doc(alias = "SHUMATE_UNIT_BOTH")] Both, #[doc(alias = "SHUMATE_UNIT_METRIC")] Metric, #[doc(alias = "SHUMATE_UNIT_IMPERIAL")] Imperial, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for Unit { type GlibType = ffi::ShumateUnit; #[inline] fn into_glib(self) -> ffi::ShumateUnit { match self { Self::Both => ffi::SHUMATE_UNIT_BOTH, Self::Metric => ffi::SHUMATE_UNIT_METRIC, Self::Imperial => ffi::SHUMATE_UNIT_IMPERIAL, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for Unit { #[inline] unsafe fn from_glib(value: ffi::ShumateUnit) -> Self { skip_assert_initialized!(); match value { ffi::SHUMATE_UNIT_BOTH => Self::Both, ffi::SHUMATE_UNIT_METRIC => Self::Metric, ffi::SHUMATE_UNIT_IMPERIAL => Self::Imperial, value => Self::__Unknown(value), } } } impl StaticType for Unit { #[inline] #[doc(alias = "shumate_unit_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::shumate_unit_get_type()) } } } impl glib::HasParamSpec for Unit { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for Unit { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for Unit { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for Unit { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: Unit) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } libshumate-0.6.0/src/auto/file_cache.rs000064400000000000000000000324531046102023000161420ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "ShumateFileCache")] pub struct FileCache(Object); match fn { type_ => || ffi::shumate_file_cache_get_type(), } } impl FileCache { #[doc(alias = "shumate_file_cache_new_full")] pub fn new_full(size_limit: u32, cache_key: &str, cache_dir: Option<&str>) -> FileCache { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_file_cache_new_full( size_limit, cache_key.to_glib_none().0, cache_dir.to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`FileCache`] objects. /// /// This method returns an instance of [`FileCacheBuilder`](crate::builders::FileCacheBuilder) which can be used to create [`FileCache`] objects. pub fn builder() -> FileCacheBuilder { FileCacheBuilder::new() } #[doc(alias = "shumate_file_cache_get_cache_dir")] #[doc(alias = "get_cache_dir")] #[doc(alias = "cache-dir")] pub fn cache_dir(&self) -> Option { unsafe { from_glib_none(ffi::shumate_file_cache_get_cache_dir(self.to_glib_none().0)) } } #[doc(alias = "shumate_file_cache_get_cache_key")] #[doc(alias = "get_cache_key")] #[doc(alias = "cache-key")] pub fn cache_key(&self) -> Option { unsafe { from_glib_none(ffi::shumate_file_cache_get_cache_key(self.to_glib_none().0)) } } #[doc(alias = "shumate_file_cache_get_size_limit")] #[doc(alias = "get_size_limit")] #[doc(alias = "size-limit")] pub fn size_limit(&self) -> u32 { unsafe { ffi::shumate_file_cache_get_size_limit(self.to_glib_none().0) } } #[doc(alias = "shumate_file_cache_get_tile_async")] #[doc(alias = "get_tile_async")] pub fn tile_async< P: FnOnce( Result<(glib::Bytes, Option, Option), glib::Error>, ) + 'static, >( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn tile_async_trampoline< P: FnOnce( Result< (glib::Bytes, Option, Option), glib::Error, >, ) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut etag = std::ptr::null_mut(); let mut modtime = std::ptr::null_mut(); let ret = ffi::shumate_file_cache_get_tile_finish( _source_object as *mut _, &mut etag, &mut modtime, res, &mut error, ); let result = if error.is_null() { Ok(( from_glib_full(ret), from_glib_full(etag), from_glib_full(modtime), )) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = tile_async_trampoline::

; unsafe { ffi::shumate_file_cache_get_tile_async( self.to_glib_none().0, x, y, zoom_level, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn tile_future( &self, x: i32, y: i32, zoom_level: i32, ) -> Pin< Box_< dyn std::future::Future< Output = Result< (glib::Bytes, Option, Option), glib::Error, >, > + 'static, >, > { Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.tile_async(x, y, zoom_level, Some(cancellable), move |res| { send.resolve(res); }); })) } #[doc(alias = "shumate_file_cache_mark_up_to_date")] pub fn mark_up_to_date(&self, x: i32, y: i32, zoom_level: i32) { unsafe { ffi::shumate_file_cache_mark_up_to_date(self.to_glib_none().0, x, y, zoom_level); } } #[doc(alias = "shumate_file_cache_purge_cache_async")] pub fn purge_cache_async) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn purge_cache_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::shumate_file_cache_purge_cache_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = purge_cache_async_trampoline::

; unsafe { ffi::shumate_file_cache_purge_cache_async( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn purge_cache_future( &self, ) -> Pin> + 'static>> { Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.purge_cache_async(Some(cancellable), move |res| { send.resolve(res); }); })) } #[doc(alias = "shumate_file_cache_set_size_limit")] #[doc(alias = "size-limit")] pub fn set_size_limit(&self, size_limit: u32) { unsafe { ffi::shumate_file_cache_set_size_limit(self.to_glib_none().0, size_limit); } } #[doc(alias = "shumate_file_cache_store_tile_async")] pub fn store_tile_async) + 'static>( &self, x: i32, y: i32, zoom_level: i32, bytes: &glib::Bytes, etag: Option<&str>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn store_tile_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::shumate_file_cache_store_tile_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = store_tile_async_trampoline::

; unsafe { ffi::shumate_file_cache_store_tile_async( self.to_glib_none().0, x, y, zoom_level, bytes.to_glib_none().0, etag.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn store_tile_future( &self, x: i32, y: i32, zoom_level: i32, bytes: &glib::Bytes, etag: Option<&str>, ) -> Pin> + 'static>> { let bytes = bytes.clone(); let etag = etag.map(ToOwned::to_owned); Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.store_tile_async( x, y, zoom_level, &bytes, etag.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); })) } #[doc(alias = "size-limit")] pub fn connect_size_limit_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_size_limit_trampoline( this: *mut ffi::ShumateFileCache, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::size-limit\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_size_limit_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`FileCache`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct FileCacheBuilder { builder: glib::object::ObjectBuilder<'static, FileCache>, } impl FileCacheBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn cache_dir(self, cache_dir: impl Into) -> Self { Self { builder: self.builder.property("cache-dir", cache_dir.into()), } } pub fn cache_key(self, cache_key: impl Into) -> Self { Self { builder: self.builder.property("cache-key", cache_key.into()), } } pub fn size_limit(self, size_limit: u32) -> Self { Self { builder: self.builder.property("size-limit", size_limit), } } // rustdoc-stripper-ignore-next /// Build the [`FileCache`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> FileCache { self.builder.build() } } libshumate-0.6.0/src/auto/functions.rs000064400000000000000000000012001046102023000160720ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::translate::*; #[doc(alias = "shumate_get_user_agent")] #[doc(alias = "get_user_agent")] pub fn user_agent() -> Option { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_get_user_agent()) } } #[doc(alias = "shumate_set_user_agent")] pub fn set_user_agent(new_user_agent: Option<&str>) { assert_initialized_main_thread!(); unsafe { ffi::shumate_set_user_agent(new_user_agent.to_glib_none().0); } } libshumate-0.6.0/src/auto/layer.rs000064400000000000000000000020361046102023000152060ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Viewport}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumateLayer")] pub struct Layer(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_layer_get_type(), } } impl Layer { pub const NONE: Option<&'static Layer> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait LayerExt: IsA + sealed::Sealed + 'static { #[doc(alias = "shumate_layer_get_viewport")] #[doc(alias = "get_viewport")] fn viewport(&self) -> Option { unsafe { from_glib_none(ffi::shumate_layer_get_viewport( self.as_ref().to_glib_none().0, )) } } } impl> LayerExt for O {} libshumate-0.6.0/src/auto/license.rs000064400000000000000000000253411046102023000155200ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, MapSource}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateLicense")] pub struct License(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_license_get_type(), } } impl License { #[doc(alias = "shumate_license_new")] pub fn new() -> License { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_license_new()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`License`] objects. /// /// This method returns an instance of [`LicenseBuilder`](crate::builders::LicenseBuilder) which can be used to create [`License`] objects. pub fn builder() -> LicenseBuilder { LicenseBuilder::new() } #[doc(alias = "shumate_license_append_map_source")] pub fn append_map_source(&self, map_source: &impl IsA) { unsafe { ffi::shumate_license_append_map_source( self.to_glib_none().0, map_source.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_license_get_extra_text")] #[doc(alias = "get_extra_text")] #[doc(alias = "extra-text")] pub fn extra_text(&self) -> Option { unsafe { from_glib_none(ffi::shumate_license_get_extra_text(self.to_glib_none().0)) } } #[doc(alias = "shumate_license_get_xalign")] #[doc(alias = "get_xalign")] pub fn xalign(&self) -> f32 { unsafe { ffi::shumate_license_get_xalign(self.to_glib_none().0) } } #[doc(alias = "shumate_license_prepend_map_source")] pub fn prepend_map_source(&self, map_source: &impl IsA) { unsafe { ffi::shumate_license_prepend_map_source( self.to_glib_none().0, map_source.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_license_remove_map_source")] pub fn remove_map_source(&self, map_source: &impl IsA) { unsafe { ffi::shumate_license_remove_map_source( self.to_glib_none().0, map_source.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_license_set_extra_text")] #[doc(alias = "extra-text")] pub fn set_extra_text(&self, text: &str) { unsafe { ffi::shumate_license_set_extra_text(self.to_glib_none().0, text.to_glib_none().0); } } #[doc(alias = "shumate_license_set_xalign")] #[doc(alias = "xalign")] pub fn set_xalign(&self, xalign: f32) { unsafe { ffi::shumate_license_set_xalign(self.to_glib_none().0, xalign); } } #[doc(alias = "extra-text")] pub fn connect_extra_text_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_extra_text_trampoline( this: *mut ffi::ShumateLicense, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::extra-text\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_extra_text_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "xalign")] pub fn connect_xalign_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_xalign_trampoline( this: *mut ffi::ShumateLicense, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::xalign\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_xalign_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for License { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`License`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct LicenseBuilder { builder: glib::object::ObjectBuilder<'static, License>, } impl LicenseBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn extra_text(self, extra_text: impl Into) -> Self { Self { builder: self.builder.property("extra-text", extra_text.into()), } } pub fn xalign(self, xalign: f32) -> Self { Self { builder: self.builder.property("xalign", xalign), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`License`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> License { self.builder.build() } } libshumate-0.6.0/src/auto/location.rs000064400000000000000000000074621046102023000157120ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateLocation")] pub struct Location(Interface); match fn { type_ => || ffi::shumate_location_get_type(), } } impl Location { pub const NONE: Option<&'static Location> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait LocationExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] #[doc(alias = "shumate_location_distance")] fn distance(&self, other: &impl IsA) -> f64 { unsafe { ffi::shumate_location_distance( self.as_ref().to_glib_none().0, other.as_ref().to_glib_none().0, ) } } #[doc(alias = "shumate_location_get_latitude")] #[doc(alias = "get_latitude")] fn latitude(&self) -> f64 { unsafe { ffi::shumate_location_get_latitude(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_location_get_longitude")] #[doc(alias = "get_longitude")] fn longitude(&self) -> f64 { unsafe { ffi::shumate_location_get_longitude(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_location_set_location")] fn set_location(&self, latitude: f64, longitude: f64) { unsafe { ffi::shumate_location_set_location(self.as_ref().to_glib_none().0, latitude, longitude); } } fn set_latitude(&self, latitude: f64) { ObjectExt::set_property(self.as_ref(), "latitude", latitude) } fn set_longitude(&self, longitude: f64) { ObjectExt::set_property(self.as_ref(), "longitude", longitude) } #[doc(alias = "latitude")] fn connect_latitude_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_latitude_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateLocation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Location::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::latitude\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_latitude_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "longitude")] fn connect_longitude_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_longitude_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateLocation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Location::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::longitude\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_longitude_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> LocationExt for O {} libshumate-0.6.0/src/auto/map.rs000064400000000000000000000442631046102023000146570ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Layer, MapSource, State, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateMap")] pub struct Map(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_map_get_type(), } } impl Map { #[doc(alias = "shumate_map_new")] pub fn new() -> Map { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_map_new()) } } #[doc(alias = "shumate_map_new_simple")] pub fn new_simple() -> Map { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_map_new_simple()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Map`] objects. /// /// This method returns an instance of [`MapBuilder`](crate::builders::MapBuilder) which can be used to create [`Map`] objects. pub fn builder() -> MapBuilder { MapBuilder::new() } #[doc(alias = "shumate_map_add_layer")] pub fn add_layer(&self, layer: &impl IsA) { unsafe { ffi::shumate_map_add_layer(self.to_glib_none().0, layer.as_ref().to_glib_none().0); } } #[doc(alias = "shumate_map_center_on")] pub fn center_on(&self, latitude: f64, longitude: f64) { unsafe { ffi::shumate_map_center_on(self.to_glib_none().0, latitude, longitude); } } #[doc(alias = "shumate_map_get_animate_zoom")] #[doc(alias = "get_animate_zoom")] #[doc(alias = "animate-zoom")] pub fn is_animate_zoom(&self) -> bool { unsafe { from_glib(ffi::shumate_map_get_animate_zoom(self.to_glib_none().0)) } } #[doc(alias = "shumate_map_get_go_to_duration")] #[doc(alias = "get_go_to_duration")] #[doc(alias = "go-to-duration")] pub fn go_to_duration(&self) -> u32 { unsafe { ffi::shumate_map_get_go_to_duration(self.to_glib_none().0) } } #[doc(alias = "shumate_map_get_state")] #[doc(alias = "get_state")] pub fn state(&self) -> State { unsafe { from_glib(ffi::shumate_map_get_state(self.to_glib_none().0)) } } #[doc(alias = "shumate_map_get_viewport")] #[doc(alias = "get_viewport")] pub fn viewport(&self) -> Option { unsafe { from_glib_none(ffi::shumate_map_get_viewport(self.to_glib_none().0)) } } #[doc(alias = "shumate_map_get_zoom_on_double_click")] #[doc(alias = "get_zoom_on_double_click")] #[doc(alias = "zoom-on-double-click")] pub fn is_zoom_on_double_click(&self) -> bool { unsafe { from_glib(ffi::shumate_map_get_zoom_on_double_click( self.to_glib_none().0, )) } } #[doc(alias = "shumate_map_go_to")] pub fn go_to(&self, latitude: f64, longitude: f64) { unsafe { ffi::shumate_map_go_to(self.to_glib_none().0, latitude, longitude); } } #[doc(alias = "shumate_map_go_to_full")] pub fn go_to_full(&self, latitude: f64, longitude: f64, zoom_level: f64) { unsafe { ffi::shumate_map_go_to_full(self.to_glib_none().0, latitude, longitude, zoom_level); } } #[doc(alias = "shumate_map_go_to_full_with_duration")] pub fn go_to_full_with_duration( &self, latitude: f64, longitude: f64, zoom_level: f64, duration_ms: u32, ) { unsafe { ffi::shumate_map_go_to_full_with_duration( self.to_glib_none().0, latitude, longitude, zoom_level, duration_ms, ); } } #[doc(alias = "shumate_map_insert_layer_above")] pub fn insert_layer_above( &self, layer: &impl IsA, next_sibling: Option<&impl IsA>, ) { unsafe { ffi::shumate_map_insert_layer_above( self.to_glib_none().0, layer.as_ref().to_glib_none().0, next_sibling.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "shumate_map_insert_layer_behind")] pub fn insert_layer_behind( &self, layer: &impl IsA, next_sibling: Option<&impl IsA>, ) { unsafe { ffi::shumate_map_insert_layer_behind( self.to_glib_none().0, layer.as_ref().to_glib_none().0, next_sibling.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "shumate_map_remove_layer")] pub fn remove_layer(&self, layer: &impl IsA) { unsafe { ffi::shumate_map_remove_layer(self.to_glib_none().0, layer.as_ref().to_glib_none().0); } } #[doc(alias = "shumate_map_set_animate_zoom")] #[doc(alias = "animate-zoom")] pub fn set_animate_zoom(&self, value: bool) { unsafe { ffi::shumate_map_set_animate_zoom(self.to_glib_none().0, value.into_glib()); } } #[doc(alias = "shumate_map_set_go_to_duration")] #[doc(alias = "go-to-duration")] pub fn set_go_to_duration(&self, duration: u32) { unsafe { ffi::shumate_map_set_go_to_duration(self.to_glib_none().0, duration); } } #[doc(alias = "shumate_map_set_map_source")] pub fn set_map_source(&self, map_source: &impl IsA) { unsafe { ffi::shumate_map_set_map_source( self.to_glib_none().0, map_source.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_map_set_zoom_on_double_click")] #[doc(alias = "zoom-on-double-click")] pub fn set_zoom_on_double_click(&self, value: bool) { unsafe { ffi::shumate_map_set_zoom_on_double_click(self.to_glib_none().0, value.into_glib()); } } #[doc(alias = "shumate_map_stop_go_to")] pub fn stop_go_to(&self) { unsafe { ffi::shumate_map_stop_go_to(self.to_glib_none().0); } } #[doc(alias = "shumate_map_zoom_in")] pub fn zoom_in(&self) { unsafe { ffi::shumate_map_zoom_in(self.to_glib_none().0); } } #[doc(alias = "shumate_map_zoom_out")] pub fn zoom_out(&self) { unsafe { ffi::shumate_map_zoom_out(self.to_glib_none().0); } } #[doc(alias = "animation-completed")] pub fn connect_animation_completed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn animation_completed_trampoline( this: *mut ffi::ShumateMap, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("animation-completed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"animation-completed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( animation_completed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "animate-zoom")] pub fn connect_animate_zoom_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_animate_zoom_trampoline( this: *mut ffi::ShumateMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::animate-zoom\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_animate_zoom_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "go-to-duration")] pub fn connect_go_to_duration_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_go_to_duration_trampoline( this: *mut ffi::ShumateMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::go-to-duration\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_go_to_duration_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state")] pub fn connect_state_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline( this: *mut ffi::ShumateMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "viewport")] pub fn connect_viewport_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_viewport_trampoline( this: *mut ffi::ShumateMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::viewport\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_viewport_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "zoom-on-double-click")] pub fn connect_zoom_on_double_click_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_zoom_on_double_click_trampoline( this: *mut ffi::ShumateMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::zoom-on-double-click\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_zoom_on_double_click_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for Map { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Map`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct MapBuilder { builder: glib::object::ObjectBuilder<'static, Map>, } impl MapBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn animate_zoom(self, animate_zoom: bool) -> Self { Self { builder: self.builder.property("animate-zoom", animate_zoom), } } pub fn go_to_duration(self, go_to_duration: u32) -> Self { Self { builder: self.builder.property("go-to-duration", go_to_duration), } } pub fn zoom_on_double_click(self, zoom_on_double_click: bool) -> Self { Self { builder: self .builder .property("zoom-on-double-click", zoom_on_double_click), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`Map`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Map { self.builder.build() } } libshumate-0.6.0/src/auto/map_layer.rs000064400000000000000000000215131046102023000160440ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use crate::SymbolEvent; use crate::{ffi, Layer, MapSource, Viewport}; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use glib::signal::{connect_raw, SignalHandlerId}; use glib::{prelude::*, translate::*}; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateMapLayer")] pub struct MapLayer(Object) @extends Layer, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_map_layer_get_type(), } } impl MapLayer { #[doc(alias = "shumate_map_layer_new")] pub fn new(map_source: &impl IsA, viewport: &Viewport) -> MapLayer { skip_assert_initialized!(); unsafe { from_glib_none(ffi::shumate_map_layer_new( map_source.as_ref().to_glib_none().0, viewport.to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`MapLayer`] objects. /// /// This method returns an instance of [`MapLayerBuilder`](crate::builders::MapLayerBuilder) which can be used to create [`MapLayer`] objects. pub fn builder() -> MapLayerBuilder { MapLayerBuilder::new() } #[doc(alias = "map-source")] pub fn map_source(&self) -> Option { ObjectExt::property(self, "map-source") } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "symbol-clicked")] pub fn connect_symbol_clicked( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn symbol_clicked_trampoline( this: *mut ffi::ShumateMapLayer, event: *mut ffi::ShumateSymbolEvent, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), &from_glib_borrow(event)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"symbol-clicked\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( symbol_clicked_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for MapLayer { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`MapLayer`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct MapLayerBuilder { builder: glib::object::ObjectBuilder<'static, MapLayer>, } impl MapLayerBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn map_source(self, map_source: &impl IsA) -> Self { Self { builder: self .builder .property("map-source", map_source.clone().upcast()), } } pub fn viewport(self, viewport: &Viewport) -> Self { Self { builder: self.builder.property("viewport", viewport.clone()), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`MapLayer`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> MapLayer { self.builder.build() } } libshumate-0.6.0/src/auto/map_source.rs000064400000000000000000000424051046102023000162330ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, MapProjection, Tile}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "ShumateMapSource")] pub struct MapSource(Object); match fn { type_ => || ffi::shumate_map_source_get_type(), } } impl MapSource { pub const NONE: Option<&'static MapSource> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MapSourceExt: IsA + sealed::Sealed + 'static { #[doc(alias = "shumate_map_source_fill_tile_async")] fn fill_tile_async) + 'static>( &self, tile: &Tile, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn fill_tile_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::shumate_map_source_fill_tile_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = fill_tile_async_trampoline::

; unsafe { ffi::shumate_map_source_fill_tile_async( self.as_ref().to_glib_none().0, tile.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn fill_tile_future( &self, tile: &Tile, ) -> Pin> + 'static>> { let tile = tile.clone(); Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.fill_tile_async(&tile, Some(cancellable), move |res| { send.resolve(res); }); })) } #[doc(alias = "shumate_map_source_get_column_count")] #[doc(alias = "get_column_count")] fn column_count(&self, zoom_level: u32) -> u32 { unsafe { ffi::shumate_map_source_get_column_count(self.as_ref().to_glib_none().0, zoom_level) } } #[doc(alias = "shumate_map_source_get_id")] #[doc(alias = "get_id")] fn id(&self) -> Option { unsafe { from_glib_none(ffi::shumate_map_source_get_id( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_get_latitude")] #[doc(alias = "get_latitude")] fn latitude(&self, zoom_level: f64, y: f64) -> f64 { unsafe { ffi::shumate_map_source_get_latitude(self.as_ref().to_glib_none().0, zoom_level, y) } } #[doc(alias = "shumate_map_source_get_license")] #[doc(alias = "get_license")] fn license(&self) -> Option { unsafe { from_glib_none(ffi::shumate_map_source_get_license( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_get_license_uri")] #[doc(alias = "get_license_uri")] #[doc(alias = "license-uri")] fn license_uri(&self) -> Option { unsafe { from_glib_none(ffi::shumate_map_source_get_license_uri( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_get_longitude")] #[doc(alias = "get_longitude")] fn longitude(&self, zoom_level: f64, x: f64) -> f64 { unsafe { ffi::shumate_map_source_get_longitude(self.as_ref().to_glib_none().0, zoom_level, x) } } #[doc(alias = "shumate_map_source_get_max_zoom_level")] #[doc(alias = "get_max_zoom_level")] #[doc(alias = "max-zoom-level")] fn max_zoom_level(&self) -> u32 { unsafe { ffi::shumate_map_source_get_max_zoom_level(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_map_source_get_meters_per_pixel")] #[doc(alias = "get_meters_per_pixel")] fn meters_per_pixel(&self, zoom_level: f64, latitude: f64, longitude: f64) -> f64 { unsafe { ffi::shumate_map_source_get_meters_per_pixel( self.as_ref().to_glib_none().0, zoom_level, latitude, longitude, ) } } #[doc(alias = "shumate_map_source_get_min_zoom_level")] #[doc(alias = "get_min_zoom_level")] #[doc(alias = "min-zoom-level")] fn min_zoom_level(&self) -> u32 { unsafe { ffi::shumate_map_source_get_min_zoom_level(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_map_source_get_name")] #[doc(alias = "get_name")] fn name(&self) -> Option { unsafe { from_glib_none(ffi::shumate_map_source_get_name( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_get_projection")] #[doc(alias = "get_projection")] fn projection(&self) -> MapProjection { unsafe { from_glib(ffi::shumate_map_source_get_projection( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_get_row_count")] #[doc(alias = "get_row_count")] fn row_count(&self, zoom_level: u32) -> u32 { unsafe { ffi::shumate_map_source_get_row_count(self.as_ref().to_glib_none().0, zoom_level) } } #[doc(alias = "shumate_map_source_get_tile_size")] #[doc(alias = "get_tile_size")] #[doc(alias = "tile-size")] fn tile_size(&self) -> u32 { unsafe { ffi::shumate_map_source_get_tile_size(self.as_ref().to_glib_none().0) } } #[doc(alias = "shumate_map_source_get_tile_size_at_zoom")] #[doc(alias = "get_tile_size_at_zoom")] fn tile_size_at_zoom(&self, zoom_level: f64) -> f64 { unsafe { ffi::shumate_map_source_get_tile_size_at_zoom( self.as_ref().to_glib_none().0, zoom_level, ) } } #[doc(alias = "shumate_map_source_get_x")] #[doc(alias = "get_x")] fn x(&self, zoom_level: f64, longitude: f64) -> f64 { unsafe { ffi::shumate_map_source_get_x(self.as_ref().to_glib_none().0, zoom_level, longitude) } } #[doc(alias = "shumate_map_source_get_y")] #[doc(alias = "get_y")] fn y(&self, zoom_level: f64, latitude: f64) -> f64 { unsafe { ffi::shumate_map_source_get_y(self.as_ref().to_glib_none().0, zoom_level, latitude) } } #[doc(alias = "shumate_map_source_set_id")] #[doc(alias = "id")] fn set_id(&self, id: &str) { unsafe { ffi::shumate_map_source_set_id(self.as_ref().to_glib_none().0, id.to_glib_none().0); } } #[doc(alias = "shumate_map_source_set_license")] #[doc(alias = "license")] fn set_license(&self, license: &str) { unsafe { ffi::shumate_map_source_set_license( self.as_ref().to_glib_none().0, license.to_glib_none().0, ); } } #[doc(alias = "shumate_map_source_set_license_uri")] #[doc(alias = "license-uri")] fn set_license_uri(&self, license_uri: &str) { unsafe { ffi::shumate_map_source_set_license_uri( self.as_ref().to_glib_none().0, license_uri.to_glib_none().0, ); } } #[doc(alias = "shumate_map_source_set_max_zoom_level")] #[doc(alias = "max-zoom-level")] fn set_max_zoom_level(&self, zoom_level: u32) { unsafe { ffi::shumate_map_source_set_max_zoom_level(self.as_ref().to_glib_none().0, zoom_level); } } #[doc(alias = "shumate_map_source_set_min_zoom_level")] #[doc(alias = "min-zoom-level")] fn set_min_zoom_level(&self, zoom_level: u32) { unsafe { ffi::shumate_map_source_set_min_zoom_level(self.as_ref().to_glib_none().0, zoom_level); } } #[doc(alias = "shumate_map_source_set_name")] #[doc(alias = "name")] fn set_name(&self, name: &str) { unsafe { ffi::shumate_map_source_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0); } } #[doc(alias = "shumate_map_source_set_projection")] #[doc(alias = "projection")] fn set_projection(&self, projection: MapProjection) { unsafe { ffi::shumate_map_source_set_projection( self.as_ref().to_glib_none().0, projection.into_glib(), ); } } #[doc(alias = "shumate_map_source_set_tile_size")] #[doc(alias = "tile-size")] fn set_tile_size(&self, tile_size: u32) { unsafe { ffi::shumate_map_source_set_tile_size(self.as_ref().to_glib_none().0, tile_size); } } #[doc(alias = "id")] fn connect_id_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_id_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::id\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_id_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "license")] fn connect_license_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_license_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::license\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_license_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "license-uri")] fn connect_license_uri_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_license_uri_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::license-uri\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_license_uri_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "max-zoom-level")] fn connect_max_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_max_zoom_level_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::max-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "min-zoom-level")] fn connect_min_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_min_zoom_level_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::min-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_min_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "name")] fn connect_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_name_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "projection")] fn connect_projection_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_projection_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::projection\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_projection_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "tile-size")] fn connect_tile_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_tile_size_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMapSource, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MapSource::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::tile-size\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_tile_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MapSourceExt for O {} libshumate-0.6.0/src/auto/map_source_registry.rs000064400000000000000000000043001046102023000201530ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, MapSource}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumateMapSourceRegistry")] pub struct MapSourceRegistry(Object) @implements gio::ListModel; match fn { type_ => || ffi::shumate_map_source_registry_get_type(), } } impl MapSourceRegistry { #[doc(alias = "shumate_map_source_registry_new")] pub fn new() -> MapSourceRegistry { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_map_source_registry_new()) } } #[doc(alias = "shumate_map_source_registry_new_with_defaults")] #[doc(alias = "new_with_defaults")] pub fn with_defaults() -> MapSourceRegistry { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_map_source_registry_new_with_defaults()) } } #[doc(alias = "shumate_map_source_registry_add")] pub fn add(&self, map_source: impl IsA) { unsafe { ffi::shumate_map_source_registry_add( self.to_glib_none().0, map_source.upcast().into_glib_ptr(), ); } } #[doc(alias = "shumate_map_source_registry_get_by_id")] #[doc(alias = "get_by_id")] pub fn by_id(&self, id: &str) -> Option { unsafe { from_glib_none(ffi::shumate_map_source_registry_get_by_id( self.to_glib_none().0, id.to_glib_none().0, )) } } #[doc(alias = "shumate_map_source_registry_populate_defaults")] pub fn populate_defaults(&self) { unsafe { ffi::shumate_map_source_registry_populate_defaults(self.to_glib_none().0); } } #[doc(alias = "shumate_map_source_registry_remove")] pub fn remove(&self, id: &str) { unsafe { ffi::shumate_map_source_registry_remove(self.to_glib_none().0, id.to_glib_none().0); } } } impl Default for MapSourceRegistry { fn default() -> Self { Self::new() } } libshumate-0.6.0/src/auto/marker.rs000064400000000000000000000302261046102023000153550ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Location}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateMarker")] pub struct Marker(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Location; match fn { type_ => || ffi::shumate_marker_get_type(), } } impl Marker { pub const NONE: Option<&'static Marker> = None; #[doc(alias = "shumate_marker_new")] pub fn new() -> Marker { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_marker_new()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Marker`] objects. /// /// This method returns an instance of [`MarkerBuilder`](crate::builders::MarkerBuilder) which can be used to create [`Marker`] objects. pub fn builder() -> MarkerBuilder { MarkerBuilder::new() } } impl Default for Marker { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Marker`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct MarkerBuilder { builder: glib::object::ObjectBuilder<'static, Marker>, } impl MarkerBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn child(self, child: &impl IsA) -> Self { Self { builder: self.builder.property("child", child.clone().upcast()), } } pub fn selectable(self, selectable: bool) -> Self { Self { builder: self.builder.property("selectable", selectable), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } pub fn latitude(self, latitude: f64) -> Self { Self { builder: self.builder.property("latitude", latitude), } } pub fn longitude(self, longitude: f64) -> Self { Self { builder: self.builder.property("longitude", longitude), } } // rustdoc-stripper-ignore-next /// Build the [`Marker`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Marker { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MarkerExt: IsA + sealed::Sealed + 'static { #[doc(alias = "shumate_marker_animate_in")] fn animate_in(&self) { unsafe { ffi::shumate_marker_animate_in(self.as_ref().to_glib_none().0); } } #[doc(alias = "shumate_marker_animate_in_with_delay")] fn animate_in_with_delay(&self, delay: u32) { unsafe { ffi::shumate_marker_animate_in_with_delay(self.as_ref().to_glib_none().0, delay); } } #[doc(alias = "shumate_marker_animate_out")] fn animate_out(&self) { unsafe { ffi::shumate_marker_animate_out(self.as_ref().to_glib_none().0); } } #[doc(alias = "shumate_marker_animate_out_with_delay")] fn animate_out_with_delay(&self, delay: u32) { unsafe { ffi::shumate_marker_animate_out_with_delay(self.as_ref().to_glib_none().0, delay); } } #[doc(alias = "shumate_marker_get_child")] #[doc(alias = "get_child")] fn child(&self) -> Option { unsafe { from_glib_none(ffi::shumate_marker_get_child( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_marker_get_draggable")] #[doc(alias = "get_draggable")] fn is_draggable(&self) -> bool { unsafe { from_glib(ffi::shumate_marker_get_draggable( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_marker_get_selectable")] #[doc(alias = "get_selectable")] #[doc(alias = "selectable")] fn is_selectable(&self) -> bool { unsafe { from_glib(ffi::shumate_marker_get_selectable( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_marker_is_selected")] fn is_selected(&self) -> bool { unsafe { from_glib(ffi::shumate_marker_is_selected( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_marker_set_child")] #[doc(alias = "child")] fn set_child(&self, child: Option<&impl IsA>) { unsafe { ffi::shumate_marker_set_child( self.as_ref().to_glib_none().0, child.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "shumate_marker_set_draggable")] fn set_draggable(&self, value: bool) { unsafe { ffi::shumate_marker_set_draggable(self.as_ref().to_glib_none().0, value.into_glib()); } } #[doc(alias = "shumate_marker_set_selectable")] #[doc(alias = "selectable")] fn set_selectable(&self, value: bool) { unsafe { ffi::shumate_marker_set_selectable(self.as_ref().to_glib_none().0, value.into_glib()); } } #[doc(alias = "child")] fn connect_child_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_child_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMarker, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Marker::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::child\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_child_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "selectable")] fn connect_selectable_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_selectable_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::ShumateMarker, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Marker::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::selectable\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_selectable_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MarkerExt for O {} libshumate-0.6.0/src/auto/marker_layer.rs000064400000000000000000000330251046102023000165510ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Layer, Marker, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateMarkerLayer")] pub struct MarkerLayer(Object) @extends Layer, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_marker_layer_get_type(), } } impl MarkerLayer { #[doc(alias = "shumate_marker_layer_new")] pub fn new(viewport: &Viewport) -> MarkerLayer { skip_assert_initialized!(); unsafe { from_glib_none(ffi::shumate_marker_layer_new(viewport.to_glib_none().0)) } } #[doc(alias = "shumate_marker_layer_new_full")] pub fn new_full(viewport: &Viewport, mode: gtk::SelectionMode) -> MarkerLayer { skip_assert_initialized!(); unsafe { from_glib_none(ffi::shumate_marker_layer_new_full( viewport.to_glib_none().0, mode.into_glib(), )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`MarkerLayer`] objects. /// /// This method returns an instance of [`MarkerLayerBuilder`](crate::builders::MarkerLayerBuilder) which can be used to create [`MarkerLayer`] objects. pub fn builder() -> MarkerLayerBuilder { MarkerLayerBuilder::new() } #[doc(alias = "shumate_marker_layer_add_marker")] pub fn add_marker(&self, marker: &impl IsA) { unsafe { ffi::shumate_marker_layer_add_marker( self.to_glib_none().0, marker.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_marker_layer_get_markers")] #[doc(alias = "get_markers")] pub fn markers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::shumate_marker_layer_get_markers( self.to_glib_none().0, )) } } #[doc(alias = "shumate_marker_layer_get_selected")] #[doc(alias = "get_selected")] pub fn selected(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::shumate_marker_layer_get_selected( self.to_glib_none().0, )) } } #[doc(alias = "shumate_marker_layer_get_selection_mode")] #[doc(alias = "get_selection_mode")] #[doc(alias = "selection-mode")] pub fn selection_mode(&self) -> gtk::SelectionMode { unsafe { from_glib(ffi::shumate_marker_layer_get_selection_mode( self.to_glib_none().0, )) } } #[doc(alias = "shumate_marker_layer_remove_all")] pub fn remove_all(&self) { unsafe { ffi::shumate_marker_layer_remove_all(self.to_glib_none().0); } } #[doc(alias = "shumate_marker_layer_remove_marker")] pub fn remove_marker(&self, marker: &impl IsA) { unsafe { ffi::shumate_marker_layer_remove_marker( self.to_glib_none().0, marker.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_marker_layer_select_all_markers")] pub fn select_all_markers(&self) { unsafe { ffi::shumate_marker_layer_select_all_markers(self.to_glib_none().0); } } #[doc(alias = "shumate_marker_layer_select_marker")] pub fn select_marker(&self, marker: &impl IsA) -> bool { unsafe { from_glib(ffi::shumate_marker_layer_select_marker( self.to_glib_none().0, marker.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_marker_layer_set_selection_mode")] #[doc(alias = "selection-mode")] pub fn set_selection_mode(&self, mode: gtk::SelectionMode) { unsafe { ffi::shumate_marker_layer_set_selection_mode(self.to_glib_none().0, mode.into_glib()); } } #[doc(alias = "shumate_marker_layer_unselect_all_markers")] pub fn unselect_all_markers(&self) { unsafe { ffi::shumate_marker_layer_unselect_all_markers(self.to_glib_none().0); } } #[doc(alias = "shumate_marker_layer_unselect_marker")] pub fn unselect_marker(&self, marker: &impl IsA) { unsafe { ffi::shumate_marker_layer_unselect_marker( self.to_glib_none().0, marker.as_ref().to_glib_none().0, ); } } #[doc(alias = "marker-selected")] pub fn connect_marker_selected( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn marker_selected_trampoline( this: *mut ffi::ShumateMarkerLayer, marker: *mut ffi::ShumateMarker, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), &from_glib_borrow(marker)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"marker-selected\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( marker_selected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "marker-unselected")] pub fn connect_marker_unselected( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn marker_unselected_trampoline< F: Fn(&MarkerLayer, &Marker) + 'static, >( this: *mut ffi::ShumateMarkerLayer, marker: *mut ffi::ShumateMarker, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), &from_glib_borrow(marker)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"marker-unselected\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( marker_unselected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "selection-mode")] pub fn connect_selection_mode_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_selection_mode_trampoline( this: *mut ffi::ShumateMarkerLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::selection-mode\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_selection_mode_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for MarkerLayer { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`MarkerLayer`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct MarkerLayerBuilder { builder: glib::object::ObjectBuilder<'static, MarkerLayer>, } impl MarkerLayerBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn selection_mode(self, selection_mode: gtk::SelectionMode) -> Self { Self { builder: self.builder.property("selection-mode", selection_mode), } } pub fn viewport(self, viewport: &Viewport) -> Self { Self { builder: self.builder.property("viewport", viewport.clone()), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`MarkerLayer`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> MarkerLayer { self.builder.build() } } libshumate-0.6.0/src/auto/mod.rs000064400000000000000000000115721046102023000146560ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT mod compass; pub use self::compass::Compass; mod coordinate; pub use self::coordinate::Coordinate; mod data_source; pub use self::data_source::DataSource; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] mod data_source_request; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use self::data_source_request::DataSourceRequest; mod file_cache; pub use self::file_cache::FileCache; mod layer; pub use self::layer::Layer; mod license; pub use self::license::License; mod location; pub use self::location::Location; mod map; pub use self::map::Map; mod map_layer; pub use self::map_layer::MapLayer; mod map_source; pub use self::map_source::MapSource; mod map_source_registry; pub use self::map_source_registry::MapSourceRegistry; mod marker; pub use self::marker::Marker; mod marker_layer; pub use self::marker_layer::MarkerLayer; mod path_layer; pub use self::path_layer::PathLayer; mod point; pub use self::point::Point; mod raster_renderer; pub use self::raster_renderer::RasterRenderer; mod scale; pub use self::scale::Scale; mod simple_map; pub use self::simple_map::SimpleMap; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] mod symbol_event; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use self::symbol_event::SymbolEvent; mod tile; pub use self::tile::Tile; mod tile_downloader; pub use self::tile_downloader::TileDownloader; #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] mod vector_reader; #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] pub use self::vector_reader::VectorReader; #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] mod vector_reader_iter; #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] pub use self::vector_reader_iter::VectorReaderIter; mod vector_renderer; pub use self::vector_renderer::VectorRenderer; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] mod vector_sprite; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use self::vector_sprite::VectorSprite; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] mod vector_sprite_sheet; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use self::vector_sprite_sheet::VectorSpriteSheet; mod viewport; pub use self::viewport::Viewport; mod enums; pub use self::enums::FileCacheError; #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] pub use self::enums::GeometryType; pub use self::enums::MapProjection; pub use self::enums::State; pub use self::enums::StyleError; pub use self::enums::TileDownloaderError; pub use self::enums::Unit; pub(crate) mod functions; mod constants; pub use self::constants::MAP_SOURCE_MFF_RELIEF; pub use self::constants::MAP_SOURCE_OSM_CYCLE_MAP; pub use self::constants::MAP_SOURCE_OSM_MAPNIK; pub use self::constants::MAP_SOURCE_OSM_TRANSPORT_MAP; pub use self::constants::MAP_SOURCE_OWM_CLOUDS; pub use self::constants::MAP_SOURCE_OWM_PRECIPITATION; pub use self::constants::MAP_SOURCE_OWM_PRESSURE; pub use self::constants::MAP_SOURCE_OWM_TEMPERATURE; pub use self::constants::MAP_SOURCE_OWM_WIND; pub(crate) mod traits { pub use super::data_source::DataSourceExt; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use super::data_source_request::DataSourceRequestExt; pub use super::layer::LayerExt; pub use super::location::LocationExt; pub use super::map_source::MapSourceExt; pub use super::marker::MarkerExt; } pub(crate) mod builders { pub use super::compass::CompassBuilder; pub use super::coordinate::CoordinateBuilder; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use super::data_source_request::DataSourceRequestBuilder; pub use super::file_cache::FileCacheBuilder; pub use super::license::LicenseBuilder; pub use super::map::MapBuilder; pub use super::map_layer::MapLayerBuilder; pub use super::marker::MarkerBuilder; pub use super::marker_layer::MarkerLayerBuilder; pub use super::path_layer::PathLayerBuilder; pub use super::point::PointBuilder; pub use super::raster_renderer::RasterRendererBuilder; pub use super::scale::ScaleBuilder; pub use super::simple_map::SimpleMapBuilder; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use super::symbol_event::SymbolEventBuilder; pub use super::tile::TileBuilder; pub use super::vector_renderer::VectorRendererBuilder; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub use super::vector_sprite::VectorSpriteBuilder; pub use super::viewport::ViewportBuilder; } libshumate-0.6.0/src/auto/path_layer.rs000064400000000000000000000525511046102023000162310ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Layer, Location, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumatePathLayer")] pub struct PathLayer(Object) @extends Layer, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_path_layer_get_type(), } } impl PathLayer { #[doc(alias = "shumate_path_layer_new")] pub fn new(viewport: &Viewport) -> PathLayer { skip_assert_initialized!(); unsafe { from_glib_none(ffi::shumate_path_layer_new(viewport.to_glib_none().0)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`PathLayer`] objects. /// /// This method returns an instance of [`PathLayerBuilder`](crate::builders::PathLayerBuilder) which can be used to create [`PathLayer`] objects. pub fn builder() -> PathLayerBuilder { PathLayerBuilder::new() } #[doc(alias = "shumate_path_layer_add_node")] pub fn add_node(&self, location: &impl IsA) { unsafe { ffi::shumate_path_layer_add_node( self.to_glib_none().0, location.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_path_layer_get_closed")] #[doc(alias = "get_closed")] #[doc(alias = "closed")] pub fn is_closed(&self) -> bool { unsafe { from_glib(ffi::shumate_path_layer_get_closed(self.to_glib_none().0)) } } //#[doc(alias = "shumate_path_layer_get_dash")] //#[doc(alias = "get_dash")] //pub fn dash(&self) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:shumate_path_layer_get_dash() } //} #[doc(alias = "shumate_path_layer_get_fill")] #[doc(alias = "get_fill")] #[doc(alias = "fill")] pub fn fills(&self) -> bool { unsafe { from_glib(ffi::shumate_path_layer_get_fill(self.to_glib_none().0)) } } #[doc(alias = "shumate_path_layer_get_fill_color")] #[doc(alias = "get_fill_color")] #[doc(alias = "fill-color")] pub fn fill_color(&self) -> Option { unsafe { from_glib_full(ffi::shumate_path_layer_get_fill_color( self.to_glib_none().0, )) } } #[doc(alias = "shumate_path_layer_get_nodes")] #[doc(alias = "get_nodes")] pub fn nodes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::shumate_path_layer_get_nodes( self.to_glib_none().0, )) } } #[doc(alias = "shumate_path_layer_get_outline_color")] #[doc(alias = "get_outline_color")] #[doc(alias = "outline-color")] pub fn outline_color(&self) -> Option { unsafe { from_glib_full(ffi::shumate_path_layer_get_outline_color( self.to_glib_none().0, )) } } #[doc(alias = "shumate_path_layer_get_outline_width")] #[doc(alias = "get_outline_width")] #[doc(alias = "outline-width")] pub fn outline_width(&self) -> f64 { unsafe { ffi::shumate_path_layer_get_outline_width(self.to_glib_none().0) } } #[doc(alias = "shumate_path_layer_get_stroke")] #[doc(alias = "get_stroke")] #[doc(alias = "stroke")] pub fn is_stroke(&self) -> bool { unsafe { from_glib(ffi::shumate_path_layer_get_stroke(self.to_glib_none().0)) } } #[doc(alias = "shumate_path_layer_get_stroke_color")] #[doc(alias = "get_stroke_color")] #[doc(alias = "stroke-color")] pub fn stroke_color(&self) -> Option { unsafe { from_glib_full(ffi::shumate_path_layer_get_stroke_color( self.to_glib_none().0, )) } } #[doc(alias = "shumate_path_layer_get_stroke_width")] #[doc(alias = "get_stroke_width")] #[doc(alias = "stroke-width")] pub fn stroke_width(&self) -> f64 { unsafe { ffi::shumate_path_layer_get_stroke_width(self.to_glib_none().0) } } #[doc(alias = "shumate_path_layer_insert_node")] pub fn insert_node(&self, location: &impl IsA, position: u32) { unsafe { ffi::shumate_path_layer_insert_node( self.to_glib_none().0, location.as_ref().to_glib_none().0, position, ); } } #[doc(alias = "shumate_path_layer_remove_all")] pub fn remove_all(&self) { unsafe { ffi::shumate_path_layer_remove_all(self.to_glib_none().0); } } #[doc(alias = "shumate_path_layer_remove_node")] pub fn remove_node(&self, location: &impl IsA) { unsafe { ffi::shumate_path_layer_remove_node( self.to_glib_none().0, location.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_path_layer_set_closed")] #[doc(alias = "closed")] pub fn set_closed(&self, value: bool) { unsafe { ffi::shumate_path_layer_set_closed(self.to_glib_none().0, value.into_glib()); } } //#[doc(alias = "shumate_path_layer_set_dash")] //pub fn set_dash(&self, dash_pattern: /*Unimplemented*/&List TypeId { ns_id: 0, id: 15 }) { // unsafe { TODO: call ffi:shumate_path_layer_set_dash() } //} #[doc(alias = "shumate_path_layer_set_fill")] #[doc(alias = "fill")] pub fn set_fill(&self, value: bool) { unsafe { ffi::shumate_path_layer_set_fill(self.to_glib_none().0, value.into_glib()); } } #[doc(alias = "shumate_path_layer_set_fill_color")] #[doc(alias = "fill-color")] pub fn set_fill_color(&self, color: Option<&gdk::RGBA>) { unsafe { ffi::shumate_path_layer_set_fill_color(self.to_glib_none().0, color.to_glib_none().0); } } #[doc(alias = "shumate_path_layer_set_outline_color")] #[doc(alias = "outline-color")] pub fn set_outline_color(&self, color: Option<&gdk::RGBA>) { unsafe { ffi::shumate_path_layer_set_outline_color( self.to_glib_none().0, color.to_glib_none().0, ); } } #[doc(alias = "shumate_path_layer_set_outline_width")] #[doc(alias = "outline-width")] pub fn set_outline_width(&self, value: f64) { unsafe { ffi::shumate_path_layer_set_outline_width(self.to_glib_none().0, value); } } #[doc(alias = "shumate_path_layer_set_stroke")] #[doc(alias = "stroke")] pub fn set_stroke(&self, value: bool) { unsafe { ffi::shumate_path_layer_set_stroke(self.to_glib_none().0, value.into_glib()); } } #[doc(alias = "shumate_path_layer_set_stroke_color")] #[doc(alias = "stroke-color")] pub fn set_stroke_color(&self, color: Option<&gdk::RGBA>) { unsafe { ffi::shumate_path_layer_set_stroke_color(self.to_glib_none().0, color.to_glib_none().0); } } #[doc(alias = "shumate_path_layer_set_stroke_width")] #[doc(alias = "stroke-width")] pub fn set_stroke_width(&self, value: f64) { unsafe { ffi::shumate_path_layer_set_stroke_width(self.to_glib_none().0, value); } } #[doc(alias = "closed")] pub fn connect_closed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_closed_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::closed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "fill")] pub fn connect_fill_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_fill_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::fill\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_fill_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "fill-color")] pub fn connect_fill_color_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_fill_color_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::fill-color\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_fill_color_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "outline-color")] pub fn connect_outline_color_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_outline_color_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::outline-color\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_outline_color_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "outline-width")] pub fn connect_outline_width_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_outline_width_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::outline-width\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_outline_width_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "stroke")] pub fn connect_stroke_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_stroke_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::stroke\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_stroke_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "stroke-color")] pub fn connect_stroke_color_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_stroke_color_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::stroke-color\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_stroke_color_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "stroke-width")] pub fn connect_stroke_width_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_stroke_width_trampoline( this: *mut ffi::ShumatePathLayer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::stroke-width\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_stroke_width_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for PathLayer { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`PathLayer`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct PathLayerBuilder { builder: glib::object::ObjectBuilder<'static, PathLayer>, } impl PathLayerBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn closed(self, closed: bool) -> Self { Self { builder: self.builder.property("closed", closed), } } pub fn fill(self, fill: bool) -> Self { Self { builder: self.builder.property("fill", fill), } } pub fn fill_color(self, fill_color: &gdk::RGBA) -> Self { Self { builder: self.builder.property("fill-color", fill_color), } } pub fn outline_color(self, outline_color: &gdk::RGBA) -> Self { Self { builder: self.builder.property("outline-color", outline_color), } } pub fn outline_width(self, outline_width: f64) -> Self { Self { builder: self.builder.property("outline-width", outline_width), } } pub fn stroke(self, stroke: bool) -> Self { Self { builder: self.builder.property("stroke", stroke), } } pub fn stroke_color(self, stroke_color: &gdk::RGBA) -> Self { Self { builder: self.builder.property("stroke-color", stroke_color), } } pub fn stroke_width(self, stroke_width: f64) -> Self { Self { builder: self.builder.property("stroke-width", stroke_width), } } pub fn viewport(self, viewport: &Viewport) -> Self { Self { builder: self.builder.property("viewport", viewport.clone()), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`PathLayer`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> PathLayer { self.builder.build() } } libshumate-0.6.0/src/auto/point.rs000064400000000000000000000165531046102023000152340ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Location, Marker}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumatePoint")] pub struct Point(Object) @extends Marker, gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, Location; match fn { type_ => || ffi::shumate_point_get_type(), } } impl Point { #[doc(alias = "shumate_point_new")] pub fn new() -> Point { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_point_new()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Point`] objects. /// /// This method returns an instance of [`PointBuilder`](crate::builders::PointBuilder) which can be used to create [`Point`] objects. pub fn builder() -> PointBuilder { PointBuilder::new() } } impl Default for Point { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Point`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct PointBuilder { builder: glib::object::ObjectBuilder<'static, Point>, } impl PointBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn child(self, child: &impl IsA) -> Self { Self { builder: self.builder.property("child", child.clone().upcast()), } } pub fn selectable(self, selectable: bool) -> Self { Self { builder: self.builder.property("selectable", selectable), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } pub fn latitude(self, latitude: f64) -> Self { Self { builder: self.builder.property("latitude", latitude), } } pub fn longitude(self, longitude: f64) -> Self { Self { builder: self.builder.property("longitude", longitude), } } // rustdoc-stripper-ignore-next /// Build the [`Point`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Point { self.builder.build() } } libshumate-0.6.0/src/auto/raster_renderer.rs000064400000000000000000000133601046102023000172620ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, DataSource, MapProjection, MapSource}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumateRasterRenderer")] pub struct RasterRenderer(Object) @extends MapSource; match fn { type_ => || ffi::shumate_raster_renderer_get_type(), } } impl RasterRenderer { #[doc(alias = "shumate_raster_renderer_new")] pub fn new(data_source: &impl IsA) -> RasterRenderer { skip_assert_initialized!(); unsafe { from_glib_full(ffi::shumate_raster_renderer_new( data_source.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_raster_renderer_new_from_url")] #[doc(alias = "new_from_url")] pub fn from_url(url_template: &str) -> RasterRenderer { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_raster_renderer_new_from_url( url_template.to_glib_none().0, )) } } #[doc(alias = "shumate_raster_renderer_new_full")] pub fn new_full( id: &str, name: &str, license: &str, license_uri: &str, min_zoom: u32, max_zoom: u32, tile_size: u32, projection: MapProjection, data_source: &impl IsA, ) -> RasterRenderer { skip_assert_initialized!(); unsafe { from_glib_full(ffi::shumate_raster_renderer_new_full( id.to_glib_none().0, name.to_glib_none().0, license.to_glib_none().0, license_uri.to_glib_none().0, min_zoom, max_zoom, tile_size, projection.into_glib(), data_source.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_raster_renderer_new_full_from_url")] pub fn new_full_from_url( id: &str, name: &str, license: &str, license_uri: &str, min_zoom: u32, max_zoom: u32, tile_size: u32, projection: MapProjection, url_template: &str, ) -> RasterRenderer { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_raster_renderer_new_full_from_url( id.to_glib_none().0, name.to_glib_none().0, license.to_glib_none().0, license_uri.to_glib_none().0, min_zoom, max_zoom, tile_size, projection.into_glib(), url_template.to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`RasterRenderer`] objects. /// /// This method returns an instance of [`RasterRendererBuilder`](crate::builders::RasterRendererBuilder) which can be used to create [`RasterRenderer`] objects. pub fn builder() -> RasterRendererBuilder { RasterRendererBuilder::new() } #[doc(alias = "data-source")] pub fn data_source(&self) -> Option { ObjectExt::property(self, "data-source") } } impl Default for RasterRenderer { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`RasterRenderer`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct RasterRendererBuilder { builder: glib::object::ObjectBuilder<'static, RasterRenderer>, } impl RasterRendererBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn data_source(self, data_source: &impl IsA) -> Self { Self { builder: self .builder .property("data-source", data_source.clone().upcast()), } } pub fn id(self, id: impl Into) -> Self { Self { builder: self.builder.property("id", id.into()), } } pub fn license(self, license: impl Into) -> Self { Self { builder: self.builder.property("license", license.into()), } } pub fn license_uri(self, license_uri: impl Into) -> Self { Self { builder: self.builder.property("license-uri", license_uri.into()), } } pub fn max_zoom_level(self, max_zoom_level: u32) -> Self { Self { builder: self.builder.property("max-zoom-level", max_zoom_level), } } pub fn min_zoom_level(self, min_zoom_level: u32) -> Self { Self { builder: self.builder.property("min-zoom-level", min_zoom_level), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn projection(self, projection: MapProjection) -> Self { Self { builder: self.builder.property("projection", projection), } } pub fn tile_size(self, tile_size: u32) -> Self { Self { builder: self.builder.property("tile-size", tile_size), } } // rustdoc-stripper-ignore-next /// Build the [`RasterRenderer`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> RasterRenderer { self.builder.build() } } libshumate-0.6.0/src/auto/scale.rs000064400000000000000000000262441046102023000151700ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Unit, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateScale")] pub struct Scale(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_scale_get_type(), } } impl Scale { #[doc(alias = "shumate_scale_new")] pub fn new(viewport: Option<&Viewport>) -> Scale { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_scale_new(viewport.to_glib_none().0)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Scale`] objects. /// /// This method returns an instance of [`ScaleBuilder`](crate::builders::ScaleBuilder) which can be used to create [`Scale`] objects. pub fn builder() -> ScaleBuilder { ScaleBuilder::new() } #[doc(alias = "shumate_scale_get_max_width")] #[doc(alias = "get_max_width")] #[doc(alias = "max-width")] pub fn max_width(&self) -> u32 { unsafe { ffi::shumate_scale_get_max_width(self.to_glib_none().0) } } #[doc(alias = "shumate_scale_get_unit")] #[doc(alias = "get_unit")] pub fn unit(&self) -> Unit { unsafe { from_glib(ffi::shumate_scale_get_unit(self.to_glib_none().0)) } } #[doc(alias = "shumate_scale_get_viewport")] #[doc(alias = "get_viewport")] pub fn viewport(&self) -> Option { unsafe { from_glib_none(ffi::shumate_scale_get_viewport(self.to_glib_none().0)) } } #[doc(alias = "shumate_scale_set_max_width")] #[doc(alias = "max-width")] pub fn set_max_width(&self, value: u32) { unsafe { ffi::shumate_scale_set_max_width(self.to_glib_none().0, value); } } #[doc(alias = "shumate_scale_set_unit")] #[doc(alias = "unit")] pub fn set_unit(&self, unit: Unit) { unsafe { ffi::shumate_scale_set_unit(self.to_glib_none().0, unit.into_glib()); } } #[doc(alias = "shumate_scale_set_viewport")] #[doc(alias = "viewport")] pub fn set_viewport(&self, viewport: Option<&Viewport>) { unsafe { ffi::shumate_scale_set_viewport(self.to_glib_none().0, viewport.to_glib_none().0); } } #[doc(alias = "max-width")] pub fn connect_max_width_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_max_width_trampoline( this: *mut ffi::ShumateScale, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::max-width\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_width_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "unit")] pub fn connect_unit_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_unit_trampoline( this: *mut ffi::ShumateScale, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::unit\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_unit_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "viewport")] pub fn connect_viewport_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_viewport_trampoline( this: *mut ffi::ShumateScale, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::viewport\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_viewport_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for Scale { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Scale`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ScaleBuilder { builder: glib::object::ObjectBuilder<'static, Scale>, } impl ScaleBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn max_width(self, max_width: u32) -> Self { Self { builder: self.builder.property("max-width", max_width), } } pub fn unit(self, unit: Unit) -> Self { Self { builder: self.builder.property("unit", unit), } } pub fn viewport(self, viewport: &Viewport) -> Self { Self { builder: self.builder.property("viewport", viewport.clone()), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`Scale`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Scale { self.builder.build() } } libshumate-0.6.0/src/auto/simple_map.rs000064400000000000000000000435521046102023000162300ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use crate::SymbolEvent; use crate::{ffi, Compass, Layer, License, Map, MapSource, Scale, Viewport}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateSimpleMap")] pub struct SimpleMap(Object) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget; match fn { type_ => || ffi::shumate_simple_map_get_type(), } } impl SimpleMap { #[doc(alias = "shumate_simple_map_new")] pub fn new() -> SimpleMap { assert_initialized_main_thread!(); unsafe { from_glib_none(ffi::shumate_simple_map_new()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`SimpleMap`] objects. /// /// This method returns an instance of [`SimpleMapBuilder`](crate::builders::SimpleMapBuilder) which can be used to create [`SimpleMap`] objects. pub fn builder() -> SimpleMapBuilder { SimpleMapBuilder::new() } #[doc(alias = "shumate_simple_map_add_overlay_layer")] pub fn add_overlay_layer(&self, layer: &impl IsA) { unsafe { ffi::shumate_simple_map_add_overlay_layer( self.to_glib_none().0, layer.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_simple_map_get_compass")] #[doc(alias = "get_compass")] pub fn compass(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_compass(self.to_glib_none().0)) } } #[doc(alias = "shumate_simple_map_get_license")] #[doc(alias = "get_license")] pub fn license(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_license(self.to_glib_none().0)) } } #[doc(alias = "shumate_simple_map_get_map")] #[doc(alias = "get_map")] pub fn map(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_map(self.to_glib_none().0)) } } #[doc(alias = "shumate_simple_map_get_map_source")] #[doc(alias = "get_map_source")] #[doc(alias = "map-source")] pub fn map_source(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_map_source( self.to_glib_none().0, )) } } #[doc(alias = "shumate_simple_map_get_scale")] #[doc(alias = "get_scale")] pub fn scale(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_scale(self.to_glib_none().0)) } } #[doc(alias = "shumate_simple_map_get_show_zoom_buttons")] #[doc(alias = "get_show_zoom_buttons")] #[doc(alias = "show-zoom-buttons")] pub fn shows_zoom_buttons(&self) -> bool { unsafe { from_glib(ffi::shumate_simple_map_get_show_zoom_buttons( self.to_glib_none().0, )) } } #[doc(alias = "shumate_simple_map_get_viewport")] #[doc(alias = "get_viewport")] pub fn viewport(&self) -> Option { unsafe { from_glib_none(ffi::shumate_simple_map_get_viewport(self.to_glib_none().0)) } } #[doc(alias = "shumate_simple_map_insert_overlay_layer")] pub fn insert_overlay_layer(&self, layer: &impl IsA, idx: u32) { unsafe { ffi::shumate_simple_map_insert_overlay_layer( self.to_glib_none().0, layer.as_ref().to_glib_none().0, idx, ); } } #[doc(alias = "shumate_simple_map_remove_overlay_layer")] pub fn remove_overlay_layer(&self, layer: &impl IsA) { unsafe { ffi::shumate_simple_map_remove_overlay_layer( self.to_glib_none().0, layer.as_ref().to_glib_none().0, ); } } #[doc(alias = "shumate_simple_map_set_map_source")] #[doc(alias = "map-source")] pub fn set_map_source(&self, map_source: Option<&impl IsA>) { unsafe { ffi::shumate_simple_map_set_map_source( self.to_glib_none().0, map_source.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "shumate_simple_map_set_show_zoom_buttons")] #[doc(alias = "show-zoom-buttons")] pub fn set_show_zoom_buttons(&self, show_zoom_buttons: bool) { unsafe { ffi::shumate_simple_map_set_show_zoom_buttons( self.to_glib_none().0, show_zoom_buttons.into_glib(), ); } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "symbol-clicked")] pub fn connect_symbol_clicked( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn symbol_clicked_trampoline< F: Fn(&SimpleMap, &SymbolEvent) + 'static, >( this: *mut ffi::ShumateSimpleMap, event: *mut ffi::ShumateSymbolEvent, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), &from_glib_borrow(event)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"symbol-clicked\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( symbol_clicked_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "compass")] pub fn connect_compass_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_compass_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::compass\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_compass_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "license")] pub fn connect_license_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_license_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::license\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_license_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "map")] pub fn connect_map_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_map_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::map\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_map_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "map-source")] pub fn connect_map_source_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_map_source_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::map-source\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_map_source_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "scale")] pub fn connect_scale_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_scale_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::scale\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_scale_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "show-zoom-buttons")] pub fn connect_show_zoom_buttons_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_show_zoom_buttons_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::show-zoom-buttons\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_show_zoom_buttons_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "viewport")] pub fn connect_viewport_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_viewport_trampoline( this: *mut ffi::ShumateSimpleMap, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::viewport\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_viewport_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for SimpleMap { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`SimpleMap`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct SimpleMapBuilder { builder: glib::object::ObjectBuilder<'static, SimpleMap>, } impl SimpleMapBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn map_source(self, map_source: &impl IsA) -> Self { Self { builder: self .builder .property("map-source", map_source.clone().upcast()), } } pub fn show_zoom_buttons(self, show_zoom_buttons: bool) -> Self { Self { builder: self .builder .property("show-zoom-buttons", show_zoom_buttons), } } pub fn can_focus(self, can_focus: bool) -> Self { Self { builder: self.builder.property("can-focus", can_focus), } } pub fn can_target(self, can_target: bool) -> Self { Self { builder: self.builder.property("can-target", can_target), } } pub fn css_classes(self, css_classes: impl Into) -> Self { Self { builder: self.builder.property("css-classes", css_classes.into()), } } pub fn css_name(self, css_name: impl Into) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } pub fn cursor(self, cursor: &gdk::Cursor) -> Self { Self { builder: self.builder.property("cursor", cursor.clone()), } } pub fn focus_on_click(self, focus_on_click: bool) -> Self { Self { builder: self.builder.property("focus-on-click", focus_on_click), } } pub fn focusable(self, focusable: bool) -> Self { Self { builder: self.builder.property("focusable", focusable), } } pub fn halign(self, halign: gtk::Align) -> Self { Self { builder: self.builder.property("halign", halign), } } pub fn has_tooltip(self, has_tooltip: bool) -> Self { Self { builder: self.builder.property("has-tooltip", has_tooltip), } } pub fn height_request(self, height_request: i32) -> Self { Self { builder: self.builder.property("height-request", height_request), } } pub fn hexpand(self, hexpand: bool) -> Self { Self { builder: self.builder.property("hexpand", hexpand), } } pub fn hexpand_set(self, hexpand_set: bool) -> Self { Self { builder: self.builder.property("hexpand-set", hexpand_set), } } pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { Self { builder: self .builder .property("layout-manager", layout_manager.clone().upcast()), } } pub fn margin_bottom(self, margin_bottom: i32) -> Self { Self { builder: self.builder.property("margin-bottom", margin_bottom), } } pub fn margin_end(self, margin_end: i32) -> Self { Self { builder: self.builder.property("margin-end", margin_end), } } pub fn margin_start(self, margin_start: i32) -> Self { Self { builder: self.builder.property("margin-start", margin_start), } } pub fn margin_top(self, margin_top: i32) -> Self { Self { builder: self.builder.property("margin-top", margin_top), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn opacity(self, opacity: f64) -> Self { Self { builder: self.builder.property("opacity", opacity), } } pub fn overflow(self, overflow: gtk::Overflow) -> Self { Self { builder: self.builder.property("overflow", overflow), } } pub fn receives_default(self, receives_default: bool) -> Self { Self { builder: self.builder.property("receives-default", receives_default), } } pub fn sensitive(self, sensitive: bool) -> Self { Self { builder: self.builder.property("sensitive", sensitive), } } pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { Self { builder: self .builder .property("tooltip-markup", tooltip_markup.into()), } } pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } } pub fn valign(self, valign: gtk::Align) -> Self { Self { builder: self.builder.property("valign", valign), } } pub fn vexpand(self, vexpand: bool) -> Self { Self { builder: self.builder.property("vexpand", vexpand), } } pub fn vexpand_set(self, vexpand_set: bool) -> Self { Self { builder: self.builder.property("vexpand-set", vexpand_set), } } pub fn visible(self, visible: bool) -> Self { Self { builder: self.builder.property("visible", visible), } } pub fn width_request(self, width_request: i32) -> Self { Self { builder: self.builder.property("width-request", width_request), } } pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self { Self { builder: self.builder.property("accessible-role", accessible_role), } } // rustdoc-stripper-ignore-next /// Build the [`SimpleMap`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> SimpleMap { self.builder.build() } } libshumate-0.6.0/src/auto/symbol_event.rs000064400000000000000000000142001046102023000165740ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Location}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateSymbolEvent")] pub struct SymbolEvent(Object) @implements Location; match fn { type_ => || ffi::shumate_symbol_event_get_type(), } } impl SymbolEvent { // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`SymbolEvent`] objects. /// /// This method returns an instance of [`SymbolEventBuilder`](crate::builders::SymbolEventBuilder) which can be used to create [`SymbolEvent`] objects. pub fn builder() -> SymbolEventBuilder { SymbolEventBuilder::new() } #[doc(alias = "shumate_symbol_event_get_feature_id")] #[doc(alias = "get_feature_id")] #[doc(alias = "feature-id")] pub fn feature_id(&self) -> Option { unsafe { from_glib_none(ffi::shumate_symbol_event_get_feature_id( self.to_glib_none().0, )) } } #[doc(alias = "shumate_symbol_event_get_layer")] #[doc(alias = "get_layer")] pub fn layer(&self) -> Option { unsafe { from_glib_none(ffi::shumate_symbol_event_get_layer(self.to_glib_none().0)) } } #[doc(alias = "shumate_symbol_event_get_source_layer")] #[doc(alias = "get_source_layer")] #[doc(alias = "source-layer")] pub fn source_layer(&self) -> Option { unsafe { from_glib_none(ffi::shumate_symbol_event_get_source_layer( self.to_glib_none().0, )) } } #[doc(alias = "shumate_symbol_event_get_tag")] #[doc(alias = "get_tag")] pub fn tag(&self, tag_name: &str) -> Option { unsafe { from_glib_none(ffi::shumate_symbol_event_get_tag( self.to_glib_none().0, tag_name.to_glib_none().0, )) } } #[cfg(not(feature = "v1_1"))] #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_1"))))] #[doc(alias = "source-layer")] pub fn source_layer(&self) -> Option { ObjectExt::property(self, "source-layer") } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "feature-id")] pub fn connect_feature_id_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_feature_id_trampoline( this: *mut ffi::ShumateSymbolEvent, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::feature-id\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_feature_id_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "layer")] pub fn connect_layer_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_layer_trampoline( this: *mut ffi::ShumateSymbolEvent, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::layer\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_layer_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "source-layer")] pub fn connect_source_layer_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_source_layer_trampoline( this: *mut ffi::ShumateSymbolEvent, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::source-layer\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_source_layer_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`SymbolEvent`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct SymbolEventBuilder { builder: glib::object::ObjectBuilder<'static, SymbolEvent>, } impl SymbolEventBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn latitude(self, latitude: f64) -> Self { Self { builder: self.builder.property("latitude", latitude), } } pub fn longitude(self, longitude: f64) -> Self { Self { builder: self.builder.property("longitude", longitude), } } // rustdoc-stripper-ignore-next /// Build the [`SymbolEvent`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> SymbolEvent { self.builder.build() } } libshumate-0.6.0/src/auto/tile.rs000064400000000000000000000331531046102023000150330ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, State}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateTile")] pub struct Tile(Object); match fn { type_ => || ffi::shumate_tile_get_type(), } } impl Tile { #[doc(alias = "shumate_tile_new")] pub fn new() -> Tile { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_tile_new()) } } #[doc(alias = "shumate_tile_new_full")] pub fn new_full(x: u32, y: u32, size: u32, zoom_level: u32) -> Tile { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_tile_new_full(x, y, size, zoom_level)) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Tile`] objects. /// /// This method returns an instance of [`TileBuilder`](crate::builders::TileBuilder) which can be used to create [`Tile`] objects. pub fn builder() -> TileBuilder { TileBuilder::new() } #[doc(alias = "shumate_tile_get_fade_in")] #[doc(alias = "get_fade_in")] #[doc(alias = "fade-in")] pub fn is_fade_in(&self) -> bool { unsafe { from_glib(ffi::shumate_tile_get_fade_in(self.to_glib_none().0)) } } #[doc(alias = "shumate_tile_get_paintable")] #[doc(alias = "get_paintable")] pub fn paintable(&self) -> Option { unsafe { from_glib_none(ffi::shumate_tile_get_paintable(self.to_glib_none().0)) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_tile_get_scale_factor")] #[doc(alias = "get_scale_factor")] #[doc(alias = "scale-factor")] pub fn scale_factor(&self) -> f64 { unsafe { ffi::shumate_tile_get_scale_factor(self.to_glib_none().0) } } #[doc(alias = "shumate_tile_get_size")] #[doc(alias = "get_size")] pub fn size(&self) -> u32 { unsafe { ffi::shumate_tile_get_size(self.to_glib_none().0) } } #[doc(alias = "shumate_tile_get_state")] #[doc(alias = "get_state")] pub fn state(&self) -> State { unsafe { from_glib(ffi::shumate_tile_get_state(self.to_glib_none().0)) } } #[doc(alias = "shumate_tile_get_x")] #[doc(alias = "get_x")] pub fn x(&self) -> u32 { unsafe { ffi::shumate_tile_get_x(self.to_glib_none().0) } } #[doc(alias = "shumate_tile_get_y")] #[doc(alias = "get_y")] pub fn y(&self) -> u32 { unsafe { ffi::shumate_tile_get_y(self.to_glib_none().0) } } #[doc(alias = "shumate_tile_get_zoom_level")] #[doc(alias = "get_zoom_level")] #[doc(alias = "zoom-level")] pub fn zoom_level(&self) -> u32 { unsafe { ffi::shumate_tile_get_zoom_level(self.to_glib_none().0) } } #[doc(alias = "shumate_tile_set_fade_in")] #[doc(alias = "fade-in")] pub fn set_fade_in(&self, fade_in: bool) { unsafe { ffi::shumate_tile_set_fade_in(self.to_glib_none().0, fade_in.into_glib()); } } #[doc(alias = "shumate_tile_set_paintable")] #[doc(alias = "paintable")] pub fn set_paintable(&self, paintable: &impl IsA) { unsafe { ffi::shumate_tile_set_paintable( self.to_glib_none().0, paintable.as_ref().to_glib_none().0, ); } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_tile_set_scale_factor")] #[doc(alias = "scale-factor")] pub fn set_scale_factor(&self, scale_factor: f64) { unsafe { ffi::shumate_tile_set_scale_factor(self.to_glib_none().0, scale_factor); } } #[doc(alias = "shumate_tile_set_size")] #[doc(alias = "size")] pub fn set_size(&self, size: u32) { unsafe { ffi::shumate_tile_set_size(self.to_glib_none().0, size); } } #[doc(alias = "shumate_tile_set_state")] #[doc(alias = "state")] pub fn set_state(&self, state: State) { unsafe { ffi::shumate_tile_set_state(self.to_glib_none().0, state.into_glib()); } } #[doc(alias = "shumate_tile_set_x")] #[doc(alias = "x")] pub fn set_x(&self, x: u32) { unsafe { ffi::shumate_tile_set_x(self.to_glib_none().0, x); } } #[doc(alias = "shumate_tile_set_y")] #[doc(alias = "y")] pub fn set_y(&self, y: u32) { unsafe { ffi::shumate_tile_set_y(self.to_glib_none().0, y); } } #[doc(alias = "shumate_tile_set_zoom_level")] #[doc(alias = "zoom-level")] pub fn set_zoom_level(&self, zoom_level: u32) { unsafe { ffi::shumate_tile_set_zoom_level(self.to_glib_none().0, zoom_level); } } #[doc(alias = "fade-in")] pub fn connect_fade_in_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_fade_in_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::fade-in\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_fade_in_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "paintable")] pub fn connect_paintable_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_paintable_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::paintable\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_paintable_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "scale-factor")] pub fn connect_scale_factor_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_scale_factor_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::scale-factor\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_scale_factor_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "size")] pub fn connect_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_size_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::size\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state")] pub fn connect_state_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "x")] pub fn connect_x_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_x_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::x\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_x_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "y")] pub fn connect_y_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_y_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::y\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_y_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "zoom-level")] pub fn connect_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_zoom_level_trampoline( this: *mut ffi::ShumateTile, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for Tile { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Tile`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct TileBuilder { builder: glib::object::ObjectBuilder<'static, Tile>, } impl TileBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn fade_in(self, fade_in: bool) -> Self { Self { builder: self.builder.property("fade-in", fade_in), } } pub fn paintable(self, paintable: &impl IsA) -> Self { Self { builder: self .builder .property("paintable", paintable.clone().upcast()), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn scale_factor(self, scale_factor: f64) -> Self { Self { builder: self.builder.property("scale-factor", scale_factor), } } pub fn size(self, size: u32) -> Self { Self { builder: self.builder.property("size", size), } } pub fn state(self, state: State) -> Self { Self { builder: self.builder.property("state", state), } } pub fn x(self, x: u32) -> Self { Self { builder: self.builder.property("x", x), } } pub fn y(self, y: u32) -> Self { Self { builder: self.builder.property("y", y), } } pub fn zoom_level(self, zoom_level: u32) -> Self { Self { builder: self.builder.property("zoom-level", zoom_level), } } // rustdoc-stripper-ignore-next /// Build the [`Tile`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Tile { self.builder.build() } } libshumate-0.6.0/src/auto/tile_downloader.rs000064400000000000000000000017041046102023000172460ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, DataSource}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "ShumateTileDownloader")] pub struct TileDownloader(Object) @extends DataSource; match fn { type_ => || ffi::shumate_tile_downloader_get_type(), } } impl TileDownloader { #[doc(alias = "shumate_tile_downloader_new")] pub fn new(url_template: &str) -> TileDownloader { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_tile_downloader_new( url_template.to_glib_none().0, )) } } #[doc(alias = "url-template")] pub fn url_template(&self) -> Option { ObjectExt::property(self, "url-template") } } libshumate-0.6.0/src/auto/vector_reader.rs000064400000000000000000000016271046102023000167230ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, VectorReaderIter}; use glib::translate::*; glib::wrapper! { #[doc(alias = "ShumateVectorReader")] pub struct VectorReader(Object); match fn { type_ => || ffi::shumate_vector_reader_get_type(), } } impl VectorReader { #[doc(alias = "shumate_vector_reader_new")] pub fn new(bytes: &glib::Bytes) -> VectorReader { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_vector_reader_new(bytes.to_glib_none().0)) } } #[doc(alias = "shumate_vector_reader_iterate")] pub fn iterate(&self) -> Option { unsafe { from_glib_full(ffi::shumate_vector_reader_iterate(self.to_glib_none().0)) } } } libshumate-0.6.0/src/auto/vector_reader_iter.rs000064400000000000000000000124661046102023000177510ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, GeometryType, VectorReader}; use glib::translate::*; glib::wrapper! { #[doc(alias = "ShumateVectorReaderIter")] pub struct VectorReaderIter(Object); match fn { type_ => || ffi::shumate_vector_reader_iter_get_type(), } } impl VectorReaderIter { #[doc(alias = "shumate_vector_reader_iter_feature_contains_point")] pub fn feature_contains_point(&self, x: f64, y: f64) -> bool { unsafe { from_glib(ffi::shumate_vector_reader_iter_feature_contains_point( self.to_glib_none().0, x, y, )) } } #[doc(alias = "shumate_vector_reader_iter_get_feature_geometry_type")] #[doc(alias = "get_feature_geometry_type")] pub fn feature_geometry_type(&self) -> GeometryType { unsafe { from_glib(ffi::shumate_vector_reader_iter_get_feature_geometry_type( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_reader_iter_get_feature_id")] #[doc(alias = "get_feature_id")] pub fn feature_id(&self) -> u64 { unsafe { ffi::shumate_vector_reader_iter_get_feature_id(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_reader_iter_get_feature_keys")] #[doc(alias = "get_feature_keys")] pub fn feature_keys(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container( ffi::shumate_vector_reader_iter_get_feature_keys(self.to_glib_none().0), ) } } #[doc(alias = "shumate_vector_reader_iter_get_feature_point")] #[doc(alias = "get_feature_point")] pub fn feature_point(&self) -> Option<(f64, f64)> { unsafe { let mut x = std::mem::MaybeUninit::uninit(); let mut y = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::shumate_vector_reader_iter_get_feature_point( self.to_glib_none().0, x.as_mut_ptr(), y.as_mut_ptr(), )); if ret { Some((x.assume_init(), y.assume_init())) } else { None } } } #[doc(alias = "shumate_vector_reader_iter_get_feature_tag")] #[doc(alias = "get_feature_tag")] pub fn feature_tag(&self, key: &str) -> Option { unsafe { let mut value = glib::Value::uninitialized(); let ret = from_glib(ffi::shumate_vector_reader_iter_get_feature_tag( self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none_mut().0, )); if ret { Some(value) } else { None } } } #[doc(alias = "shumate_vector_reader_iter_get_layer_count")] #[doc(alias = "get_layer_count")] pub fn layer_count(&self) -> u32 { unsafe { ffi::shumate_vector_reader_iter_get_layer_count(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_reader_iter_get_layer_extent")] #[doc(alias = "get_layer_extent")] pub fn layer_extent(&self) -> u32 { unsafe { ffi::shumate_vector_reader_iter_get_layer_extent(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_reader_iter_get_layer_feature_count")] #[doc(alias = "get_layer_feature_count")] pub fn layer_feature_count(&self) -> u32 { unsafe { ffi::shumate_vector_reader_iter_get_layer_feature_count(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_reader_iter_get_layer_name")] #[doc(alias = "get_layer_name")] pub fn layer_name(&self) -> Option { unsafe { from_glib_none(ffi::shumate_vector_reader_iter_get_layer_name( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_reader_iter_get_reader")] #[doc(alias = "get_reader")] pub fn reader(&self) -> Option { unsafe { from_glib_none(ffi::shumate_vector_reader_iter_get_reader( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_reader_iter_next_feature")] pub fn next_feature(&self) -> bool { unsafe { from_glib(ffi::shumate_vector_reader_iter_next_feature( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_reader_iter_read_feature")] pub fn read_feature(&self, index: i32) { unsafe { ffi::shumate_vector_reader_iter_read_feature(self.to_glib_none().0, index); } } #[doc(alias = "shumate_vector_reader_iter_read_layer")] pub fn read_layer(&self, index: i32) { unsafe { ffi::shumate_vector_reader_iter_read_layer(self.to_glib_none().0, index); } } #[doc(alias = "shumate_vector_reader_iter_read_layer_by_name")] pub fn read_layer_by_name(&self, name: &str) -> bool { unsafe { from_glib(ffi::shumate_vector_reader_iter_read_layer_by_name( self.to_glib_none().0, name.to_glib_none().0, )) } } } libshumate-0.6.0/src/auto/vector_renderer.rs000064400000000000000000000177751046102023000173020ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT #![allow(deprecated)] #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] use crate::DataSource; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use crate::VectorSpriteSheet; use crate::{ffi, MapProjection, MapSource}; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use glib::signal::{connect_raw, SignalHandlerId}; use glib::{prelude::*, translate::*}; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateVectorRenderer")] pub struct VectorRenderer(Object) @extends MapSource, @implements gio::Initable; match fn { type_ => || ffi::shumate_vector_renderer_get_type(), } } impl VectorRenderer { #[doc(alias = "shumate_vector_renderer_new")] pub fn new(id: &str, style_json: &str) -> Result { assert_initialized_main_thread!(); unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::shumate_vector_renderer_new( id.to_glib_none().0, style_json.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`VectorRenderer`] objects. /// /// This method returns an instance of [`VectorRendererBuilder`](crate::builders::VectorRendererBuilder) which can be used to create [`VectorRenderer`] objects. pub fn builder() -> VectorRendererBuilder { VectorRendererBuilder::new() } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_vector_renderer_get_sprite_sheet")] #[doc(alias = "get_sprite_sheet")] #[doc(alias = "sprite-sheet")] pub fn sprite_sheet(&self) -> Option { unsafe { from_glib_none(ffi::shumate_vector_renderer_get_sprite_sheet( self.to_glib_none().0, )) } } #[cfg(feature = "v1_2")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))] #[doc(alias = "shumate_vector_renderer_set_data_source")] pub fn set_data_source(&self, name: &str, data_source: &impl IsA) { unsafe { ffi::shumate_vector_renderer_set_data_source( self.to_glib_none().0, name.to_glib_none().0, data_source.as_ref().to_glib_none().0, ); } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "shumate_vector_renderer_set_sprite_sheet")] #[doc(alias = "sprite-sheet")] pub fn set_sprite_sheet(&self, sprites: &VectorSpriteSheet) { unsafe { ffi::shumate_vector_renderer_set_sprite_sheet( self.to_glib_none().0, sprites.to_glib_none().0, ); } } #[cfg_attr(feature = "v1_1", deprecated = "Since 1.1")] #[allow(deprecated)] #[doc(alias = "shumate_vector_renderer_set_sprite_sheet_data")] pub fn set_sprite_sheet_data( &self, sprites_pixbuf: &gdk_pixbuf::Pixbuf, sprites_json: &str, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::shumate_vector_renderer_set_sprite_sheet_data( self.to_glib_none().0, sprites_pixbuf.to_glib_none().0, sprites_json.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "style-json")] pub fn style_json(&self) -> Option { ObjectExt::property(self, "style-json") } #[doc(alias = "shumate_vector_renderer_is_supported")] pub fn is_supported() -> bool { assert_initialized_main_thread!(); unsafe { from_glib(ffi::shumate_vector_renderer_is_supported()) } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] #[doc(alias = "sprite-sheet")] pub fn connect_sprite_sheet_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_sprite_sheet_trampoline( this: *mut ffi::ShumateVectorRenderer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::sprite-sheet\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_sprite_sheet_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for VectorRenderer { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`VectorRenderer`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct VectorRendererBuilder { builder: glib::object::ObjectBuilder<'static, VectorRenderer>, } impl VectorRendererBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn sprite_sheet(self, sprite_sheet: &VectorSpriteSheet) -> Self { Self { builder: self.builder.property("sprite-sheet", sprite_sheet.clone()), } } pub fn style_json(self, style_json: impl Into) -> Self { Self { builder: self.builder.property("style-json", style_json.into()), } } pub fn id(self, id: impl Into) -> Self { Self { builder: self.builder.property("id", id.into()), } } pub fn license(self, license: impl Into) -> Self { Self { builder: self.builder.property("license", license.into()), } } pub fn license_uri(self, license_uri: impl Into) -> Self { Self { builder: self.builder.property("license-uri", license_uri.into()), } } pub fn max_zoom_level(self, max_zoom_level: u32) -> Self { Self { builder: self.builder.property("max-zoom-level", max_zoom_level), } } pub fn min_zoom_level(self, min_zoom_level: u32) -> Self { Self { builder: self.builder.property("min-zoom-level", min_zoom_level), } } pub fn name(self, name: impl Into) -> Self { Self { builder: self.builder.property("name", name.into()), } } pub fn projection(self, projection: MapProjection) -> Self { Self { builder: self.builder.property("projection", projection), } } pub fn tile_size(self, tile_size: u32) -> Self { Self { builder: self.builder.property("tile-size", tile_size), } } // rustdoc-stripper-ignore-next /// Build the [`VectorRenderer`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> VectorRenderer { self.builder.build() } } libshumate-0.6.0/src/auto/vector_sprite.rs000064400000000000000000000133331046102023000167640ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::ffi; use glib::{prelude::*, translate::*}; #[cfg(feature = "gtk_v4_6")] #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_6")))] glib::wrapper! { #[doc(alias = "ShumateVectorSprite")] pub struct VectorSprite(Object) @implements gdk::Paintable, gtk::SymbolicPaintable; match fn { type_ => || ffi::shumate_vector_sprite_get_type(), } } #[cfg(not(any(feature = "gtk_v4_6")))] glib::wrapper! { #[doc(alias = "ShumateVectorSprite")] pub struct VectorSprite(Object) @implements gdk::Paintable; match fn { type_ => || ffi::shumate_vector_sprite_get_type(), } } impl VectorSprite { #[doc(alias = "shumate_vector_sprite_new")] pub fn new(source_paintable: &impl IsA) -> VectorSprite { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_vector_sprite_new( source_paintable.as_ref().to_glib_none().0, )) } } #[doc(alias = "shumate_vector_sprite_new_full")] pub fn new_full( source_paintable: &impl IsA, width: i32, height: i32, scale_factor: f64, source_rect: Option<&gdk::Rectangle>, ) -> VectorSprite { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_vector_sprite_new_full( source_paintable.as_ref().to_glib_none().0, width, height, scale_factor, mut_override(source_rect.to_glib_none().0), )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`VectorSprite`] objects. /// /// This method returns an instance of [`VectorSpriteBuilder`](crate::builders::VectorSpriteBuilder) which can be used to create [`VectorSprite`] objects. pub fn builder() -> VectorSpriteBuilder { VectorSpriteBuilder::new() } #[doc(alias = "shumate_vector_sprite_get_height")] #[doc(alias = "get_height")] pub fn height(&self) -> i32 { unsafe { ffi::shumate_vector_sprite_get_height(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_sprite_get_scale_factor")] #[doc(alias = "get_scale_factor")] #[doc(alias = "scale-factor")] pub fn scale_factor(&self) -> f64 { unsafe { ffi::shumate_vector_sprite_get_scale_factor(self.to_glib_none().0) } } #[doc(alias = "shumate_vector_sprite_get_source_paintable")] #[doc(alias = "get_source_paintable")] #[doc(alias = "source-paintable")] pub fn source_paintable(&self) -> Option { unsafe { from_glib_none(ffi::shumate_vector_sprite_get_source_paintable( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_sprite_get_source_rect")] #[doc(alias = "get_source_rect")] #[doc(alias = "source-rect")] pub fn source_rect(&self) -> Option { unsafe { from_glib_none(ffi::shumate_vector_sprite_get_source_rect( self.to_glib_none().0, )) } } #[doc(alias = "shumate_vector_sprite_get_width")] #[doc(alias = "get_width")] pub fn width(&self) -> i32 { unsafe { ffi::shumate_vector_sprite_get_width(self.to_glib_none().0) } } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] impl Default for VectorSprite { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`VectorSprite`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct VectorSpriteBuilder { builder: glib::object::ObjectBuilder<'static, VectorSprite>, } impl VectorSpriteBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn height(self, height: i32) -> Self { Self { builder: self.builder.property("height", height), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn scale_factor(self, scale_factor: f64) -> Self { Self { builder: self.builder.property("scale-factor", scale_factor), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn source_paintable(self, source_paintable: &impl IsA) -> Self { Self { builder: self .builder .property("source-paintable", source_paintable.clone().upcast()), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn source_rect(self, source_rect: &gdk::Rectangle) -> Self { Self { builder: self.builder.property("source-rect", source_rect), } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] pub fn width(self, width: i32) -> Self { Self { builder: self.builder.property("width", width), } } // rustdoc-stripper-ignore-next /// Build the [`VectorSprite`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> VectorSprite { self.builder.build() } } libshumate-0.6.0/src/auto/vector_sprite_sheet.rs000064400000000000000000000107541046102023000201600ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, VectorSprite}; use glib::{prelude::*, translate::*}; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateVectorSpriteSheet")] pub struct VectorSpriteSheet(Object); match fn { type_ => || ffi::shumate_vector_sprite_sheet_get_type(), } } impl VectorSpriteSheet { #[doc(alias = "shumate_vector_sprite_sheet_new")] pub fn new() -> VectorSpriteSheet { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_vector_sprite_sheet_new()) } } #[doc(alias = "shumate_vector_sprite_sheet_add_page")] pub fn add_page( &self, texture: &impl IsA, json: &str, default_scale: f64, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::shumate_vector_sprite_sheet_add_page( self.to_glib_none().0, texture.as_ref().to_glib_none().0, json.to_glib_none().0, default_scale, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "shumate_vector_sprite_sheet_add_sprite")] pub fn add_sprite(&self, name: &str, sprite: &VectorSprite) { unsafe { ffi::shumate_vector_sprite_sheet_add_sprite( self.to_glib_none().0, name.to_glib_none().0, sprite.to_glib_none().0, ); } } #[doc(alias = "shumate_vector_sprite_sheet_get_sprite")] #[doc(alias = "get_sprite")] pub fn sprite(&self, name: &str, scale: f64) -> Option { unsafe { from_glib_full(ffi::shumate_vector_sprite_sheet_get_sprite( self.to_glib_none().0, name.to_glib_none().0, scale, )) } } #[doc(alias = "shumate_vector_sprite_sheet_set_fallback")] pub fn set_fallback( &self, fallback: Option< Box_ Option + 'static>, >, ) { let fallback_data: Box_< Option Option + 'static>>, > = Box_::new(fallback); unsafe extern "C" fn fallback_func( sprite_sheet: *mut ffi::ShumateVectorSpriteSheet, name: *const libc::c_char, scale: libc::c_double, user_data: glib::ffi::gpointer, ) -> *mut ffi::ShumateVectorSprite { let sprite_sheet = from_glib_borrow(sprite_sheet); let name: Borrowed = from_glib_borrow(name); let callback = &*(user_data as *mut Option< Box_ Option + 'static>, >); if let Some(ref callback) = *callback { callback(&sprite_sheet, name.as_str(), scale) } else { panic!("cannot get closure...") } .to_glib_full() } let fallback = if fallback_data.is_some() { Some(fallback_func as _) } else { None }; unsafe extern "C" fn notify_func(data: glib::ffi::gpointer) { let _callback = Box_::from_raw( data as *mut Option< Box_ Option + 'static>, >, ); } let destroy_call3 = Some(notify_func as _); let super_callback0: Box_< Option Option + 'static>>, > = fallback_data; unsafe { ffi::shumate_vector_sprite_sheet_set_fallback( self.to_glib_none().0, fallback, Box_::into_raw(super_callback0) as *mut _, destroy_call3, ); } } } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] impl Default for VectorSpriteSheet { fn default() -> Self { Self::new() } } libshumate-0.6.0/src/auto/versions.txt000064400000000000000000000002161046102023000161330ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ d7c0763cacbc) from from gir-files (https://github.com/gtk-rs/gir-files.git @ 4d1189172a70) libshumate-0.6.0/src/auto/viewport.rs000064400000000000000000000271241046102023000157560ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from // from gir-files (https://github.com/gtk-rs/gir-files.git) // DO NOT EDIT use crate::{ffi, Location, MapSource}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "ShumateViewport")] pub struct Viewport(Object) @implements Location; match fn { type_ => || ffi::shumate_viewport_get_type(), } } impl Viewport { #[doc(alias = "shumate_viewport_new")] pub fn new() -> Viewport { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::shumate_viewport_new()) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Viewport`] objects. /// /// This method returns an instance of [`ViewportBuilder`](crate::builders::ViewportBuilder) which can be used to create [`Viewport`] objects. pub fn builder() -> ViewportBuilder { ViewportBuilder::new() } #[doc(alias = "shumate_viewport_get_max_zoom_level")] #[doc(alias = "get_max_zoom_level")] #[doc(alias = "max-zoom-level")] pub fn max_zoom_level(&self) -> u32 { unsafe { ffi::shumate_viewport_get_max_zoom_level(self.to_glib_none().0) } } #[doc(alias = "shumate_viewport_get_min_zoom_level")] #[doc(alias = "get_min_zoom_level")] #[doc(alias = "min-zoom-level")] pub fn min_zoom_level(&self) -> u32 { unsafe { ffi::shumate_viewport_get_min_zoom_level(self.to_glib_none().0) } } #[doc(alias = "shumate_viewport_get_reference_map_source")] #[doc(alias = "get_reference_map_source")] #[doc(alias = "reference-map-source")] pub fn reference_map_source(&self) -> Option { unsafe { from_glib_none(ffi::shumate_viewport_get_reference_map_source( self.to_glib_none().0, )) } } #[doc(alias = "shumate_viewport_get_rotation")] #[doc(alias = "get_rotation")] pub fn rotation(&self) -> f64 { unsafe { ffi::shumate_viewport_get_rotation(self.to_glib_none().0) } } #[doc(alias = "shumate_viewport_get_zoom_level")] #[doc(alias = "get_zoom_level")] #[doc(alias = "zoom-level")] pub fn zoom_level(&self) -> f64 { unsafe { ffi::shumate_viewport_get_zoom_level(self.to_glib_none().0) } } #[doc(alias = "shumate_viewport_location_to_widget_coords")] pub fn location_to_widget_coords( &self, widget: &impl IsA, latitude: f64, longitude: f64, ) -> (f64, f64) { unsafe { let mut x = std::mem::MaybeUninit::uninit(); let mut y = std::mem::MaybeUninit::uninit(); ffi::shumate_viewport_location_to_widget_coords( self.to_glib_none().0, widget.as_ref().to_glib_none().0, latitude, longitude, x.as_mut_ptr(), y.as_mut_ptr(), ); (x.assume_init(), y.assume_init()) } } #[doc(alias = "shumate_viewport_set_max_zoom_level")] #[doc(alias = "max-zoom-level")] pub fn set_max_zoom_level(&self, max_zoom_level: u32) { unsafe { ffi::shumate_viewport_set_max_zoom_level(self.to_glib_none().0, max_zoom_level); } } #[doc(alias = "shumate_viewport_set_min_zoom_level")] #[doc(alias = "min-zoom-level")] pub fn set_min_zoom_level(&self, min_zoom_level: u32) { unsafe { ffi::shumate_viewport_set_min_zoom_level(self.to_glib_none().0, min_zoom_level); } } #[doc(alias = "shumate_viewport_set_reference_map_source")] #[doc(alias = "reference-map-source")] pub fn set_reference_map_source(&self, map_source: Option<&impl IsA>) { unsafe { ffi::shumate_viewport_set_reference_map_source( self.to_glib_none().0, map_source.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "shumate_viewport_set_rotation")] #[doc(alias = "rotation")] pub fn set_rotation(&self, rotation: f64) { unsafe { ffi::shumate_viewport_set_rotation(self.to_glib_none().0, rotation); } } #[doc(alias = "shumate_viewport_set_zoom_level")] #[doc(alias = "zoom-level")] pub fn set_zoom_level(&self, zoom_level: f64) { unsafe { ffi::shumate_viewport_set_zoom_level(self.to_glib_none().0, zoom_level); } } #[doc(alias = "shumate_viewport_widget_coords_to_location")] pub fn widget_coords_to_location( &self, widget: &impl IsA, x: f64, y: f64, ) -> (f64, f64) { unsafe { let mut latitude = std::mem::MaybeUninit::uninit(); let mut longitude = std::mem::MaybeUninit::uninit(); ffi::shumate_viewport_widget_coords_to_location( self.to_glib_none().0, widget.as_ref().to_glib_none().0, x, y, latitude.as_mut_ptr(), longitude.as_mut_ptr(), ); (latitude.assume_init(), longitude.assume_init()) } } #[doc(alias = "max-zoom-level")] pub fn connect_max_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_max_zoom_level_trampoline( this: *mut ffi::ShumateViewport, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::max-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "min-zoom-level")] pub fn connect_min_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_min_zoom_level_trampoline( this: *mut ffi::ShumateViewport, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::min-zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_min_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "reference-map-source")] pub fn connect_reference_map_source_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_reference_map_source_trampoline( this: *mut ffi::ShumateViewport, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::reference-map-source\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_reference_map_source_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "rotation")] pub fn connect_rotation_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_rotation_trampoline( this: *mut ffi::ShumateViewport, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::rotation\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_rotation_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "zoom-level")] pub fn connect_zoom_level_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_zoom_level_trampoline( this: *mut ffi::ShumateViewport, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::zoom-level\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_zoom_level_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for Viewport { fn default() -> Self { Self::new() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Viewport`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ViewportBuilder { builder: glib::object::ObjectBuilder<'static, Viewport>, } impl ViewportBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn max_zoom_level(self, max_zoom_level: u32) -> Self { Self { builder: self.builder.property("max-zoom-level", max_zoom_level), } } pub fn min_zoom_level(self, min_zoom_level: u32) -> Self { Self { builder: self.builder.property("min-zoom-level", min_zoom_level), } } pub fn reference_map_source(self, reference_map_source: &impl IsA) -> Self { Self { builder: self.builder.property( "reference-map-source", reference_map_source.clone().upcast(), ), } } pub fn rotation(self, rotation: f64) -> Self { Self { builder: self.builder.property("rotation", rotation), } } pub fn zoom_level(self, zoom_level: f64) -> Self { Self { builder: self.builder.property("zoom-level", zoom_level), } } pub fn latitude(self, latitude: f64) -> Self { Self { builder: self.builder.property("latitude", latitude), } } pub fn longitude(self, longitude: f64) -> Self { Self { builder: self.builder.property("longitude", longitude), } } // rustdoc-stripper-ignore-next /// Build the [`Viewport`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Viewport { self.builder.build() } } libshumate-0.6.0/src/lib.rs000064400000000000000000000050471046102023000136750ustar 00000000000000#![allow(clippy::needless_doctest_main)] //! # Rust Shumate bindings //! //! This library contains safe Rust bindings for [Shumate](https://gitlab.gnome.org/GNOME/libshumate), a library that offers //! a GTK4 widget to display maps. //! //! See also //! //! - [GTK 4 Rust bindings documentation](mod@gtk) //! - [libshumate documentation](https://gnome.pages.gitlab.gnome.org/libshumate/) //! - [gtk-rs project overview](https://gtk-rs.org/) //! //! # Example //! //! The [`libshumate`](mod@crate) crate is usually renamed to `shumate`. You can //! do this globally in your `Cargo.toml` file: //! //! ```toml //! [dependencies.shumate] //! package = "libshumate" //! version = "0.x.y" //! ``` //! //! ```no_run //! # use libshumate as shumate; //! use shumate::prelude::*; //! //! use shumate::{Map}; //! use gtk::{Application, Box, ListBox, Orientation, ApplicationWindow}; //! //! fn main() { //! let application = Application::builder() //! .application_id("com.example.FirstShumateApp") //! .build(); //! //! application.connect_activate(|app| { //! let content = Map::new(); //! //! let window = ApplicationWindow::builder() //! .application(app) //! .default_width(350) //! // add content to window //! .child(&content) //! .build(); //! window.show(); //! }); //! //! application.run(); //! } //! ``` // Re-export the -sys bindings pub use ffi; #[doc(hidden)] pub use gtk; #[doc(alias = "SHUMATE_MAX_LATITUDE")] pub const MAX_LATITUDE: f64 = ffi::SHUMATE_MAX_LATITUDE; #[doc(alias = "SHUMATE_MAX_LONGITUDE")] pub const MAX_LONGITUDE: f64 = ffi::SHUMATE_MAX_LONGITUDE; #[doc(alias = "SHUMATE_MIN_LATITUDE")] pub const MIN_LATITUDE: f64 = ffi::SHUMATE_MIN_LATITUDE; #[doc(alias = "SHUMATE_MIN_LONGITUDE")] pub const MIN_LONGITUDE: f64 = ffi::SHUMATE_MIN_LONGITUDE; /// Asserts that this is the main thread and `gtk::init` has been called. macro_rules! assert_initialized_main_thread { () => { if !::gtk::is_initialized_main_thread() { if ::gtk::is_initialized() { panic!("libshumate may only be used from the main thread."); } else { panic!("Gtk has to be initialized before using libshumate."); } } }; } macro_rules! skip_assert_initialized { () => {}; } #[allow(unused_imports)] #[allow(clippy::type_complexity)] #[allow(clippy::too_many_arguments)] mod auto; pub use auto::*; pub mod prelude; pub mod subclass; pub mod functions { pub use super::auto::functions::*; } libshumate-0.6.0/src/prelude.rs000064400000000000000000000001111046102023000145520ustar 00000000000000#[doc(hidden)] pub use gtk::prelude::*; pub use crate::auto::traits::*; libshumate-0.6.0/src/subclass/data_source.rs000064400000000000000000000164571046102023000172460ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`DataSource`](crate::DataSource). #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] use crate::DataSourceRequest; use crate::{prelude::*, DataSource}; use gio::Cancellable; use glib::subclass::prelude::*; use glib::translate::*; use std::{future::Future, pin::Pin}; pub trait DataSourceImpl: ObjectImpl { fn tile_data_future( &self, x: i32, y: i32, zoom_level: i32, ) -> Pin> + 'static>>; #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] fn start_request( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option, ) -> Option { self.parent_start_request(x, y, zoom_level, cancellable) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait DataSourceImplExt: sealed::Sealed + ObjectSubclass { #[allow(clippy::type_complexity)] fn parent_tile_data_async< Q: IsA, C: FnOnce(Result) + Send + 'static, >( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option<&Q>, callback: C, ) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::ShumateDataSourceClass; let f = (*parent_class) .get_tile_data_async .expect("no parent \"get_tile_data_async\" implementation"); let finish = (*parent_class) .get_tile_data_finish .expect("no parent \"get_tile_data_finish\" implementation"); let user_data: Box<(C, _)> = Box::new((callback, finish)); unsafe extern "C" fn parent_get_tile_data_async_trampoline< C: FnOnce(Result) + Send + 'static, >( source_object_ptr: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let cb: Box<( C, fn( *mut ffi::ShumateDataSource, *mut gio::ffi::GAsyncResult, *mut *mut glib::ffi::GError, ) -> *mut glib::ffi::GBytes, )> = Box::from_raw(user_data as *mut _); let bytes = cb.1(source_object_ptr as _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(bytes)) } else { Err(from_glib_full(error)) }; cb.0(result); } let cancellable = cancellable.map(|p| p.as_ref()); let callback = parent_get_tile_data_async_trampoline::; f( self.obj().unsafe_cast_ref::().to_glib_none().0, x, y, zoom_level, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn parent_tile_data_future( &self, x: i32, y: i32, zoom_level: i32, ) -> Pin> + 'static>> { Box::pin(gio::GioFuture::new( &self.ref_counted(), move |imp, cancellable, send| { imp.parent_tile_data_async(x, y, zoom_level, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[cfg(feature = "v1_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))] fn parent_start_request( &self, x: i32, y: i32, zoom_level: i32, cancellable: Option, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::ShumateDataSourceClass; if let Some(f) = (*parent_class).start_request { from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, x, y, zoom_level, cancellable.to_glib_none().0, )) } else { None } } } } impl DataSourceImplExt for T {} unsafe impl IsSubclassable for DataSource { fn class_init(class: &mut glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.get_tile_data_async = Some(data_source_get_tile_data_async::); klass.get_tile_data_finish = Some(data_source_get_tile_data_finish); #[cfg(feature = "v1_1")] { klass.start_request = Some(data_source_start_request::); } } } unsafe extern "C" fn data_source_get_tile_data_async( ptr: *mut ffi::ShumateDataSource, x: i32, y: i32, zoom_level: i32, cancellable_ptr: *mut gio::ffi::GCancellable, callback: gio::ffi::GAsyncReadyCallback, user_data: glib::ffi::gpointer, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let cancellable: Option = from_glib_none(cancellable_ptr); let closure = move |result: gio::LocalTask, source_object: Option<&DataSource>| { let result: *mut gio::ffi::GAsyncResult = result .unsafe_cast_ref::() .to_glib_none() .0; let source_object = source_object .map(|o| o.unsafe_cast_ref::()) .to_glib_none() .0; callback.unwrap()(source_object, result, user_data) }; let t = gio::LocalTask::new(None, cancellable.as_ref(), closure); glib::MainContext::default().spawn_local(async move { let res = imp.tile_data_future(x, y, zoom_level).await; t.return_result(res); }); } unsafe extern "C" fn data_source_get_tile_data_finish( _ptr: *mut ffi::ShumateDataSource, res_ptr: *mut gio::ffi::GAsyncResult, error_ptr: *mut *mut glib::ffi::GError, ) -> *mut glib::ffi::GBytes { let res: gio::AsyncResult = from_glib_none(res_ptr); let task = res.downcast::>().unwrap(); match task.propagate() { Ok(bytes) => bytes.to_glib_full(), Err(e) => { *error_ptr = e.into_glib_ptr(); std::ptr::null_mut() } } } #[cfg(feature = "v1_1")] unsafe extern "C" fn data_source_start_request( ptr: *mut ffi::ShumateDataSource, x: i32, y: i32, zoom_level: i32, cancellable_ptr: *mut gio::ffi::GCancellable, ) -> *mut ffi::ShumateDataSourceRequest { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.start_request(x, y, zoom_level, from_glib_none(cancellable_ptr)) .to_glib_full() } libshumate-0.6.0/src/subclass/location.rs000064400000000000000000000065151046102023000165570ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for implementing the [`Location`](crate::Location) interface. use crate::{prelude::*, Location}; use glib::subclass::prelude::*; use glib::translate::*; pub trait LocationImpl: ObjectImpl { fn latitude(&self) -> f64 { self.parent_latitude() } fn longitude(&self) -> f64 { self.parent_longitude() } fn set_location(&self, latitude: f64, longitude: f64) { self.parent_set_location(latitude, longitude) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait LocationImplExt: sealed::Sealed + ObjectSubclass { fn parent_latitude(&self) -> f64 { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::ShumateLocationInterface; let func = (*parent_iface) .get_latitude .expect("no parent \"get_latitude\" implementation"); func(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_longitude(&self) -> f64 { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::ShumateLocationInterface; let func = (*parent_iface) .get_longitude .expect("no parent \"get_longitude\" implementation"); func(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_set_location(&self, latitude: f64, longitude: f64) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::ShumateLocationInterface; let func = (*parent_iface) .set_location .expect("no parent \"set_location\" implementation"); func( self.obj().unsafe_cast_ref::().to_glib_none().0, latitude, longitude, ) } } } impl LocationImplExt for T {} unsafe impl IsImplementable for Location { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.get_latitude = Some(location_get_latitude::); iface.get_longitude = Some(location_get_longitude::); iface.set_location = Some(location_set_location::); } } unsafe extern "C" fn location_get_latitude( location: *mut ffi::ShumateLocation, ) -> f64 { let instance = &*(location as *mut T::Instance); let imp = instance.imp(); imp.latitude() } unsafe extern "C" fn location_get_longitude( location: *mut ffi::ShumateLocation, ) -> f64 { let instance = &*(location as *mut T::Instance); let imp = instance.imp(); imp.longitude() } unsafe extern "C" fn location_set_location( location: *mut ffi::ShumateLocation, latitude: f64, longitude: f64, ) { let instance = &*(location as *mut T::Instance); let imp = instance.imp(); imp.set_location(latitude, longitude) } libshumate-0.6.0/src/subclass/map_source.rs000064400000000000000000000113531046102023000171000ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`MapSource`](crate::MapSource). use crate::{prelude::*, MapSource, Tile}; use gio::{AsyncResult, Cancellable}; use glib::subclass::prelude::*; use glib::translate::*; use std::{future::Future, pin::Pin}; pub trait MapSourceImpl: ObjectImpl { fn fill_tile_future( &self, tile: &Tile, ) -> Pin> + 'static>>; } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait MapSourceImplExt: sealed::Sealed + ObjectSubclass { #[allow(clippy::type_complexity)] fn parent_fill_tile_async, C: FnOnce(&AsyncResult) + Send + 'static>( &self, tile: &Tile, cancellable: Option<&Q>, callback: C, ) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::ShumateMapSourceClass; let f = (*parent_class) .fill_tile_async .expect("no parent \"fill_tile_async\" implementation"); let user_data: Box = Box::new(callback); unsafe extern "C" fn parent_fill_tile_async_trampoline< C: FnOnce(&AsyncResult) + Send + 'static, >( _source_object_ptr: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let res = AsyncResult::from_glib_borrow(res); let cb: Box = Box::from_raw(user_data as *mut _); cb(&res) } let cancellable = cancellable.map(|p| p.as_ref()); let callback = parent_fill_tile_async_trampoline::; f( self.obj().unsafe_cast_ref::().to_glib_none().0, tile.to_glib_none().0, cancellable.to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn parent_fill_tile_future( &self, tile: &Tile, ) -> Pin> + 'static>> { let tile = tile.clone(); Box::pin(gio::GioFuture::new( &self.ref_counted(), move |imp, cancellable, send| { imp.parent_fill_tile_async(&tile, Some(cancellable), move |res| { send.resolve(res.legacy_propagate_error()); }); }, )) } } impl MapSourceImplExt for T {} unsafe impl IsSubclassable for MapSource { fn class_init(class: &mut glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.fill_tile_async = Some(map_source_fill_tile_async::); klass.fill_tile_finish = Some(map_source_fill_tile_finish); } } unsafe extern "C" fn map_source_fill_tile_async( ptr: *mut ffi::ShumateMapSource, tile: *mut ffi::ShumateTile, cancellable_ptr: *mut gio::ffi::GCancellable, callback: gio::ffi::GAsyncReadyCallback, user_data: glib::ffi::gpointer, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let cancellable: Option = from_glib_none(cancellable_ptr); let closure = move |result: gio::LocalTask, source_object: Option<&MapSource>| { let result: *mut gio::ffi::GAsyncResult = result .unsafe_cast_ref::() .to_glib_none() .0; let source_object = source_object .map(|o| o.unsafe_cast_ref::()) .to_glib_none() .0; callback.unwrap()(source_object, result, user_data) }; let t = gio::LocalTask::new(None, cancellable.as_ref(), closure); glib::MainContext::default().spawn_local(async move { let res = imp.fill_tile_future(&from_glib_none(tile)).await; match res { Ok(_) => t.return_result(Ok(true)), Err(e) => t.return_result(Err(e)), } }); } unsafe extern "C" fn map_source_fill_tile_finish( _ptr: *mut ffi::ShumateMapSource, res_ptr: *mut gio::ffi::GAsyncResult, error_ptr: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let res: gio::AsyncResult = from_glib_none(res_ptr); let task = res.downcast::>().unwrap(); match task.propagate() { Ok(v) => { assert!(v); true.into_glib() } Err(e) => { *error_ptr = e.into_glib_ptr(); false.into_glib() } } } libshumate-0.6.0/src/subclass/marker.rs000064400000000000000000000005551046102023000162260ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`Marker`](crate::Marker). use crate::Marker; use glib::subclass::prelude::*; use gtk::subclass::prelude::WidgetImpl; pub trait MarkerImpl: WidgetImpl {} unsafe impl IsSubclassable for Marker {} libshumate-0.6.0/src/subclass/mod.rs000064400000000000000000000011611046102023000155160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits intended for creating custom types. pub mod data_source; pub mod location; pub mod map_source; pub mod marker; // rustdoc-stripper-ignore-next /// Traits intended for blanket imports. pub mod prelude { #[doc(hidden)] pub use gtk::subclass::prelude::*; pub use super::data_source::{DataSourceImpl, DataSourceImplExt}; pub use super::location::{LocationImpl, LocationImplExt}; pub use super::map_source::{MapSourceImpl, MapSourceImplExt}; pub use super::marker::MarkerImpl; }