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.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/preferences/pages/map.rs b/src/preferences/pages/map.rs
index 4355c6f..5645a59 100644
--- a/src/preferences/pages/map.rs
+++ b/src/preferences/pages/map.rs
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-use gtk::prelude::*;
use relm4::Sender;
use relm4::gtk;
+use sourceview5::prelude::*;
use crate::tr;
use crate::ui_helpers::create_switch_row;
@@ -29,7 +29,7 @@ pub struct MapPage {
show_background_switch: gtk::Switch,
smart_positioning_switch: gtk::Switch,
custom_font_switch: gtk::Switch,
- font_button: gtk::FontButton,
+ font_button: gtk::FontDialogButton,
export_format_dropdown: gtk::DropDown,
}
@@ -61,7 +61,7 @@ impl MapPage {
container: &gtk::Box,
preferences: &UserPreferences,
sender: &Sender<PreferencesInput>,
- ) -> (gtk::Switch, gtk::Switch, gtk::Switch, gtk::FontButton) {
+ ) -> (gtk::Switch, gtk::Switch, gtk::Switch, gtk::FontDialogButton) {
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);
@@ -109,19 +109,20 @@ impl MapPage {
let font_row = gtk::Box::new(gtk::Orientation::Horizontal, 10);
font_row.append(&gtk::Label::new(Some(&tr!("preferences.map.font"))));
- let font_button = gtk::FontButton::new();
- font_button.set_font(&preferences.custom_font_name);
+ let font_dialog = gtk::FontDialog::new();
+ let font_button = gtk::FontDialogButton::new(Some(font_dialog));
+ let font_desc = gtk::pango::FontDescription::from_string(&preferences.custom_font_name);
+ font_button.set_font_desc(&font_desc);
font_button.set_sensitive(preferences.use_custom_font);
font_button.set_hexpand(true);
font_button.set_use_font(true);
{
let sender = sender.clone();
- font_button.connect_font_set(move |button| {
- if let Some(font) = button.font() {
- let font_desc = gtk::pango::FontDescription::from_string(&font);
- if let Some(family) = font_desc.family() {
- sender.emit(PreferencesInput::SetCustomFontName(family.to_string()));
- }
+ font_button.connect_font_desc_notify(move |button| {
+ if let Some(font) = button.font_desc()
+ && let Some(family) = font.family()
+ {
+ sender.emit(PreferencesInput::SetCustomFontName(family.to_string()));
}
});
}
@@ -199,7 +200,8 @@ impl MapPage {
self.custom_font_switch
.set_active(preferences.use_custom_font);
self.font_button.set_sensitive(preferences.use_custom_font);
- self.font_button.set_font(&preferences.custom_font_name);
+ let font_desc = gtk::pango::FontDescription::from_string(&preferences.custom_font_name);
+ self.font_button.set_font_desc(&font_desc);
let selected = match preferences.default_export_format.as_str() {
"svg" => 1,