vfmg (DEVEL): vfmg - trying modular vfmg, should speed up compilat...

sparky sparky at pld-linux.org
Fri Dec 1 22:31:53 CET 2006


Author: sparky                       Date: Fri Dec  1 21:31:53 2006 GMT
Module: vfmg                          Tag: DEVEL
---- Log message:
- trying modular vfmg, should speed up compilation (800 lines less)

---- Files affected:
vfmg:
   vfmg (1.98 -> 1.98.2.1) 

---- Diffs:

================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.98 vfmg/vfmg:1.98.2.1
--- vfmg/vfmg:1.98	Fri Dec  1 20:42:20 2006
+++ vfmg/vfmg	Fri Dec  1 22:31:48 2006
@@ -44,23 +44,15 @@
 my $o_output;
 $defopt{xterm}="$ENV{'VFMG_TERM'}" if $ENV{'VFMG_TERM'};
 
-my @wms = qw(ASCII DR17 aewm afterstep blackbox e16 enlightenment fbpanel
-	fluxbox fvwm fvwm2 icewm metisse olvwm openbox qvwm wmaker wmaker-old wmii
-	xfce4 xpde);
-
-# %destdir and %iconsdir should only contain directories propsed by WM
-my %destdir = (
-	DR17			=>	"$ENV{'HOME'}/.e/e/applications/favorite",
-	afterstep		=>	"$ENV{'HOME'}/GNUstep/Library/AfterStep/start",
-	e16				=>	"$ENV{'HOME'}/.e16/menus",
-	enlightenment	=>	"$ENV{'HOME'}/.enlightenment/menus",
-	xpde			=>	"$ENV{'HOME'}/.xpde/Start Menu/Programs",
-);
-my %iconsdir = (
-	DR17			=>	"$ENV{'HOME'}/.e/e/applications/all",
-	e16				=>	"$ENV{'HOME'}/.e16/icons",
-	enlightenment	=>	"$ENV{'HOME'}/.enlightenment/icons",
-);
+sub wms() {
+	my @wms;
+	foreach (grep -d, map {"$_/VFMG"} @INC) {
+		opendir DIR, $_;
+		push @wms, map /^(.*)_out\.pm$/, readdir DIR;
+		closedir DIR;
+	}
+	return join ", ", sort @wms;
+}
 # }}}
 
 GetOptions( # {{{
@@ -105,9 +97,9 @@
 	); # }}}
 
 if($o_help) { # {{{
-	local $" = ", ";
-	print<<EOF;
-Usage:	$0 [options] {@wms}
+	my $wms = wms();
+	print <<EOF;
+Usage:	$0 [options] {$wms}
 
 Options:
     -h, --help	  - print this help and exit
@@ -164,13 +156,11 @@
 	exit;
 }
 
-unless (exists $ARGV[0]) {
-	local $" = ", ";
-	die "Missing argument {@wms}\n";
-}
-$o_output=$ARGV[0];
-die "Unrecognized argument: $o_output\n"
-	unless grep { $o_output eq $_ } @wms;
+die "Missing argument {".wms()."}\n" unless exists $ARGV[0];
+
+$o_output = $ARGV[0];
+eval { require "VFMG/${o_output}_out.pm" }
+	or die "Unrecognized argument: $o_output\n";
 
 # vfmgrc {{{
 my @rcFiles = ("/etc/vfmgrc", "$ENV{'HOME'}/.vfmgrc");
@@ -204,10 +194,9 @@
 }
 
 # check dependencies
