fabric icon indicating copy to clipboard operation
fabric copied to clipboard

Rewrite Fabric

Open its-darsh opened this issue 4 months ago • 0 comments

This rewrite focuses on refining the existing codebase, with the goal of improving the development experience (DevEx) and providing enhanced typing support. Rather than introducing new features, the aim is to establish a more robust foundation for future development.

[!NOTE] The current codebase in the main branch will be replaced by this rewrite. once this PR is merged, a new version tag, v0.0.1, will be created to represent the current state of the live main branch. future releases will follow this versioning format, with the next version following this PR being v0.0.2.

Key Changes in This Rewrite

1. Overrides and Typing Improvements

The rewrite significantly improves the PyGObject overrides, addressing long-standing issues such as property inheritance, where properties of inherited objects were previously lost.

2. Services

  • Services now override the default GObject.Object class, enabling all methods and features of Service to be accessible in any GObject.Object-based objects.
  • The bind method has been improved for better typing, along with enhanced support for methods like connect, emit, and others.

3. Builders

As detailed in the updated wiki:

The builder pattern allows for constructing complex objects step by step. In the context of a Service, you can chain function calls to set properties and connect signals in one line, simplifying the setup process. This approach minimizes boilerplate code and makes the initialization more readable and efficient.

For more details, refer to the wiki.

4. Signals

The Signal class, a core component of Service (referred to as an accessory), has been significantly improved. This update simplifies signal declaration and management.

Key Changes:

  • Simplified Declaration: Signals can now be easily defined using the class as a decorator.
  • Enhanced emit and connect: Signals can now be emitted and connected more intuitively. You can use service.signal_name.[connect | emit](), or simply call service.signal_name(...).

5. Properties

The Property accessory has been revamped to offer a simpler way to define properties with significantly less overhead and boilerplate code. Previously, the Python property class was used to declare properties; now, a custom Property class, which inherits from GObject.Property, has been introduced.

Key Changes:

  • The Property class can be used as a decorator.
  • Improved Typing: The new Property class provides better typing support, with fully typed setter and getter functions.
  • Simplified API for Setting/Getting Properties: Properties can now be accessed in multiple ways, such as service.my_property, service.get_my_property(), and service["my-property"]. Similarly, properties can be set via service.my_property = ..., service.set_my_property(...), or service["my-property"] = ....

6. Applications

Fabric now uses the Application class to manage multi-instance configurations, handle CLI calls, and manage the list of Windows present in the configuration. It also manages CSS styling.

The introduction of the Application class means the death to the fabric.start() function, which can be replaced by the Application.run() method. Additionally, all set_stylesheet_* functions previously found in utils and helpers have been moved into the Application class.

[!TIP] Fabric now has a standalone CLI Go application that can be installed separately. Check it out here.


TL;DR: This rewrite establishes a stronger foundation for a more efficient and streamlined development process moving forward.


Our TODO

  • [ ] Bring back an updated version of docstrings.
  • [ ] Update the wiki pages.

Notable Mentions

  • @wholikeel: For providing the Nix flake included in this PR.
  • dieg0.net on Discord: For supporting Fabric through donations.

its-darsh avatar Oct 06 '24 22:10 its-darsh