1 ###########################################################################
2 # Copyright (C) 2007 by Mark Kretschmann <markey@web.de> #
4 # This program is free software; you can redistribute it and/or modify #
5 # it under the terms of the GNU General Public License as published by #
6 # the Free Software Foundation; either version 2 of the License, or #
7 # (at your option) any later version. #
9 # This program is distributed in the hope that it will be useful, #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12 # GNU General Public License for more details. #
14 # You should have received a copy of the GNU General Public License #
15 # along with this program; if not, write to the #
16 # Free Software Foundation, Inc., #
17 # 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. #
18 ###########################################################################
20 # Small tool for reverting all instances of Amarok::icon("foo") back
21 # to the original oxygen icon names.
23 ###########################################################################
27 def search_cpp(folder)
28 @cpp_files += Dir["#{folder}/*.cpp"]
29 Dir.foreach(folder) do |x|
30 next if x[0, 1] == "."
31 search_cpp("#{folder}/#{x}") if FileTest.directory?("#{folder}/#{x}")
36 file = File.new(path, File::RDWR)
39 scanner = StringScanner.new(str)
42 scanner.scan(/(.*?)(Amarok::icon\( *?)(".*?")( *?\))/m)
43 break if scanner[3].nil?
46 whole_match = scanner[2] + scanner[3] + scanner[4]
47 new_name = @name_table[name]
48 new_name = name if new_name == nil
49 str_output.sub!(whole_match, new_name)
58 # Make sure the current working directory is amarok
59 unless Dir::getwd().split( "/" ).last() == "amarok"
60 print "ERROR: This script must be started from the amarok/ folder. Aborting.\n\n"
64 file = File.new("src/iconloader.cpp", File::RDONLY)
66 @name_table = Hash.new
68 str.each_line do |line|
69 if line.include?('iconMap["')
70 reg = /(".*?")(.*)(".*?")/
71 a = reg.match(line)[1]
72 b = reg.match(line)[3]
81 @cpp_files.each do |x|
82 puts("Processing " + x)
83 puts("#{(100.0 / @cpp_files.length * i).to_i} %")