--- kcm-gtk-0.5.3/gtkrcfile.cpp	2011-12-19 16:20:37.538234257 +0200
+++ kcm-gtk3/gtkrcfile.cpp	2011-12-19 15:33:20.000000000 +0200
@@ -26,8 +26,6 @@
 #include <QTextStream>
 #include <QStringList>
 #include <QtDebug>
-#include <ktoolinvocation.h>
-#include <klauncher_iface.h>
 
 QRegExp GtkRcFile::k_themeNameRe("([^/]+)/gtk-2.0/gtkrc$");
 
@@ -44,6 +42,7 @@ void GtkRcFile::load()
 	
 	QRegExp includeRe("include\\s*\"([^\"]*)\"");
 	QRegExp fontRe("gtk-font-name\\s*=\\s*\"([^\"]*)\"");
+	QRegExp cursorRe("gtk-cursor-theme-name\\s*=\\s*\"([^\"]*)\"");
 	
 	
 	QStringList includes;
@@ -58,23 +57,30 @@ void GtkRcFile::load()
 		
 		line = line.trimmed();
 		
-		if (line.startsWith("include"))
+		if (line.startsWith(QLatin1String("include")))
 		{
 			if (includeRe.indexIn(line) == -1)
 				continue;
 			QString themePath = includeRe.cap(1);
-			if (themePath.startsWith("/etc"))
+			if (themePath.startsWith(QLatin1String("/etc")))
 				continue;
 			
 			setTheme(themePath);
 		}
-		if (line.startsWith("gtk-font-name"))
+		if (line.startsWith(QLatin1String("gtk-font-name")))
 		{
 			if (fontRe.indexIn(line) == -1)
 				continue;
 			// Assume there will only be one font line
 			parseFont(fontRe.cap(1));
 		}
+		if (line.startsWith(QLatin1String("gtk-cursor-theme-name")))
+		{
+			if (cursorRe.indexIn(line) == -1)
+				continue;
+			// Assume there will only be one cursor theme line
+			setCursor(cursorRe.cap(1));
+		}
 	}
 	
 	file.close();
@@ -136,14 +142,8 @@ void GtkRcFile::save()
 	stream << "\n";
 	stream << "gtk-theme-name=\"" << m_themeName << "\"\n";
 	stream << "gtk-font-name=\"" << fontName << "\"\n";
-	
-	QByteArray gtkrc = getenv("GTK2_RC_FILES");
-	QStringList list = QFile::decodeName(gtkrc).split( ':');
-	if (!list.contains(m_fileName)) {
-	  list.append(m_fileName);
-	  QString value = QFile::encodeName(list.join(":"));
-	  KToolInvocation::klauncher()->setLaunchEnv("GTK2_RC_FILES", value);
-	}
+	if (!m_cursorName.isEmpty())
+		stream << "gtk-cursor-theme-name = \"" << m_cursorName << "\"\n";
 }
 
 void GtkRcFile::setFont(const QString& family, int pointSize, bool bold, bool italic)
--- kcm-gtk-0.5.3/gtkrcfile.h	2009-10-23 16:07:44.000000000 +0300
+++ kcm-gtk3/gtkrcfile.h	2011-12-19 15:33:20.000000000 +0200
@@ -34,10 +34,12 @@ public:
 	
 	QString fileName() const { return m_fileName; }
 	QString themeName() const { return m_themeName; }
+	QString cursorName() const { return m_cursorName; }
 	QString themePath() const { return m_themePath; }
 	QFont font() const { return m_font; }
 	
 	void setTheme(const QString& path);
+	void setCursor(const QString& cursor) { m_cursorName = cursor; };
 	void setFont(const QFont& font) { m_font = font; }
 	void setFont(const QString& family, int pointSize, bool bold, bool italic);
 	
@@ -46,6 +48,7 @@ private:
 	
 	QString m_fileName;
 	QString m_themeName;
+	QString m_cursorName;
 	QString m_themePath;
 	QFont m_font;
 	
--- kcm-gtk-0.5.3/kcmgtk.cpp	2009-10-23 16:07:44.000000000 +0300
+++ kcm-gtk3/kcmgtk.cpp	2011-12-19 15:33:20.000000000 +0200
@@ -37,6 +37,7 @@
 
 
 const QString KcmGtk::k_gtkRcFileName(QDir::homePath() + "/.gtkrc-2.0-kde4");
