~ubuntu-branches/ubuntu/karmic/gmusicbrowser/karmic

« back to all changes in this revision

Viewing changes to gmusicbrowser.pl

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Soyez
  • Date: 2008-11-09 22:17:04 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081109221704-gcbxbmfc29mwfxxv
Tags: 1.0-0ubuntu1
New upstream version. (LP: #273697)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *Gtk2::Notebook::set_tab_reorderable=  sub {} unless *Gtk2::Notebook::set_tab_reorderable{CODE};
29
29
 *Gtk2::AboutDialog::set_url_hook=      sub {} unless *Gtk2::AboutDialog::set_url_hook{CODE};   #for perl-Gtk2 version <1.080~1.083
30
30
 *Gtk2::Label::set_ellipsize=           sub {} unless *Gtk2::Label::set_ellipsize{CODE};        #for perl-Gtk2 version <1.080~1.083
 
31
 *Gtk2::Pango::Layout::set_height=      sub {} unless *Gtk2::Pango::Layout::set_height{CODE};   #for perl-Gtk2 version <1.180  pango <1.20
31
32
 my $set_clip_rectangle_orig=\&Gtk2::Gdk::GC::set_clip_rectangle;
32
33
 *Gtk2::Gdk::GC::set_clip_rectangle=sub { goto $set_clip_rectangle_orig if $_[1]; } if $Gtk2::VERSION <1.102; #work-around $rect can't be undef in old bindings versions
33
34
}
56
57
{
57
58
 TRUE  => 1,
58
59
 FALSE => 0,
59
 
 VERSION => '0.964',
 
60
 VERSION => '1.0',
60
61
 PIXPATH => $DATADIR.SLASH.'pix'.SLASH,
61
62
 PROGRAM_NAME => 'gmusicbrowser',
62
63
 
354
355
$DRAGTYPES{$DRAGTYPES[$_][0]}=$_ for DRAG_FILE,DRAG_USTRING,DRAG_STRING,DRAG_ID,DRAG_ARTIST,DRAG_ALBUM,DRAG_FILTER,DRAG_MARKUP;
355
356
 
356
357
our @submenuRemove=
357
 
(       { label => _"Remove from list", code => sub { $_[0]{self}->RemoveSelected; }, mode => 'BL'},
 
358
(       { label => _"Remove from list", code => sub { $_[0]{self}->RemoveSelected; }, mode => 'BLQ'},
358
359
#(      { label => _"Remove from list', code => sub { $_[0]{self}->RemoveID(@{ $_[0]{IDs} }); }, mode => 'B'},
359
360
        { label => _"Remove from library",      code => sub { SongsRemove($_[0]{IDs}); }, },
360
361
        { label => _"Remove from disk",         code => sub { DeleteFiles($_[0]{IDs}); },       test => sub {!$CmdLine{ro}},    stockicon => 'gtk-delete' },
902
903
        ChangeDisplay   => [\&ChangeDisplay,                    _"Change Display",_"Display (:1 or host:0 for example)",qr/:\d/],
903
904
        GoToCurrentSong => [\&Layout::GoToCurrentSong,          _"Select current song"],
904
905
        EnqueueSelected => [\&Layout::EnqueueSelected,          _"Enqueue Selected Songs"],
 
906
        EnqueueArtist   => [sub {EnqueueArtist($SongID)},       _"Enqueue Songs from Current Artist"],
 
907
        EnqueueAlbum    => [sub {EnqueueAlbum($SongID)},        _"Enqueue Songs from Current Album"],
905
908
        EnqueueAction   => [sub {EnqueueAction($_[1])},         _"Enqueue Action", _"Queue mode" ,sub { TextCombo->new({map {$_ => $QActions{$_}[2]} sort keys %QActions}) }],
906
909
        ClearQueue      => [\&::ClearQueue,                     _"Clear queue"],
907
910
        IncVolume       => [sub {ChangeVol('up')},              _"Increase Volume"],
937
940
        #system @cmd;
938
941
        my @cmd=grep defined, $syscmd=~m/(?:(?:"(.*[^\\])")|([^ ]*[^ \\]))(?: |$)/g;
939
942
        return unless @cmd;
 
943
        if ($syscmd=~m/%F/)
 
944
        {       my @files;
 
945
                if ($_[0] and my $songlist=GetSonglist($_[0])) { @files=map $Songs[$_][SONG_PATH].SLASH.$Songs[$_][SONG_FILE], $songlist->GetSelectedIDs; }
 
946
                unless (@files) { warn "Not executing '$syscmd' because no song is selected in the current window\n"; return }
 
947
                @cmd=map { $_ ne '%F' ? $_ : @files } @cmd ;
 
948
        }
940
949
        if (defined $SongID) { $_=ReplaceFields($SongID,$_) for @cmd; }
941
950
        forksystem(@cmd);
942
951
}
1348
1357
        $slider=$slider->new($adj);
1349
1358
        $slider->set_draw_value(FALSE) if $opt1->{hide};
1350
1359
        $slider->set_digits(0);
1351
 
        $slider->set_inverted(TRUE);
 
1360
        $slider->set_inverted(TRUE) unless $opt1->{horizontal};
1352
1361
        $slider->signal_connect(value_changed => sub { UpdateVol($_[0]->get_value); 1; });
1353
1362
        return $slider
1354
1363
}
1837
1846
}
1838
1847
 
