vfmg: VFMG/e17-eap_out.pm (NEW), VFMG/DR17_out.pm (NEW) - backend ...
sparky
sparky at pld-linux.org
Sat Dec 2 01:41:25 CET 2006
Author: sparky Date: Sat Dec 2 00:41:25 2006 GMT
Module: vfmg Tag: HEAD
---- Log message:
- backend for old e17 menu (using eap)
---- Files affected:
vfmg/VFMG:
e17-eap_out.pm (NONE -> 1.1) (NEW), DR17_out.pm (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: vfmg/VFMG/e17-eap_out.pm
diff -u /dev/null vfmg/VFMG/e17-eap_out.pm:1.1
--- /dev/null Sat Dec 2 01:41:25 2006
+++ vfmg/VFMG/e17-eap_out.pm Sat Dec 2 01:41:20 2006
@@ -0,0 +1,295 @@
+package VFMG::Output;
+
+use strict;
+use warnings;
+use File::Path qw(mkpath);
+
+sub decode_tags() {
+ return qw(GenericName Comment);
+}
+
+sub destdir() {
+ return "$ENV{'HOME'}/.e/e/applications/favorite";
+}
+
+sub icons_dir() {
+ return "$ENV{'HOME'}/.e/e/applications/all";
+}
+
+my %DR;
+
+sub e17($$$);
+sub e17($$$) {
+ my ($no, $dir, $tab) = @_;
+ my $dirs = "";
+ my $apps = "";
+ my @edje = qw(edje_cc -id . -fd . icon.edc icon.eap);
+ foreach my $entry (sort main::cmpdname keys %{$main::menu[$no]}) {
+ my $icon_exists = 0;
+ my $d = $main::desktop[$entry];
+ my $name = $$d{Name};
+ print $tab.$name.".." if $main::o_verbose;
+ my $icon = $$d{Icon};
+
+ if ( defined $DR{existing}->{$$d{file}} ) {
+ my $e = $DR{existing}->{$$d{file}};
+ if (
+ -r "$main::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;
+ main::scale_icon($icon);
+ }
+ die "No icon $DR{icon}\n" unless -r $DR{icon};
+ print ".." if $main::o_verbose;
+ }
+
+ if ($main::menu[$no]{$entry} < 0) {
+ if ( $icon_exists ) {
+ $apps .= $$d{file} . ".eap\n";
+ print "..EXISTS\n" if $main::o_verbose;
+ next;
+ }
+ my $file = "$main::opt{icons_dir}/$$d{file}.eap";
+
+ unlink "icon.eap";
+ system(@edje);
+ print ".." if $main::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 $main::opt{termapp_class} ) {
+ (my $tapp = $main::opt{termapp_class}) =~ s/%1/$$d{bin}/;
+ push @eapp, "-set-win-class", $tapp;
+ }
+ if ( defined $main::opt{termapp_name} ) {
+ (my $tapp = $main::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 $main::o_verbose;
+ $apps .= $$d{file} . ".eap\n";
+ } else {
+ my $subdir = sprintf "%s/%s", $dir, $$d{file};
+ my $file = $subdir . "/.directory.eap";
+ my $file2 = "$main::opt{icons_dir}/$$d{file}.eap";
+ mkpath($subdir,0,0700);
+ print ".." if $main::o_verbose;
+ unless ( $icon_exists ) {
+ unlink "icon.eap";
+ system(@edje);
+ print ".." if $main::o_verbose;
+ system("enlightenment_eapp","icon.eap",
+ "-set-name",$name);
+ }
+ rename "icon.eap", $file2;
+ symlink ($file2, $file);
+
+ print "..DONE\n" if $main::o_verbose;
+ e17($main::menu[$no]{$entry},$subdir,"$tab\t");
+ $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 do_menu() {
+ die "Enlightenment DR17 requires icon scaling\n"
+ unless $main::opt{icons_scale};
+ die "Enlightenment DR17 conflicts with icons fork\n"
+ if $main::opt{icons_fork};
+
+ $| = 1;
+ print "Generating DR17 menu, this may take a long time\n";
+ $DR{tmp} = $ENV{'TMPDIR'};
+ $DR{tmp} = $ENV{'TMP'} unless -d $DR{tmp};
+ $DR{tmp} = "/tmp" unless -d $DR{tmp};
+ $DR{icon} = $DR{tmp}."/icon.".$main::opt{icons_oext};
+
+ $main::opt{convert} =~ s/\%out/$DR{icon}/g;
+ chdir($DR{tmp});
+ unlink $DR{icon};
+ # icon is allways needed
+ open F_OUT, "> blank.xpm"; # {{{
+ print F_OUT <<EOF;
+ static char *blank[] = {
+ "1 1 1 1",
+ ". c None",
+ "."
+ };
+EOF
+ close F_OUT; # }}}
+ open F_OUT, "> icon.edc"; # {{{
+ print F_OUT << "EOF";
+ images {
+ image: "icon.$main::opt{icons_oext}" COMP;
+ }
+ collections {
+ group {
+ name: "icon";
+ max: 48 48;
+ parts {
+ part {
+ name: "image";
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ aspect: 1.0 1.0;
+ image.normal: "icon.$main::opt{icons_oext}";
+ }
+ }
+ }
+ }
+ }
+EOF
+ close F_OUT; # }}}
+
+ $main::opt{wcnt_file} = "" unless defined $main::opt{wcnt_file};
+ $DR{wcnt} = {};
+ foreach my $wcnt_file (split /\s*;\s*/, $main::opt{wcnt_file}) { # {{{
+ unless (open F_IN, $wcnt_file) {
+ warn "Can't open WCNT file '$wcnt_file': $!\n";
+ next;
+ }
+ while ( <F_IN> ) {
+ next if /^\s*#/;
+ next unless s/^\s*(\S+)//;
+ my $name = $1;
+ $DR{wcnt}{$name} = [undef, undef, undef];
+ foreach my $num (0..3) {
+ last unless s/^\s*"(([^"]|\")*?[^\\])"// or s/^\s*(\S+)//;
+ $DR{wcnt}{$name}[$num] = $1 unless $1 eq "*";
+ }
+ warn "Omitted: $_\n" if length($_) and $main::o_verbose;
+ }
+ close F_IN;
+ } # }}}
+ $DR{wcnt} = undef unless %{$DR{wcnt}};
+
+ $DR{text_icon} = $main::opt{text_icon};
+ if ( defined $DR{text_icon} ) {
+ $DR{text_icon} =~ s#\%in#$DR{tmp}/blank.xpm#g;
+ $DR{text_icon} =~ s#\%out#$DR{icon}#g;
+ }
+
+ $DR{existing} = {};
+ if (not $main::opt{full_regen} and
+ open F_IN, "$main::opt{icons_dir}/.existing") {
+
+ my $icon = "broken?";
+ while (my $line = <F_IN>) {
+ if ( $line =~ /^\[(.*)\]$/ ) {
+ $icon = $1;
+ $DR{existing}->{$icon} = {};
+ } elsif ( $line =~ /^(\S+?):\t(.*)$/ ) {
+ $DR{existing}->{$icon}->{$1} = $2;
+ }
+ }
+ close F_IN;
+ }
+
+ warn "icon: $DR{icon}\n";
+ e17($main::opt{strip}, $main::opt{destdir}, "");
+ unlink "blank.xpm";
+ unlink "icon.edc";
+ unlink "icon.eap";
+ unlink $DR{icon};
+ unlink "$main::opt{icons_dir}/.eap.cache.cfg"
+ if -r "$main::opt{icons_dir}/.eap.cache.cfg";
+ for my $dir (qw(all bar favorite restart startup)) {
+ unlink "$main::opt{destdir}/../$dir/.eap.cache.cfg"
+ if -r "$main::opt{destdir}/../$dir/.eap.cache.cfg";
+ }
+ utime undef, undef, "$main::opt{destdir}/../bar/.order";
+
+ open F_OUT, "> $main::opt{icons_dir}/.existing";
+ foreach my $icon ( keys %{$DR{existing}} ) {
+ print F_OUT "[$icon]\n";
+ foreach my $entry ( keys %{$DR{existing}->{$icon}} ) {
+ print F_OUT "$entry: $DR{existing}->{$icon}->{$entry}\n"
+ if defined $DR{existing}->{$icon}->{$entry};
+ }
+ }
+ close F_OUT;
+
+ exit;
+}
+
+1;
================================================================
Index: vfmg/VFMG/DR17_out.pm
diff -u /dev/null vfmg/VFMG/DR17_out.pm:1.1
--- /dev/null Sat Dec 2 01:41:25 2006
+++ vfmg/VFMG/DR17_out.pm Sat Dec 2 01:41:20 2006
@@ -0,0 +1,295 @@
+package VFMG::Output;
+
+use strict;
+use warnings;
+use File::Path qw(mkpath);
+
+sub decode_tags() {
+ return qw(GenericName Comment);
+}
+
+sub destdir() {
+ return "$ENV{'HOME'}/.e/e/applications/favorite";
+}
+
+sub icons_dir() {
+ return "$ENV{'HOME'}/.e/e/applications/all";
+}
+
+my %DR;
+
+sub e17($$$);
+sub e17($$$) {
+ my ($no, $dir, $tab) = @_;
+ my $dirs = "";
+ my $apps = "";
+ my @edje = qw(edje_cc -id . -fd . icon.edc icon.eap);
+ foreach my $entry (sort main::cmpdname keys %{$main::menu[$no]}) {
+ my $icon_exists = 0;
+ my $d = $main::desktop[$entry];
+ my $name = $$d{Name};
+ print $tab.$name.".." if $main::o_verbose;
+ my $icon = $$d{Icon};
+
+ if ( defined $DR{existing}->{$$d{file}} ) {
+ my $e = $DR{existing}->{$$d{file}};
+ if (
+ -r "$main::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;
+ main::scale_icon($icon);
+ }
+ die "No icon $DR{icon}\n" unless -r $DR{icon};
+ print ".." if $main::o_verbose;
+ }
+
+ if ($main::menu[$no]{$entry} < 0) {
+ if ( $icon_exists ) {
+ $apps .= $$d{file} . ".eap\n";
+ print "..EXISTS\n" if $main::o_verbose;
+ next;
+ }
+ my $file = "$main::opt{icons_dir}/$$d{file}.eap";
+
+ unlink "icon.eap";
+ system(@edje);
+ print ".." if $main::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 $main::opt{termapp_class} ) {
+ (my $tapp = $main::opt{termapp_class}) =~ s/%1/$$d{bin}/;
+ push @eapp, "-set-win-class", $tapp;
+ }
+ if ( defined $main::opt{termapp_name} ) {
+ (my $tapp = $main::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 $main::o_verbose;
+ $apps .= $$d{file} . ".eap\n";
+ } else {
+ my $subdir = sprintf "%s/%s", $dir, $$d{file};
+ my $file = $subdir . "/.directory.eap";
+ my $file2 = "$main::opt{icons_dir}/$$d{file}.eap";
+ mkpath($subdir,0,0700);
+ print ".." if $main::o_verbose;
+ unless ( $icon_exists ) {
+ unlink "icon.eap";
+ system(@edje);
+ print ".." if $main::o_verbose;
+ system("enlightenment_eapp","icon.eap",
+ "-set-name",$name);
+ }
+ rename "icon.eap", $file2;
+ symlink ($file2, $file);
+
+ print "..DONE\n" if $main::o_verbose;
+ e17($main::menu[$no]{$entry},$subdir,"$tab\t");
+ $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 do_menu() {
+ die "Enlightenment DR17 requires icon scaling\n"
+ unless $main::opt{icons_scale};
+ die "Enlightenment DR17 conflicts with icons fork\n"
+ if $main::opt{icons_fork};
+
+ $| = 1;
+ print "Generating DR17 menu, this may take a long time\n";
+ $DR{tmp} = $ENV{'TMPDIR'};
+ $DR{tmp} = $ENV{'TMP'} unless -d $DR{tmp};
+ $DR{tmp} = "/tmp" unless -d $DR{tmp};
+ $DR{icon} = $DR{tmp}."/icon.".$main::opt{icons_oext};
+
+ $main::opt{convert} =~ s/\%out/$DR{icon}/g;
+ chdir($DR{tmp});
+ unlink $DR{icon};
+ # icon is allways needed
+ open F_OUT, "> blank.xpm"; # {{{
+ print F_OUT <<EOF;
+ static char *blank[] = {
+ "1 1 1 1",
+ ". c None",
+ "."
+ };
+EOF
+ close F_OUT; # }}}
+ open F_OUT, "> icon.edc"; # {{{
+ print F_OUT << "EOF";
+ images {
+ image: "icon.$main::opt{icons_oext}" COMP;
+ }
+ collections {
+ group {
+ name: "icon";
+ max: 48 48;
+ parts {
+ part {
+ name: "image";
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ aspect: 1.0 1.0;
+ image.normal: "icon.$main::opt{icons_oext}";
+ }
+ }
+ }
+ }
+ }
+EOF
+ close F_OUT; # }}}
+
+ $main::opt{wcnt_file} = "" unless defined $main::opt{wcnt_file};
+ $DR{wcnt} = {};
+ foreach my $wcnt_file (split /\s*;\s*/, $main::opt{wcnt_file}) { # {{{
+ unless (open F_IN, $wcnt_file) {
+ warn "Can't open WCNT file '$wcnt_file': $!\n";
+ next;
+ }
+ while ( <F_IN> ) {
+ next if /^\s*#/;
+ next unless s/^\s*(\S+)//;
+ my $name = $1;
+ $DR{wcnt}{$name} = [undef, undef, undef];
+ foreach my $num (0..3) {
+ last unless s/^\s*"(([^"]|\")*?[^\\])"// or s/^\s*(\S+)//;
+ $DR{wcnt}{$name}[$num] = $1 unless $1 eq "*";
+ }
+ warn "Omitted: $_\n" if length($_) and $main::o_verbose;
+ }
+ close F_IN;
+ } # }}}
+ $DR{wcnt} = undef unless %{$DR{wcnt}};
+
+ $DR{text_icon} = $main::opt{text_icon};
+ if ( defined $DR{text_icon} ) {
+ $DR{text_icon} =~ s#\%in#$DR{tmp}/blank.xpm#g;
+ $DR{text_icon} =~ s#\%out#$DR{icon}#g;
+ }
+
+ $DR{existing} = {};
+ if (not $main::opt{full_regen} and
+ open F_IN, "$main::opt{icons_dir}/.existing") {
+
+ my $icon = "broken?";
+ while (my $line = <F_IN>) {
+ if ( $line =~ /^\[(.*)\]$/ ) {
+ $icon = $1;
+ $DR{existing}->{$icon} = {};
+ } elsif ( $line =~ /^(\S+?):\t(.*)$/ ) {
+ $DR{existing}->{$icon}->{$1} = $2;
+ }
+ }
+ close F_IN;
+ }
+
+ warn "icon: $DR{icon}\n";
+ e17($main::opt{strip}, $main::opt{destdir}, "");
+ unlink "blank.xpm";
+ unlink "icon.edc";
+ unlink "icon.eap";
+ unlink $DR{icon};
+ unlink "$main::opt{icons_dir}/.eap.cache.cfg"
+ if -r "$main::opt{icons_dir}/.eap.cache.cfg";
+ for my $dir (qw(all bar favorite restart startup)) {
+ unlink "$main::opt{destdir}/../$dir/.eap.cache.cfg"
+ if -r "$main::opt{destdir}/../$dir/.eap.cache.cfg";
+ }
+ utime undef, undef, "$main::opt{destdir}/../bar/.order";
+
+ open F_OUT, "> $main::opt{icons_dir}/.existing";
+ foreach my $icon ( keys %{$DR{existing}} ) {
+ print F_OUT "[$icon]\n";
+ foreach my $entry ( keys %{$DR{existing}->{$icon}} ) {
+ print F_OUT "$entry: $DR{existing}->{$icon}->{$entry}\n"
+ if defined $DR{existing}->{$icon}->{$entry};
+ }
+ }
+ close F_OUT;
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list