Author: sparky                       Date: Tue Nov  1 00:16:26 2005 GMT
Module: vfmg                          Tag: DEVEL
---- Log message:
- checking options dependencies
- resolve ${HOME} in .vfmgrc
- killed >80 long lines

---- Files affected:
vfmg:
   vfmg (1.73.2.16 -> 1.73.2.17) 

---- Diffs:

================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.73.2.16 vfmg/vfmg:1.73.2.17
--- vfmg/vfmg:1.73.2.16 Mon Oct 31 23:51:43 2005
+++ vfmg/vfmg   Tue Nov  1 01:16:21 2005
@@ -17,7 +17,7 @@
        icons           => 1,
        icons_full      => 0,
        icons_scale     => 0,
-#      icons_dir       => "", should be used only if defined
+       icons_dir       => "",
        
        utf                     => 0,
        encoding        => "",
@@ -61,7 +61,7 @@
 my @wms = qw(aewm afterstep blackbox enlightenment fbpanel fluxbox fvwm fvwm2
        icewm metisse openbox olvwm qvwm wmaker wmaker-old xfce4 xpde);
 
-if($o_help) {
+if($o_help) { # {{{
        local $" = ", ";
        print<<EOF;
 Usage: $0 [options] [EMAIL PROTECTED]
@@ -90,7 +90,8 @@
     -c, --clear    - remove empty menus
     -p, --promote  - promote submenus with single entry
     -s, --strip    - strip 1st level menu
-    -m, --nomenu   - don't add additional menu info (valid for blackbox, 
fluxbox, openbox, xfce4)
+    -m, --nomenu   - don't add additional menu info
+                     (valid for blackbox, fluxbox, openbox, xfce4)
 
     -r, --xterm=   - set x terminal application
                      default: "$defopt{xterm}"
@@ -102,7 +103,7 @@
 
 EOF
        exit;
-}
+} # }}}
 
 unless (exists $ARGV[0]) {
        local $" = ", ";
@@ -139,6 +140,31 @@
 foreach my $opt (keys %opt) {
        $opt{$opt} = $rcopt{$opt} unless defined $opt{$opt};
        $opt{$opt} = $defopt{$opt} unless defined $opt{$opt};
+       $opt{$opt} =~ s/\${HOME}/$ENV{'HOME'}/go;
+       print "$opt => $opt{$opt}\n";
+}
+
+# check dependencies
+$opt{exec}=1 if $opt{exec_full};
+if ($opt{icons_scale}) {
+       if ( length $opt{icons_dir} ) {
+               my $conv = (split /\s/, $opt{convert})[0];
+               if ( length `which $conv` ) {
+                       $opt{icons} = 1;
+                       $opt{icons_full} = 1;
+               } else {
+                       $opt{icons_scale} = 0;
+                       warn "$conv is not executable, not scaling icons.\n";
+               }
+       } else {
+               $opt{icons_scale} = 0;
+               warn "Icons destination directory is not specified, not 
scaling.\n";
+       }
+}
+$opt{encoding}="utf8" if $opt{utf};
+
+print "After checking:\n";
+foreach my $opt (keys %opt) {
        print "$opt => $opt{$opt}\n";
 }
 exit;
@@ -354,7 +380,7 @@
          foreach grep length, split /;+/, $tags{Categories};
 
        $file =~ s/\.desktop$//;
-       $desktop{$File::Find::name} = [ $file, $utfname, $tags{Icon}, 
$tags{Exec} ];
+       $desktop{$File::Find::name} = [$file, $utfname, $tags{Icon}, 
$tags{Exec}];
 } # }}}
 
 # read XDG menu specification
@@ -557,7 +583,7 @@
                $mno=$menustack[$#menustack];
                $#menustack--;
                $level--;
-               $parent =~ s/(.*):.*?$/$1/ if length $name;
+               $parent =~ s/(.*):.*?$/$1/;
                next;
        }
        if($tag eq 'include') {
@@ -669,8 +695,9 @@
                }
                next;
        }
-       if(($tag=~/^\/(name|directory|and|or|not|category|mergefile)$/)&& 
$include) {
-               warn "warning: XDG file corrupted!\n" if $o_verbose;
+       if( $o_verbose && $include &&
+               ( $tag=~/^\/(name|directory|and|or|not|category|mergefile)$/ )) 
{
+               warn "warning: XDG file corrupted!\n";
        }
        warn "Omitted tag: $tag\n" if $o_tags;
 }
