[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KIconTheme patch
From: Antonio Larrosa <antlarr () arrakis ! es>
Date: 2000-10-12 18:43:26
[Download RAW message or body]
David Faure wrote:
>
> On Thursday 12 October 2000 14:05, Antonio Larrosa wrote :
> >Btw, this version of the patch also adds
> >(dir)/share/apps/appname/icons/(theme)/whatever
> >to the search list, so that khelpcenter gets its icons too.
> >
> >(dir)== each dir in $KDEDIRS
> >(theme) == the current theme.
>
> This already works, at least with (dir) = ${prefix} (aka $KDEDIR).
>
Yes, but it only added the $prefix, and didn't searched in $KDEDIRS
as everyone expects it to do.
Btw, this patch (I hope it's the final one now :) ) also removes some
unnecesary functions that are not needed anymore and duplicate search
directories.
I've tested with some apps (including kspread, which do some
"not-normal"
things with the icon loader) and they work fine.
Anyway, please check it.
Greetings,
--
Antonio Larrosa Jimenez
KDE core developer
antlarr@arrakis.es larrosa@kde.org
http://www.arrakis.es/~rlarrosa
KDE - The development framework of the future, today.
["icontheme4.diff" (text/plain)]
Index: kiconloader.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kiconloader.cpp,v
retrieving revision 1.143
diff -u -r1.143 kiconloader.cpp
--- kiconloader.cpp 2000/10/03 15:44:53 1.143
+++ kiconloader.cpp 2000/10/12 18:36:38
@@ -4,6 +4,7 @@
*
* This file is part of the KDE project, module kdecore.
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * Antonio Larrosa <larrosa@kde.org>
*
* This is free software; it comes under the GNU Library General
* Public License, version 2. See the file "COPYING.LIB" for the
@@ -181,19 +182,23 @@
return;
}
+ QString appname = _appname;
+ if (appname.isEmpty())
+ appname = KGlobal::instance()->instanceName();
+
// Add the default theme and its base themes to the theme tree
- KIconTheme *def = new KIconTheme(KIconTheme::current());
+ KIconTheme *def = new KIconTheme(KIconTheme::current(), appname);
if (!def->isValid())
{
delete def;
if (QPixmap::defaultDepth() > 8)
- def = new KIconTheme(QString::fromLatin1("hicolor"));
+ def = new KIconTheme(QString::fromLatin1("hicolor"), appname);
else
- def = new KIconTheme(QString::fromLatin1("locolor"));
+ def = new KIconTheme(QString::fromLatin1("locolor"), appname);
}
d->mpThemeRoot = new KIconThemeNode(def);
d->mThemesInTree += KIconTheme::current();
- addBaseThemes(d->mpThemeRoot);
+ addBaseThemes(d->mpThemeRoot, appname);
// These have to match the order in kicontheme.h
const char *groups[] = { "Desktop", "Toolbar", "MainToolbar", "Small", "Panel", 0L };
@@ -214,10 +219,10 @@
}
// Insert application specific themes at the top.
- QString appname = _appname;
- if (appname.isEmpty())
- appname = KGlobal::instance()->instanceName();
- addAppDir(appname);
+ d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") +
+ appname + "/pics/");
+ d->mpDirs->addResourceType("appicon", KStandardDirs::kde_default("data") +
+ appname + "/toolbar/");
// Add legacy icon dirs.
QStringList dirs;
@@ -278,9 +283,10 @@
node->links.append(d->mpThemeRoot);
d->mpThemeRoot = node;
}
+
}
-void KIconLoader::addBaseThemes(KIconThemeNode *node)
+void KIconLoader::addBaseThemes(KIconThemeNode *node, const QString &appname)
{
QStringList lst = node->theme->inherits();
QStringList::ConstIterator it;
@@ -289,12 +295,12 @@
{
if (!d->mThemeList.contains(*it) || d->mThemesInTree.contains(*it))
continue;
- KIconTheme *theme = new KIconTheme(*it);
+ KIconTheme *theme = new KIconTheme(*it,appname);
if (!theme->isValid())
continue;
KIconThemeNode *n = new KIconThemeNode(theme);
d->mThemesInTree.append(*it);
- addBaseThemes(n);
+ addBaseThemes(n, appname);
node->links.append(n);
}
}
Index: kiconloader.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kiconloader.h,v
retrieving revision 1.85
diff -u -r1.85 kiconloader.h
--- kiconloader.h 2000/10/03 15:44:53 1.85
+++ kiconloader.h 2000/10/12 18:36:38
@@ -4,6 +4,7 @@
*
* This file is part of the KDE project, module kdecore.
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * Antonio Larrosa <larrosa@kde.org>
*
* This is free software; it comes under the GNU Library General
* Public License, version 2. See the file "COPYING.LIB" for the
@@ -202,7 +203,7 @@
* below (the fallbacks of the theme) in the tree.
* @internal
*/
- void addBaseThemes(KIconThemeNode *node);
+ void addBaseThemes(KIconThemeNode *node, const QString &appname);
// @internal the data object
KIconLoaderPrivate *d;
Index: kicontheme.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kicontheme.cpp,v
retrieving revision 1.33
diff -u -r1.33 kicontheme.cpp
--- kicontheme.cpp 2000/09/29 18:20:42 1.33
+++ kicontheme.cpp 2000/10/12 18:36:39
@@ -4,6 +4,7 @@
*
* This file is part of the KDE project, module kdecore.
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * Antonio Larrosa <larrosa@kde.org>
*
* This is free software; it comes under the GNU Library General
* Public License, version 2. See the file "COPYING.LIB" for the
@@ -77,48 +78,45 @@
d = new KIconThemePrivate;
QStringList icnlibs;
- QStringList::ConstIterator it;
- QString appIconPath;
+ QStringList::ConstIterator it, itDir;
+ QStringList themeDirs;
+ QString cDir;
// Applications can have local additions to the global "locolor" and
// "hicolor" icon themes. For these, the _global_ theme description
// files are used..
- bool isApp = !appName.isEmpty();
- if (isApp)
+ if (!appName.isEmpty() && ( name== "hicolor" || name == "locolor" ) )
{
- if ((name != "hicolor") && (name != "locolor"))
- {
- kdDebug(264) << "Only hicolor and locolor themes can be local.\n";
- return;
- }
-
- icnlibs = KGlobal::dirs()->resourceDirs("data");
- for (it=icnlibs.begin(); it!=icnlibs.end(); it++)
- {
- appIconPath = *it + appName + "/icons/" + name;
- if (QFile::exists( appIconPath ))
- break;
- }
- if (it == icnlibs.end())
- return;
+ icnlibs = KGlobal::dirs()->resourceDirs("data");
+ for (it=icnlibs.begin(); it!=icnlibs.end(); it++)
+ {
+ cDir = *it + appName + "/icons/" + name;
+ if (QFile::exists( cDir ))
+ themeDirs += cDir + "/";
+ }
}
-
// Find the theme description file. These are always global.
icnlibs = KGlobal::dirs()->resourceDirs("icon");
for (it=icnlibs.begin(); it!=icnlibs.end(); it++)
{
- if (KStandardDirs::exists(*it + name + "/index.desktop"))
- break;
+ cDir = *it + name + "/";
+ if (KStandardDirs::exists(cDir))
+ {
+ themeDirs += cDir;
+ if (mDir.isEmpty()
+ && KStandardDirs::exists( cDir + "index.desktop"))
+ mDir = cDir;
+ }
}
- if (it == icnlibs.end())
+
+ if (mDir.isEmpty())
{
kdDebug(264) << "Icon theme " << name << " not found.\n";
return;
}
- mDir = *it + name + "/";
KSimpleConfig cfg(mDir + "index.desktop");
cfg.setGroup("KDE Icon Theme");
mName = cfg.readEntry("Name");
@@ -131,19 +129,14 @@
d->lockOverlay = cfg.readEntry("LockOverlay", "lock");
d->zipOverlay = cfg.readEntry("ZipOverlay", "zip");
- if (isApp)
- {
- mDir = appIconPath + "/";
- mName += "-";
- mName += appName;
- }
-
QStringList dirs = cfg.readListEntry("Directories");
mDirs.setAutoDelete(true);
for (it=dirs.begin(); it!=dirs.end(); it++)
{
cfg.setGroup(*it);
- mDirs.append(new KIconThemeDir(mDir + *it, &cfg));
+ for (itDir=themeDirs.begin(); itDir!=themeDirs.end(); itDir++)
+ if (KStandardDirs::exists(*itDir + *it + "/"))
+ mDirs.append(new KIconThemeDir(*itDir + *it, &cfg));
}
// Expand available sizes for scalable icons to their full range
Index: kicontheme.h
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kicontheme.h,v
retrieving revision 1.12
diff -u -r1.12 kicontheme.h
--- kicontheme.h 2000/09/24 11:25:35 1.12
+++ kicontheme.h 2000/10/12 18:36:40
@@ -4,6 +4,7 @@
*
* This file is part of the KDE project, module kdecore.
* Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * Antonio Larrosa <larrosa@kde.org>
*
* This is free software; it comes under the GNU Library General
* Public License, version 2. See the file "COPYING.LIB" for the
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic