From 3acc96e087976f22e999f6f2d8af8d43d6540343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20P=20M=C3=B6ller?= Date: Sat, 6 Oct 2018 08:58:33 -0700 Subject: [PATCH] Set default GTK theme if rc file doesn't exists. Summary: Set default GTK theme if rc file doesn't exists. Test Plan: See if default GTK theme is according to 'gsettings get org.gnome.desktop.interface gtk-theme' Reviewers: wxl, tsimonq2 Reviewed By: wxl, tsimonq2 Differential Revision: https://phab.lubuntu.me/D27 --- debian/changelog | 6 ++ debian/patches/series | 1 + debian/patches/set-default-gtk-theme.patch | 72 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 debian/patches/set-default-gtk-theme.patch diff --git a/debian/changelog b/debian/changelog index acba213..fba69e2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +lxqt-config (0.13.0-0ubuntu5) cosmic; urgency=medium + + * Set default GTK theme if rc file doesn't exists. + + -- Hans P. Möller Thu, 04 Oct 2018 14:44:03 -0300 + lxqt-config (0.13.0-0ubuntu4) cosmic; urgency=medium * Make a path for GTK settings if it does not exist. diff --git a/debian/patches/series b/debian/patches/series index 5098590..8faf170 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ gtk-appearance-settings.patch +set-default-gtk-theme.patch mkpath-for-null-gtk-settings.patch diff --git a/debian/patches/set-default-gtk-theme.patch b/debian/patches/set-default-gtk-theme.patch new file mode 100644 index 0000000..35e1d7b --- /dev/null +++ b/debian/patches/set-default-gtk-theme.patch @@ -0,0 +1,72 @@ +Description: Set default GTK theme if rc file doesn't exists. +Author: P.L. Lucas +Applied-Upstream: https://github.com/lxqt/lxqt-config/commit/4c3ad403dc14dde4fe41e56cf3272ac11e30346f +Last-Update: 2018-10-05 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/lxqt-config-appearance/configothertoolkits.cpp ++++ b/lxqt-config-appearance/configothertoolkits.cpp +@@ -34,6 +34,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -246,7 +247,7 @@ QString ConfigOtherToolKits::getGTKTheme + QFile file(gtkrcPath); + if(file.exists()) { + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) +- return QString(); ++ return getDefaultGTKTheme(); + while (!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); + if(line.startsWith("gtk-theme-name")) { +@@ -264,7 +265,7 @@ QString ConfigOtherToolKits::getGTKTheme + QFile file(gtkrcPath); + if(file.exists()) { + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) +- return QString(); ++ return getDefaultGTKTheme(); + bool settingsFound = false; + while (!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); +@@ -283,7 +284,26 @@ QString ConfigOtherToolKits::getGTKTheme + file.close(); + } + } +- return QString(); ++ return getDefaultGTKTheme(); ++} ++ ++QString ConfigOtherToolKits::getDefaultGTKTheme() ++{ ++ // Get the GTK default theme. Command line: ++ // $ gsettings get org.gnome.desktop.interface gtk-theme ++ QProcess gsettings; ++ QStringList args; ++ args << "get" << "org.gnome.desktop.interface" << "gtk-theme"; ++ gsettings.start("gsettings", args); ++ if(! gsettings.waitForFinished()) ++ return QString(); ++ QByteArray defaultTheme = gsettings.readAll().trimmed(); ++ gsettings.close(); ++ if(defaultTheme.size() <= 1) ++ return QString(); ++ // The theme has got quotation marks. Remove it: ++ defaultTheme.replace("'",""); ++ return QString(defaultTheme); + } + + void ConfigOtherToolKits::updateConfigFromSettings() +--- a/lxqt-config-appearance/configothertoolkits.h ++++ b/lxqt-config-appearance/configothertoolkits.h +@@ -42,6 +42,7 @@ public: + QString getGTKThemeFromRCFile(QString version); + QString getGTKConfigPath(QString version); + bool backupGTKSettings(QString version); ++ QString getDefaultGTKTheme(); + + public slots: + void setConfig();