#!/usr/bin/perl #H# This does the same thing as 'mp3db info -current' however it does it in a nice #H# Tk based window. #H# There are no parameters to this program. # print out help info if requested if ($ARGV[0] ne "") { open (SELF, $0); while () { if ($_ =~ /^#H# /) { $_ =~ s/^#H# //; print $_; } } exit; } # now for some Tk stuff... use Tk; # make window $mw = MainWindow->new; # set the font $mw->fontCreate('textfont', -family => 'moulinrouge', -size => 17); #$mw->fontCreate('textfont', -family => 'meath', -size => 21); #$mw->fontCreate('textfont', -family => 'courier', -size => 18); # set the default colors $mw->setPalette(background => 'Black', foreground => 'Green'); # set the window title $mw->title("Music Information Database"); open (INFO, "mp3db info -current 2>\&1 |"); while () { $Line=$_; chomp $Line; if ($Line eq "File not found in database!") { $mw->Label(-text=>$Line, -font => 'textfont')->pack(-side => 'top'); } else { # Fix up the allignment by adding some tabs $Line =~ s/FileName:\t/FileName:\t\t/; $Line =~ s/Category:\t/Category:\t\t/; $Line =~ s/AC3Size:\t/AC3Size:\t\t/; $Line =~ s/AACSize:\t/AACSize:\t\t/; $Line =~ s/MP3Size:\t/MP3Size:\t\t/; $Line =~ s/OGGSize:\t/OGGSize:\t\t/; $Line =~ s/FLACSize:\t/FLACSize:\t\t/; $Line =~ s/Playlists:\t/Playlists:\t\t/; # Need an extra tab added here $Line =~ s/:\t/:\t\t/; # Split up the 2 halves of the line so the values are all selectable if ($Line =~ /^(.*:\s+)(.*)/) { $Label=$1; $Value=$2; } # Throw in a "none" instead of an empty field if null if ($Value eq "") { $Value="none"; } # Make a frame to keep the 2 label and value pairs side by side. $Frame=$mw->Frame->pack(-anchor => 'w', -fill => 'x'); $Frame->Label(-text=>$Label, -font => 'textfont')->pack(-side => 'left'); $Frame->Entry(-text=>$Value, -font => 'textfont', -takefocus => 0, -selectbackground => 'Blue', -relief => 'flat', -width => 0)->pack(-side => 'left'); } } close (INFO); # Simply exit if the OK button is hit $mw->Button(-foreground => 'Black', -activeforeground => 'Black', -background => 'Dark Red', -activebackground => 'Red', -font => 'textfont', -text=>"Exit", -command=>sub { exit } )->pack(-anchor => 'center'); # Silly command that MUST be here for ANY Tk stuff to do ANYTHING. MainLoop;