geigi / cozy

🎧 Listen to audio books 📚 on Linux
https://cozy.sh
GNU General Public License v3.0
1.09k stars 83 forks source link

Migrate to Blueprint #801

Closed rdbende closed 4 months ago

rdbende commented 7 months ago

Glade is basically dead.

Cozy will soon be using GTK 4, and we're left with these XML files that we have to edit manually. Personally, I find this still easier than using a GUI designer, but yeah, I'm afraid my < and > keys are going to fall out soon.

Fortunately, there is Blueprint, which is a markup language that can be compiled to GTK's standard XML UI files. It is enjoying a lot of love and popularity in the GNOME community, and there are a great number of apps already using it ^1. I would therefore propose migrating Cozy to Blueprint. Of course, if we decide to do it, I would do the hard(?) work.

For comparison, here's the headerbar definition file with XMl vs. Blueprint `headerbar.ui` ```xml
app.scan _Scan Library
app.hide_offline _Hide unavailable books
app.prefs _Preferences app.about _About
app.quit _Quit
``` `headerbar.blp` (unfortunately GitHub doesn't have syntax highlighting for it): ```blueprint using Gtk 4.0; using Adw 1; template $Headerbar : Adw.Bin { Adw.HeaderBar headerbar { [title] Adw.ViewSwitcher view_switcher { policy: wide; } [start] ToggleButton show_sidebar_button { visible: false; icon-name: "sidebar-show-symbolic"; tooltip-text: _("Toggle Filter Sidebar"); } [end] MenuButton menu_button { tooltip-text: _("Options"); menu-model: primary_menu; icon-name: "open-menu-symbolic"; accessibility { label: _("Open the options popover"); } } [end] MenuButton search_button { name: "Search toggle button"; tooltip-text: _("Search your library"); icon-name: "edit-find-symbolic"; accessibility { label: _("Open the search popover"); } } [end] MenuButton progress_menu_button { visible: false; can-focus: true; tooltip-text: _("Display background task progress"); Spinner progress_spinner {} styles [ "flat" ] } } } menu primary_menu { section { item { action: "app.scan"; label: _("_Scan Library"); } } section { item { action: "app.hide_offline"; label: _("_Hide unavailable books"); } } section { item { action: "app.prefs"; label: _("_Preferences"); } item { action: "app.about"; label: _("_About"); } } section { item { action: "app.quit"; label: _("_Quit"); } } } ```
geigi commented 7 months ago

Definitely a fan :) I think Blueprint is the future. Nobody wants to write xml by themselves 😅