aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kernozhitsky <[email protected]>2018-11-25 14:30:44 +0300
committerAlexander Kernozhitsky <[email protected]>2018-11-25 14:30:44 +0300
commit8e2a0481db72eae61aa36136f00167981348077b (patch)
treee5cad4255d42f8ecfa5d0cabc6000eda889951d9
parent4698cbfde5bc008d00614a99a0e187b28db695a8 (diff)
Add files from upstream breeze-gtk
-rw-r--r--.arcconfig4
-rw-r--r--Breeze-dark-gtk/CMakeLists.txt7
-rw-r--r--Breeze-gtk/CMakeLists.txt7
-rw-r--r--CMakeLists.txt27
-rw-r--r--COPYING.LIB (renamed from LICENSE)0
-rw-r--r--cmake/FindGTKEngine.cmake22
-rw-r--r--kconf_update/CMakeLists.txt9
-rw-r--r--kconf_update/gtkbreeze5.5.upd3
-rw-r--r--kconf_update/main.cpp200
9 files changed, 279 insertions, 0 deletions
diff --git a/.arcconfig b/.arcconfig
new file mode 100644
index 0000000..bc0df43
--- /dev/null
+++ b/.arcconfig
@@ -0,0 +1,4 @@
+{
+ "phabricator.uri" : "https://phabricator.kde.org/"
+}
+
diff --git a/Breeze-dark-gtk/CMakeLists.txt b/Breeze-dark-gtk/CMakeLists.txt
new file mode 100644
index 0000000..a9f4d85
--- /dev/null
+++ b/Breeze-dark-gtk/CMakeLists.txt
@@ -0,0 +1,7 @@
+install(DIRECTORY gtk-2.0 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze-Dark
+ ${directory_EXCLUDES})
+install(DIRECTORY assets DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze-Dark
+ ${directory_EXCLUDES})
+
+install(DIRECTORY gtk-3.18 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze-Dark)
+install(DIRECTORY gtk-3.20 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze-Dark)
diff --git a/Breeze-gtk/CMakeLists.txt b/Breeze-gtk/CMakeLists.txt
new file mode 100644
index 0000000..16e8bb2
--- /dev/null
+++ b/Breeze-gtk/CMakeLists.txt
@@ -0,0 +1,7 @@
+install(DIRECTORY gtk-2.0 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze
+ ${directory_EXCLUDES})
+install(DIRECTORY assets DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze
+ ${directory_EXCLUDES})
+
+install(DIRECTORY gtk-3.18 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze)
+install(DIRECTORY gtk-3.20 DESTINATION ${KDE_INSTALL_FULL_DATAROOTDIR}/themes/Breeze)
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..8641ae0
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,27 @@
+project(breeze-gtk)
+set(PROJECT_VERSION "5.14.80")
+set(PROJECT_VERSION_MAJOR 5)
+
+cmake_minimum_required(VERSION 2.8.12)
+
+find_package(ECM 0.0.9 REQUIRED NO_MODULE)
+include(FeatureSummary)
+
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_SOURCE_DIR}/cmake")
+find_package(GTKEngine)
+
+include(KDEInstallDirs)
+
+# Exclude these patterns when installing directories as they have no use
+# in production.
+set(directory_EXCLUDES
+ PATTERN "render-assets.sh" EXCLUDE
+ PATTERN "assets.svg" EXCLUDE
+ PATTERN "assets.txt" EXCLUDE
+)
+
+add_subdirectory(Breeze-dark-gtk)
+add_subdirectory(Breeze-gtk)
+add_subdirectory(kconf_update)
+
+feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
diff --git a/LICENSE b/COPYING.LIB
index 6a67a0d..6a67a0d 100644
--- a/LICENSE
+++ b/COPYING.LIB
diff --git a/cmake/FindGTKEngine.cmake b/cmake/FindGTKEngine.cmake
new file mode 100644
index 0000000..456b3a0
--- /dev/null
+++ b/cmake/FindGTKEngine.cmake
@@ -0,0 +1,22 @@
+include(KDEInstallDirs)
+
+set_package_properties(GTKEngine PROPERTIES
+ DESCRIPTION "Pixmap/Pixbuf theme engine for GTK 2"
+ URL "http://www.gtk.org/"
+ TYPE RUNTIME
+ PURPOSE "Required for GTK 2 theme")
+
+set(_versions 2.20 2.18 2.16 2.14 2.12
+ 2.10 2.8 2.6 2.4 2.2 2.0
+ 1.20 1.18 1.16 1.14 1.12
+ 1.10 1.8 1.6 1.4 1.2 1.0)
+
+foreach(_ver ${_versions})
+ find_library(GTKPIXMAP_PLUGIN NAMES pixmap
+ PATHS
+ ${KDE_INSTALL_FULL_LIBDIR}/gtk-2.0/${_ver}.0/engines)
+endforeach()
+
+if(NOT ${GTKPIXMAP_PLUGIN} STREQUAL "GTKPIXMAP_PLUGIN-NOTFOUND")
+ set(GTKEngine_FOUND TRUE)
+endif()
diff --git a/kconf_update/CMakeLists.txt b/kconf_update/CMakeLists.txt
new file mode 100644
index 0000000..558f07d
--- /dev/null
+++ b/kconf_update/CMakeLists.txt
@@ -0,0 +1,9 @@
+find_package(Qt5 REQUIRED COMPONENTS Core)
+include(KDEInstallDirs)
+
+add_executable(gtkbreeze5.5 main.cpp)
+
+target_link_libraries(gtkbreeze5.5 Qt5::Core)
+
+install(TARGETS gtkbreeze5.5 DESTINATION ${LIB_INSTALL_DIR}/kconf_update_bin/)
+install(FILES gtkbreeze5.5.upd DESTINATION ${KCONF_UPDATE_INSTALL_DIR})
diff --git a/kconf_update/gtkbreeze5.5.upd b/kconf_update/gtkbreeze5.5.upd
new file mode 100644
index 0000000..5884513
--- /dev/null
+++ b/kconf_update/gtkbreeze5.5.upd
@@ -0,0 +1,3 @@
+Version=5
+Id=GTKBreeze5.5
+Script=gtkbreeze5.5
diff --git a/kconf_update/main.cpp b/kconf_update/main.cpp
new file mode 100644
index 0000000..d5f7ce0
--- /dev/null
+++ b/kconf_update/main.cpp
@@ -0,0 +1,200 @@
+/*
+ Copyright 2014 Jonathan Riddell <[email protected]>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// 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 <QCoreApplication>
+#include <QStandardPaths>
+#include <QDebug>
+#include <QFile>
+#include <QLoggingCategory>
+#include <QSettings>
+#include <QDir>
+
+Q_DECLARE_LOGGING_CATEGORY(GTKBREEZE)
+Q_LOGGING_CATEGORY(GTKBREEZE, "gtkbreeze")
+
+/*
+ * returns whether a GTK 3 theme with the given name is installed
+ * themeName: Name of gtk 3 theme
+ */
+static bool isGTK3ThemeInstalled(QString themeName)
+{
+ // Check that the theme contains a gtk-3.* subdirectory
+ QStringList gtk3SubdirPattern{QStringLiteral("gtk-3.*")};
+ foreach (const QString& themesDir, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "themes", QStandardPaths::LocateDirectory)) {
+ QDir themeDir(themesDir + QDir::separator() + themeName);
+ if (!themeDir.entryList(gtk3SubdirPattern, QDir::Dirs).isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/*
+ * 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
+ */
+static QString gtk2ThemePath(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 + QDir::separator() + themeName;
+ }
+ }
+ return {};
+}
+
+/*
+ * Check if gtk theme is already set to oxygen or Orion, 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
+ */
+bool isGtkThemeSetToOldTheme(QString gtkSettingsFile, QString settingsKey)
+{
+ QString home = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
+ QString gtkSettingsPath;
+ if (!gtkSettingsFile.startsWith(home)) {
+ gtkSettingsPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() + QDir::separator() + gtkSettingsFile;
+ } else {
+ gtkSettingsPath = 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 it is set to Oxygen or Orion then we want to upgrade it to Breeze
+ if (gtkrcSettings.value("gtk-theme-name") == QLatin1String("oxygen-gtk") || gtkrcSettings.value("gtk-theme-name") == QLatin1String("Orion")) {
+ qCDebug(GTKBREEZE) << "using oxygen or orion " << gtkrcSettings.value("gtk-theme-name");
+ return true;
+ } else {
+ return false;
+ }
+ }
+ //if it doesn't exist then we also want to upgrade it
+ return true;
+}
+
+/*
+ * Set gtk2 theme if no theme is set or if oxygen is set and gtk theme is installed
+ */
+int setGtk2()
+{
+ const QString gtk2Theme = QStringLiteral("Breeze");
+ const QString gtkrc2path = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() + QDir::separator() + QStringLiteral(".gtkrc-2.0");
+ const QString gtk2ThemeSettings = QStringLiteral("gtk-2.0/gtkrc"); // system installed file to check for
+
+ const QString gtkThemeDirectory = gtk2ThemePath(gtk2Theme, gtk2ThemeSettings);
+
+ if (gtkThemeDirectory.isEmpty()) {
+ qCDebug(GTKBREEZE) << "Breeze GTK 2 not found, quitting";
+ return 0;
+ }
+ qCDebug(GTKBREEZE) << "found gtktheme: " << gtkThemeDirectory;
+
+ bool needsUpdate = isGtkThemeSetToOldTheme(gtkrc2path, QString());
+ if (needsUpdate == false) {
+ qCDebug(GTKBREEZE) << "gtkrc2 already exists and is not using oxygen or orion, quitting";
+ return 0;
+ }
+
+ qCDebug(GTKBREEZE) << "no gtkrc2 file or oxygen/orion 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(&gtkrc2writer);
+ out << QStringLiteral("include \"") << gtkThemeDirectory << QStringLiteral("/gtk-2.0/gtkrc\"\n");
+ out << QStringLiteral("style \"user-font\"\n");
+ out << QStringLiteral("{\n");
+ out << QStringLiteral(" font_name=\"Noto Sans Regular\"\n");
+ out << QStringLiteral("}\n");
+ out << QStringLiteral("widget_class \"*\" style \"user-font\"\n");
+ out << QStringLiteral("gtk-font-name=\"Noto Sans Regular 10\"\n"); // matches plasma-workspace:startkde/startkde.cmake
+ out << QStringLiteral("gtk-theme-name=\"Breeze\"\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()
+{
+ const QString gtk3Theme = QStringLiteral("Breeze");
+
+ if (!isGTK3ThemeInstalled(gtk3Theme)) {
+ qCDebug(GTKBREEZE) << "not found, quitting";
+ return 0;
+ }
+ qCDebug(GTKBREEZE) << "found gtk3theme";
+ QString configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
+ QString gtkrc3path = configPath + "/gtk-3.0/settings.ini";
+ bool needsUpdate = isGtkThemeSetToOldTheme(gtkrc3path, "Settings");
+ if ( !needsUpdate ) {
+ qCDebug(GTKBREEZE) << "gtkrc3 already exists and is not using oxygen/orion, quitting";
+ return 0;
+ }
+ QDir dir = QFileInfo(gtkrc3path).dir();
+ dir.mkpath(dir.path());
+
+ qCDebug(GTKBREEZE) << "no gtkrc3 file or oxygen/orion 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(&gtkrc3writer);
+ out << QStringLiteral("[Settings]\n");
+ out << QStringLiteral("gtk-font-name=Noto 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");
+ out << QStringLiteral("gtk-primary-button-warps-slider=0\n");
+ qCDebug(GTKBREEZE) << "gtk3rc written";
+
+ return 0;
+}
+
+int main(/*int argc, char **argv*/)
+{
+ QString home = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
+ int resultGTK2 = 0;
+ int resultGTK3 = 0;
+ resultGTK2 = setGtk2();
+ resultGTK3 = setGtk3();
+
+ return resultGTK2 | resultGTK3;
+}