You are not logged in.

#1 2022-03-27 17:56:43

sc25ni
Member
Registered: 2022-03-23
Posts: 1

Providing a libadwaita version without the CSS override

I hope this is the correct place for this.

Currently, the arch-core libadwaita library forces the adwaita theme, whereas other GTK apps traditionally use org.gnome.desktop.interface.gtk-theme to load a stylesheet.
(I know that you can overwrite this behaviour with the GTK_THEME environment variable, but that is not ideal, especially when there is already an established way of doing this)

For apps from the main repos that use the system library, it would be pretty easy to provide a PKGBUILD in the AUR that overrides libadwaita and just loads the system theme. Since something like that has not yet appeared on the AUR, I was wondering if there is some solution I'm missing, if there are political problems with that or if it would be OK for me to upload one.

Here is what I would upload (with the diff in a seperate file):

# Maintainer: ich <remove dashes in s-c--25-ni at gmail dot com>

pkgname=libadwaita-with-theming-git
pkgver=1.1
pkgrel=1
pkgdesc='Libadwaita; Includes a patch to not overwrite the system theme'
arch=('i686' 'x86_64' 'armv7h' 'armv6h' 'aarch64')
license=('LGPL')
depends=('gtk4')
makedepends=(git meson gi-docgen sassc gobject-introspection vala pkg-config patch cmake meson libsass gcc)
source=("${pkgname}::git+https://gitlab.gnome.org/GNOME/libadwaita")
sha256sums=('SKIP')
provides=("libadwaita=${pkgver}" "libadwaita-1.so=0-64")
conflicts=('libadwaita')
options=(!strip)

_diff='235a236,250
> static void
> adw_style_manager_theme_changed(GSettings *settings, const char *key, GdkDisplay *display)
> {
>   char *theme = g_settings_get_string(settings, "gtk-theme");
>   if (!theme) {
>     theme = "Adwaita-empty";
>   }
>   gboolean is_dark_variant = NULL != strstr(theme, "-dark");
> 
>   g_object_set (gtk_settings_get_for_display (display),
>                 "gtk-theme-name", theme,
>                 "gtk-application-prefer-dark-theme", is_dark_variant,
>                 NULL);
> }
> 
261,273c276,281
<       g_object_set (gtk_settings_get_for_display (self->display),
<                     "gtk-theme-name", "Adwaita-empty",
<                     NULL);
< 
<       self->provider = gtk_css_provider_new ();
<       gtk_style_context_add_provider_for_display (self->display,
<                                                   GTK_STYLE_PROVIDER (self->provider),
<                                                   GTK_STYLE_PROVIDER_PRIORITY_THEME);
< 
<       self->colors_provider = gtk_css_provider_new ();
<       gtk_style_context_add_provider_for_display (self->display,
<                                                   GTK_STYLE_PROVIDER (self->colors_provider),
<                                                   GTK_STYLE_PROVIDER_PRIORITY_THEME);
---
>       GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default();
>       GSettingsSchema *schema =  g_settings_schema_source_lookup(schema_source, "org.gnome.desktop.interface", true);
>       GSettings *interface_settings = g_settings_new_full(schema, NULL, NULL);
> 
>       adw_style_manager_theme_changed(interface_settings, "gtk-theme", self->display);
>       g_signal_connect (interface_settings, "changed", G_CALLBACK (adw_style_manager_theme_changed), self->display);
'

build() {
  cd "${srcdir}/${pkgname}"
  echo "$_diff" | patch src/adw-style-manager.c
  meson build --prefix=/usr
  ninja -C build 
}

package() {
  cd "${srcdir}/${pkgname}"
  DESTDIR="$pkgdir" ninja -C build install
}

edit: Since there weren't any comments in the last 10 days, I'll assume that nobody has a problem with this

Last edited by sc25ni (2022-04-08 09:31:22)

Offline

#2 2022-04-09 13:24:14

thesola10
Member
Registered: 2021-01-13
Posts: 3
Website

Re: Providing a libadwaita version without the CSS override

So far, I've had appearance issues forcing Gtk4 themes onto libadwaita apps, through the GTK_THEME variable in Flatpak apps.

I would wait for a little bit before providing a theming patch on libadwaita.

Offline

Board footer

Powered by FluxBB