Fix linux compilation error
This commit is contained in:
parent
d7b2c313f8
commit
7915541a7d
@ -1,7 +1,10 @@
|
|||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
use ui::UI;
|
use ui::{UI, SET};
|
||||||
|
#[cfg(unix)]
|
||||||
|
use nvim::RedrawEvents;
|
||||||
|
|
||||||
use ui::Ui;
|
use ui::Ui;
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
use gio;
|
use gio;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
@ -15,13 +18,13 @@ pub enum FontSource {
|
|||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
font_source: FontSource,
|
font_source: FontSource,
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
gnome_interface_settings: gio::Settings,
|
gnome_interface_settings: gio::Settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
pub fn new() -> Settings {
|
pub fn new() -> Settings {
|
||||||
Settings {
|
Settings {
|
||||||
font_source: FontSource::Default,
|
font_source: FontSource::Default,
|
||||||
@ -36,7 +39,7 @@ impl Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
pub fn init(&mut self, ui: &mut Ui) {
|
pub fn init(&mut self, ui: &mut Ui) {
|
||||||
self.gnome_interface_settings.connect_changed(|_, _| monospace_font_changed());
|
self.gnome_interface_settings.connect_changed(|_, _| monospace_font_changed());
|
||||||
self.update_font(ui);
|
self.update_font(ui);
|
||||||
@ -51,7 +54,7 @@ impl Settings {
|
|||||||
fn update_font(&mut self, ui: &mut Ui) {
|
fn update_font(&mut self, ui: &mut Ui) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
fn update_font(&mut self, ui: &mut Ui) {
|
fn update_font(&mut self, ui: &mut Ui) {
|
||||||
// rpc is priority for font
|
// rpc is priority for font
|
||||||
if self.font_source == FontSource::Rpc {
|
if self.font_source == FontSource::Rpc {
|
||||||
@ -69,16 +72,19 @@ impl Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(unix)]
|
||||||
fn monospace_font_changed() {
|
fn monospace_font_changed() {
|
||||||
UI.with(|ui_cell| {
|
UI.with(|ui_cell| {
|
||||||
let mut ui = ui_cell.borrow_mut();
|
let mut ui = ui_cell.borrow_mut();
|
||||||
|
|
||||||
// rpc is priority for font
|
SET.with(|set_cell| {
|
||||||
if ui.settings.font_source != FontSource::Rpc {
|
let mut set = set_cell.borrow_mut();
|
||||||
ui.settings.update_font(ui);
|
// rpc is priority for font
|
||||||
ui.on_redraw();
|
if set.font_source != FontSource::Rpc {
|
||||||
}
|
set.update_font(&mut *ui);
|
||||||
|
ui.on_redraw();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user