+const QString KcmGtk::k_gtk3RcFileName(QDir::homePath() + "/.config/gtk-3.0/settings.ini");
 const QString KcmGtk::k_qtThemeName("Qt4");
 const QString KcmGtk::k_qtcurveThemeName("QtCurve");
 
@@ -51,11 +52,15 @@ KcmGtk::KcmGtk(QWidget* parent, const QV
 	connect(m_ui.fontChange, SIGNAL(clicked()), SLOT(fontChangeClicked()));
 	connect(m_ui.fontKde, SIGNAL(clicked(bool)), SLOT(fontKdeClicked()));
 	connect(m_ui.styleBox, SIGNAL(activated(int)), SLOT(styleChanged()));
-	
+	connect(m_ui.style3Box, SIGNAL(activated(int)), SLOT(style3Changed()));
+	connect(m_ui.cursorBox, SIGNAL(activated(int)), SLOT(cursorChanged()));
+
 	m_gtkRc = new GtkRcFile(k_gtkRcFileName);
-	
+	m_gtk3Rc = new KConfigGroup(KSharedConfig::openConfig(k_gtk3RcFileName, KConfig::SimpleConfig), "Settings");
+
 	m_searchPaths = new SearchPaths(this);
 	connect(m_searchPaths, SIGNAL(accepted()), SLOT(getInstalledThemes()));
+	connect(m_searchPaths, SIGNAL(accepted()), SLOT(getInstalledCursors()));
 	connect(m_ui.warning3, SIGNAL(clicked()), m_searchPaths, SLOT(exec()));
 	
 	// Load icons
@@ -72,6 +77,7 @@ KcmGtk::KcmGtk(QWidget* parent, const QV
 	
 	// Load GTK settings
 	getInstalledThemes();
+	getInstalledCursors();
 	load();
 	setButtons(Apply);
 }
@@ -79,6 +85,7 @@ KcmGtk::KcmGtk(QWidget* parent, const QV
 KcmGtk::~KcmGtk()
 {
 	delete m_gtkRc;
+	delete m_gtk3Rc;
 }
 
 void KcmGtk::load()
@@ -89,6 +96,11 @@ void KcmGtk::load()
 	checkQtCurve();
 
 	m_ui.styleBox->setCurrentIndex(m_themes.keys().indexOf(m_gtkRc->themeName()));
+	m_ui.style3Box->setCurrentIndex(m_gtk3themes.indexOf(m_gtk3Rc->readEntry("gtk-theme-name")));
+	if (m_gtkRc->cursorName().isEmpty())
+		m_ui.cursorBox->setCurrentIndex(0);
+	else
+		m_ui.cursorBox->setCurrentIndex(m_cursors.keys().indexOf(m_gtkRc->cursorName()) + 1);
 	
 	QFont defaultFont;
 	bool usingKdeFont = (m_gtkRc->font().family() == defaultFont.family() &&
@@ -104,19 +116,66 @@ void KcmGtk::load()
 void KcmGtk::updateFontPreview()
 {
 	m_ui.fontPreview->setFont(m_gtkRc->font());
-	m_ui.fontPreview->setText(i18n("%1 (size %2)", m_gtkRc->font().family(), QString::number(m_gtkRc->font().pointSize())));
+	m_ui.fontPreview->setText(i18n("%1 (size %2)", m_gtkRc->font().family(), m_gtkRc->font().pointSize()));
 }
 
 void KcmGtk::save()
 {
 	// Write ~/.gtkrc-2.0-kde4
 	m_gtkRc->save();
+	const QFont & font = m_gtkRc->font();
+	QString fontName = font.family() + ' ' +
+	QLatin1String(font.bold() ? "Bold " : "") +
+	QLatin1String(font.italic() ? "Italic " : "") +
+	QString::number(font.pointSize());
+	m_gtk3Rc->writeEntry("gtk-theme-name", m_ui.style3Box->currentText());
+	m_gtk3Rc->writeEntry("gtk-font-name", fontName);
+	if (!m_gtkRc->cursorName().isEmpty())
+		m_gtk3Rc->writeEntry("gtk-cursor-theme-name", m_gtkRc->cursorName());
+	else
+		m_gtk3Rc->deleteEntry("gtk-cursor-theme-name");
+	m_gtk3Rc->sync();
 }
 
 void KcmGtk::defaults()
 {
 }
 
+void KcmGtk::getInstalledCursors()
+{
+	m_cursors.clear();
+	Q_FOREACH (QString path, m_searchPaths->paths())
+	{
+		path += "/share/icons/";
+		Q_FOREACH (QString subdir, QDir(path).entryList(QDir::Dirs, QDir::Unsorted))
+		{
+			if (subdir.startsWith('.'))
+				continue;
+			if (m_cursors.contains(subdir))
+				continue;
+			if (QFile::exists(path + subdir + "/cursors") && QFile::exists(path + subdir + "/index.theme"))
+				m_cursors[subdir] = subdir;
+		}
+	}
+
+	/* search user home dir for any custom icons too. user changes
+     * override the system cursor icons if the same exists in user home dir */
+	QString apath = QDir::homePath() + "/.icons/";
+	Q_FOREACH (QString subdir, QDir(apath).entryList(QDir::Dirs, QDir::Unsorted))
+		{
+			if (subdir.startsWith('.'))
+				continue;
+			if (m_cursors.contains(subdir))
+				continue;
+			if (QFile::exists(apath + subdir + "/cursors") && QFile::exists(apath + subdir + "/index.theme"))
+				m_cursors[subdir] = subdir;
+		}
+
+	m_ui.cursorBox->clear();
+	m_ui.cursorBox->addItem(i18n("Use default cursor"));
+	m_ui.cursorBox->addItems(m_cursors.keys());
+}
+
 void KcmGtk::getInstalledThemes()
 {
 	m_themes.clear();
@@ -127,16 +186,16 @@ void KcmGtk::getInstalledThemes()
 		{
 			if (subdir.startsWith('.'))
 				continue;
-			if (m_themes.contains(subdir))
-				continue;
-			if (!QFile::exists(path + subdir + "/gtk-2.0/gtkrc"))
-				continue;
-			m_themes[subdir] = path + subdir + "/gtk-2.0/gtkrc";
+			if (!m_themes.contains(subdir) && QFile::exists(path + subdir + "/gtk-2.0/gtkrc"))
+				m_themes[subdir] = path + subdir + "/gtk-2.0/gtkrc";
+			if (!m_gtk3themes.contains(subdir) && QFile::exists(path + subdir + "/gtk-3.0/gtk.css"))
+				m_gtk3themes.append(subdir);
 		}
 	}
 
 	m_ui.styleBox->clear();
 	m_ui.styleBox->addItems(m_themes.keys());
+	m_ui.style3Box->addItems(m_gtk3themes);
 }
 
 void KcmGtk::fontChangeClicked()
@@ -157,6 +216,15 @@ void KcmGtk::fontKdeClicked()
 	updateFontPreview();
 	changed(true);
 }
+ 
+void KcmGtk::cursorChanged()
+{
+	if (m_ui.cursorBox->currentIndex() != 0)
+		m_gtkRc->setCursor(m_cursors[m_ui.cursorBox->currentText()]);
+	else
+		m_gtkRc->setCursor(QLatin1String(""));
+	changed(true);
+}
 
 void KcmGtk::styleChanged()
 {
@@ -165,6 +233,11 @@ void KcmGtk::styleChanged()
 	changed(true);
 }
 
+void KcmGtk::style3Changed()
+{
+	changed(true);
+}
+
 void KcmGtk::checkQtCurve()
 {
 	if (m_gtkRc->themeName() == k_qtcurveThemeName)
--- kcm-gtk-0.5.3/kcmgtk.h	2009-10-23 16:07:44.000000000 +0300
+++ kcm-gtk3/kcmgtk.h	2011-12-19 15:33:20.000000000 +0200
@@ -18,15 +18,16 @@
  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
  ***************************************************************************/
 
-#ifndef _KCMTEST_H_
-#define _KCMTEST_H_
+#ifndef KCMGTK_H
+#define KCMGTK_H
 
-#include <QStringList>
 #include <kcmodule.h>
 
+#include <QStringList>
+
 #include "ui_kcmgtkwidget.h"
 
-class KConfig;
+class KConfigGroup;
 class GtkRcFile;
 class SearchPaths;
 
@@ -34,7 +35,7 @@ class KcmGtk: public KCModule
 {
 	Q_OBJECT
 public:
-	KcmGtk(QWidget* parent = 0, const QVariantList& = QVariantList());
+	explicit KcmGtk(QWidget* parent = 0, const QVariantList& = QVariantList());
 	~KcmGtk();
 	
 	void load();
@@ -45,7 +46,10 @@ private Q_SLOTS:
 	void fontChangeClicked();
 	void fontKdeClicked();
 	void styleChanged();
+	void style3Changed();
+	void cursorChanged();
 	void getInstalledThemes();
+	void getInstalledCursors();
 
 private:
 	void updateFontPreview();
@@ -54,10 +58,14 @@ private:
 	Ui_KcmGtkWidget m_ui;
 	
 	GtkRcFile* m_gtkRc;
+	KConfigGroup* m_gtk3Rc;
 	QMap<QString, QString> m_themes;
+	QList<QString> m_gtk3themes;
+	QMap<QString, QString> m_cursors;
 	SearchPaths* m_searchPaths;
 	
 	static const QString k_gtkRcFileName;
+	static const QString k_gtk3RcFileName;
 	static const QString k_envFileName;
 	static const QString k_qtThemeName;
 	static const QString k_qtcurveThemeName;
--- kcm-gtk-0.5.3/kcmgtkwidget.ui	2009-10-23 16:07:44.000000000 +0300
+++ kcm-gtk3/kcmgtkwidget.ui	2011-12-19 15:33:20.000000000 +0200
@@ -6,11 +6,12 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>543</width>
+    <width>549</width>
     <height>429</height>
    </rect>
   </property>
   <property name="windowTitle">
+   <string/>
   </property>
   <layout class="QVBoxLayout">
    <item>
@@ -19,7 +20,7 @@
       <string>GTK+ Styles</string>
      </property>
      <layout class="QGridLayout" name="gridLayout">
-      <item row="0" column="0" rowspan="2">
+      <item row="0" column="0" rowspan="5">
        <layout class="QVBoxLayout">
         <item>
          <widget class="QLabel" name="styleIcon"/>
@@ -39,20 +40,20 @@
         </item>
        </layout>
       </item>
-      <item row="0" column="1">
+      <item row="0" column="2">
        <widget class="QLabel" name="label">
         <property name="text">
-         <string>&amp;Widget style:</string>
+         <string>GTK+2 &amp;Widget style:</string>
         </property>
         <property name="buddy">
          <cstring>styleBox</cstring>
         </property>
        </widget>
       </item>
-      <item row="0" column="2">
-       <widget class="QComboBox" name="styleBox"/>
-      </item>
       <item row="0" column="3">
+       <widget class="KComboBox" name="styleBox"/>
+      </item>
+      <item row="0" column="5">
        <spacer>
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
@@ -65,14 +66,14 @@
         </property>
        </spacer>
       </item>
-      <item row="1" column="1" colspan="2">
+      <item row="4" column="2" colspan="2">
        <widget class="QPushButton" name="warning3">
         <property name="text">
          <string>Change search paths...</string>
         </property>
        </widget>
       </item>
-      <item row="1" column="3">
+      <item row="4" column="5">
        <spacer>
         <property name="orientation">
          <enum>Qt::Horizontal</enum>
@@ -85,6 +86,58 @@
         </property>
        </spacer>
       </item>
+      <item row="2" column="2">
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>&amp;Cursor Style:</string>
+        </property>
+        <property name="buddy">
+         <cstring>cursorBox</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="3">
+       <widget class="KComboBox" name="cursorBox"/>
+      </item>
+      <item row="2" column="5">
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+      <item row="1" column="2">
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>GTK+3 Widget &amp;style</string>
+        </property>
+        <property name="buddy">
+         <cstring>style3Box</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="3">
+       <widget class="KComboBox" name="style3Box"/>
+      </item>
+      <item row="1" column="5">
+       <spacer name="horizontalSpacer_2">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>40</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
      </layout>
     </widget>
    </item>
@@ -162,7 +215,7 @@
       <item row="3" column="1" colspan="3">
        <widget class="KSqueezedTextLabel" name="qtcurveFontLabel">
         <property name="text">
-         <string>The QtCurve widget theme uses your KDE font settings</string>
+         <string>KSqueezedTextLabel</string>
         </property>
         <property name="indent">
          <number>32</number>
@@ -205,6 +258,11 @@
  </widget>
  <customwidgets>
   <customwidget>
+   <class>KComboBox</class>
+   <extends>QComboBox</extends>
+   <header>kcombobox.h</header>
+  </customwidget>
+  <customwidget>
    <class>KSqueezedTextLabel</class>
    <extends>QLabel</extends>
    <header>ksqueezedtextlabel.h</header>
--- kcm-gtk-0.5.3/po/kcm_gtk.pot	1970-01-01 03:00:00.000000000 +0300
+++ kcm-gtk3/po/kcm_gtk.pot	2011-12-19 15:33:20.000000000 +0200
@@ -0,0 +1,142 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR This_file_is_part_of_KDE
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2010-01-11 12:00-0500\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: kcmgtk.cpp:69
+msgid "kcm_gtk"
+msgstr ""
+
+#: kcmgtk.cpp:70
+msgid "GTK Styles and Fonts"
+msgstr ""
+
+#: kcmgtk.cpp:71
+msgid "(C) 2008 David Sansome"
+msgstr ""
+
+#: kcmgtk.cpp:72
+msgid "(C) 2009 Jonathan Thomas"
+msgstr ""
+
+#: kcmgtk.cpp:73
+msgid "Change the appearance of GTK+ applications in KDE"
+msgstr ""
+
+#: kcmgtk.cpp:111
+#, kde-format
+msgid "%1 (size %2)"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:20
+#. i18n: ectx: property (title), widget (QGroupBox, groupBox)
+#: rc.cpp:3 rc.cpp:47
+msgid "GTK+ Styles"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:46
+#. i18n: ectx: property (text), widget (QLabel, label)
+#: rc.cpp:6 rc.cpp:50
+msgid "&Widget style:"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:72
+#. i18n: ectx: property (text), widget (QPushButton, warning3)
+#: rc.cpp:9 rc.cpp:53
+msgid "Change search paths..."
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:92
+#. i18n: ectx: property (text), widget (QLabel, label_2)
+#: rc.cpp:12 rc.cpp:56
+msgid "&Cursor Style:"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:121
+#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2)
+#: rc.cpp:15 rc.cpp:59
+msgid "GTK+ Fonts"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:151
+#. i18n: ectx: property (text), widget (QRadioButton, fontKde)
+#: rc.cpp:18 rc.cpp:62
+msgid "Use m&y KDE fonts in GTK+ applications"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:158
+#. i18n: ectx: property (text), widget (QRadioButton, fontOther)
+#: rc.cpp:21 rc.cpp:65
+msgid "Use another font:"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:165
+#. i18n: ectx: property (text), widget (QPushButton, fontChange)
+#: rc.cpp:24 rc.cpp:68
+msgid "Change..."
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:192
+#. i18n: ectx: property (text), widget (KSqueezedTextLabel, qtcurveFontLabel)
+#: rc.cpp:27 rc.cpp:71
+msgid "The QtCurve widget theme uses your KDE font settings"
+msgstr ""
+
+#. i18n: file: kcmgtkwidget.ui:211
+#. i18n: ectx: property (text), widget (QLabel, label_6)
+#: rc.cpp:30 rc.cpp:74
+msgid ""
+"Note that changes made here will only affect GTK+ applications when KDE is "
+"running.  To change the styles and fonts used by applications in GNOME, use "
+"the GNOME configuration tools."
+msgstr ""
+
+#. i18n: file: searchpaths.ui:20
+#. i18n: ectx: property (windowTitle), widget (QWidget, SearchPaths)
+#: rc.cpp:33 rc.cpp:77
+msgid "Change search paths"
+msgstr ""
+
+#. i18n: file: searchpaths.ui:26
+#. i18n: ectx: property (text), widget (QLabel, textLabel1)
+#: rc.cpp:36 rc.cpp:80
+msgid ""
+"You can set a custom search path here if we were not able to find a GTK+ "
+"theme engine. This could happen if the theme engine was installed to a "
+"custom location."
+msgstr ""
+
+#. i18n: file: searchpaths.ui:50
+#. i18n: ectx: property (text), widget (QPushButton, addButton)
+#: rc.cpp:39 rc.cpp:83
+msgid "Add"
+msgstr ""
+
+#. i18n: file: searchpaths.ui:63
+#. i18n: ectx: property (text), widget (QPushButton, removeButton)
+#: rc.cpp:42 rc.cpp:86
+msgid "Remove"
+msgstr ""
+
+#: rc.cpp:43
+msgctxt "NAME OF TRANSLATORS"
+msgid "Your names"
+msgstr ""
+
+#: rc.cpp:44
+msgctxt "EMAIL OF TRANSLATORS"
+msgid "Your emails"
+msgstr ""
--- kcm-gtk-0.5.3/searchpaths.ui	2009-10-23 16:07:44.000000000 +0300
+++ kcm-gtk3/searchpaths.ui	2011-12-19 15:33:20.000000000 +0200
@@ -39,7 +39,7 @@
    <item>
     <layout class="QHBoxLayout">
      <item>
-      <widget class="QLineEdit" name="pathBox"/>
+      <widget class="KLineEdit" name="pathBox"/>
      </item>
      <item>
       <widget class="QPushButton" name="addButton">