@@ -748,10 +775,13 @@
 
 # WM functions {{{
 $level="";
+sub cmpdname {
+       return $desktop{$a}[1] cmp $desktop{$b}[1];
+}
 sub icewm { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                $name = $$d[1];
                $name =~ s/\"/\\\"/g;
@@ -773,7 +803,7 @@
 sub blackbox { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                if($menu[$no]{$entry} < 0) {
                        $apps .= "$level"."[exec] ($$d[1]) {$$d[3]}\n";
@@ -791,7 +821,7 @@
 sub wmakerold { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                my $name = $$d[1];
                $name =~ s/\"/\\\"/g;
@@ -811,7 +841,7 @@
 sub wmaker { # {{{
        my ($no, $coma)[EMAIL PROTECTED];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                $name = $$d[1];
                $name =~ s/\"/\\\"/g;
@@ -843,7 +873,7 @@
 sub xfce4 {
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                $name = ($$d[1] =~ /["&<>]/) ? xmlname($$d[1]) : $$d[1];
                if($menu[$no]{$entry} < 0) {
@@ -889,7 +919,7 @@
        my $apps = "";
        my $this_menu = "";
        $this_menu .= qq(Popup "$file"\n\tTitle "$basename"\n);
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                if($menu[$no]{$entry} < 0) {
                        $name = $$d[1];
@@ -908,7 +938,7 @@
 sub fvwm2 { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                ( my $name = $$d[1] ) =~ s/\"/\\\"/g;
                if($menu[$no]{$entry}<0) {
@@ -935,7 +965,7 @@
        my $apps = "";
        my $this_menu = "";
        $this_menu .= qq(DestroyMenu $file\nAddToMenu $file "$basename" 
Title\n);
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                my $icon = "";
                $icon = $$d[2] if $opt{icons};
@@ -957,7 +987,7 @@
 sub olvwm { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                ( my $name = $$d[1] ) =~ s/\"/\\\"/g;
                if($menu[$no]{$entry}<0) {
@@ -976,7 +1006,7 @@
 sub qvwm { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                ( my $name = $$d[1] ) =~ s/\"/\\\"/g;
                if($menu[$no]{$entry} < 0) {
@@ -998,7 +1028,7 @@
        my $no=$_[0];
        my $name;
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                ( my $name = $$d[1] ) =~ s/\"/\\\"/g;
                if($menu[$no]{$entry}<0) {
@@ -1021,7 +1051,7 @@
        open $F_OUT, ">> $dir/$mfile.menu" or warn "$dir/$mfile.menu: $!\n";
        print $F_OUT qq("$title"\n);
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                $name=encode($opt{enc},$$d[1]);
                $name=~s/\"/\'/g;
@@ -1063,7 +1093,7 @@
 sub fbpanel { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                if($menu[$no]{$entry}<0) {
                        $apps .=
@@ -1088,7 +1118,7 @@
 sub openbox { # {{{
        my $no=$_[0];
        my $apps="";
-       foreach my $entry (sort {$desktop{$a}[1] cmp $desktop{$b}[1]} keys 
%{$menu[$no]}) {
+       foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
                my $d = $desktop{$entry};
                if($menu[$no]{$entry}<0) {
                        $apps .=
@@ -1145,7 +1175,7 @@
 }
 if($o_output eq "xfce4") {
        print "<xfdesktop-menu>\n";
-       print "<title name=\"Desktop Menu\" visible=\"yes\"/>\n" unless 
$opt{nomenu};
+       print qq(<title name="Desktop Menu" visible="yes"/>\n) unless 
$opt{nomenu};
        $level.="       ";
        xfce4($opt{strip});
        print "</xfdesktop-menu>\n";
@@ -1241,7 +1271,7 @@
 }
 if($o_output eq "openbox") { # {{{
        print "<openbox_menu>\n" unless $opt{nomenu};
-       print "<menu id=\"root-menu\" label=\"PLD Linux\">\n" unless 
$opt{nomenu};
+       print qq(<menu id="root-menu" label="PLD Linux">\n) unless $opt{nomenu};
        openbox($opt{strip});
        print "</menu>\n" unless $opt{nomenu};
        print "</openbox_menu>\n" unless $opt{nomenu};
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/vfmg/vfmg?r1=1.73.2.16&r2=1.73.2.17&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to