vfmg (DEVEL): vfmg - GenericName support in DR17 (slows down a lit...
sparky
sparky at pld-linux.org
Sun Nov 20 23:46:14 CET 2005
Author: sparky Date: Sun Nov 20 22:46:14 2005 GMT
Module: vfmg Tag: DEVEL
---- Log message:
- GenericName support in DR17 (slows down a little)
---- Files affected:
vfmg:
vfmg (1.73.2.38 -> 1.73.2.39)
---- Diffs:
================================================================
Index: vfmg/vfmg
diff -u vfmg/vfmg:1.73.2.38 vfmg/vfmg:1.73.2.39
--- vfmg/vfmg:1.73.2.38 Fri Nov 11 22:28:58 2005
+++ vfmg/vfmg Sun Nov 20 23:46:09 2005
@@ -285,8 +285,8 @@
sub findfirstlang {
return 0 if $a eq $b;
foreach my $lang (@lang) {
- return -1 if $a eq "Name[$lang]";
- return 1 if $b eq "Name[$lang]";
+ return -1 if $a =~ /\[$lang\]/;
+ return 1 if $b =~ /\[$lang\]/;
}
return 0;
} # }}}
@@ -303,14 +303,16 @@
open F_IN, "$file" or warn "$File::Find::name: $!\n" and return;
my %tags = (
- Name => '',
- Icon => '',
- Categories => '',
- Type => '',
+ Name => '',
+ GenericName => '',
+ Icon => '',
+ Categories => '',
+ Type => '',
map {
## "foo = bar" or "Name[baz] = bar"
/^\s*
(Name(?:\[(?:$langs)\])?
+ |GenericName(?:\[(?:$langs)\])?
|Icon|Exec|Categories|Terminal|Type|Encoding)
\s* = \s* (.+?)
\s*$/ox
@@ -322,6 +324,10 @@
$tags{_name} =
(sort findfirstlang grep /^Name/, keys %tags)[0];
$tags{name} = $tags{ $tags{_name} };
+ $tags{_genericname} =
+ (sort findfirstlang grep /^GenericName/, keys %tags)[0];
+ $tags{genericname} = $tags{ $tags{_genericname} };
+
$tags{enc} = exists $tags{Encoding} ? $tags{Encoding} : 'iso-8859-1';
$tags{term} =
($tags{Terminal} && $tags{Terminal} =~ /^(?:1|true)$/i) ? 1 : 0;
@@ -399,6 +405,39 @@
($utfname = $file) =~ s/\.desktop$//;
warn "$File::Find::name: missing Name tag! using $utfname\n";
}
+ my $genname = "";
+ if (length $tags{genericname}) {
+ if ($tags{enc} eq 'Legacy-Mixed') {
+ warn "$File::Find::name: Legacy-Mixed encoding is depreciated.\n";
+
+ # this code is untested
+ # --radek
+ ($tags{lang}) = ($tags{_genericname} =~ /^GenericName\[([^\]]+)/);
+ if ($tags{lang} !~ /\./) {
+ warn "$File::Find::name: cannot get encoding name for"
+ . " `$tags{lang}'. Assuming iso-8859-1\n";
+ $tags{enc} = "iso-8859-1";
+ } else {
+ require POSIX;
+ my $old_locale = setlocale(POSIX::LC_ALL());
+ eval {
+ setlocale(POSIX::LC_ALL(), $tags{lang});
+ require I18N::Langinfo;
+ $tags{enc} =
+ I18N::Langinfo::langinfo(I18N::Langinfo::CODESET());
+ };
+ warn "something went wrong: $@" if $@;
+ setlocale(POSIX::LC_ALL(), $old_locale);
+ }
+ }
+ $genname = decode($tags{enc}, $tags{genericname});
+ unless ($genname) {
+ warn "$File::Find::name: wrong encoding!\n";
+ $genname = $tags{name};
+ }
+
+ }
+
$tags{Exec} =~ s/([^%])%v/$1/g;
$tags{Exec} =~ s/([^%])%k/$1$file/g;
$tags{Exec} =~ s/([^%])%c/$1$utfname/g;
@@ -411,7 +450,7 @@
$tags{Exec} =~ s/%%/%/g;
$file =~ s/\.desktop$//;
- push @desktop, [$file, $utfname, $tags{Icon}, $tags{Exec}];
+ push @desktop, [$file, $utfname, $tags{Icon}, $tags{Exec}, $genname];
$apps[$#desktop]{$_} = 1 # two apps can have same names now:)
foreach grep length, split /;+/, $tags{Categories};
@@ -807,6 +846,7 @@
use constant LOCALENAME => 1;
use constant ICON => 2;
use constant EXEC => 3;
+use constant GENNAME => 4;
use constant step => "\t";
@@ -876,10 +916,13 @@
system(@edje,$file);
print "..";
- system("enlightenment_eapp",$file,
- "-set-name",$name,
- "-set-generic",$name,
- "-set-exe",$$d[EXEC]);
+ my @eapp = qw(enlightenment_eapp);
+ push @eapp, $file;
+ push @eapp, "-set-name",$name;
+ push @eapp, "-set-generic",$$d[GENNAME] if length $$d[GENNAME];
+ push @eapp, "-set-exe",$$d[EXEC];
+
+ system(@eapp);
print "..DONE\n";
$apps .= $$d[FILENAME] . ".eap\n";
} else {
@@ -890,8 +933,7 @@
system(@edje, $file);
print "..";
system("enlightenment_eapp",$file,
- "-set-name",$name,
- "-set-generic",$name);
+ "-set-name",$name);
print "..DONE\n";
DR17($menu[$no]{$entry},$subdir,$tab.step,$dr);
================================================================
---- CVS-web:
http://cvs.pld-linux.org/vfmg/vfmg?r1=1.73.2.38&r2=1.73.2.39&f=u
More information about the pld-cvs-commit
mailing list