Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the gtk-theme extension #1

Open
cassidyjames opened this issue Aug 26, 2019 · 8 comments
Open

Remove the gtk-theme extension #1

cassidyjames opened this issue Aug 26, 2019 · 8 comments

Comments

@cassidyjames
Copy link
Contributor

I'm told we should delete this

"inherit-extensions": [
"org.gtk.Gtk3theme"
],

according to @alatiera

@alatiera
Copy link
Contributor

Basically the reasoning for this is that elementary apps will only be/depending on the elementary style sheet which should be hardcoded to be the default rather than bringing in all the "theming" machinery of flatpak.

@Marukesu
Copy link
Contributor

Marukesu commented May 7, 2020

So, it's needed to install the settings overrides to runtime? But if the user have adwaita has host theme the platform theme get overridden because adwaita comes with the gnome SDK that used to build the platform.

@alatiera
Copy link
Contributor

Yes, for some reason it seems like gtk is trying to set the same stylesheet as the host is running and it doesn't respect gsettings defaults/locks inside the runtime either. I tried to debug this a while ago but it didn't seem to work.

alatiera@cf8992f

diff --git a/defaults.ini b/defaults.ini
new file mode 100644
index 0000000..67b3e6d
--- /dev/null
+++ b/defaults.ini
@@ -0,0 +1,4 @@
+[org.gnome.desktop.interface]
+gtk-theme='elementary'
+icon-theme='elementary'
+cursor-theme='elementary'
diff --git a/io.elementary.Sdk.json.in b/io.elementary.Sdk.json.in
index 20bae57..ce0b776 100644
--- a/io.elementary.Sdk.json.in
+++ b/io.elementary.Sdk.json.in
@@ -6,9 +6,6 @@
     "runtime-version": "@GNOME_VERSION@",
     "runtime": "org.gnome.Platform",
     "sdk": "org.gnome.Sdk",
-    "inherit-extensions": [
-        "org.gtk.Gtk3theme"
-    ],
     "sdk-extensions": ["org.gnome.Sdk.Debug", "org.gnome.Sdk.Locale", "org.gnome.Sdk.Docs"],
     "platform-extensions": [ "org.gnome.Platform.Locale"],
     "finish-args": [
@@ -109,6 +106,19 @@
                     ]
                 }
             ]
+        },
+        {   "name" : "defaults",
+            "buildsystem" : "simple",
+            "build-commands" : [
+                "mkdir -p /usr/etc/glib-2.0/settings/",
+                "install -m644 -pD defaults.ini /usr/etc/glib-2.0/settings/defaults"
+            ],
+             "sources" : [
+                {
+                    "type" : "file",
+                    "path" : "defaults.ini"
+                }
+            ]
         }
     ]
 }

@Marukesu
Copy link
Contributor

The only way that i can lock the theme is passing --env=GTK_THEME=elementary. but with the new stylesheet we have actually 10 themes(20 with the dark variants) instead of one.

@Marukesu
Copy link
Contributor

Looking in manifest of appcenters apps in flathub. they define the theme applying a patch inside the app. maybe do the same but only if the theme is not "elementary"? the same can be applied to icons.

@Marukesu
Copy link
Contributor

Thinking about this issue lately, flatpak, on X11, uses the selected system xsettings to set the theme, and if the theme don't exist in the sandbox it will use Adwaita (what is the same thing that happens if the same occurs in the system).

One solution can be patching Gtk to if they can't find the selected theme, define the gschema defined default and, if it don't exist, define Adwaita.

Another solution can be use the Gtk.Settings.set () in the application, but it lock the same in that theme, so it will need to add a signal for the colors changes, and make it reachable inside the flatpak (Using notify () in the gtk_theme property don't worked for me), so applications can make the change too.

@alatiera
Copy link
Contributor

Gave this another try using gschema overrides this time.

alatiera@80fc7c3

diff --git defaults.ini defaults.ini
new file mode 100644
index 0000000..67b3e6d
--- /dev/null
+++ defaults.ini
@@ -0,0 +1,4 @@
+[org.gnome.desktop.interface]
+gtk-theme='elementary'
+icon-theme='elementary'
+cursor-theme='elementary'
diff --git io.elementary.Sdk.json.in io.elementary.Sdk.json.in
index 8a9abdd..be815fc 100644
--- io.elementary.Sdk.json.in
+++ io.elementary.Sdk.json.in
@@ -119,6 +119,20 @@
                     ]
                 }
             ]
+        },
+        {   "name" : "defaults",
+            "buildsystem" : "simple",
+            "build-commands" : [
+                "mkdir -p /usr/share/glib-2.0/schemas/",
+                "install -m644 -pD defaults.ini /usr/share/glib-2.0/schemas/org.gnome.desktop.interface.gschema.override",
+                "glib-compile-schemas /usr/share/glib-2.0/schemas/"
+            ],
+             "sources" : [
+                {
+                    "type" : "file",
+                    "path" : "defaults.ini"
+                }
+            ]
         }
     ]
 }

This works as expected when invoking gsettings from the cli, but when launching the app and going through the portal it seems like the Settings portal takes precedence over it or overrides it. This results in inheriting the host .desktop.interface which might not be a bad thing after all.

➜  dippi git:(flatpak-manifest) ✗ flatpak run --command=sh com.github.cassidyjames.dippi
[📦 com.github.cassidyjames.dippi ~]$ gsettings get org.gnome.desktop.interface gtk-theme
'elementary'
[📦 com.github.cassidyjames.dippi ~]$ gsettings get org.gnome.desktop.interface icon-theme
'elementary'

foo

Given that we ain't going to get a stylesheet api on gtk itself anytime soon it might be fine to move all the stylesheet code to Granite Application or such.

On ElementaryOS its going to inherit the host theme name and be able to use the color variants, and if it doesn't much it could default to hardcoding the default elementary stylesheet. (Should also hardcode the icon theme to be elementary regardless as we don't seem to have a way to fix that, unless we patch gtk in the runtime).

@Marukesu
Copy link
Contributor

so, i made a similar service like the pefers dark, and it's work.
Screenshot from 2020-09-29 19-12-29

Screenshot from 2020-09-29 19-12-46

like the prefers dark, the app need to listen to the interface

var granite_settings = Granite.Settings.get_default ();
var gtk_settings = Gtk.Settings.get_default ();

gtk_settings.gtk_theme_name = "io.elementary.stylesheet." + granite_settings.accent_color;
granite_settings.notify["accent-color"].connect (() => {
    gtk_settings.gtk_theme_name = "io.elementary.stylesheet." + granite_settings.accent_color;
});

and in the app manifest:

finish-args:
  ...
  - '--system-talk-name=org.freedesktop.Accounts'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants