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

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

Open
Arcitec opened this issue Aug 7, 2022 · 0 comments

Comments

@Arcitec
Copy link

Arcitec commented Aug 7, 2022

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 #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)
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

1 participant