Skip to content

Commit

Permalink
更新依赖版本,修复依赖更新造成的错误。
Browse files Browse the repository at this point in the history
  • Loading branch information
gmg137 committed Oct 28, 2022
1 parent 9d65690 commit 1a7fcac
Show file tree
Hide file tree
Showing 16 changed files with 394 additions and 321 deletions.
587 changes: 327 additions & 260 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
gettext-rs = { version = "0.7", features = ["gettext-system"] }
gtk = { version = "0.4.7", package = "gtk4" }
gtk = { version = "0.5", package = "gtk4" }
once_cell = "*"
qrcode-generator = "^4.1"
ncm-api = { git = "https://github.com/gmg137/netease-cloud-music-api.git", version = "*", package = "netease-cloud-music-api" }
Expand All @@ -14,11 +14,11 @@ gstreamer = "*"
gstreamer-player = "*"
fragile = "*"
fastrand = "*"
mpris-player = "0.6.1"
mpris-player = "0.6.2"
regex = "*"
log = "*"
env_logger = "*"

[dependencies.adw]
package = "libadwaita"
version = "0.1.1"
version = "0.2"
13 changes: 7 additions & 6 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use adw::subclass::prelude::*;
use gettextrs::gettext;
use gio::Settings;
use glib::{clone, timeout_future, timeout_future_seconds, MainContext, Receiver, Sender, WeakRef};
use gtk::{gio, glib, prelude::*, subclass::prelude::*};
use gtk::{gio, glib, prelude::*};
use log::*;
use ncm_api::{BannersInfo, LoginInfo, SingerInfo, SongInfo, SongList, TopList};
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -113,8 +113,9 @@ mod imp {
}

