1 | /* This file is part of the KDE project |
2 | Copyright (C) 2008 David Faure <faure@kde.org> |
3 | |
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 ( at |
7 | your option ) version 3 or, at the discretion of KDE e.V. ( which shall |
8 | act as a proxy as in section 14 of the GPLv3 ), any later version. |
9 | |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU General Public License |
16 | along with this program; see the file COPYING. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include <kcmdlineargs.h> |
22 | #include <kiconloader.h> |
23 | #include <kdeversion.h> |
24 | #include <klocale.h> |
25 | #include <stdio.h> |
26 | #include <kapplication.h> |
27 | |
28 | int main(int argc, char *argv[]) |
29 | { |
30 | KCmdLineArgs::init( argc, argv, "kiconfinder" , 0, ki18n("Icon Finder" ), KDE_VERSION_STRING , ki18n("Finds an icon based on its name" )); |
31 | |
32 | |
33 | KCmdLineOptions options; |
34 | |
35 | options.add("+iconname" , ki18n("The icon name to look for" )); |
36 | |
37 | KCmdLineArgs::addCmdLineOptions( options ); |
38 | |
39 | KComponentData instance("kiconfinder" ); |
40 | |
41 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
42 | if( args->count() < 1 ) { |
43 | printf( "No icon name specified\n" ); |
44 | return 1; |
45 | } |
46 | const QString iconName = args->arg( 0 ); |
47 | const QString icon = KIconLoader::global()->iconPath(iconName, KIconLoader::Desktop /*TODO configurable*/, true); |
48 | if ( !icon.isEmpty() ) { |
49 | printf("%s\n" , icon.toLatin1().constData()); |
50 | } else { |
51 | return 1; // error |
52 | } |
53 | |
54 | return 0; |
55 | } |
56 | |