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