summaryrefslogtreecommitdiffstats
path: root/kcm_gtk
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-17 14:21:59 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-11-17 14:21:59 -0600
commit381fd1dcdfc205283428ebba6b3bf38324a93ca5 (patch)
treefc811900ff3619290b1bcb7145cf6391776971be /kcm_gtk
parenta862630a8353b47d09c8a109051c5f194799f905 (diff)
downloadgtk-qt-engine-381fd1dcdfc205283428ebba6b3bf38324a93ca5.tar.gz
gtk-qt-engine-381fd1dcdfc205283428ebba6b3bf38324a93ca5.zip
Add GTK3 theme configuration support
Diffstat (limited to 'kcm_gtk')
-rw-r--r--kcm_gtk/kcmgtk.cpp96
-rw-r--r--kcm_gtk/kcmgtk.h4
-rw-r--r--kcm_gtk/kcmgtkwidget.ui189
3 files changed, 278 insertions, 11 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);
}
diff --git a/kcm_gtk/kcmgtk.h b/kcm_gtk/kcmgtk.h
index 4e827b5..dee376b 100644
--- a/kcm_gtk/kcmgtk.h
+++ b/kcm_gtk/kcmgtk.h
@@ -56,6 +56,9 @@ class KcmGtk: public KCModule
// How to name qtk-qt-engines rc-file
static const TQString GTK_TQT_RC_FILE;
+ static const TQString GTK3_INI_DIR;
+ static const TQString GTK3_INI_FILE;
+
public:
KcmGtk( TQWidget *parent=0, const char *name=0, const TQStringList& = TQStringList() );
~KcmGtk();
@@ -92,6 +95,7 @@ private:
KcmGtkWidget* widget;
TQMap<TQString,TQString> themes;
+ TQMap<TQString,TQString> gtk3Themes;
GtkRcParser parser;
KAboutData *myAboutData;
TQFont font;
diff --git a/kcm_gtk/kcmgtkwidget.ui b/kcm_gtk/kcmgtkwidget.ui
index 03482fc..512a610 100644
--- a/kcm_gtk/kcmgtkwidget.ui
+++ b/kcm_gtk/kcmgtkwidget.ui
@@ -35,7 +35,7 @@
</sizepolicy>
</property>
<property name="title">
- <string>GTK Styles</string>
+ <string>GTK2 Styles</string>
</property>
<hbox>
<property name="name">
@@ -141,7 +141,7 @@
<cstring>styleKde</cstring>
</property>
<property name="text">
- <string>&amp;Use my TDE style in GTK applications</string>
+ <string>&amp;Use my TDE style in GTK2 applications</string>
</property>
</widget>
<widget class="TQComboBox" row="1" column="1">
@@ -176,7 +176,7 @@
<cstring>warning1</cstring>
</property>
<property name="text">
- <string>&lt;b&gt;Warning:&lt;/b&gt; The Gtk-Qt theme engine is not installed. This means you will not be able to use your TDE style in GTK applications.</string>
+ <string>&lt;b&gt;Warning:&lt;/b&gt; The Gtk-Qt theme engine is not installed. This means you will not be able to use your TDE style in GTK2 applications.</string>
</property>
</widget>
<widget class="KURLLabel" row="4" column="0" rowspan="1" colspan="3">
@@ -194,6 +194,178 @@
</widget>
</hbox>
</widget>
+ <widget class="TQButtonGroup">
+ <property name="name">
+ <cstring>styleGroup3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>4</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>GTK3 Styles</string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout12</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLabel">
+ <property name="name">
+ <cstring>styleIcon3</cstring>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Minimum</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="TQLayoutWidget">
+ <property name="name">
+ <cstring>layout17</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="1" column="2">
+ <property name="name">
+ <cstring>spacer8_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>150</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQLayoutWidget" row="3" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>layout16</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>warning6</cstring>
+ </property>
+ <property name="text">
+ <string>Change search paths...</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>176</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="TQRadioButton" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>styleKde3</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Use my TDE style in GTK3 applications</string>
+ </property>
+ </widget>
+ <widget class="TQComboBox" row="1" column="1">
+ <property name="name">
+ <cstring>styleBox3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>styleOther3</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;another style:</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>warning4</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Warning:&lt;/b&gt; The Gtk3-TQt theme engine is not installed. This means you will not be able to use your TDE style in GTK3 applications.</string>
+ </property>
+ </widget>
+ <widget class="KURLLabel" row="4" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>warning5</cstring>
+ </property>
+ <property name="text">
+ <string>Gtk3-TQt theme engine homepage</string>
+ </property>
+ <property name="url" stdset="0">
+ <string>http://www.trinitydesktop.org/</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </hbox>
+ </widget>
<widget class="TQButtonGroup">
<property name="name">
<cstring>fontGroup</cstring>
@@ -207,7 +379,7 @@
</sizepolicy>
</property>
<property name="title">
- <string>GTK Fonts</string>
+ <string>GTK2 Fonts</string>
</property>
<hbox>
<property name="name">
@@ -329,7 +501,7 @@
<cstring>fontKde</cstring>
</property>
<property name="text">
- <string>Use m&amp;y TDE fonts in GTK applications</string>
+ <string>Use m&amp;y TDE fonts in GTK2 applications</string>
</property>
<property name="accel">
<string>Alt+Y</string>
@@ -382,7 +554,7 @@
<cstring>groupBox2</cstring>
</property>
<property name="title">
- <string>GTK Keyboard Shortcuts</string>
+ <string>GTK2 Keyboard Shortcuts</string>
</property>
<hbox>
<property name="name">
@@ -629,6 +801,11 @@
<tabstop>styleBox</tabstop>
<tabstop>warning3</tabstop>
<tabstop>warning2</tabstop>
+ <tabstop>styleKde3</tabstop>
+ <tabstop>styleOther3</tabstop>
+ <tabstop>styleBox3</tabstop>
+ <tabstop>warning4</tabstop>
+ <tabstop>warning5</tabstop>
<tabstop>fontKde</tabstop>
<tabstop>fontOther</tabstop>
<tabstop>fontChange</tabstop>