diff -puN kcm-gtk-0.5.3/gtkrcfile.cpp kcm-gtk-0.5.3.working/gtkrcfile.cpp --- kcm-gtk-0.5.3/gtkrcfile.cpp 2009-10-23 18:37:44.000000000 +0530 +++ kcm-gtk-0.5.3.working/gtkrcfile.cpp 2010-01-11 19:15:37.034049064 +0530 @@ -42,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; @@ -73,6 +74,13 @@ void GtkRcFile::load() // Assume there will only be one font line parseFont(fontRe.cap(1)); } + if (line.startsWith("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(); @@ -134,6 +142,7 @@ void GtkRcFile::save() stream << "\n"; stream << "gtk-theme-name=\"" << m_themeName << "\"\n"; stream << "gtk-font-name=\"" << fontName << "\"\n"; + stream << "gtk-cursor-theme-name = \"" << m_cursorName << "\"\n"; } void GtkRcFile::setFont(const QString& family, int pointSize, bool bold, bool italic) diff -puN kcm-gtk-0.5.3/gtkrcfile.h kcm-gtk-0.5.3.working/gtkrcfile.h --- kcm-gtk-0.5.3/gtkrcfile.h 2009-10-23 18:37:44.000000000 +0530 +++ kcm-gtk-0.5.3.working/gtkrcfile.h 2010-01-11 19:32:27.527679437 +0530 @@ -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; diff -puN kcm-gtk-0.5.3/kcmgtk.cpp kcm-gtk-0.5.3.working/kcmgtk.cpp --- kcm-gtk-0.5.3/kcmgtk.cpp 2009-10-23 18:37:44.000000000 +0530 +++ kcm-gtk-0.5.3.working/kcmgtk.cpp 2010-01-11 21:13:26.480665852 +0530 @@ -51,11 +51,13 @@ 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.cursorBox, SIGNAL(activated(int)), SLOT(cursorChanged())); m_gtkRc = new GtkRcFile(k_gtkRcFileName); 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 +74,7 @@ KcmGtk::KcmGtk(QWidget* parent, const QV // Load GTK settings getInstalledThemes(); + getInstalledCursors(); load(); setButtons(Apply); } @@ -89,6 +92,7 @@ void KcmGtk::load() checkQtCurve(); m_ui.styleBox->setCurrentIndex(m_themes.keys().indexOf(m_gtkRc->themeName())); + m_ui.cursorBox->setCurrentIndex(m_cursors.keys().indexOf(m_gtkRc->cursorName())); QFont defaultFont; bool usingKdeFont = (m_gtkRc->font().family() == defaultFont.family() && @@ -117,6 +121,40 @@ 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->addItems(m_cursors.keys()); +} + void KcmGtk::getInstalledThemes() { m_themes.clear(); @@ -157,6 +195,12 @@ void KcmGtk::fontKdeClicked() updateFontPreview(); changed(true); } + +void KcmGtk::cursorChanged() +{ + m_gtkRc->setCursor(m_cursors[m_ui.cursorBox->currentText()]); + changed(true); +} void KcmGtk::styleChanged() { diff -puN kcm-gtk-0.5.3/kcmgtk.h kcm-gtk-0.5.3.working/kcmgtk.h --- kcm-gtk-0.5.3/kcmgtk.h 2009-10-23 18:37:44.000000000 +0530 +++ kcm-gtk-0.5.3.working/kcmgtk.h 2010-01-11 19:33:27.587179319 +0530 @@ -45,7 +45,9 @@ private Q_SLOTS: void fontChangeClicked(); void fontKdeClicked(); void styleChanged(); + void cursorChanged(); void getInstalledThemes(); + void getInstalledCursors(); private: void updateFontPreview(); @@ -55,6 +57,7 @@ private: GtkRcFile* m_gtkRc; QMap m_themes; + QMap m_cursors; SearchPaths* m_searchPaths; static const QString k_gtkRcFileName; diff -puN kcm-gtk-0.5.3/kcmgtkwidget.ui kcm-gtk-0.5.3.working/kcmgtkwidget.ui --- kcm-gtk-0.5.3/kcmgtkwidget.ui 2009-10-23 18:37:44.000000000 +0530 +++ kcm-gtk-0.5.3.working/kcmgtkwidget.ui 2010-01-11 19:54:25.966662106 +0530 @@ -6,11 +6,12 @@ 0 0 - 543 + 549 429 + @@ -19,7 +20,7 @@ GTK+ Styles - + @@ -39,7 +40,7 @@ - + &Widget style: @@ -49,10 +50,10 @@ - + - + Qt::Horizontal @@ -65,14 +66,14 @@ - + Change search paths... - + Qt::Horizontal @@ -85,6 +86,32 @@ + + + + &Cursor Style + + + cursorBox + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + Common subdirectories: kcm-gtk-0.5.3/lib and kcm-gtk-0.5.3.working/lib