Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
philn committed Feb 2, 2023
1 parent a0073b9 commit b82cdc7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/channel_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn uri_to_sha256(uri: &str) -> string::String {
sh.update(uri.as_bytes());
sh.finalize()
.into_iter()
.map(|b| format!("{:02x}", b))
.map(|b| format!("{b:02x}"))
.collect::<Vec<_>>()
.concat()
}
Expand Down Expand Up @@ -177,7 +177,7 @@ fn prepare_video_overlay(video_area: &gtk::DrawingArea, video_overlay: &gst_play
video_overlay.set_window_handle(xid as usize);
}
} else {
eprintln!("Add support for display type '{}'", display_type_name);
eprintln!("Add support for display type '{display_type_name}'");
process::exit(-1);
}
}
Expand Down Expand Up @@ -459,7 +459,7 @@ impl ChannelPlayer {
assert!(!playlist.is_empty());
let player = &self.player;
with_mut_player!(player player_data {
self.load_uri(&*playlist[0]);
self.load_uri(&playlist[0]);
player_data.set_playlist(playlist);
});
}
Expand Down
34 changes: 17 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl VideoPlayer {
self.ui_context.set_progress_bar_format_callback(|value, duration| {
let position = gst::ClockTime::from_seconds(value as u64);
let duration = gst::ClockTime::from_seconds(duration as u64);
format!("{:.0} / {:.0}", position, duration)
format!("{position:.0} / {duration:.0}")
});

self.ui_context.set_volume_value_changed_callback(|value| {
Expand Down Expand Up @@ -503,7 +503,7 @@ impl VideoPlayer {

pub fn player_error(&self, msg: std::string::String) {
// FIXME: display some GTK error dialog...
eprintln!("Internal player error: {}", msg);
eprintln!("Internal player error: {msg}");
with_video_player!(video_player { video_player.quit() });
}

Expand Down Expand Up @@ -531,7 +531,7 @@ impl VideoPlayer {
if let Some(info) = self.player.get_media_info() {
if let Some(uri) = self.player.get_current_uri() {
if let Some(title) = info.title() {
self.ui_context.set_window_title(&*title);
self.ui_context.set_window_title(&title);
} else if let Ok((filename, _)) = glib::filename_from_uri(&uri) {
self.ui_context
.set_window_title(&filename.as_os_str().to_string_lossy());
Expand Down Expand Up @@ -625,20 +625,20 @@ impl VideoPlayer {
if l == title {
"".to_string()
} else {
format!(" - [{}]", l)
format!(" - [{l}]")
}
});

let action_label = format!("{}{}", title, lang.unwrap_or_else(|| "".to_string()));
let action_id = format!("app.subtitle::sub-{}", i);
let action_label = format!("{}{}", title, lang.unwrap_or_default());
let action_id = format!("app.subtitle::sub-{i}");
let item = gio::MenuItem::new(Some(&action_label), Some(&action_id));
item.set_detailed_action(&*action_id);
item.set_detailed_action(&action_id);
section.append_item(&item);

if selected_action.is_none() {
if let Some(ref track) = current_subtitle_track {
if track.language() == sub_stream.language() {
selected_action = Some(format!("sub-{}", i));
selected_action = Some(format!("sub-{i}"));
}
}
}
Expand All @@ -650,10 +650,10 @@ impl VideoPlayer {
let subfile = path.as_path();
if let Some(filename) = subfile.file_name() {
if let Some(f) = filename.to_str() {
let v = format!("ext-{}", uri);
let action_id = format!("app.subtitle::{}", v);
let v = format!("ext-{uri}");
let action_id = format!("app.subtitle::{v}");
let item = gio::MenuItem::new(Some(f), Some(&action_id));
item.set_detailed_action(&*action_id);
item.set_detailed_action(&action_id);
section.append_item(&item);
selected_action = Some(v);
}
Expand Down Expand Up @@ -683,7 +683,7 @@ impl VideoPlayer {
for vis in gst_player::Player::visualizations_get() {
let action_id = format!("app.audio-visualization::{}", vis.name());
let item = gio::MenuItem::new(Some(vis.description()), Some(&action_id));
item.set_detailed_action(&*action_id);
item.set_detailed_action(&action_id);
section.append_item(&item);
}

Expand All @@ -700,11 +700,11 @@ impl VideoPlayer {
for (i, audio_stream) in info.audio_streams().iter().enumerate() {
let mut label = format!("{} channels", audio_stream.channels());
if let Some(l) = audio_stream.language() {
label = format!("{} - [{}]", label, l);
label = format!("{label} - [{l}]");
}
let action_id = format!("app.audio-track::audio-{}", i);
let action_id = format!("app.audio-track::audio-{i}");
let item = gio::MenuItem::new(Some(&label), Some(&action_id));
item.set_detailed_action(&*action_id);
item.set_detailed_action(&action_id);
section.append_item(&item);
}
self.ui_context.update_audio_track_menu(&section);
Expand All @@ -718,10 +718,10 @@ impl VideoPlayer {
section.append_item(&item);

for (i, video_stream) in info.video_streams().iter().enumerate() {
let action_id = format!("app.video-track::video-{}", i);
let action_id = format!("app.video-track::video-{i}");
let description = format!("{}x{}", video_stream.width(), video_stream.height());
let item = gio::MenuItem::new(Some(&description), Some(&action_id));
item.set_detailed_action(&*action_id);
item.set_detailed_action(&action_id);
section.append_item(&item);
}
self.ui_context.update_video_track_menu(&section);
Expand Down
6 changes: 3 additions & 3 deletions src/ui_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl UIContext {
("dump-pipeline", ["<Ctrl>d"]),
];
for (action, accels) in accels_per_action.iter() {
app.set_accels_for_action(&format!("app.{}", action), accels);
app.set_accels_for_action(&format!("app.{action}"), accels);
}

if let Some(window) = window_weak.upgrade() {
Expand Down Expand Up @@ -456,8 +456,8 @@ impl UIContext {
}

pub fn set_video_area(&self, video_area: &gtk::Widget) {
self.main_box.pack_start(&*video_area, true, true, 0);
self.main_box.reorder_child(&*video_area, 0);
self.main_box.pack_start(video_area, true, true, 0);
self.main_box.reorder_child(video_area, 0);
video_area.show();
}

Expand Down

0 comments on commit b82cdc7

Please sign in to comment.