-$opt{exec}=1 if $opt{exec_full};
-if ( grep { $o_output eq $_ } keys %iconsdir ) {
-	$opt{icons_dir} = $iconsdir{$o_output} unless (length $opt{icons_dir});
-}
+$opt{exec} = 1 if $opt{exec_full};
+eval { $opt{icons_dir} = VFMG::Output::icons_dir() }
+	unless (length $opt{icons_dir});
 if ($opt{icons_scale}) {
 	if ( length $opt{icons_dir} ) {
 		my $conv = (split /\s/, $opt{convert})[0];
@@ -225,10 +214,9 @@
 }
 $opt{icons_ext} = 1 if $opt{icons_full};
 $opt{encoding}="utf8" if $opt{utf};
-if ( grep { $o_output eq $_ } keys %destdir ) {
-	$opt{destdir} = $destdir{$o_output} unless (length $opt{destdir});
-} else {
-	delete $opt{destdir};
+unless (length $opt{destdir}) {
+	eval { $opt{destdir} = VFMG::Output::destdir() }
+		or delete $opt{destdir};
 }
 my %OSI_accept;
 if ( defined $opt{only_in} ) {
@@ -852,584 +840,15 @@
 	return $icon_out;
 }
 
-# WM functions {{{
-use constant step		=> "\t";
-
-sub cmpdname {
+sub cmpdname($$) {
 	use locale;
 	return 
-			encode($opt{encoding}, $desktop[$a]{Name} )
+			encode($opt{encoding}, $desktop[shift]{Name} )
 		cmp
-			encode($opt{encoding}, $desktop[$b]{Name} )
+			encode($opt{encoding}, $desktop[shift]{Name} )
 		;
 }
 
-sub ASCII { # {{{
-	my ($no, $level, $cnum)=@_;
-	my $cnext = $cnum + 1;
-	my @apps;
-	my @tmp = ();
-	@tmp = %{$menu[$no]} if defined %{$menu[$no]};
-	my $all = ($#tmp + 1) / 2;
-	my $num = 0;
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		$num++;
-		if($menu[$no]{$entry} < 0) {
-			push @apps, $d;
-		} else {
-			my $step = " \033[${cnum}m\033(0\017x\033(B\033[0m ";
-			if ($num >= $all and ( $#apps < 0 )) {
-				$step = "   ";
-				print "$level \033[${cnum}m\033(0mq\033(B\033[${cnext}m\033[1m[$$d{Name}]";
-			} else {
-				print "$level \033[${cnum}m\033(0tq\033(B\033[${cnext}m\033[1m[$$d{Name}]";
-			}
-			print " ($$d{GenericName})" if $$d{GenericName};
-			print " [$$d{Comment}]" if $$d{Comment};
-			print "\033[0m\n";
-			ASCII($menu[$no]{$entry},$level.$step, $cnext);
-		}
-	}
-	$num = 0;
-	foreach my $d (@apps) {
-		if ($num >= $#apps) {
-			print "$level \033[${cnum}m\033(0\017mq\033(B\033[${cnext}m$$d{Name}";
-		} else {
-			print "$level \033[${cnum}m\033(0\017tq\033(B\033[${cnext}m$$d{Name}";
-		}
-		print " ($$d{GenericName})" if $$d{GenericName};
-		print " [$$d{Comment}]" if $$d{Comment};
-		print "\033[0m\n";
-		$num++;
-	}
-} # }}}
-
-sub DR17 { # {{{
-	my ($no, $dir, $tab, $dr)=@_;
-	my $dirs = "";
-	my $apps = "";
-	my @edje = qw(edje_cc -id . -fd . icon.edc icon.eap);
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $icon_exists = 0;
-		my $d = $desktop[$entry];
-		my $name = $$d{Name};
-		print $tab.$name.".." if $o_verbose;
-		my $icon = $$d{Icon};
-
-		if ( defined $dr->{existing}->{$$d{file}} ) {
-			my $e = $dr->{existing}->{$$d{file}};
-			if (
-				-r "$opt{icons_dir}/$$d{file}.eap"
-					and
-				(
-					(not defined $$e{Name} and not defined $$d{Name}) 
-						or ($$e{Name} eq $$d{Name})
-				)
-				and
-				(
-					(not defined $$e{GenericName} and not defined $$d{GenericName})
-						or ($$e{GenericName} eq $$d{GenericName})
-				)
-				and
-				(
-					(not defined $$e{Comment} and not defined $$d{Comment})
-						or ($$e{Comment} eq $$d{Comment})
-				)
-				and
-				(
-					(not defined $$e{Exec} and not defined $$d{Exec})
-						or ($$e{Exec} eq $$d{Exec} )
-				)
-			)
-			{
-				if ( -r $icon ) {
-					(my $md5 = `md5sum $icon`) =~ s/\s+.*//s;
-					if ( defined $$e{IconMD5} ) {
-						$icon_exists = 1 if ( $md5 eq $$e{IconMD5} );
-					}
-				} else {
-					$icon_exists = 1 unless defined $$e{IconMD5};
-				}
-			}
-		}
-		
-		unless ( $icon_exists ) {
-			delete $dr->{existing}->{$$d{file}}
-				if exists $dr->{existing}->{$$d{file}};
-			my $md5;
-			if ( -r $icon ) {
-				($md5 = `md5sum $icon`) =~ s/\s+.*//s;
-			}
-			my $e = {
-				Name	=> $$d{Name},
-				GenericName	=> $$d{GenericName},
-				Comment	=> $$d{Comment},
-				Exec	=> $$d{Exec},
-				IconMD5	=> $md5
-			};
-			$dr->{existing}->{$$d{file}} = $e;
-			
-			unlink $$dr{icon};
-			if ( not -r $icon and defined $$dr{text_icon} ) {
-				( my $exe = $$dr{text_icon} ) =~ s/%1/"$name"/;
-				system($exe);
-			} else {
-				$icon = $$dr{tmp}."/blank.xpm" unless -r $icon;
-				scale_icon($icon);
-			}
-			die "No icon $$dr{icon}\n" unless -r $$dr{icon};
-			print ".." if $o_verbose;
-		}
-		
-		if($menu[$no]{$entry} < 0) {
-			if ( $icon_exists ) {
-				$apps .= $$d{file} . ".eap\n";
-				print "..EXISTS\n" if $o_verbose;
-				next;
-			}
-			my $file = "$opt{icons_dir}/$$d{file}.eap";
-
-			unlink "icon.eap";
-			system(@edje);
-			print ".." if $o_verbose;
-			my @eapp = qw(enlightenment_eapp icon.eap);
-			push @eapp, "-set-name",$name;
-			push @eapp, "-set-generic",$$d{GenericName}
-				if $$d{GenericName};
-			push @eapp, "-set-comment",$$d{Comment}
-				if $$d{Comment};
-			push @eapp, "-set-exe",$$d{Exec};
-			if ( defined $$dr{wcnt} and exists $$dr{wcnt}{$$d{file}} ) {
-				my $wcnt = $$dr{wcnt}{$$d{file}};
-				push @eapp, "-set-win-class", $$wcnt[0]
-					if defined $$wcnt[0];
-				push @eapp, "-set-win-name", $$wcnt[1] if defined $$wcnt[1];
-				push @eapp, "-set-win-title", $$wcnt[2]
-					if defined $$wcnt[2];
-				push @eapp, "-set-win-role", $$wcnt[3] if defined $$wcnt[3];
-			} else {
-				if ( $$d{term} == 1 ) {
-					if ( defined $opt{termapp_class} ) {
-						(my $tapp = $opt{termapp_class}) =~ s/%1/$$d{bin}/;
-						push @eapp, "-set-win-class", $tapp;
-					}
-					if ( defined $opt{termapp_name} ) {
-						(my $tapp = $opt{termapp_name}) =~ s/%1/$$d{bin}/;
-						push @eapp, "-set-win-name", $tapp;
-					}
-				} else {
-					(my $exe = (split /\s/, $$d{Exec})[0]) =~ s#.*/##;
-					$exe = ucfirst lc $exe;
-					push @eapp, "-set-win-class", $exe;
-				}
-			}
-			system(@eapp);
-			rename "icon.eap", $file;
-			
-			print "..DONE\n" if $o_verbose;
-			$apps .= $$d{file} . ".eap\n";
-		} else {
-			my $subdir = sprintf "%s/%s", $dir, $$d{file};
-			my $file = $subdir . "/.directory.eap";
-			my $file2 = "$opt{icons_dir}/$$d{file}.eap";
-			mkpath($subdir,0,0700);
-			print ".." if $o_verbose;
-			unless ( $icon_exists ) {
-				unlink "icon.eap";
-				system(@edje);
-				print ".." if $o_verbose;
-				system("enlightenment_eapp","icon.eap",
-					"-set-name",$name);
-			}
-			rename "icon.eap", $file2;
-			symlink ($file2, $file);
-
-			print "..DONE\n" if $o_verbose;
-			DR17($menu[$no]{$entry},$subdir,$tab.step,$dr);
-			$dirs .= $$d{file}."\n";
-		}
-	}
-	open F_OUT, ">> $dir/.order" or warn "$dir/.order: $!\n";
-	print F_OUT $dirs;
-	print F_OUT $apps;
-	close F_OUT;	
-} # }}}
-
-sub aewm { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		( my $name = $$d{Name} ) =~ s/\"/\\\"/g;
-		if($menu[$no]{$entry} < 0) {
-			( my $exec = $$d{Exec} ) =~ s/\"/\\\"/g;
-			$apps .= qq(${level}cmd "$name" "$exec"\n);
-		} else {
-			print qq(${level}menu "$name"\n);
-			aewm($menu[$no]{$entry},$level.step);
-			print "${level}end\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub afterstep { # {{{
-	my ($no, $dir)=@_;
-	
-	foreach my $entry(keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $name = encode($opt{encoding},$$d{Name});
-		if($menu[$no]{$entry} < 0) {
-			$name=~s/\"/\\\"/g;
-			my $icon = "";
-			$icon = scale_icon($$d{Icon}) if $opt{icons};
-			my $F_OUT;
-			open $F_OUT, ">> $dir/$$d{file}" or warn "$dir/$$d{file}: $!\n";
-			print $F_OUT qq(Exec "$name" exec $$d{Exec}\n);
-			print $F_OUT qq(MiniPixmap "$icon"\n) if length $icon;
-			close $F_OUT;
-		} else {
-			$name =~ s|/||g;
-			mkpath("$dir/$name",0,0700);
-			afterstep($menu[$no]{$entry},"$dir/$name");
-		}
-	}
-} # }}}
-
-sub blackbox { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		if($menu[$no]{$entry} < 0) {
-			$apps .= "$level"."[exec] ($$d{Name}) {$$d{Exec}}\n";
-		} else {
-			print "$level"."[submenu] ($$d{Name})\n";
-			blackbox($menu[$no]{$entry}, $level.step);
-			print "$level\[end]\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub enlightenment { # {{{
-	my ($no, $mfile, $title)=@_;
-	my $F_OUT;
-	open $F_OUT, ">> $opt{destdir}/$mfile.menu" or warn "$opt{destdir}/$mfile.menu: $!\n";
-	print $F_OUT qq("$title"\n);
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $name = encode($opt{encoding},$$d{Name});
-		$name=~s/\"/\'/g;
-		my $icon="";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		if($menu[$no]{$entry}<0) {
-			$apps .= qq("$name" "$icon" exec "$$d{Exec}"\n);
-		} else {
-			print $F_OUT qq("$name" "$icon" menu "$opt{destdir}/$$d{file}.menu"\n);
-			enlightenment($menu[$no]{$entry},$$d{file},$name);
-		}
-	}
-	print $F_OUT $apps;
-	close $F_OUT;
-} # }}}
-
-sub fbpanel { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $icon = "";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		if($menu[$no]{$entry}<0) {
-			$apps .=
-				"${level}item {\n".
-				"${level}	name = $$d{Name}\n".
-				"${level}	action = $$d{Exec}\n";
-			$apps .= "${level}	image = $icon\n" if length $icon;
-			$apps .= "${level}}\n";
-		} else {
-			print "${level}menu {\n";
-			print "${level}	name = $$d{Name}\n";
-			print "${level}	image = $icon\n" if length $icon;
-			fbpanel($menu[$no]{$entry},$level.step);
-			print "${level}}\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub fvwm { # {{{
-	my ($no, $file, $basename)=@_;
-	$file=~s|^\.||;
-	
-	my $apps = "";
-	my $this_menu = "";
-	$this_menu .= qq(Popup "$file"\n\tTitle "$basename"\n);
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		if($menu[$no]{$entry} < 0) {
-			my $name = $$d{Name};
-			$name =~ s/\"/\\\"/g;
-			$apps .= qq(\tExec "$name"\texec $$d{Exec}\n);
-		} else {
-			my $name = $$d{file};
-			$name =~ s/\s+/_/g;
-			$this_menu .= qq(\tPopup "$$d{Name}"\t$file.$name\n);
-			fvwm($menu[$no]{$entry},"$file.$name",$$d{Name});
-		}
-	}
-	print $this_menu . $apps . "EndPopup\n\n" if length $file;
-} # }}}
-
-sub fvwm2 { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		( my $name = $$d{Name} ) =~ s/\"/\\\"/g;
-		my $icon = "";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		$icon = "\%$icon\%" if length $icon;
-		if($menu[$no]{$entry}<0) {
-			$apps .= qq(AddToMenu $level	"$icon$name"	Exec $$d{Exec} &\n);
-		} else {
-			my $file = $$d{file};
-			$file =~ s/\s+/_/g;
-			print qq(AddToMenu $level	"$icon$name"	Popup $level.$file\n);
-			print "DestroyMenu recreate $level.$file\n\n";
-			print qq(AddToMenu $level.$file	"$icon$name"	Title\n);
-			fvwm2($menu[$no]{$entry},"$level.$file");
-		}
-	}
-	print $apps."\n";
-} # }}}
-
-sub icewm { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $name = $$d{Name};
-		$name =~ s/\"/\\\"/g;
-		my $icon = "";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		if($menu[$no]{$entry} < 0) {
-			$apps .= qq(${level}prog "$name" "$icon" $$d{Exec}\n);
-		} else {
-			$icon = "folder" if not length $icon and $opt{icons};
-			print qq(${level}menu "$name" "$icon" {\n);
-			icewm($menu[$no]{$entry}, $level.step);
-			print "$level}\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub metisse { # {{{
-	my ($no, $file, $basename) = @_;
-	$file =~ s|^\.||;
-	
-	my $apps = "";
-	my $this_menu = "";
-	$this_menu .= qq(DestroyMenu $file\nAddToMenu $file "$basename" Title\n);
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $icon = "";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		$icon = "\%$icon\%" if length $icon;
-		
-		if($menu[$no]{$entry} < 0) {
-			( my $name = $$d{Name} ) =~ s/\"/\\\"/g;
-			$apps .= qq(+ "$icon$name"\tExec exec $$d{Exec}\n);
-		} else {
-			( my $name = $$d{file} ) =~ s/\s+/_/g;
-			$this_menu .= qq(+ "$icon$$d{Name}"\tPopup\t$file.$name\n);
-			metisse($menu[$no]{$entry},"$file.$name",$$d{Name});
-		}
-	}
-	print $this_menu . $apps . "\n" if length $file;
-} # }}}
-
-sub olvwm { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		( my $name = $$d{Name} ) =~ s/\"/\\\"/g;
-		if($menu[$no]{$entry}<0) {
-			$apps .= qq($level"$name"	exec $$d{Exec}\n);
-		} else {
-			print qq($level"$name" MENU\n);
-			olvwm($menu[$no]{$entry},$level.step);
-			print qq($level"$name" END PIN\n);
-		}
-	}
-	print $apps;
-} # }}}
-
-sub openbox { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		if($menu[$no]{$entry}<0) {
-			$apps .=
-				qq($level<item label="$$d{Name}">\n).
-				qq($level	<action name="Execute">\n).
-				qq($level	 <execute>$$d{Exec}</execute>\n).
-				qq($level	</action>\n).
-				qq($level</item>\n);
-		} else {
-			print qq($level<menu id="$$d{Name}" label="$$d{Name}">\n);
-			openbox($menu[$no]{$entry},$level.step);
-			print "$level</menu>\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub qvwm { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		( my $name = $$d{Name} ) =~ s/\"/\\\"/g;
-		my $icon = "";
-		$icon = scale_icon($$d{Icon}) if $opt{icons};
-		if($menu[$no]{$entry} < 0) {
-			( my $exec = $$d{Exec} ) =~ s/\"/\\\"/g;
-			$apps .= qq($level"$name" "$icon" "$exec"\n);
-		} else {
-			print qq($level"$name" "$icon"\n),
-				"$level+\n";
-			qvwm($menu[$no]{$entry},$level.step);
-			print "$level-\n";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub wmaker { # {{{
-	my ($no, $coma, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $name = $$d{Name};
-		$name =~ s/\"/\\\"/g;
-		if($menu[$no]{$entry} < 0) {
-			(my $exec = $$d{Exec}) =~ s/\"/\\\"/g;
-			$apps .= "$coma\n".
-				qq{$level("$name", EXEC, "$exec")};
-		} else {
-			print "$coma\n",
-				qq{$level("$name"};
-			wmaker($menu[$no]{$entry},",",$level.step);
-			print "\n$level)";
-		}
-	}
-	print $apps;
-} # }}}
-
-sub wmakerold { # {{{
-	my ($no, $level)=@_;
-	my $apps="";
-	foreach my $entry (sort cmpdname keys %{$menu[$no]}) {
-		my $d = $desktop[$entry];
-		my $name = $$d{Name};
-		$name =~ s/\"/\\\"/g;
-		if($menu[$no]{$entry} < 0) {
-			$apps .= qq($level"$name" EXEC $$d{Exec}\n);
-		} else {
-			print qq($level"$name" MENU\n);
<<Diff was trimmed, longer than 597 lines>>

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



More information about the pld-cvs-commit mailing list