From e4a4ed9bf5d1adc3b9dbed3958146fbca25c4498 Mon Sep 17 00:00:00 2001
From: Akira Ohgaki <akiraohgaki@gmail.com>
Date: Fri, 16 Jun 2017 16:09:10 +0900
Subject: [PATCH] Apply gtk3 theme with gnome

---
 app/src/handlers/systemhandler.cpp | 12 +++++++++++-
 app/src/handlers/systemhandler.h   |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/app/src/handlers/systemhandler.cpp b/app/src/handlers/systemhandler.cpp
index b6351d4..5c4cb04 100644
--- a/app/src/handlers/systemhandler.cpp
+++ b/app/src/handlers/systemhandler.cpp
@@ -99,7 +99,7 @@ bool SystemHandler::isApplicableType(const QString &installType) const
         applicableTypes << "wallpapers";
     }
     else if (desktop == "gnome") {
-        applicableTypes << "wallpapers" << "icons" << "cursors";
+        applicableTypes << "wallpapers" << "icons" << "cursors" << "gtk3_themes";
     }
     else if (desktop == "xfce") {
         applicableTypes << "wallpapers";
@@ -129,6 +129,9 @@ bool SystemHandler::applyFile(const QString &path, const QString &installType) c
             else if (installType == "cursors") {
                 return applyGnomeCursor(path);
             }
+            else if (installType == "gtk3_themes") {
+                return applyGnomeGtk3Theme(path);
+            }
         }
         else if (desktop == "xfce") {
             if (installType == "wallpapers") {
@@ -189,6 +192,13 @@ bool SystemHandler::applyGnomeCursor(const QString &path) const
     return QProcess::startDetached("gsettings", arguments);
 }
 
+bool SystemHandler::applyGnomeGtk3Theme(const QString &path) const
+{
+    auto themeName = QFileInfo(path).fileName();
+    QStringList arguments{"set", "org.gnome.desktop.interface", "gtk-theme", themeName};
+    return QProcess::startDetached("gsettings", arguments);
+}
+
 bool SystemHandler::applyXfceWallpaper(const QString &path) const
 {
     auto message = QDBusMessage::createMethodCall("org.xfce.Xfconf", "/org/xfce/Xfconf", "org.xfce.Xfconf", "SetProperty");
diff --git a/app/src/handlers/systemhandler.h b/app/src/handlers/systemhandler.h
index 7145021..d99d484 100644
--- a/app/src/handlers/systemhandler.h
+++ b/app/src/handlers/systemhandler.h
@@ -28,6 +28,7 @@ private:
     bool applyGnomeWallpaper(const QString &path) const;
     bool applyGnomeIcon(const QString &path) const;
     bool applyGnomeCursor(const QString &path) const;
+    bool applyGnomeGtk3Theme(const QString &path) const;
 
     bool applyXfceWallpaper(const QString &path) const;
 #endif
-- 
GitLab