File indexing completed on 2024-04-28 09:42:16
0001 #!/usr/bin/env perl 0002 # Copyright 2007 - 2010 Craig Drummond <craig.p.drummond@gmail.com> 0003 # Copyright 2013 - 2015 Yichao Yu <yyc1992@gmail.com> 0004 # 0005 # This program is free software; you can redistribute it and/or modify 0006 # it under the terms of the GNU Lesser General Public License as 0007 # published by the Free Software Foundation; either version 2.1 of the 0008 # License, or (at your option) version 3, or any later version accepted 0009 # by the membership of KDE e.V. (or its successor approved by the 0010 # membership of KDE e.V.), which shall act as a proxy defined in 0011 # Section 6 of version 3 of the license. 0012 # 0013 # This program is distributed in the hope that it will be useful, 0014 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 # Lesser General Public License for more details. 0017 # 0018 # You should have received a copy of the GNU Lesser General Public 0019 # License along with this library. If not, 0020 # see <http://www.gnu.org/licenses/>. 0021 0022 # This perl script is called by the QtCurve Gtk2 theme, it is not intended 0023 # to be useful by itself. 0024 # 0025 # Usage perl map_kde_icons.pl <icon map file> <kde prefix> <kde version> <small toolbar size> <toolbar size> <dnd size> <btn size> <menu size> <dialog size> <icon theme name> <icons map file version> 0026 # @iconSizes = (22, 32, 22, 16, 16, 48); 0027 # KDE Uses 32x32 for dialogs, and 16x16 for buttons 0028 @iconSizes = ($ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8]); 0029 @gtk = ("gtk-small-toolbar", "gtk-large-toolbar", "gtk-dnd", "gtk-button", 0030 "gtk-menu", "gtk-dialog" ); 0031 $numSizes = $#iconSizes + 1; 0032 $useCustom = 0; 0033 0034 printf "#%s %s %02X%02X%02X%02X%02X%02X%02X\n", $ARGV[10], $ARGV[9], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5], $ARGV[6], $ARGV[7], $ARGV[8]; 0035 printf "#This file is created, and used by, QtCurve. Alterations may be overwritten.\n"; 0036 print "gtk-icon-sizes=\"gtk-small-toolbar=$ARGV[3],$ARGV[3]:gtk-large-toolbar=$ARGV[4],$ARGV[4]:"; 0037 print "gtk-dnd=$ARGV[5],$ARGV[5]:gtk-button=$ARGV[6],$ARGV[6]:gtk-menu=$ARGV[7],$ARGV[7]:gtk-dialog=$ARGV[8],$ARGV[8]\"\n"; 0038 #print "gtk-dnd=$ARGV[5],$ARGV[5]:gtk-button=$ARGV[6],$ARGV[6]:gtk-menu=$ARGV[7],$ARGV[7]\"\n"; 0039 0040 if ($ARGV[1]) 0041 { 0042 $baseDefault=$ARGV[1]; 0043 if($ARGV[9] ne "XX") 0044 { 0045 $useCustom=1; 0046 $baseCustom=join("", $baseDefault, "/"); 0047 $baseCustom=join("", $baseCustom, "$ARGV[9]"); 0048 $baseCustom=join("", $baseCustom, "/"); 0049 } 0050 } 0051 0052 if($ARGV[2] == "3") 0053 { 0054 $baseDefault=join("", $baseDefault, "/crystalsvg/"); 0055 } 0056 else 0057 { 0058 $baseDefault=join("", $baseDefault, "/oxygen/"); 0059 } 0060 0061 open(icons, "$ARGV[0]") || die "Could not open \"$ARGV[0]\"\n"; 0062 0063 sub checkSize 0064 { 0065 $fname=join("", $_[0], $_[1], "x", $_[1], "/", $_[2]); 0066 if (open(tst, $fname)) 0067 { 0068 close(tst); 0069 $fname; 0070 } 0071 else 0072 { 0073 ""; 0074 } 0075 } 0076 0077 sub printSize 0078 { 0079 if($_[0]) 0080 { 0081 print "\t\t{ \"$_[1]x$_[1]/$_[2]\", *, *, \"$_[3]\" },\n"; 0082 $_[4]--; 0083 } 0084 } 0085 0086 print "\nstyle \"KDE$ARGV[2]-icons\"\n{\n"; 0087 0088 while($entry=<icons>) 0089 { 0090 @iconMap=split(/ /, $entry); 0091 0092 for($i=0; $i<$#iconMap; $i++) 0093 { 0094 $iconMap[$i+1]=~s/\n//; 0095 } 0096 0097 if($iconMap[1] == /WHAT/) 0098 { 0099 $got=0; 0100 $use=0; 0101 if($useCustom) 0102 { 0103 for($i=0; $i<$#iconMap && $use == 0; $i++) 0104 { 0105 for($index=0; $index<$numSizes; $index++) 0106 { 0107 $files[$index]=checkSize($baseCustom, $iconSizes[$index], $iconMap[$i+1]); 0108 if($files[$index]) 0109 { 0110 $got++; 0111 } 0112 } 0113 0114 if($got) 0115 { 0116 $use=$i+1; 0117 } 0118 } 0119 } 0120 0121 if($got == 0) 0122 { 0123 for($i=0; $i<$#iconMap && $use == 0; $i++) 0124 { 0125 for($index=0; $index<$numSizes; $index++) 0126 { 0127 $files[$index]=checkSize($baseDefault, $iconSizes[$index], $iconMap[$i+1]); 0128 if($files[$index]) 0129 { 0130 $got++; 0131 } 0132 } 0133 0134 if($got) 0135 { 0136 $use=$i+1; 0137 } 0138 } 0139 } 0140 0141 if($got) 0142 { 0143 print "\tstock[\"$iconMap[0]\"]={\n"; 0144 if($got > 1) 0145 { 0146 for($index=0; $index<$numSizes; $index++) 0147 { 0148 $got=printSize($files[$index], $iconSizes[$index], $iconMap[$use], $gtk[$index], $got); 0149 } 0150 } 0151 $found=0; 0152 for($index=0; $index<$numSizes && !$found; $index++) 0153 { 0154 if($files[$index]) 0155 { 0156 print "\t\t{ \"$iconSizes[$index]x$iconSizes[$index]/$iconMap[$use]\" }\n"; 0157 $found=1; 0158 } 0159 } 0160 print "\t}\n"; 0161 } 0162 #else 0163 #{ 0164 # print "#\tstock[\"$iconMap[0]\"]=<No matching KDE icon>\n"; 0165 #} 0166 } 0167 } 0168 print "}\nclass \"*\" style \"KDE$ARGV[2]-icons\"\n"; 0169 0170 close(icons);