libshumate/
lib.rs

1#![allow(clippy::needless_doctest_main)]
2//! # Rust Shumate bindings
3//!
4//! This library contains safe Rust bindings for [Shumate](https://gitlab.gnome.org/GNOME/libshumate), a library that offers
5//! a GTK4 widget to display maps.
6//!
7//! See also
8//!
9//! - [GTK 4 Rust bindings documentation](mod@gtk)
10//! - [libshumate documentation](https://gnome.pages.gitlab.gnome.org/libshumate/)
11//! - [gtk-rs project overview](https://gtk-rs.org/)
12//!
13//! # Example
14//!
15//! The [`libshumate`](mod@crate) crate is usually renamed to `shumate`. You can
16//! do this globally in your `Cargo.toml` file:
17//!
18//! ```toml
19//! [dependencies.shumate]
20//! package = "libshumate"
21//! version = "0.x.y"
22//! ```
23//!
24//! ```no_run
25//! # use libshumate as shumate;
26//! use shumate::prelude::*;
27//!
28//! use shumate::{Map};
29//! use gtk::{Application, Box, ListBox, Orientation, ApplicationWindow};
30//!
31//! fn main() {
32//!     let application = Application::builder()
33//!         .application_id("com.example.FirstShumateApp")
34//!         .build();
35//!
36//!     application.connect_activate(|app| {
37//!         let content = Map::new();
38//!
39//!         let window = ApplicationWindow::builder()
40//!             .application(app)
41//!             .default_width(350)
42//!             // add content to window
43//!             .child(&content)
44//!             .build();
45//!         window.show();
46//!     });
47//!
48//!     application.run();
49//! }
50//! ```
51
52// Re-export the -sys bindings
53pub use ffi;
54#[doc(hidden)]
55pub use gtk;
56
57/// The maximal possible latitude value.
58#[doc(alias = "SHUMATE_MAX_LATITUDE")]
59pub const MAX_LATITUDE: f64 = ffi::SHUMATE_MAX_LATITUDE;
60/// The maximal possible longitude value.
61#[doc(alias = "SHUMATE_MAX_LONGITUDE")]
62pub const MAX_LONGITUDE: f64 = ffi::SHUMATE_MAX_LONGITUDE;
63/// The minimal possible latitude value.
64#[doc(alias = "SHUMATE_MIN_LATITUDE")]
65pub const MIN_LATITUDE: f64 = ffi::SHUMATE_MIN_LATITUDE;
66/// The minimal possible longitude value.
67#[doc(alias = "SHUMATE_MIN_LONGITUDE")]
68pub const MIN_LONGITUDE: f64 = ffi::SHUMATE_MIN_LONGITUDE;
69
70/// Asserts that this is the main thread and `gtk::init` has been called.
71macro_rules! assert_initialized_main_thread {
72    () => {
73        if !::gtk::is_initialized_main_thread() {
74            if ::gtk::is_initialized() {
75                panic!("libshumate may only be used from the main thread.");
76            } else {
77                panic!("Gtk has to be initialized before using libshumate.");
78            }
79        }
80    };
81}
82
83macro_rules! skip_assert_initialized {
84    () => {};
85}
86
87#[allow(unused_imports)]
88#[allow(clippy::type_complexity)]
89#[allow(clippy::too_many_arguments)]
90mod auto;
91
92pub use auto::*;
93
94pub mod prelude;
95pub mod subclass;
96
97pub mod functions {
98    pub use super::auto::functions::*;
99}