From ca5c7022ef3a2cbc2271d63b8d2cb870925111bc Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Mon, 21 May 2018 11:49:35 +0100 Subject: [PATCH] Fixed some shortcut display issues Also give FileChooserNative arguments in the right order & add F5 to refresh --- hammond-gtk/resources/gtk/help-overlay.ui | 14 ++++++-- hammond-gtk/resources/gtk/menus.ui | 1 + hammond-gtk/src/app.rs | 41 +++++++++++++---------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/hammond-gtk/resources/gtk/help-overlay.ui b/hammond-gtk/resources/gtk/help-overlay.ui index e8af8f7..25bd08a 100644 --- a/hammond-gtk/resources/gtk/help-overlay.ui +++ b/hammond-gtk/resources/gtk/help-overlay.ui @@ -6,13 +6,23 @@ shortcuts 12 + True - Miscellaneous + General + True + True + F5 + Check for new episodes + + + + + True <primary>q - Quit + Quit the application diff --git a/hammond-gtk/resources/gtk/menus.ui b/hammond-gtk/resources/gtk/menus.ui index fc22bbb..10bc0eb 100644 --- a/hammond-gtk/resources/gtk/menus.ui +++ b/hammond-gtk/resources/gtk/menus.ui @@ -6,6 +6,7 @@ _Check for new episodes app.refresh + F5 _Import Shows diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index e9e69e8..a29c844 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -1,6 +1,7 @@ #![allow(new_without_default)] -use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags, Settings, SettingsExt, SimpleAction, SimpleActionExt, ActionMapExt}; +use gio::{ApplicationExt, ApplicationExtManual, ApplicationFlags, Settings, + SettingsExt, SimpleAction, SimpleActionExt, ActionMapExt}; use glib; use gtk; use gtk::prelude::*; @@ -62,8 +63,6 @@ impl App { let cleanup_date = settings::get_cleanup_date(&settings); utils::cleanup(cleanup_date); - // Ideally a lot more than actions would happen in startup & window - // creation would be in activate application.connect_startup(clone!(settings => move |app| { let (sender, receiver) = channel(); let receiver = Rc::new(RefCell::new(receiver)); @@ -115,7 +114,8 @@ impl App { // Create a content instance let content = - Rc::new(Content::new(sender.clone()).expect("Content Initialization failed.")); + Rc::new(Content::new(sender.clone()).expect( + "Content Initialization failed.")); // Create the headerbar let header = Rc::new(Header::new(&content, &window, &sender)); @@ -134,24 +134,26 @@ impl App { window.show_all(); window.activate(); - let headerbar = header; gtk::timeout_add(50, clone!(sender, receiver => move || { - // Uses receiver, content, headerbar, sender, overlay + // Uses receiver, content, header, sender, overlay let act = receiver.borrow().try_recv(); //let act: Result = Ok(Action::RefreshAllViews); match act { Ok(Action::RefreshAllViews) => content.update(), Ok(Action::RefreshShowsView) => content.update_shows_view(), - Ok(Action::RefreshWidgetIfSame(id)) => content.update_widget_if_same(id), + Ok(Action::RefreshWidgetIfSame(id)) => + content.update_widget_if_same(id), Ok(Action::RefreshEpisodesView) => content.update_home(), - Ok(Action::RefreshEpisodesViewBGR) => content.update_home_if_background(), + Ok(Action::RefreshEpisodesViewBGR) => + content.update_home_if_background(), Ok(Action::ReplaceWidget(pd)) => { let shows = content.get_shows(); let mut pop = shows.borrow().populated(); pop.borrow_mut() .replace_widget(pd.clone()) .map_err(|err| error!("Failed to update ShowWidget: {}", err)) - .map_err(|_| error!("Failed ot update ShowWidget {}", pd.title())) + .map_err(|_| + error!("Failed ot update ShowWidget {}", pd.title())) .ok(); } Ok(Action::ShowWidgetAnimated) => { @@ -166,12 +168,16 @@ impl App { let shows = content.get_shows(); let mut pop = shows.borrow().populated(); pop.borrow_mut() - .switch_visible(PopulatedState::View, gtk::StackTransitionType::SlideRight); + .switch_visible(PopulatedState::View, + gtk::StackTransitionType::SlideRight); } - Ok(Action::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title), - Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(), - Ok(Action::HeaderBarShowUpdateIndicator) => headerbar.show_update_notification(), - Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(), + Ok(Action::HeaderBarShowTile(title)) => + header.switch_to_back(&title), + Ok(Action::HeaderBarNormal) => header.switch_to_normal(), + Ok(Action::HeaderBarShowUpdateIndicator) => + header.show_update_notification(), + Ok(Action::HeaderBarHideUpdateIndicator) => + header.hide_update_notification(), Ok(Action::MarkAllPlayerNotification(pd)) => { let notif = mark_all_notif(pd, &sender); notif.show(&overlay); @@ -183,7 +189,8 @@ impl App { Ok(Action::ErrorNotification(err)) => { error!("An error notification was triggered: {}", err); let callback = || glib::Continue(false); - let notif = InAppNotification::new(&err, callback, || {}, UndoState::Hidden); + let notif = InAppNotification::new(&err, callback, + || {}, UndoState::Hidden); notif.show(&overlay); } Err(_) => (), @@ -260,7 +267,7 @@ fn about_dialog(window: >k::Window) { "Jordan Petridis", "Julian Sparber", "Rowan Lewis", - "Zander Brown" + "Zander Brown", ]; let dialog = gtk::AboutDialog::new(); @@ -297,8 +304,8 @@ fn on_import_clicked(window: >k::Window, sender: &Sender) { Some("Select the file from which to you want to Import Shows."), Some(window), FileChooserAction::Open, - Some("_Cancel"), Some("_Import"), + None, ); // Do not show hidden(.thing) files