fix deprecation warnings that occured due to cursive 0.14.0 upgrade
This commit is contained in:
@@ -10,7 +10,7 @@ use librespot_protocol::authentication::AuthenticationType;
|
|||||||
|
|
||||||
pub fn create_credentials(path: &Path) -> Result<RespotCredentials, String> {
|
pub fn create_credentials(path: &Path) -> Result<RespotCredentials, String> {
|
||||||
let mut login_cursive = Cursive::default();
|
let mut login_cursive = Cursive::default();
|
||||||
let mut info_buf = TextContent::new("Failed to authenticate\n");
|
let info_buf = TextContent::new("Failed to authenticate\n");
|
||||||
info_buf.append(format!(
|
info_buf.append(format!(
|
||||||
"Cannot read config file from {}\n",
|
"Cannot read config file from {}\n",
|
||||||
path.to_str().unwrap()
|
path.to_str().unwrap()
|
||||||
@@ -23,23 +23,23 @@ pub fn create_credentials(path: &Path) -> Result<RespotCredentials, String> {
|
|||||||
ListView::new()
|
ListView::new()
|
||||||
.child(
|
.child(
|
||||||
"Username",
|
"Username",
|
||||||
EditView::new().with_id("spotify_user").fixed_width(18),
|
EditView::new().with_name("spotify_user").fixed_width(18),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
"Password",
|
"Password",
|
||||||
EditView::new()
|
EditView::new()
|
||||||
.secret()
|
.secret()
|
||||||
.with_id("spotify_password")
|
.with_name("spotify_password")
|
||||||
.fixed_width(18),
|
.fixed_width(18),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.button("Login", |s| {
|
.button("Login", |s| {
|
||||||
let username = s
|
let username = s
|
||||||
.call_on_id("spotify_user", |view: &mut EditView| view.get_content())
|
.call_on_name("spotify_user", |view: &mut EditView| view.get_content())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
let auth_data = s
|
let auth_data = s
|
||||||
.call_on_id("spotify_password", |view: &mut EditView| view.get_content())
|
.call_on_name("spotify_password", |view: &mut EditView| view.get_content())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string()
|
.to_string()
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ impl CommandManager {
|
|||||||
|
|
||||||
fn handle_callbacks(&self, s: &mut Cursive, cmd: &Command) -> Result<Option<String>, String> {
|
fn handle_callbacks(&self, s: &mut Cursive, cmd: &Command) -> Result<Option<String>, String> {
|
||||||
let local = {
|
let local = {
|
||||||
let mut main: ViewRef<Layout> = s.find_id("main").unwrap();
|
let mut main: ViewRef<Layout> = s.find_name("main").unwrap();
|
||||||
main.on_command(s, cmd)?
|
main.on_command(s, cmd)?
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ impl CommandManager {
|
|||||||
s.add_layer(modal);
|
s.add_layer(modal);
|
||||||
Ok(None)
|
Ok(None)
|
||||||
} else if let CommandResult::View(view) = local {
|
} else if let CommandResult::View(view) = local {
|
||||||
s.call_on_id("main", move |v: &mut Layout| {
|
s.call_on_name("main", move |v: &mut Layout| {
|
||||||
v.push_view(view);
|
v.push_view(view);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ impl CommandManager {
|
|||||||
pub fn handle(&self, s: &mut Cursive, cmd: Command) {
|
pub fn handle(&self, s: &mut Cursive, cmd: Command) {
|
||||||
let result = self.handle_callbacks(s, &cmd);
|
let result = self.handle_callbacks(s, &cmd);
|
||||||
|
|
||||||
s.call_on_id("main", |v: &mut Layout| {
|
s.call_on_name("main", |v: &mut Layout| {
|
||||||
v.set_result(result);
|
v.set_result(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,8 +213,14 @@ impl CommandManager {
|
|||||||
kb.insert("/".into(), Command::Focus("search".into()));
|
kb.insert("/".into(), Command::Focus("search".into()));
|
||||||
kb.insert("f".into(), Command::Seek(SeekDirection::Relative(1000)));
|
kb.insert("f".into(), Command::Seek(SeekDirection::Relative(1000)));
|
||||||
kb.insert("b".into(), Command::Seek(SeekDirection::Relative(-1000)));
|
kb.insert("b".into(), Command::Seek(SeekDirection::Relative(-1000)));
|
||||||
kb.insert("Shift+f".into(), Command::Seek(SeekDirection::Relative(10000)));
|
kb.insert(
|
||||||
kb.insert("Shift+b".into(), Command::Seek(SeekDirection::Relative(-10000)));
|
"Shift+f".into(),
|
||||||
|
Command::Seek(SeekDirection::Relative(10000)),
|
||||||
|
);
|
||||||
|
kb.insert(
|
||||||
|
"Shift+b".into(),
|
||||||
|
Command::Seek(SeekDirection::Relative(-10000)),
|
||||||
|
);
|
||||||
kb.insert("+".into(), Command::VolumeUp);
|
kb.insert("+".into(), Command::VolumeUp);
|
||||||
kb.insert("-".into(), Command::VolumeDown);
|
kb.insert("-".into(), Command::VolumeDown);
|
||||||
kb.insert("r".into(), Command::Repeat(None));
|
kb.insert("r".into(), Command::Repeat(None));
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -220,21 +220,21 @@ fn main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
||||||
.view("search", search.with_id("search"), "Search")
|
.view("search", search.with_name("search"), "Search")
|
||||||
.view("library", libraryview.with_id("library"), "Library")
|
.view("library", libraryview.with_name("library"), "Library")
|
||||||
.view("queue", queueview, "Queue");
|
.view("queue", queueview, "Queue");
|
||||||
|
|
||||||
// initial view is library
|
// initial view is library
|
||||||
layout.set_view("library");
|
layout.set_view("library");
|
||||||
|
|
||||||
cursive.add_global_callback(':', move |s| {
|
cursive.add_global_callback(':', move |s| {
|
||||||
s.call_on_id("main", |v: &mut ui::layout::Layout| {
|
s.call_on_name("main", |v: &mut ui::layout::Layout| {
|
||||||
v.enable_cmdline();
|
v.enable_cmdline();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
layout.cmdline.set_on_edit(move |s, cmd, _| {
|
layout.cmdline.set_on_edit(move |s, cmd, _| {
|
||||||
s.call_on_id("main", |v: &mut ui::layout::Layout| {
|
s.call_on_name("main", |v: &mut ui::layout::Layout| {
|
||||||
if cmd.is_empty() {
|
if cmd.is_empty() {
|
||||||
v.clear_cmdline();
|
v.clear_cmdline();
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ fn main() {
|
|||||||
let cmd_manager = cmd_manager.clone();
|
let cmd_manager = cmd_manager.clone();
|
||||||
layout.cmdline.set_on_submit(move |s, cmd| {
|
layout.cmdline.set_on_submit(move |s, cmd| {
|
||||||
{
|
{
|
||||||
let mut main = s.find_id::<ui::layout::Layout>("main").unwrap();
|
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
|
||||||
main.clear_cmdline();
|
main.clear_cmdline();
|
||||||
}
|
}
|
||||||
let c = &cmd[1..];
|
let c = &cmd[1..];
|
||||||
@@ -258,7 +258,7 @@ fn main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cursive.add_fullscreen_layer(layout.with_id("main"));
|
cursive.add_fullscreen_layer(layout.with_name("main"));
|
||||||
|
|
||||||
// cursive event loop
|
// cursive event loop
|
||||||
while cursive.is_running() {
|
while cursive.is_running() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use cursive::view::{View, ViewWrapper};
|
use cursive::view::{View, ViewWrapper};
|
||||||
use cursive::views::IdView;
|
use cursive::views::NamedView;
|
||||||
use cursive::Cursive;
|
use cursive::Cursive;
|
||||||
|
|
||||||
use album::Album;
|
use album::Album;
|
||||||
@@ -49,7 +49,7 @@ pub trait ViewExt: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<V: ViewExt> ViewExt for IdView<V> {
|
impl<V: ViewExt> ViewExt for NamedView<V> {
|
||||||
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
fn on_command(&mut self, s: &mut Cursive, cmd: &Command) -> Result<CommandResult, String> {
|
||||||
self.with_view_mut(move |v| v.on_command(s, cmd)).unwrap()
|
self.with_view_mut(move |v| v.on_command(s, cmd)).unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ impl ContextMenu {
|
|||||||
match action {
|
match action {
|
||||||
ContextMenuAction::ShowItem(item) => {
|
ContextMenuAction::ShowItem(item) => {
|
||||||
if let Some(view) = item.open(queue, library) {
|
if let Some(view) = item.open(queue, library) {
|
||||||
s.call_on_id("main", move |v: &mut Layout| v.push_view(view));
|
s.call_on_name("main", move |v: &mut Layout| v.push_view(view));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ContextMenuAction::ShareUrl(url) => {
|
ContextMenuAction::ShareUrl(url) => {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ impl QueueView {
|
|||||||
library.save_playlist(name, &tracks);
|
library.save_playlist(name, &tracks);
|
||||||
s.pop_layer();
|
s.pop_layer();
|
||||||
})
|
})
|
||||||
.with_id("name")
|
.with_name("name")
|
||||||
.fixed_width(20);
|
.fixed_width(20);
|
||||||
let dialog = Dialog::new()
|
let dialog = Dialog::new()
|
||||||
.title("Enter name")
|
.title("Enter name")
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use cursive::direction::Orientation;
|
|||||||
use cursive::event::{AnyCb, Event, EventResult, Key};
|
use cursive::event::{AnyCb, Event, EventResult, Key};
|
||||||
use cursive::traits::{Boxable, Finder, Identifiable, View};
|
use cursive::traits::{Boxable, Finder, Identifiable, View};
|
||||||
use cursive::view::{Selector, ViewWrapper};
|
use cursive::view::{Selector, ViewWrapper};
|
||||||
use cursive::views::{EditView, IdView, ViewRef};
|
use cursive::views::{EditView, NamedView, ViewRef};
|
||||||
use cursive::{Cursive, Printer, Vec2};
|
use cursive::{Cursive, Printer, Vec2};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
use std::sync::{Arc, Mutex, RwLock};
|
||||||
@@ -32,8 +32,8 @@ pub struct SearchView {
|
|||||||
pagination_artists: Pagination<Artist>,
|
pagination_artists: Pagination<Artist>,
|
||||||
results_playlists: Arc<RwLock<Vec<Playlist>>>,
|
results_playlists: Arc<RwLock<Vec<Playlist>>>,
|
||||||
pagination_playlists: Pagination<Playlist>,
|
pagination_playlists: Pagination<Playlist>,
|
||||||
edit: IdView<EditView>,
|
edit: NamedView<EditView>,
|
||||||
tabs: IdView<TabView>,
|
tabs: NamedView<TabView>,
|
||||||
edit_focused: bool,
|
edit_focused: bool,
|
||||||
events: EventManager,
|
events: EventManager,
|
||||||
spotify: Arc<Spotify>,
|
spotify: Arc<Spotify>,
|
||||||
@@ -59,13 +59,13 @@ impl SearchView {
|
|||||||
let searchfield = EditView::new()
|
let searchfield = EditView::new()
|
||||||
.on_submit(move |s, input| {
|
.on_submit(move |s, input| {
|
||||||
if !input.is_empty() {
|
if !input.is_empty() {
|
||||||
s.call_on_id("search", |v: &mut SearchView| {
|
s.call_on_name("search", |v: &mut SearchView| {
|
||||||
v.run_search(input);
|
v.run_search(input);
|
||||||
v.focus_view(&Selector::Id(LIST_ID)).unwrap();
|
v.focus_view(&Selector::Name(LIST_ID)).unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.with_id(EDIT_ID);
|
.with_name(EDIT_ID);
|
||||||
|
|
||||||
let list_tracks = ListView::new(results_tracks.clone(), queue.clone(), library.clone());
|
let list_tracks = ListView::new(results_tracks.clone(), queue.clone(), library.clone());
|
||||||
let pagination_tracks = list_tracks.get_pagination().clone();
|
let pagination_tracks = list_tracks.get_pagination().clone();
|
||||||
@@ -93,7 +93,7 @@ impl SearchView {
|
|||||||
results_playlists,
|
results_playlists,
|
||||||
pagination_playlists,
|
pagination_playlists,
|
||||||
edit: searchfield,
|
edit: searchfield,
|
||||||
tabs: tabs.with_id(LIST_ID),
|
tabs: tabs.with_name(LIST_ID),
|
||||||
edit_focused: true,
|
edit_focused: true,
|
||||||
events,
|
events,
|
||||||
spotify,
|
spotify,
|
||||||
@@ -102,7 +102,7 @@ impl SearchView {
|
|||||||
|
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
self.edit
|
self.edit
|
||||||
.call_on(&Selector::Id(EDIT_ID), |v: &mut EditView| {
|
.call_on(&Selector::Name(EDIT_ID), |v: &mut EditView| {
|
||||||
v.set_content("");
|
v.set_content("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ impl SearchView {
|
|||||||
{
|
{
|
||||||
let query = query.clone();
|
let query = query.clone();
|
||||||
self.edit
|
self.edit
|
||||||
.call_on(&Selector::Id(EDIT_ID), |v: &mut EditView| {
|
.call_on(&Selector::Name(EDIT_ID), |v: &mut EditView| {
|
||||||
v.set_content(query);
|
v.set_content(query);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -420,13 +420,13 @@ impl View for SearchView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_on_any<'a>(&mut self, selector: &Selector<'_>, mut callback: AnyCb<'a>) {
|
fn call_on_any<'a>(&mut self, selector: &Selector<'_>, callback: AnyCb<'a>) {
|
||||||
self.edit.call_on_any(selector, &mut |v| callback(v));
|
self.edit.call_on_any(selector, &mut |v| callback(v));
|
||||||
self.tabs.call_on_any(selector, &mut |v| callback(v));
|
self.tabs.call_on_any(selector, &mut |v| callback(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn focus_view(&mut self, selector: &Selector<'_>) -> Result<(), ()> {
|
fn focus_view(&mut self, selector: &Selector<'_>) -> Result<(), ()> {
|
||||||
if let Selector::Id(s) = selector {
|
if let Selector::Name(s) = selector {
|
||||||
self.edit_focused = s == &"search_edit";
|
self.edit_focused = s == &"search_edit";
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user