From cc466876d2679f7824686aba6a39a7b2bd7fb24e Mon Sep 17 00:00:00 2001 From: Jonathan Riddell Date: Wed, 28 Oct 2015 09:41:39 +0000 Subject: [PATCH] gtkbreeze now moved to breeze-gtk repository --- misc/CMakeLists.txt | 1 - misc/gtkbreeze/CMakeLists.txt | 9 -- misc/gtkbreeze/gtkbreeze.upd | 3 - misc/gtkbreeze/main.cpp | 194 ---------------------------------- 4 files changed, 207 deletions(-) delete mode 100644 misc/gtkbreeze/CMakeLists.txt delete mode 100644 misc/gtkbreeze/gtkbreeze.upd delete mode 100644 misc/gtkbreeze/main.cpp diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index 4cb1ba91..ff891a9c 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -1,3 +1,2 @@ add_subdirectory(qtcurvepreset) add_subdirectory(kde4breeze) -add_subdirectory(gtkbreeze) diff --git a/misc/gtkbreeze/CMakeLists.txt b/misc/gtkbreeze/CMakeLists.txt deleted file mode 100644 index 2dfc4393..00000000 --- a/misc/gtkbreeze/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -find_package(Qt5 REQUIRED COMPONENTS Core Widgets) -find_package(KF5 REQUIRED COMPONENTS CoreAddons Config) - -add_executable(gtkbreeze main.cpp) - -target_link_libraries(gtkbreeze Qt5::Widgets KF5::CoreAddons KF5::ConfigCore) - -install(TARGETS gtkbreeze DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/) -install(FILES gtkbreeze.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR}) diff --git a/misc/gtkbreeze/gtkbreeze.upd b/misc/gtkbreeze/gtkbreeze.upd deleted file mode 100644 index e5eb34f6..00000000 --- a/misc/gtkbreeze/gtkbreeze.upd +++ /dev/null @@ -1,3 +0,0 @@ -Version=5 -Id=GTKBreeze -Script=gtkbreeze diff --git a/misc/gtkbreeze/main.cpp b/misc/gtkbreeze/main.cpp deleted file mode 100644 index b4dfcaa8..00000000 --- a/misc/gtkbreeze/main.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright 2014 Jonathan Riddell - - 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, see . -*/ - -// Wee program to be run at login by kconf_update -// checks if gtk theme is set -// if not or if it is set to oxygen, update to new theme which matches breeze theme - -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_LOGGING_CATEGORY(GTKBREEZE) -Q_LOGGING_CATEGORY(GTKBREEZE, "gtkbreeze") - -/* - * returns a path to the installed gtk if it can be found - * themeName: gtk theme - * settingsFile: a file installed with the theme to set default options - */ -QString isGtkThemeInstalled(QString themeName, QString settingsFile) -{ - foreach (const QString& themesDir, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "themes", QStandardPaths::LocateDirectory)) { - if (QFile::exists(themesDir + QDir::separator() + themeName + QDir::separator() + settingsFile)) { - return themesDir + "/" + themeName; - } - } - return 0; -} - -/* - * Check if gtk theme is already set to oxygen, if it is then we want to upgrade to the breeze theme - * gtkSettingsFile: filename to use - * settingsKey: ini group to read from - * returns: full path to settings file - */ -QString isGtkThemeSetToOxygen(QString gtkSettingsFile, QString settingsKey) -{ - QString gtkSettingsPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() + QDir::separator() + gtkSettingsFile; - qCDebug(GTKBREEZE) << "looking for" << gtkSettingsPath; - if (QFile::exists(gtkSettingsPath)) { - qCDebug(GTKBREEZE) << "found settings file" << gtkSettingsPath; - QSettings gtkrcSettings(gtkSettingsPath, QSettings::IniFormat); - if (!settingsKey.isNull()) { - gtkrcSettings.beginGroup(settingsKey); - } - if (gtkrcSettings.value("gtk-theme-name") != QStringLiteral("oxygen-gtk")) { - qCDebug(GTKBREEZE) << "gtk settings file " + gtkSettingsFile + " already exists and is not using oxygen, will not change"; - return QString(); - } - } - return gtkSettingsPath; -} - -/* - * Set gtk2 theme if no theme is set or if oxygen is set and gtk theme is installed - */ -int setGtk2() -{ - const QString gtk2Theme = QStringLiteral("Orion"); // Orion looks kindae like breeze - const QString gtk2ThemeSettings = QStringLiteral("gtk-2.0/gtkrc"); // system installed file to check for - - const QString gtkThemeDirectory = isGtkThemeInstalled(gtk2Theme, gtk2ThemeSettings); - - if (gtkThemeDirectory == 0) { - qCDebug(GTKBREEZE) << "not found, quitting"; - return 0; - } - qCDebug(GTKBREEZE) << "found gtktheme: " << gtkThemeDirectory; - - QString gtkrc2path = isGtkThemeSetToOxygen(".gtkrc-2.0", QString()); - if (gtkrc2path.isEmpty()) { - qCDebug(GTKBREEZE) << "gtkrc2 already exists and is not using oxygen, quitting"; - return 0; - } - - qCDebug(GTKBREEZE) << "no gtkrc2 file or oxygen being used, setting to new theme"; - QFile gtkrc2writer(gtkrc2path); - bool opened = gtkrc2writer.open(QIODevice::WriteOnly | QIODevice::Text); - if (!opened) { - qCWarning(GTKBREEZE) << "failed to open " << gtkrc2path; - return 1; - } - QTextStream out(>krc2writer); - out << QStringLiteral("include \"") << gtkThemeDirectory << QStringLiteral("/gtk-2.0/gtkrc\"\n"); - out << QStringLiteral("style \"user-font\"\n"); - out << QStringLiteral("{\n"); - out << QStringLiteral(" font_name=\"Oxygen-Sans Sans-Book\"\n"); - out << QStringLiteral("}\n"); - out << QStringLiteral("widget_class \"*\" style \"user-font\"\n"); - out << QStringLiteral("gtk-font-name=\"Oxygen-Sans Sans-Book 10\"\n"); // matches plasma-workspace:startkde/startkde.cmake - out << QStringLiteral("gtk-theme-name=\"Orion\"\n"); - out << QStringLiteral("gtk-icon-theme-name=\"breeze\"\n"); - out << QStringLiteral("gtk-fallback-icon-theme=\"gnome\"\n"); - out << QStringLiteral("gtk-toolbar-style=GTK_TOOLBAR_ICONS\n"); - out << QStringLiteral("gtk-menu-images=1\n"); - out << QStringLiteral("gtk-button-images=1\n"); - qCDebug(GTKBREEZE) << "gtk2rc written"; - return 0; -} - -/* - * Set gtk3 theme if no theme is set or if oxygen is set and gtk theme is installed - */ -int setGtk3() -{ - qCDebug(GTKBREEZE) << "setGtk3()"; - - const QString gtk3Theme = QStringLiteral("Orion"); // Orion looks kindae like breeze - const QString gtk3ThemeSettings = QStringLiteral("gtk-3.0/settings.ini"); // check for installed /usr/share/themes/Orion/gtk-3.0/settings.ini - - const QString gtkThemeDirectory = isGtkThemeInstalled(gtk3Theme, gtk3ThemeSettings); - if (gtkThemeDirectory == 0) { - qCDebug(GTKBREEZE) << "not found, quitting"; - return 0; - } - qCDebug(GTKBREEZE) << "found gtk3theme:" << gtkThemeDirectory; - - QString gtkrc3path = isGtkThemeSetToOxygen(".config/gtk-3.0/settings.ini", "Settings"); - if ( gtkrc3path.isEmpty() ) { - qCDebug(GTKBREEZE) << "gtkrc3 already exists and is not using oxygen, quitting"; - return 0; - } - QDir dir = QFileInfo(gtkrc3path).dir(); - dir.mkpath(dir.path()); - - qCDebug(GTKBREEZE) << "no gtkrc3 file or oxygen being used, setting to new theme"; - QFile gtkrc3writer(gtkrc3path); - bool opened = gtkrc3writer.open(QIODevice::WriteOnly | QIODevice::Text); - if (!opened) { - qCWarning(GTKBREEZE) << "failed to open " << gtkrc3path; - return 1; - } - QTextStream out(>krc3writer); - out << QStringLiteral("[Settings]\n"); - out << QStringLiteral("gtk-font-name=Oxygen-Sans 10\n"); // matches plasma-workspace:startkde/startkde.cmake - out << QStringLiteral("gtk-theme-name=")+gtk3Theme+QStringLiteral("\n"); - out << QStringLiteral("gtk-icon-theme-name=breeze\n"); - out << QStringLiteral("gtk-fallback-icon-theme=gnome\n"); - out << QStringLiteral("gtk-toolbar-style=GTK_TOOLBAR_ICONS\n"); - out << QStringLiteral("gtk-menu-images=1\n"); - out << QStringLiteral("gtk-button-images=1\n"); - qCDebug(GTKBREEZE) << "gtk3rc written"; - - QString cssFile = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() + - QDir::separator() + ".config/gtk-3.0/gtk.css"; - QFile gtkcss3writer(cssFile); - opened = gtkcss3writer.open(QIODevice::WriteOnly | QIODevice::Text); - if (!opened) { - qCWarning(GTKBREEZE) << "failed to open " << cssFile; - return 1; - } - QTextStream outcss(>kcss3writer); - outcss << QStringLiteral(".window-frame, .window-frame:backdrop {\n"); - outcss << QStringLiteral(" box-shadow: 0 0 0 black;\n"); - outcss << QStringLiteral(" border-style: none;\n"); - outcss << QStringLiteral(" margin: 0;\n"); - outcss << QStringLiteral(" border-radius: 0;\n"); - outcss << QStringLiteral("}\n\n"); - outcss << QStringLiteral(".titlebar {\n"); - outcss << QStringLiteral(" border-radius: 0;\n"); - outcss << QStringLiteral("}\n"); - qCDebug(GTKBREEZE) << ".config/gtk-3.0/gtk.css written"; - return 0; -} - -int main(/*int argc, char **argv*/) -{ - QLoggingCategory::setFilterRules(QStringLiteral("gtkbreeze.debug = false")); - qCDebug(GTKBREEZE) << "updateGtk2()"; - - int result = 0; - result = setGtk2(); - result = setGtk3(); - - return result; -}