impl ObjectImpl for NeteaseCloudMusicGtk4Application {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();

obj.setup_gactions();
obj.setup_cache_clear();
Expand All @@ -129,8 +130,9 @@ mod imp {
// has been launched. Additionally, this callback notifies us when the user
// tries to launch a "second instance" of the application. When they try
// to do that, we'll just present any existing window.
fn activate(&self, application: &Self::Type) {
let app = application
fn activate(&self) {
let obj = self.obj();
let app = obj
.downcast_ref::<super::NeteaseCloudMusicGtk4Application>()
.unwrap();

Expand Down Expand Up @@ -167,7 +169,6 @@ glib::wrapper! {
impl NeteaseCloudMusicGtk4Application {
pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self {
glib::Object::new(&[("application-id", &application_id), ("flags", flags)])
.expect("Failed to create NeteaseCloudMusicGtk4Application")
}

fn create_window(&self) -> NeteaseCloudMusicGtk4Window {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/discover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ glib::wrapper! {

impl Discover {
pub fn new() -> Self {
let discover: Discover = glib::Object::new(&[]).expect("Failed to create Discover");
let discover: Discover = glib::Object::new(&[]);
discover
}

Expand Down Expand Up @@ -304,8 +304,8 @@ mod imp {
}

impl ObjectImpl for Discover {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
self.parent_constructed();

self.banners.replace(Vec::new());

Expand Down
6 changes: 3 additions & 3 deletions src/gui/my_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ glib::wrapper! {

impl MyPage {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create MyPage")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -157,8 +157,8 @@ mod imp {
}

impl ObjectImpl for MyPage {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
self.parent_constructed();
if let Ok(datetime) = glib::DateTime::now_local() {
self.daily_rec_avatar.set_show_initials(true);
self.daily_rec_avatar.set_text(Some(&format!(
Expand Down
21 changes: 12 additions & 9 deletions src/gui/player_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ glib::wrapper! {

impl PlayerControls {
pub fn new() -> Self {
let player_controls: PlayerControls =
glib::Object::new(&[]).expect("Failed to create PlayerControls");
let player_controls: PlayerControls = glib::Object::new(&[]);
player_controls
}

Expand Down Expand Up @@ -122,8 +121,10 @@ impl PlayerControls {
pub fn setup_player(&self) {
let imp = self.imp();
let dispatcher = PlayerGMainContextSignalDispatcher::new(None);
let player = Player::new(None, Some(&dispatcher.upcast::<PlayerSignalDispatcher>()));

let player = Player::new(
PlayerVideoRenderer::NONE,
Some(&dispatcher.upcast::<PlayerSignalDispatcher>()),
);
let mut config = player.config();
config.set_user_agent(
"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0",
Expand Down Expand Up @@ -678,8 +679,9 @@ mod imp {
}

impl ObjectImpl for PlayerControls {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();
*self.playlist.lock().unwrap() = PlayList::new();

obj.setup_settings();
Expand Down Expand Up @@ -711,7 +713,7 @@ mod imp {
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
match pspec.name() {
"volume" => {
let input_number = value.get().expect("The value needs to be of type `f64`.");
Expand All @@ -721,14 +723,15 @@ mod imp {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"volume" => self.volume.get().to_value(),
_ => unimplemented!(),
}
}

fn dispose(&self, obj: &Self::Type) {
fn dispose(&self) {
let obj = self.obj();
obj.settings()
.set_double("volume", obj.property("volume"))
.unwrap();
Expand Down
11 changes: 6 additions & 5 deletions src/gui/playlist_lyrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ glib::wrapper! {

impl PlayListLyricsPage {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create PlayListLyricsPage")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -140,8 +140,9 @@ mod imp {
}

impl ObjectImpl for PlayListLyricsPage {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();

self.playlist_box.connect_row_activated(
glib::clone!(@weak obj as s => move |list, row| {
Expand Down Expand Up @@ -181,7 +182,7 @@ mod imp {
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
match pspec.name() {
"select-row" => {
let input_number = value.get().expect("The value needs to be of type `i32`.");
Expand All @@ -191,7 +192,7 @@ mod imp {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"select-row" => self.select_row.get().to_value(),
_ => unimplemented!(),
Expand Down
7 changes: 4 additions & 3 deletions src/gui/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ glib::wrapper! {

impl NeteaseCloudMusicGtk4Preferences {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create NeteaseCloudMusicGtk4Preferences")
glib::Object::new(&[])
}

fn setup_settings(&self) {
Expand Down Expand Up @@ -110,8 +110,9 @@ mod imp {
}

impl ObjectImpl for NeteaseCloudMusicGtk4Preferences {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
let obj = self.obj();
self.parent_constructed();

obj.setup_settings();
obj.bind_settings();
Expand Down
6 changes: 3 additions & 3 deletions src/gui/search_singer_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ glib::wrapper! {

impl SearchSingerPage {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create SearchSingerPage")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -177,7 +177,7 @@ mod imp {
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
match pspec.name() {
"update" => {
let update = value.get().expect("The value needs to be of type `bool`.");
Expand All @@ -195,7 +195,7 @@ mod imp {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"update" => self.update.get().to_value(),
"offset" => self.offset.get().to_value(),
Expand Down
10 changes: 5 additions & 5 deletions src/gui/search_song_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ glib::wrapper! {

impl SearchSongPage {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create SearchSongPage")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -137,8 +137,8 @@ mod imp {
}

impl ObjectImpl for SearchSongPage {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
self.parent_constructed();

let select_row = Rc::new(RefCell::new(-1));
self.listbox.connect_row_activated(move |list, row| {
Expand Down Expand Up @@ -220,7 +220,7 @@ mod imp {
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
match pspec.name() {
"update" => {
let update = value.get().expect("The value needs to be of type `bool`.");
Expand All @@ -244,7 +244,7 @@ mod imp {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"update" => self.update.get().to_value(),
"offset" => self.offset.get().to_value(),
Expand Down
6 changes: 3 additions & 3 deletions src/gui/search_songlist_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ glib::wrapper! {

impl SearchSongListPage {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create SearchSongListPage")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -210,7 +210,7 @@ mod imp {
PROPERTIES.as_ref()
}

fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) {
fn set_property(&self, _id: usize, value: &Value, pspec: &ParamSpec) {
match pspec.name() {
"update" => {
let update = value.get().expect("The value needs to be of type `bool`.");
Expand All @@ -234,7 +234,7 @@ mod imp {
}
}

fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
fn property(&self, _id: usize, pspec: &ParamSpec) -> Value {
match pspec.name() {
"update" => self.update.get().to_value(),
"offset" => self.offset.get().to_value(),
Expand Down
7 changes: 3 additions & 4 deletions src/gui/songlist_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ glib::wrapper! {

impl SonglistPage {
pub fn new() -> Self {
let songlist_page: SonglistPage =
glib::Object::new(&[]).expect("Failed to create SonglistPage");
let songlist_page: SonglistPage = glib::Object::new(&[]);
songlist_page
}

Expand Down Expand Up @@ -173,8 +172,8 @@ mod imp {
}

impl ObjectImpl for SonglistPage {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
self.parent_constructed();

let select_row = Rc::new(RefCell::new(-1));
self.listbox.connect_row_activated(move |list, row| {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/songlist_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for SonglistRow {

impl SonglistRow {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create SonglistRow")
glib::Object::new(&[])
}

pub fn switch_image(&self, visible: bool) {
Expand Down
4 changes: 2 additions & 2 deletions src/gui/theme_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for ThemeSelector {

impl ThemeSelector {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create Button")
glib::Object::new(&[])
}
}

Expand Down Expand Up @@ -61,7 +61,7 @@ mod imp {
}

impl ObjectImpl for ThemeSelector {
fn dispose(&self, _obj: &Self::Type) {
fn dispose(&self) {
self.gbox.unparent();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/toplist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Default for TopListView {

impl TopListView {
pub fn new() -> Self {
glib::Object::new(&[]).expect("Failed to create TopListView")
glib::Object::new(&[])
}

pub fn set_sender(&self, sender: Sender<Action>) {
Expand Down Expand Up @@ -176,8 +176,8 @@ mod imp {
}

impl ObjectImpl for TopListView {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
fn constructed(&self) {
self.parent_constructed();
let select_row = Rc::new(RefCell::new(-1));
self.songs_list.connect_row_activated(move |list, row| {
let index;
Expand Down
Loading

0 comments on commit 1a7fcac

Please sign in to comment.