Add application menu item for checking for updates
This commit is contained in:
parent
9c469f2fdb
commit
fb2caf3c58
3 changed files with 13 additions and 0 deletions
|
@ -70,6 +70,12 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut Mutab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check(cx: &mut MutableAppContext) {
|
||||||
|
if let Some(updater) = AutoUpdater::get(cx) {
|
||||||
|
updater.update(cx, |updater, cx| updater.poll(cx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AutoUpdater {
|
impl AutoUpdater {
|
||||||
fn get(cx: &mut MutableAppContext) -> Option<ModelHandle<Self>> {
|
fn get(cx: &mut MutableAppContext) -> Option<ModelHandle<Self>> {
|
||||||
cx.default_global::<Option<ModelHandle<Self>>>().clone()
|
cx.default_global::<Option<ModelHandle<Self>>>().clone()
|
||||||
|
|
|
@ -13,6 +13,11 @@ pub fn menus(state: &Arc<AppState>) -> Vec<Menu<'static>> {
|
||||||
keystroke: None,
|
keystroke: None,
|
||||||
action: Box::new(super::About),
|
action: Box::new(super::About),
|
||||||
},
|
},
|
||||||
|
MenuItem::Action {
|
||||||
|
name: "Check for Updates",
|
||||||
|
keystroke: None,
|
||||||
|
action: Box::new(super::CheckForUpdates),
|
||||||
|
},
|
||||||
MenuItem::Separator,
|
MenuItem::Separator,
|
||||||
MenuItem::Action {
|
MenuItem::Action {
|
||||||
name: "Quit",
|
name: "Quit",
|
||||||
|
|
|
@ -31,6 +31,7 @@ action!(About);
|
||||||
action!(Quit);
|
action!(Quit);
|
||||||
action!(OpenSettings);
|
action!(OpenSettings);
|
||||||
action!(AdjustBufferFontSize, f32);
|
action!(AdjustBufferFontSize, f32);
|
||||||
|
action!(CheckForUpdates);
|
||||||
|
|
||||||
const MIN_FONT_SIZE: f32 = 6.0;
|
const MIN_FONT_SIZE: f32 = 6.0;
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ lazy_static! {
|
||||||
|
|
||||||
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
cx.add_global_action(quit);
|
cx.add_global_action(quit);
|
||||||
|
cx.add_global_action(|_: &CheckForUpdates, cx| auto_update::check(cx));
|
||||||
cx.add_global_action({
|
cx.add_global_action({
|
||||||
move |action: &AdjustBufferFontSize, cx| {
|
move |action: &AdjustBufferFontSize, cx| {
|
||||||
cx.update_global::<Settings, _, _>(|settings, cx| {
|
cx.update_global::<Settings, _, _>(|settings, cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue