flat-remix-gtk icon indicating copy to clipboard operation
flat-remix-gtk copied to clipboard

GTK4/LibAdwaita version breaks in GTK4 apps without any official HeaderBar

Open Arcitec opened this issue 1 year ago • 0 comments

This is about a scenario where GTK4 apps don't have any HeaderBar. The official LibAdwaita theme handles that perfectly. It breaks in Flat-Remix GTK.

I've coded a small reproducer for this bug, with a variable at the top to test both behavior.

  • skip_headerbar: True (Headerbar is skipped. Theme breaks in Flat-Remix, but works properly in normal LibAdwaita. You can see that Flat-Remix expects the headerbar to be a fixed size.)

image

  • skip_headerbar: False (Headerbar is included. Theme works properly.)

image

This is almost guaranteed to be related to https://github.com/daniruiz/flat-remix-gtk/issues/151 about the transparency being added to the incorrect titlebar element. Basically the theme currently expects a specific element and titlebar height, but it seems to be the wrong element. Hopefully it can be solved with some CSS inspection with GNOME's dev tools to find the correct class to apply the Flat-Remix transparent titlebar styles to (I'm not aware how those inspector tools work but have seen others use them).

Here's the reproducer code:

from __future__ import annotations
import gi
import sys

gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1")
from gi.repository import Gtk, Adw, Gdk, GLib


skip_headerbar = False


class MainWindow(Gtk.ApplicationWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        app = self.get_application()

        GLib.set_prgname(app.get_application_id())
        GLib.set_application_name("Demo App")
        Gtk.Window.set_default_icon_name("input-gaming")

        sm = app.get_style_manager()
        sm.set_color_scheme(Adw.ColorScheme.PREFER_LIGHT)

        self.set_title("Demo App")
        self.set_size_request(400, -1)

        if not skip_headerbar:
            self.header = Gtk.HeaderBar()
            self.set_titlebar(self.header)

        self.box1 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.box1.set_spacing(10)
        self.box1.set_margin_top(10)
        self.box1.set_margin_bottom(10)
        self.box1.set_margin_start(10)
        self.box1.set_margin_end(10)

        self.set_child(self.box1)

        for btn_label in ["Button 1", "Button 2", "Button 3"]:
            btn = Gtk.Button(label=btn_label)
            self.box1.append(btn)


class MyApp(Adw.Application):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.connect("activate", self.on_activate)

    def on_activate(self, app):
        self.win = MainWindow(application=app)
        self.win.present()

app = MyApp(application_id="com.example.DemoApp")
app.run(sys.argv)

Arcitec avatar Aug 07 '22 01:08 Arcitec