can-lehmann / owlkettle

A declarative user interface framework based on GTK 4
https://can-lehmann.github.io/owlkettle/README
MIT License
375 stars 13 forks source link

Add `adw.StatusPage` widget #86

Closed can-lehmann closed 11 months ago

can-lehmann commented 1 year ago

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.StatusPage.html

PhilippMDoerner commented 1 year ago

Currently starting to tinker with this as well: How do you figure out whether to put something behind a when defined(adwaita12) block or not? What determines that?

At least from a glimpse at the docs I'm not getting much of an idea: image

can-lehmann commented 1 year ago

Usually the docs say since: 1.2 (see e.g. here: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.Breakpoint.html - although that is since 1.4). The CI should fail anyways if the widget is only available since 1.2, but you did not put it inside a adwaita12 block.

PhilippMDoerner commented 12 months ago

So do we distinguish only between 1.0 and 1.2 or should the instruction be "If you see it a since 1.X block, put your code behind a when defined (adwaita1X) block?"

I'd want to add something regarding this to the wrap-widget-docs that we currently have a PR open for, thus the question for clarification.

can-lehmann commented 12 months ago

If a new feature is only available after 1.X, it should be in a when defined (adwaita1X) block, this case just did not come up yet.

PhilippMDoerner commented 12 months ago

This likely will end up in a separate issue: Could it make sense to refactor the adwaita bits of the library to use a flag -d:adwaita=12 instead of -d:adwaita12 ?

This way you could easily implement logic that allows you to compile with -d:adwaita=14 and because 14 > 12 all when-statements requiring adwaita 1.2 will be there.

Something like:

const adwTargetVersion {.intdefine: "adwaita".}: int = 10 ## The version of adwaita 1.0

template minAdwaitaVersion(minVersion: int, body: untyped)=
  when adwTargetVersion >= minVersion:
    body

Usage example (compile with -d:adwaita=14 or any value larger than 12 really):

const adwTargetVersion {.intdefine: "adwaita".}: int = 10

template minAdwaitaVersion(minVersion: int, body: untyped)=
  when adwTargetVersion >= minVersion:
    body

minAdwaitaVersion(12):
  echo "The adwaita version was larger than 12: ", adwTargetVersion

It might even make sense to have a "maxAdwaitaVersion" since 2.X may remove Widgets one might currently be using. Particularly Flap, Squeezer, SqueezerPage, Leaflet, LeafletPage and ViewSwitcherTitle are already deprecated and I'm pretty sure we have "Flap" already wrapped.

can-lehmann commented 12 months ago

Good idea. It would make sense to do this before 3.0.0, since it would be a breaking change.

can-lehmann commented 12 months ago

Although I think we shouldn't use a template for the comparisons, but rather just use a regular when statement. It might also be nice to split the version into a tuple: (majorVersion, minorVersion).

PhilippMDoerner commented 12 months ago

Kinda like nim does it with NimMajor and NimMinor: AdwMajor and AdwMinor defined by default as 1 and 0.

PhilippMDoerner commented 12 months ago

I suggest moving further discussions about this to #96

PhilippMDoerner commented 12 months ago

Okay I've got this one down so far I think, will post PR the once #94 is merged.