~ubuntu-branches/ubuntu/trusty/gmusicbrowser/trusty-proposed

« back to all changes in this revision

Viewing changes to gmusicbrowser_layout.pm

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2014-03-08 06:19:26 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20140308061926-853dpa53gr1yy8lu
Tags: 1.1.12-1
* New upstream release
* debian/rules: Use make distclean rather than make clean
* debian/control:
  - Add myself to uploaders
  - Add build-depends on markdown

Show diffs side-by-side

added added

removed removed

Lines of Context:
770
770
 
771
771
sub ReadLayoutFile
772
772
{       my $file=shift;
773
 
        my $path=$file; $path=~s#[^/]+$##;
774
773
        return unless -f $file;
775
774
        open my$fh,"<:utf8",$file  or do { warn $!; return };
776
775
        my $first;
 
776
        my $linecount=0; my ($linefirst,$linenext);
777
777
        while (1)
778
778
        {       my ($next,$longline);
779
779
                my @lines=($first);
780
780
                while (local $_=<$fh>)
781
 
                {       s#^\s+##;
 
781
                {       $linecount++;
 
782
                        s#^\s+##;
782
783
                        next if m/^#/;
783
784
                        s#\s*[\n\r]+$##;
784
785
                        if (s#\\$##) {$longline.=$_;next}
785
786
                        next if $_ eq '';
786
787
                        if ($longline) {$_=$longline.$_;undef $longline;}
787
 
                        if (m#^[{[]#) {$next=$_;last}
 
788
                        if (m#^[{[]#) { $next=$_; $linenext=$linecount; last}
788
789
                        push @lines,$_;
789
790
                }
790
791
                if ($first)
791
 
                {       if ($first=~m#^\[#) {ParseLayout(\@lines,$path)}
 
792
                {       if ($first=~m#^\[#) {ParseLayout(\@lines,$file,$linefirst)}
792
793
                        else            {ParseSongTreeSkin(\@lines)}
793
794
                }
794
 
                $first=$next;
 
795
                $first=$next; $linefirst=$linenext;
795
796
                last unless $first;
796
797
        }
797
798
        close $fh;
798
799
}
799
800
 
800
801
sub ParseLayout
801
 
{       my ($lines,$path)=@_;
 
802
{       my ($lines,$file,$line)=@_;
802
803
        my $first=shift @$lines;
803
804
        my $name;
804
805
        if ($first=~m/^\[([^]=]+)\](?:\s*based on (.+))?$/)
822
823
        for my $key (qw/Name Category Title/)
823
824
        {       $Layouts{$name}{$key}=~s/^"(.*)"$/$1/ if $Layouts{$name}{$key}; #remove quotes from layout name and category
824
825
        }
 
826
        my $path=$file; $path=~s#([^/]+)$##; $file=$1;
825
827
        $Layouts{$name}{PATH}=$path;
 
828
        $Layouts{$name}{FILE}=$file;
 
829
        $Layouts{$name}{LINE}=$line;
826
830
}
827
831
 
828
832
sub ParseSongTreeSkin
871
875
                %default= @optlist;
872
876
        }
873
877
        $_=::ParseOptions($_) for values %default;
 
878
        $default{DEFAULT_OPTIONS}=1;
 
879
        $default{Window}{DEFAULT_OPTIONS}=1;
874
880
        return \%default;
875
881
}
876
882
 
1815
1821
        my (undef,undef,$monitorwidth,$monitorheight)=$screen->get_monitor_geometry($monitor)->values;
1816
1822
        $w= $1*$monitorwidth/100 if $w=~m/(\d+)%/;
1817
1823
        $h= $1*$monitorheight/100 if $h=~m/(\d+)%/;
 
1824
        if ($self->{options}{DEFAULT_OPTIONS}) { $monitorwidth-=40; $monitorheight-=80; } # if using default layout size, reserve some space for potential panels and decorations
 
1825
        $w=$monitorwidth if $w>$monitorwidth;
 
1826
        $h=$monitorheight if $h>$monitorheight;
1818
1827
        if ($self->{fixedsize})
1819
1828
        {       $w=-1 if $w<1;  # -1 => do not override default minimum size
1820
1829
                $h=-1 if $h<1;
2594
2603
}
2595
2604
 
2596
2605
sub newbutton_cb
2597
 
{        my $self= ::find_ancestor($_[0],__PACKAGE__);
 
2606
{       my $self= ::find_ancestor($_[0],__PACKAGE__);
2598
2607
        ::PopupContextMenu(\@contextmenu, { self=>$self, type=>$self->{typesubmenu}, usemenupos=>1 } );
2599
2608
        1;
2600
2609
}
4057
4066
        }
4058
4067
}
4059
4068
sub SaveOptions
4060
 
{       my $self=shift,
 
4069
{       my $self=shift;
4061
4070
        my %opt;
4062
4071
        if (my $cats=$self->{cats})
4063
4072
        {       $opt{collapsed}= $self->{collapsed}= join ' ', sort grep !$cats->{$_}->get_expanded, keys %$cats;