📄 mplayertv
字号:
$item->select; $self->{channels} = \@channels; }}### Configuration/Channels page, callback function for new channel buttonsub NewBtn{ my ($btn, $self) = @_; my $name = $self->{name_ent}->get_text ne "" ? $self->{name_ent}->get_text : "Unnamed"; my $brightness = $self->{brightness_spin}->get_text ne "" ? $self->{brightness_spin}->get_text : "0"; my $contrast = $self->{contrast_spin}->get_text ne "" ? $self->{contrast_spin}->get_text : "0"; my $hue = $self->{hue_spin}->get_text ne "" ? $self->{hue_spin}->get_text : "0"; my $saturation = $self->{saturation_spin}->get_text ne "" ? $self->{saturation_spin}->get_text : "0"; my $volume = $self->{volume_spin}->get_text ne "" ? $self->{volume_spin}->get_text : "0"; if ($name eq "defaults" || $name eq "global") { my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "'defaults' and 'global' are invalid names!"); $dialog->run; $dialog->destroy; return; } $name =~ s/ /_/g; if ($name !~ /^[_a-zA-Z0-9]+$/) { my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Invalid channel name! Only alphanumeric characters are allowed."); $dialog->run; $dialog->destroy; return; } $self->{name_ent}->set_text ($name); my $channel = $self->{channel_ent}->get_text ne "" ? $self->{channel_ent}->get_text : "1"; my $item = new Gtk2::ListItem ($name); $item->{name} = $name; my @channels = @{$self->{channels}}; $item->{number} = $#channels + 2; $item->{channel} = $channel; $item->{brightness} = $brightness; $item->{contrast} = $contrast; $item->{hue} = $hue; $item->{saturation} = $saturation; $item->{volume} = $volume; $item->signal_connect ('select', \&select_channel_item, $self); $self->{name_list}->add ($item); push @{$self->{channels}}, $item; $item->show;}### Configuration/Channels page, callback function for modify channel buttonsub ModifyBtn{ my ($btn, $self) = @_; my $name = $self->{name_ent}->get_text; my $brightness = $self->{brightness_spin}->get_text ne "" ? $self->{brightness_spin}->get_text : "0"; my $contrast = $self->{contrast_spin}->get_text ne "" ? $self->{contrast_spin}->get_text : "0"; my $hue = $self->{hue_spin}->get_text ne "" ? $self->{hue_spin}->get_text : "0"; my $saturation = $self->{saturation_spin}->get_text ne "" ? $self->{saturation_spin}->get_text : "0"; my $volume = $self->{volume_spin}->get_text ne "" ? $self->{volume_spin}->get_text : "0"; if ($name eq "defaults" || $name eq "global") { my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "'defaults' and 'global' are invalid names!"); $dialog->run; $dialog->destroy; return; } $name =~ s/ /_/g; if ($name !~ /^[_a-zA-Z0-9]+$/) { my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Invalid channel name! Only alphanumeric are characters allowed."); $dialog->run; $dialog->destroy; return; } $self->{name_ent}->set_text ($name); my $channel = $self->{channel_ent}->get_text; my $item = $self->{selected_channel}; return unless defined ($item); $item->{name} = $name; $item->{channel} = $channel; $item->{brightness} = $brightness; $item->{contrast} = $contrast; $item->{hue} = $hue; $item->{saturation} = $saturation; $item->{volume} = $volume; my $label = $item->get_children; $label->set_label ($name); $item->signal_connect ('select', \&select_channel_item, $self); #$self->{name_list}->add ($item); $item->show;}### Configuration/Channels page, callback function for delete channel buttonsub DeleteBtn{ my ($btn, $self) = @_; my $item = $self->{selected_channel}; if (defined ($item)) { $pos = $self->{name_list}->child_position ($item); $self->{name_list}->remove ($item); splice (@{$self->{channels}}, $pos, 1); }}### Configuration/Channels page, callback function for delete all channel buttonsub DeleteAllBtn{ my ($btn, $self) = @_; my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_YES_NO, "Do you want to delete all channels?" ); if ($dialog->run () eq "yes") { $self->{selected_channel} = undef; $self->{name_list}->foreach (sub { my ($item, $self) = @_; $self->{name_list}->remove ($item); }, $self); $self->{name_list}->remove ($item) if defined ($item); @{$self->{channels}} = (); } $dialog->destroy;}sub scantv_callback{ my ($scantv_dialog, $channel, $freq, $channel_name) = @_; $scantv_dialog->set_label ("Channel: $channel ($freq)"); if ($channel_name ne "no station") { $channel_name = "unknown_$channel" if ($channel_name eq "???"); $scantv_dialog->set_label2 ("New station: $channel_name"); }}sub scantv_exit{ my ($self) = @_; print "Reading scantv output file...\n"; my $config = MyConfigFile::read_config_file ($cfg); # if -r $cfg; TODO my @folders = @{$config->{_folders}}; foreach (@folders) { next if ($_ eq "defaults" || $_ eq "global"); my $name = $_; my $channel = $config->{"_$_"}->{channel}; my $exists = 0; foreach $ch (@{$self->{channels}}) { if ($ch->{channel} eq $channel) { #print "$channel exists!\n"; $exists = 1; } } next if ($exists); # adding new channel item to channel list... my $item = new Gtk2::ListItem ($name); $item->{name} = $name; $item->{channel} = $channel; $item->{brightness} = 0; $item->{contrast} = 0; $item->{hue} = 0; $item->{saturation} = 0; $item->{volume} = 0; $item->signal_connect ('select', \&select_channel_item, $self); $self->{name_list}->add ($item); push @{$self->{channels}}, $item; $item->show; } # deleting temporary file unlink $cfg; # running mplayer if needed $self->{app}->start_mplayer ($self->{app}) if ($self->{mplayer_running}); $self->{scantv_dialog}->destroy ();}### Configuration/Channels page, callback function for scan buttonsub ScantvBtn{ my ($btn, $self) = @_; my $cfg = "/tmp/mplayertv_chan_list"; my $norm = get_option_menu_text ($self->{norm_option}); my $chan_list = get_option_menu_text ($self->{channel_list_option}); my $prg; my $vbi = "/dev/vbi"; $vbi = "/dev/vbi0" unless (-f $vbi); # Quick workaround if /dev/vbi isn't exists my $tv_device = $self->{config}->{tv_device}; # TODO: getting and interpreting output of scantv # Quick workaround for '/dev/vbi0: Device or resource busy' bug my $dialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "May I use teletext interface ($vbi) to get channel names?\n" . "Notice: If you see 'Device or resource busy' error message, choose next time no!" ); if ($dialog->run () ne "yes") { $vbi = "/dev/null"; } $dialog->destroy; if ($terminal_path =~ /gnome-terminal/) { # gnome-terminal incompatible with other terminal emulators (-e switch, Bug 152717) $prg = "$terminal_path \"-e sh -c '$scantv_path -f $chan_list -n $norm -o $cfg; sleep 2'\""; } else { $prg = "$terminal_path -e sh -c '$scantv_path -f $chan_list -n $norm -o $cfg -c $tv_device -C $vbi; sleep 2'"; } my $mplayer_running = $self->{app}->mplayer_running ($self->{app}); print "chan_list: $chan_list\n" if ($verbose_level >= 2); print "norm: $norm\n" if ($verbose_level >= 2); print "cfg: $cfg\n" if ($verbose_level >= 2); $self->{app}->stop_mplayer ($self->{app}); print "*** [mplayerTV] Running: $prg\n" if ($verbose_level >= 1); @output = `$prg`; print "\n", @output, "\n" if ($verbose_level >= 2); if (!-r $cfg) { print "*** [mplayerTV] Can't read output of scantv: $!\n" if ($verbose_level >= 1); my $errdialog = new Gtk2::MessageDialog ($self->{window}, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Can't read output of scantv!\nscantv not installed or not executable by user." ); $errdialog->run; $errdialog->destroy; return undef; } my $config = MyConfigFile::read_config_file ($cfg) if -r $cfg; my @folders = @{$config->{_folders}}; foreach (@folders) { next if ($_ eq "defaults" || $_ eq "global"); my $name = $_; my $channel = $config->{"_$_"}->{channel}; my $exists = 0; foreach $ch (@{$self->{channels}}) { if ($ch->{channel} eq $channel) { #print "$channel exists!\n"; $exists = 1; } } next if ($exists); # adding new channel item to channel list... my $item = new Gtk2::ListItem ($name); $item->{name} = $name; $item->{channel} = $channel; $item->{brightness} = 0; $item->{contrast} = 0; $item->{hue} = 0; $item->{saturation} = 0; $item->{volume} = 0; $item->signal_connect ('select', \&select_channel_item, $self); $self->{name_list}->add ($item); push @{$self->{channels}}, $item; $item->show; } unlink $cfg; $self->{app}->start_mplayer ($self->{app}) if ($mplayer_running); return 1;}### Configuration/General page, callback function for browse button#sub MplayerBrowseBtn#{# my ($btn, $self) = @_;# my $mplayer_browser = Gtk2::FileSelection->new ("Select mplayer");# $mplayer_browser->ok_button->signal_connect (clicked => sub {# $self->{mplayer_path_ent}->set_text ($mplayer_browser->get_filename); # $mplayer_browser->destroy; # update_vo_drivers_list ();# });# $mplayer_browser->cancel_button->signal_connect (clicked => sub {$mplayer_browser->destroy});# $mplayer_browser->show_all;#}### Configuration/General page, callback function for browse buttonsub TerminalEmulatorBrowseBtn{ my ($btn, $self) = @_; my $terminal_browser = Gtk2::FileSelection->new ("Select terminal emulator"); $terminal_browser->ok_button->signal_connect (clicked => sub { $self->{terminal_emulator_ent}->set_text ($terminal_browser->get_filename); $terminal_browser->destroy; }); $terminal_browser->cancel_button->signal_connect (clicked => sub {$terminal_browser->destroy}); $terminal_browser->show_all;}### Configuration/General page, callback function for browse bu
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -