summaryrefslogtreecommitdiffstats
path: root/kcm_gtk/kcmgtk.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-11-17 14:21:59 -0600
committerTimothy Pearson <[email protected]>2012-11-17 14:21:59 -0600
commit381fd1dcdfc205283428ebba6b3bf38324a93ca5 (patch)
treefc811900ff3619290b1bcb7145cf6391776971be /kcm_gtk/kcmgtk.cpp
parenta862630a8353b47d09c8a109051c5f194799f905 (diff)
downloadgtk-qt-engine-381fd1dcdfc205283428ebba6b3bf38324a93ca5.tar.gz
gtk-qt-engine-381fd1dcdfc205283428ebba6b3bf38324a93ca5.zip
Add GTK3 theme configuration support
Diffstat (limited to 'kcm_gtk/kcmgtk.cpp')
-rw-r--r--kcm_gtk/kcmgtk.cpp96
1 files changed, 91 insertions, 5 deletions
diff --git a/kcm_gtk/kcmgtk.cpp b/kcm_gtk/kcmgtk.cpp
index 328d286..c577306 100644
--- a/kcm_gtk/kcmgtk.cpp
+++ b/kcm_gtk/kcmgtk.cpp
@@ -15,7 +15,7 @@
* 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. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <tqlayout.h>
@@ -60,6 +60,9 @@ const TQString KcmGtk::GTK_RC_FILE(".gtkrc-2.0-kde-kde4");
const TQString KcmGtk::KDE_RC_DIR(KGlobal::dirs()->localtdedir() + "/env/");
const TQString KcmGtk::GTK_TQT_RC_FILE("gtk-qt-engine.rc.sh");
+const TQString KcmGtk::GTK3_INI_DIR(TQDir::homeDirPath() + "/.config/gtk-3.0/");
+const TQString KcmGtk::GTK3_INI_FILE("settings.ini");
+
/*typedef KGenericFactory<KcmGtk, TQWidget> KcmGtkFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_gtk, KcmGtkFactory("gtk"))*/
@@ -183,6 +186,7 @@ KcmGtk::KcmGtk(TQWidget *parent, const char *name, const TQStringList&)
// Load the icons
KIconLoader iconLoader;
widget->styleIcon->setPixmap(iconLoader.loadIcon("style", KIcon::Desktop));
+ widget->styleIcon3->setPixmap(iconLoader.loadIcon("style", KIcon::Desktop));
widget->fontIcon->setPixmap(iconLoader.loadIcon("fonts", KIcon::Desktop));
widget->firefoxIcon->setPixmap(iconLoader.loadIcon("firefox", KIcon::Desktop));
widget->keyboardIcon->setPixmap(iconLoader.loadIcon("keyboard", KIcon::Desktop));
@@ -193,14 +197,19 @@ KcmGtk::KcmGtk(TQWidget *parent, const char *name, const TQStringList&)
// Connect some signals
connect(widget->warning2, TQT_SIGNAL(leftClickedURL(const TQString&)), KApplication::kApplication(), TQT_SLOT(invokeBrowser(const TQString&)));
connect(widget->styleGroup, TQT_SIGNAL(clicked(int)), TQT_SLOT(itemChanged()));
+ connect(widget->warning5, TQT_SIGNAL(leftClickedURL(const TQString&)), KApplication::kApplication(), TQT_SLOT(invokeBrowser(const TQString&)));
+ connect(widget->styleGroup3, TQT_SIGNAL(clicked(int)), TQT_SLOT(itemChanged()));
connect(widget->fontGroup, TQT_SIGNAL(clicked(int)), TQT_SLOT(itemChanged()));
connect(widget->styleBox, TQT_SIGNAL(activated(int)), TQT_SLOT(itemChanged()));
connect(widget->styleBox, TQT_SIGNAL(activated(int)), TQT_SLOT(styleChanged()));
+ connect(widget->styleBox3, TQT_SIGNAL(activated(int)), TQT_SLOT(itemChanged()));
+ connect(widget->styleBox3, TQT_SIGNAL(activated(int)), TQT_SLOT(styleChanged()));
connect(widget->emacsBox, TQT_SIGNAL(toggled(bool)), TQT_SLOT(itemChanged()));
connect(widget->fontChange, TQT_SIGNAL(clicked()), TQT_SLOT(fontChangeClicked()));
connect(widget->firefoxFix, TQT_SIGNAL(clicked()), TQT_SLOT(firefoxFixClicked()));
connect(widget->emacsDetails, TQT_SIGNAL(clicked()), TQT_SLOT(emacsDetailsClicked()));
connect(widget->warning3, TQT_SIGNAL(clicked()), TQT_SLOT(searchPathsClicked()));
+ connect(widget->warning6, TQT_SIGNAL(clicked()), TQT_SLOT(searchPathsClicked()));
}
void KcmGtk::getInstalledThemes()
@@ -224,13 +233,44 @@ void KcmGtk::getInstalledThemes()
}
widget->styleBox->clear();
- widget->styleBox->insertStringList(themes.keys());
+ TQStringList otherStyles = themes.keys();
+ otherStyles.remove(otherStyles.find("Qt"));
+ widget->styleBox->insertStringList(otherStyles);
bool installed = (themes.find("Qt") != themes.end());
widget->styleKde->setEnabled(installed);
widget->warning1->setHidden(installed);
widget->warning2->setHidden(installed);
widget->warning3->setHidden(installed);
+
+ gtk3Themes.clear();
+ for ( TQStringList::Iterator it = gtkSearchPaths.begin(); it != gtkSearchPaths.end(); ++it )
+ {
+ TQString path = (*it) + "/share/themes/";
+ TQDir dir(path);
+ TQStringList entryList = dir.entryList(TQDir::Dirs, TQDir::Unsorted);
+ for ( TQStringList::Iterator it2 = entryList.begin(); it2 != entryList.end(); ++it2 )
+ {
+ if ((*it2).startsWith("."))
+ continue;
+ if (gtk3Themes.find(*it2) != gtk3Themes.end())
+ continue;
+ if (!TQFile::exists(path + (*it2) + "/gtk-3.0/gtk.css"))
+ continue;
+ gtk3Themes.insert((*it2), path + (*it2) + "/gtk-3.0/gtk.css");
+ }
+ }
+
+ widget->styleBox3->clear();
+ TQStringList otherGtk3Styles = gtk3Themes.keys();
+ otherGtk3Styles.remove(otherGtk3Styles.find("tdegtk"));
+ widget->styleBox3->insertStringList(otherGtk3Styles);
+
+ bool gtk3installed = (gtk3Themes.find("tdegtk") != gtk3Themes.end());
+ widget->styleKde3->setEnabled(gtk3installed);
+ widget->warning4->setHidden(gtk3installed);
+ widget->warning5->setHidden(gtk3installed);
+ widget->warning6->setHidden(gtk3installed);
}
void KcmGtk::itemChanged()
@@ -306,10 +346,12 @@ void KcmGtk::load()
break;
}
- if (usingQtEngine)
+ if (usingQtEngine) {
widget->styleGroup->setButton(widget->styleGroup->id(widget->styleKde));
- else
+ }
+ else {
widget->styleGroup->setButton(widget->styleGroup->id(widget->styleOther));
+ }
}
font = parser.font;
@@ -324,6 +366,30 @@ void KcmGtk::load()
widget->emacsBox->setChecked(parser.emacs);
updateFontPreview();
+
+ bool usingGtk3TQtEngine = false;
+ if (TQFile::exists(GTK3_INI_DIR + GTK3_INI_FILE)) {
+ TQString activeGtk3Style;
+ KConfig gtk3Config(GTK3_INI_DIR + GTK3_INI_FILE);
+ gtk3Config.setGroup("Settings");
+ activeGtk3Style = gtk3Config.readEntry("gtk-theme-name");
+ if (activeGtk3Style == "tdegtk") {
+ usingGtk3TQtEngine = true;
+ }
+
+ if (usingGtk3TQtEngine) {
+ widget->styleGroup3->setButton(widget->styleGroup3->id(widget->styleKde3));
+ }
+ else {
+ widget->styleGroup3->setButton(widget->styleGroup3->id(widget->styleOther3));
+ for (int i=0; i<widget->styleBox3->count(); ++i) {
+ if (widget->styleBox3->text(i) == activeGtk3Style) {
+ widget->styleBox3->setCurrentItem(i);
+ break;
+ }
+ }
+ }
+ }
}
@@ -342,6 +408,9 @@ void KcmGtk::save()
TQString themeName = widget->styleKde->isChecked() ? themes["Qt"] : themes[widget->styleBox->currentText()];
TQString themeNameShort = widget->styleKde->isChecked() ? TQString("Qt") : widget->styleBox->currentText();
+
+ TQString themeName3 = widget->styleKde3->isChecked() ? gtk3Themes["tdegtk"] : gtk3Themes[widget->styleBox3->currentText()];
+ TQString themeNameShort3 = widget->styleKde3->isChecked() ? TQString("tdegtk") : widget->styleBox3->currentText();
stream << "# This file was written by TDE\n";
stream << "# You can edit it in the TDE control center, under \"GTK Styles and Fonts\"\n";
@@ -438,7 +507,24 @@ void KcmGtk::save()
stream << fileDataString;
file.close();
}
-
+
+ TQDir gtk3IniDir;
+ if (!gtk3IniDir.exists(GTK3_INI_DIR))
+ {
+ // Make sure the GTK INI dir exists
+ gtk3IniDir.mkdir(GTK3_INI_DIR);
+ }
+
+ TQFile gtk3IniFile(GTK3_INI_DIR + GTK3_INI_FILE);
+ gtk3IniFile.open(IO_WriteOnly);
+ TQTextStream gtk3IniStream(&gtk3IniFile);
+ gtk3IniStream << "# This file was written by TDE\n";
+ gtk3IniStream << "# You can edit it in the TDE control center, under \"GTK Styles and Fonts\"\n";
+ gtk3IniStream << "\n";
+ gtk3IniStream << "[Settings]\n";
+ gtk3IniStream << "gtk-theme-name = " << themeNameShort3 << "\n";
+ gtk3IniFile.close();
+
emit changed(true);
}