aboutsummaryrefslogtreecommitdiff
path: root/src/preferences/pages/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/preferences/pages/map.rs')
-rw-r--r--src/preferences/pages/map.rs65
1 files changed, 48 insertions, 17 deletions
diff --git a/src/preferences/pages/map.rs b/src/preferences/pages/map.rs
index 5ffd04a..4355c6f 100644
--- a/src/preferences/pages/map.rs
+++ b/src/preferences/pages/map.rs
@@ -34,7 +34,7 @@ pub struct MapPage {
}
impl MapPage {
- pub fn new(preferences: &UserPreferences, sender: Sender<PreferencesInput>) -> Self {
+ pub fn new(preferences: &UserPreferences, sender: &Sender<PreferencesInput>) -> Self {
let container = gtk::Box::new(gtk::Orientation::Vertical, 20);
container.set_margin_top(20);
container.set_margin_bottom(20);
@@ -42,15 +42,36 @@ impl MapPage {
container.set_margin_end(20);
container.set_valign(gtk::Align::Start);
- // Map Style section
+ let (show_background_switch, smart_positioning_switch, custom_font_switch, font_button) =
+ Self::init_style_section(&container, preferences, sender);
+
+ let export_format_dropdown = Self::init_export_section(&container, preferences, sender);
+
+ Self {
+ container,
+ show_background_switch,
+ smart_positioning_switch,
+ custom_font_switch,
+ font_button,
+ export_format_dropdown,
+ }
+ }
+
+ fn init_style_section(
+ container: &gtk::Box,
+ preferences: &UserPreferences,
+ sender: &Sender<PreferencesInput>,
+ ) -> (gtk::Switch, gtk::Switch, gtk::Switch, gtk::FontButton) {
let style_label = gtk::Label::new(Some(&tr!("preferences.map.map_style.title")));
style_label.add_css_class("heading");
style_label.set_halign(gtk::Align::Start);
container.append(&style_label);
// Show Background
- let background_row =
- create_switch_row(&tr!("preferences.map.map_style.show_background"), preferences.show_map_background);
+ let background_row = create_switch_row(
+ &tr!("preferences.map.map_style.show_background"),
+ preferences.show_map_background,
+ );
let show_background_switch = background_row.1.clone();
{
let sender = sender.clone();
@@ -77,7 +98,10 @@ impl MapPage {
container.append(&smart_row.0);
// Use Custom Font
- let custom_font_row = create_switch_row(&tr!("preferences.map.map_style.use_custom_font"), preferences.use_custom_font);
+ let custom_font_row = create_switch_row(
+ &tr!("preferences.map.map_style.use_custom_font"),
+ preferences.use_custom_font,
+ );
let custom_font_switch = custom_font_row.1.clone();
container.append(&custom_font_row.0);
@@ -115,7 +139,19 @@ impl MapPage {
});
}
- // Export section
+ (
+ show_background_switch,
+ smart_positioning_switch,
+ custom_font_switch,
+ font_button,
+ )
+ }
+
+ fn init_export_section(
+ container: &gtk::Box,
+ preferences: &UserPreferences,
+ sender: &Sender<PreferencesInput>,
+ ) -> gtk::DropDown {
let export_label = gtk::Label::new(Some(&tr!("preferences.map.export.title")));
export_label.add_css_class("heading");
export_label.set_halign(gtk::Align::Start);
@@ -123,9 +159,12 @@ impl MapPage {
container.append(&export_label);
let export_row = gtk::Box::new(gtk::Orientation::Horizontal, 10);
- export_row.append(&gtk::Label::new(Some(&tr!("preferences.map.export.default_format"))));
+ export_row.append(&gtk::Label::new(Some(&tr!(
+ "preferences.map.export.default_format"
+ ))));
- let formats = gtk::StringList::new(&[&tr!("export_formats.png"), &tr!("export_formats.svg")]);
+ let formats =
+ gtk::StringList::new(&[&tr!("export_formats.png"), &tr!("export_formats.svg")]);
let export_format_dropdown = gtk::DropDown::new(Some(formats), None::<gtk::Expression>);
let selected = match preferences.default_export_format.as_str() {
"svg" => 1,
@@ -145,14 +184,7 @@ impl MapPage {
export_row.append(&export_format_dropdown);
container.append(&export_row);
- Self {
- container,
- show_background_switch,
- smart_positioning_switch,
- custom_font_switch,
- font_button,
- export_format_dropdown,
- }
+ export_format_dropdown
}
pub fn widget(&self) -> gtk::Box {
@@ -176,4 +208,3 @@ impl MapPage {
self.export_format_dropdown.set_selected(selected);
}
}
-