summaryrefslogtreecommitdiff
path: root/src/utils/iconprovider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/iconprovider.cpp')
-rw-r--r--src/utils/iconprovider.cpp116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/utils/iconprovider.cpp b/src/utils/iconprovider.cpp
deleted file mode 100644
index 9830fa2..0000000
--- a/src/utils/iconprovider.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (C) 2008 Lukas Lalinsky
-// Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-#include <cstdlib>
-#include <QDebug>
-#include <QIcon>
-#include <QDir>
-#include <QVariant>
-#include <QLibrary>
-#include <QApplication>
-#include "iconprovider.h"
-
-using namespace std;
-
-#ifdef Q_WS_X11
-extern "C" {
- struct GConfClient;
- struct GError;
- typedef void (*Ptr_g_type_init)();
- typedef GConfClient* (*Ptr_gconf_client_get_default)();
- typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
- typedef void (*Ptr_g_object_unref)(void *);
- typedef void (*Ptr_g_error_free)(GError *);
- typedef void (*Ptr_g_free)(void*);
-}
-
-static Ptr_g_type_init p_g_type_init = 0;
-static Ptr_gconf_client_get_default p_gconf_client_get_default = 0;
-static Ptr_gconf_client_get_string p_gconf_client_get_string = 0;
-static Ptr_g_object_unref p_g_object_unref = 0;
-static Ptr_g_error_free p_g_error_free = 0;
-static Ptr_g_free p_g_free = 0;
-#endif
-
-void IconProvider::gnomeLookupIconTheme()
-{
-#ifdef Q_WS_X11
- if (themeName.isEmpty()) {
- //resolve glib and gconf functions
- p_g_type_init = (Ptr_g_type_init)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_type_init");
- p_gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_default");
- p_gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_string");
- p_g_object_unref = (Ptr_g_object_unref)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_object_unref");
- p_g_error_free = (Ptr_g_error_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_error_free");
- p_g_free = (Ptr_g_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_free");
-
- if (p_g_type_init &&
- p_gconf_client_get_default &&
- p_gconf_client_get_string &&
- p_g_object_unref &&
- p_g_error_free &&
- p_g_free) {
-
- p_g_type_init();
- GConfClient* client = p_gconf_client_get_default();
- GError *err = 0;
- char *str = p_gconf_client_get_string(client, "/desktop/gnome/interface/icon_theme", &err);
- if (!err) {
- themeName = QString::fromUtf8(str);
- p_g_free(str);
- }
- p_g_object_unref(client);
- if (err)
- p_g_error_free (err);
- }
- if (themeName.isEmpty())
- themeName = QLatin1String("gnome");
- }
-#endif
-}
-
-IconProvider::IconProvider()
-{
-#ifdef Q_WS_X11
- if (getenv("GNOME_DESKTOP_SESSION_ID")) {
- gnomeLookupIconTheme();
- }
- else if (getenv("KDE_FULL_SESSION")) {
- // FIXME
- }
- if (!themeName.isEmpty()) {
- iconDirs << QDir::homePath() + "/.icons/";
- iconDirs << "/usr/share/icons/";
- }
-#endif
-}
-
-QIcon
-IconProvider::findIcon(int size, const QString &name)
-{
-#ifdef Q_WS_X11
- IconProvider *iconProvider = instance();
- QString sizeString = QString("/%1x%2/").arg(size).arg(size);
- foreach(QString path, iconProvider->iconDirs) {
- QString fullPath = path + iconProvider->themeName + sizeString + "actions/" + name;
- if (QFile::exists(fullPath)) {
- return QIcon(fullPath);
- }
- }
-#endif
- return QIcon(":/icons" + sizeString + name);
-}