Skip to main content

libshumate/auto/
tile_downloader.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{DataSource, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// A [`DataSource`][crate::DataSource] that asynchronously downloads tiles from an online
11    /// service using a given template.
12    ///
13    /// It contains an internal [`FileCache`][crate::FileCache] to cache the tiles on the system.
14    ///
15    /// ## Properties
16    ///
17    ///
18    /// #### `url-template`
19    ///  A template for construting the URL to download a tile from.
20    ///
21    /// The template has the following replacements:
22    /// - "{x}": The X coordinate of the tile
23    /// - "{y}": The Y coordinate of the tile
24    /// - "{z}": The zoom level of the tile
25    /// - "{tmsy}": The inverted Y coordinate (i.e. tile numbering starts with 0 at
26    /// the bottom, rather than top, of the map)
27    ///
28    /// Readable | Writable | Construct Only
29    /// <details><summary><h4>DataSource</h4></summary>
30    ///
31    ///
32    /// #### `max-zoom-level`
33    ///  The maximum zoom level
34    ///
35    /// Readable | Writable | Construct
36    ///
37    ///
38    /// #### `min-zoom-level`
39    ///  The minimum zoom level
40    ///
41    /// Readable | Writable | Construct
42    /// </details>
43    ///
44    /// # Implements
45    ///
46    /// [`DataSourceExt`][trait@crate::prelude::DataSourceExt], [`trait@glib::ObjectExt`]
47    #[doc(alias = "ShumateTileDownloader")]
48    pub struct TileDownloader(Object<ffi::ShumateTileDownloader, ffi::ShumateTileDownloaderClass>) @extends DataSource;
49
50    match fn {
51        type_ => || ffi::shumate_tile_downloader_get_type(),
52    }
53}
54
55impl TileDownloader {
56    /// Creates a new [`TileDownloader`][crate::TileDownloader] that fetches tiles from an API and
57    /// caches them on disk.
58    ///
59    /// See [`url-template`][struct@crate::TileDownloader#url-template] for the format of the URL template.
60    /// ## `url_template`
61    /// a URL template to fetch tiles from
62    ///
63    /// # Returns
64    ///
65    /// a newly constructed [`TileDownloader`][crate::TileDownloader]
66    #[doc(alias = "shumate_tile_downloader_new")]
67    pub fn new(url_template: &str) -> TileDownloader {
68        assert_initialized_main_thread!();
69        unsafe {
70            from_glib_full(ffi::shumate_tile_downloader_new(
71                url_template.to_glib_none().0,
72            ))
73        }
74    }
75
76    /// A template for construting the URL to download a tile from.
77    ///
78    /// The template has the following replacements:
79    /// - "{x}": The X coordinate of the tile
80    /// - "{y}": The Y coordinate of the tile
81    /// - "{z}": The zoom level of the tile
82    /// - "{tmsy}": The inverted Y coordinate (i.e. tile numbering starts with 0 at
83    /// the bottom, rather than top, of the map)
84    #[doc(alias = "url-template")]
85    pub fn url_template(&self) -> Option<glib::GString> {
86        ObjectExt::property(self, "url-template")
87    }
88}