Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
gtk: added the right-click "Play as audio" entry.
Browse files Browse the repository at this point in the history
Will play the selected video as audio with CLI straw-viewer in a new terminal.
  • Loading branch information
trizen committed Oct 15, 2020
1 parent 7f81e14 commit 3bd20cf
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions bin/gtk-straw-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#-------------------------------------------------------
# GTK Straw Viewer
# Fork: 14 February 2020
# Edit: 06 October 2020
# Edit: 15 October 2020
# https://github.com/trizen/straw-viewer
#-------------------------------------------------------

Expand Down Expand Up @@ -1336,6 +1336,23 @@ sub menu_popup {
$menu->append($item);
}

# Play as audio
{
my $item = 'Gtk3::ImageMenuItem'->new("Play as audio");
$item->signal_connect(
activate => sub {
my ($video_id, $iter) = get_selected_entry_code();
if (defined($video_id) and $liststore->get($iter, 7) eq 'video') {
execute_cli_straw_viewer("--id=$video_id --no-video");
}
}
);
$item->set_property(tooltip_text => "Play as audio in a new terminal");
$item->set_image('Gtk3::Image'->new_from_icon_name("multimedia-audio-player", q{menu}));
$item->show;
$menu->append($item);
}

# Play with CLI straw-viewer
{
my $item = 'Gtk3::ImageMenuItem'->new("Play in terminal");
Expand Down Expand Up @@ -3118,13 +3135,12 @@ sub run_cli_straw_viewer {
sub get_options_as_arguments {
my @args;
my %options = (
'no-interactive' => q{},
'resolution' => $CONFIG{resolution},
'download-dir' => quotemeta(rel2abs($CONFIG{downloads_dir})),
'fullscreen' => $CONFIG{fullscreen} ? q{} : undef,
'no-dash' => $CONFIG{dash_support} ? undef : q{},
'no-video' => $CONFIG{audio_only} ? q{} : undef,
'resolution=audio' => $CONFIG{audio_only} ? q{} : undef,
'no-interactive' => q{},
'resolution' => $CONFIG{resolution},
'download-dir' => quotemeta(rel2abs($CONFIG{downloads_dir})),
'fullscreen' => $CONFIG{fullscreen} ? q{} : undef,
'no-dash' => $CONFIG{dash_support} ? undef : q{},
'no-video' => $CONFIG{audio_only} ? q{} : undef,
);

while (my ($argv, $value) = each %options) {
Expand Down

0 comments on commit 3bd20cf

Please sign in to comment.