1839
1848
sub UpdateTime
1840
 
{       return if defined $PlayTime && $_[0] eq $PlayTime;
 
1849
{       return if defined $PlayTime && $_[0] == $PlayTime;
1841
1850
        $PlayTime=$_[0];
1842
1851
        HasChanged('Time');
1843
1852
}
1871
1880
        }
1872
1881
 
1873
1882
        return unless defined $PlayTime;
1874
 
        $PlayedPartial=$PlayTime-$StartedAt < $Options{PlayedPercent}*$Songs[$ID][SONG_LENGTH];
 
1883
        $PlayedPartial= $PlayTime-$StartedAt < $Options{PlayedPercent}*$Songs[$ID][SONG_LENGTH];
1875
1884
        if ($PlayedPartial) #FIXME maybe only count as a skip if played less than ~20% ?
1876
1885
        {       $Songs[$ID][SONG_NBSKIP]++;
1877
1886
                $Songs[$ID][SONG_LASTSKIP]=$StartTime;
1923
1932
sub Enqueue
1924
1933
{       my @l=@_;
1925
1934
        SortList(\@l) if @l>1;
1926
 
        #@l=grep $_!=$SongID, @l  if @l>1 && defined $SongID; #good idea ?
 
1935
        @l=grep $_!=$SongID, @l  if @l>1 && defined $SongID;
1927
1936
        push @Queue,@l;
1928
1937
        # ToggleLock($TogLock) if $TogLock;     #unset lock
1929
1938
        HasChanged(Queue=>'push');
2121
2130
                $list=[@ListPlay[0..$pos],@list,@ListPlay[$pos+1..$#ListPlay]];
2122
2131
                Select( song=>'trykeep', staticlist => $list );
2123
2132
        }
2124
 
        elsif ($action eq 'queue') { EnQueue(@list) }
 
2133
        elsif ($action eq 'queue') { Enqueue(@list) }
2125
2134
        elsif ($action eq 'replacequeue') { ReplaceQueue(@list) }
2126
2135
}
2127
2136
 
4829
4838
        $dialog->set_copyright("Copyright � 2005-2008 Quentin Sculo");
4830
4839
        #$dialog->set_comments();
4831
4840
        $dialog->set_license("Released under the GNU General Public Licence version 3\n(http://www.gnu.org/copyleft/gpl.html)");
4832
 
        $dialog->set_website('http://squentin.free.fr/gmusicbrowser/gmusicbrowser.html');
 
4841
        $dialog->set_website('http://gmusicbrowser.sourceforge.net/');
4833
4842
        $dialog->set_authors('Quentin Sculo <squentin@free.fr>');
4834
4843
        $dialog->set_artists("tango icon theme : Jean-Philippe Guillemin\n tray icon for the tango theme by Piotr");
4835
 
        $dialog->set_translator_credits("French : Quentin Sculo\nHungarian : Zsombor\nSpanish : Martintxo\nGerman : vlad <donvla\@users.sourceforge.net> & staubi <staubi\@linuxmail.org>\nPolish : tizzilzol team");
 
4844
        $dialog->set_translator_credits("French : Quentin Sculo\nHungarian : Zsombor\nSpanish : Martintxo and Juanjo\nGerman : vlad <donvla\@users.sourceforge.net> & staubi <staubi\@linuxmail.org>\nPolish : tizzilzol team");
4836
4845
        $dialog->signal_connect( response => sub { $_[0]->destroy if $_[1] eq 'cancel'; }); #used to worked without this, see http://mail.gnome.org/archives/gtk-perl-list/2006-November/msg00035.html
4837
4846
        $dialog->show_all;
4838
4847
}
7206
7215
  @FLIST=
7207
7216
  (     _"Title",
7208
7217
        [       _"contains %s",         ::SONG_TITLE.'s%s',
7209
 
                _"doesn't contains %s", '-'.::SONG_TITLE.'s%s',
 
7218
                _"doesn't contain %s",  '-'.::SONG_TITLE.'s%s',
7210
7219
                _"is %s",               ::SONG_TITLE.'~%s',
7211
7220
                _"is not %s",           '-'.::SONG_TITLE.'~%s',
7212
7221
                _"match regexp %r",     ::SONG_TITLE.'m%r',
7214
7223
        ],
7215
7224
        _"Artist",
7216
7225
        [       _"contains %s",         ::SONG_ARTIST.'s%s',
7217
 
                _"doesn't contains %s", '-'.::SONG_ARTIST.'s%s',
 
7226
                _"doesn't contain %s",  '-'.::SONG_ARTIST.'s%s',
7218
7227
                _"is %s",               ::SONG_ARTIST.'~%s',
7219
7228
                _"is not %s",           '-'.::SONG_ARTIST.'~%s',
7220
7229
                _"match regexp %r",     ::SONG_ARTIST.'m%r',
7222
7231
        ],
7223
7232
        _"Album",
7224
7233
        [       _"contains %s",         ::SONG_ALBUM.'s%s',
7225
 
                _"doesn't contains %s", '-'.::SONG_ALBUM.'s%s',
 
7234
                _"doesn't contain %s",  '-'.::SONG_ALBUM.'s%s',
7226
7235
                _"is %s",               ::SONG_ALBUM.'e%s',
7227
7236
                _"is not %s",           '-'.::SONG_ALBUM.'e%s',
7228
7237
                _"match regexp %r",     ::SONG_ALBUM.'m%r',
7341
7350
        [       _"is %g",               ::SONG_GENRE.'f%s',
7342
7351
                _"isn't %g",            '-'.::SONG_GENRE.'f%s',
7343
7352
                _"contains %s",         ::SONG_GENRE.'s%s',
7344
 
                _"doesn't contains %s", '-'.::SONG_GENRE.'s%s',
 
7353
                _"doesn't contain %s",  '-'.::SONG_GENRE.'s%s',
7345
7354
                _"(: )none",            ::SONG_GENRE.'e',
7346
7355
                _"(: )has one",         '-'.::SONG_GENRE.'e',
7347
7356
        ],
7349
7358
        [       _"%f is set",           ::SONG_LABELS.'f%s',
7350
7359
                _"%f isn't set",        '-'.::SONG_LABELS.'f%s',
7351
7360
                _"contains %s",         ::SONG_LABELS.'s%s',
7352
 
                _"doesn't contains %s", '-'.::SONG_LABELS.'s%s',
 
7361
                _"doesn't contain %s",  '-'.::SONG_LABELS.'s%s',
7353
7362
                _"(: )none",            ::SONG_LABELS.'e',
7354
7363
                _"(: )has one",         '-'.::SONG_LABELS.'e',
7355
7364
        ],
7356
7365
        _"Filename",
7357
7366
        [       _"contains %s",         ::SONG_UFILE.'s%s',
7358
 
                _"doesn't contains %s", '-'.::SONG_UFILE.'s%s',
 
7367
                _"doesn't contain %s",  '-'.::SONG_UFILE.'s%s',
7359
7368
                _"is %s",               ::SONG_UFILE.'e%s',
7360
7369
                _"is not %s",           '-'.::SONG_UFILE.'e%s',
7361
7370
                _"match regexp %r",     ::SONG_UFILE.'m%r',
7363
7372
        ],
7364
7373
        _"Folder",
7365
7374
        [       _"contains %s",         ::SONG_UPATH.'s%s',
7366
 
                _"doesn't contains %s", '-'.::SONG_UPATH.'s%s',
 
7375
                _"doesn't contain %s",  '-'.::SONG_UPATH.'s%s',
7367
7376
                _"is %s",               ::SONG_UPATH.'e%s',
7368
7377
                _"is not %s",           '-'.::SONG_UPATH.'e%s',
7369
7378
                _"is in %s",            ::SONG_UPATH.'i%s',
7373
7382
        ],
7374
7383
        _"Comment",
7375
7384
        [       _"contains %s",         ::SONG_COMMENT.'s%s',
7376
 
                _"doesn't contains %s", '-'.::SONG_COMMENT.'s%s',
 
7385
                _"doesn't contain %s",  '-'.::SONG_COMMENT.'s%s',
7377
7386
                _"is %s",               ::SONG_COMMENT.'e%s',
7378
7387
                _"is not %s",           '-'.::SONG_COMMENT.'e%s',
7379
7388
                _"match regexp %r",     ::SONG_COMMENT.'m%r',
7381
7390
        ],
7382
7391
        _"Version",
7383
7392
        [       _"contains %s",         ::SONG_VERSION.'s%s',
7384
 
                _"doesn't contains %s", '-'.::SONG_VERSION.'s%s',
 
7393
                _"doesn't contain %s",  '-'.::SONG_VERSION.'s%s',
7385
7394
                _"is %s",               ::SONG_VERSION.'e%s',
7386
7395
                _"is not %s",           '-'.::SONG_VERSION.'e%s',
7387
7396
                _"match regexp %r",     ::SONG_VERSION.'m%r',
7913
7922
  %NGrepSubs=
7914
7923
  (     t => sub
7915
7924
             {  my ($n,$pat,$lref,$assign,$inv)=@_;
7916
 
                $inv=$inv ? "$pat..(($pat>@\$tmp)? $pat : \$#\$tmp)"
 
7925
                $inv=$inv ? "$pat..(($pat>@\$tmp)? 0 : \$#\$tmp)"
7917
7926
                          :    "0..(($pat>@\$tmp)? \$#\$tmp : ".($pat-1).')';
7918
7927
                return "\$tmp=$lref;::SortList(\$tmp,$n);$assign @\$tmp[$inv];";
7919
7928
             },
7920
7929
        h => sub
7921
7930
             {  my ($n,$pat,$lref,$assign,$inv)=@_;
7922
 
                $inv=$inv ? "$pat..(($pat>@\$tmp)? $pat : \$#\$tmp)"
 
7931
                $inv=$inv ? "$pat..(($pat>@\$tmp)? 0 : \$#\$tmp)"
7923
7932
                          :    "0..(($pat>@\$tmp)? \$#\$tmp : ".($pat-1).')';
7924
7933
                return "\$tmp=$lref;::SortList(\$tmp,-$n);$assign @\$tmp[$inv];";
7925
7934
             },