From 293116bc5effcc05ec01b968995bae08afd26197 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 27 Aug 2024 15:40:43 -0600 Subject: [PATCH 1/4] Devel: add separate profile, use icon --- com.cassidyjames.butler.Devel.json | 30 +++++++++++ com.cassidyjames.butler.json | 3 ++ data/gresource.xml | 7 +-- data/{gschema.xml => gschema.xml.in} | 2 +- data/icons/{devel.svg => development.svg} | 0 data/icons/{app.svg => release.svg} | 0 .../{launcher.desktop => launcher.desktop.in} | 8 +-- data/meson.build | 46 ++++++++++++----- data/{metainfo.xml => metainfo.xml.in} | 16 ++++-- meson.build | 50 ++++++++----------- meson.options | 1 + src/Config.vala.in | 2 + src/MainWindow.vala | 17 +++---- src/meson.build | 17 +++++++ 14 files changed, 135 insertions(+), 64 deletions(-) create mode 100644 com.cassidyjames.butler.Devel.json rename data/{gschema.xml => gschema.xml.in} (94%) rename data/icons/{devel.svg => development.svg} (100%) rename data/icons/{app.svg => release.svg} (100%) rename data/{launcher.desktop => launcher.desktop.in} (60%) rename data/{metainfo.xml => metainfo.xml.in} (94%) create mode 100644 meson.options create mode 100644 src/meson.build diff --git a/com.cassidyjames.butler.Devel.json b/com.cassidyjames.butler.Devel.json new file mode 100644 index 0000000..cff8070 --- /dev/null +++ b/com.cassidyjames.butler.Devel.json @@ -0,0 +1,30 @@ +{ + "app-id": "com.cassidyjames.butler.Devel", + "runtime": "org.gnome.Platform", + "runtime-version": "46", + "sdk": "org.gnome.Sdk", + "command": "com.cassidyjames.butler.Devel", + "finish-args": [ + "--socket=wayland", + "--socket=fallback-x11", + "--share=ipc", + "--share=network", + "--device=dri" + ], + "modules": [ + { + "name": "butler", + "buildsystem": "meson", + "run-tests": true, + "config-opts": [ + "-Dprofile=development" + ], + "sources": [ + { + "type": "dir", + "path": "." + } + ] + } + ] +} diff --git a/com.cassidyjames.butler.json b/com.cassidyjames.butler.json index 264a576..fec1243 100644 --- a/com.cassidyjames.butler.json +++ b/com.cassidyjames.butler.json @@ -16,6 +16,9 @@ "name": "butler", "buildsystem": "meson", "run-tests": true, + "config-opts": [ + "-Dprofile=release" + ], "sources": [ { "type": "dir", diff --git a/data/gresource.xml b/data/gresource.xml index f54825f..058ffb3 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -1,10 +1,7 @@ - metainfo.xml - style.css - - - icons/app.svg + metainfo.xml.in + style.css diff --git a/data/gschema.xml b/data/gschema.xml.in similarity index 94% rename from data/gschema.xml rename to data/gschema.xml.in index 01de8b3..e3a200c 100644 --- a/data/gschema.xml +++ b/data/gschema.xml.in @@ -1,6 +1,6 @@ - + "" Current URL diff --git a/data/icons/devel.svg b/data/icons/development.svg similarity index 100% rename from data/icons/devel.svg rename to data/icons/development.svg diff --git a/data/icons/app.svg b/data/icons/release.svg similarity index 100% rename from data/icons/app.svg rename to data/icons/release.svg diff --git a/data/launcher.desktop b/data/launcher.desktop.in similarity index 60% rename from data/launcher.desktop rename to data/launcher.desktop.in index a8df4ac..7cbe657 100644 --- a/data/launcher.desktop +++ b/data/launcher.desktop.in @@ -1,11 +1,11 @@ [Desktop Entry] -Name=Butler +Name=@app_name@ GenericName=Smart Home Dashboard Comment=Control your smart home Categories=Network;GTK; -Exec=com.cassidyjames.butler -Icon=com.cassidyjames.butler +Exec=@app_id@ +Icon=@app_id@ Terminal=false Type=Application -X-GNOME-Gettext-Domain=com.cassidyjames.butler +X-GNOME-Gettext-Domain=@app_id@ Keywords=hass;home;assistant;smart;lights; diff --git a/data/meson.build b/data/meson.build index 72b908a..0274e88 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,29 +1,51 @@ +data_config = configuration_data() +data_config.set('app_id', app_id) +data_config.set('app_name', app_name) + install_data( - 'icons' / 'app.svg', + 'icons' / profile + '.svg', install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'scalable', 'apps'), - rename: meson.project_name() + '.svg' + rename: app_id + '.svg' ) install_data( 'icons' / 'symbolic.svg', install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', 'symbolic', 'apps'), - rename: meson.project_name() + '-symbolic.svg' + rename: app_id + '-symbolic.svg' ) -install_data( - 'gschema.xml', +gschema_file = configure_file( + input: files('gschema.xml.in'), + output: app_id + '.gschema.xml', + configuration: data_config, + install: true, install_dir: get_option('datadir') / 'glib-2.0' / 'schemas', - rename: meson.project_name() + '.gschema.xml' ) -install_data( - 'launcher.desktop', +desktop_file = configure_file( + input: files('launcher.desktop.in'), + output: app_id + '.desktop', + configuration: data_config, + install: true, install_dir: get_option('datadir') / 'applications', - rename: meson.project_name() + '.desktop' ) -install_data( - 'metainfo.xml', +metainfo_file = configure_file( + input: files('metainfo.xml.in'), + output: '@BASENAME@', + configuration: data_config, + install: true, install_dir: get_option('datadir') / 'metainfo', - rename: meson.project_name() + '.metainfo.xml' ) + +asresources = gnome.compile_resources( + 'as-resources', + 'gresource.xml', + source_dir: 'data', + c_name: 'as', +) + +desktop_utils = find_program('desktop-file-validate', required: false) +if desktop_utils.found() + test('Validate desktop file', desktop_utils, args: [desktop_file]) +endif diff --git a/data/metainfo.xml b/data/metainfo.xml.in similarity index 94% rename from data/metainfo.xml rename to data/metainfo.xml.in index 30c4e7e..d73a97c 100644 --- a/data/metainfo.xml +++ b/data/metainfo.xml.in @@ -1,11 +1,11 @@ - com.cassidyjames.butler + @app_id@ CC-BY-SA-4.0 GPL-3.0-or-later - Butler + @app_name@ Companion for Home Assistant @@ -38,9 +38,9 @@ - com.cassidyjames.butler + @app_id@ - com.cassidyjames.butler.desktop + @app_id@.desktop 360 @@ -63,6 +63,14 @@ + + +

Under the hood

+
    +
  • Separate development and release profiles to make development easier
  • +
+
+

Improved app listing

diff --git a/meson.build b/meson.build index 79c590b..04eea98 100644 --- a/meson.build +++ b/meson.build @@ -1,49 +1,41 @@ project( 'com.cassidyjames.butler', 'vala', 'c', - version: '1.1.3', + version: '1.2.0', meson_version: '>=0.58', ) -gnome = import('gnome') +app_id = meson.project_name() +app_name = 'Butler' -add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language:'c') +profile = get_option('profile') +if profile == 'development' + app_id += '.Devel' + app_name += ' (Devel)' +endif -asresources = gnome.compile_resources( - 'as-resources', - 'data' / 'gresource.xml', - source_dir: 'data', - c_name: 'as', -) +summary({ + 'Profile': profile, +}, section: 'Development') -config_data = configuration_data() +config_include = include_directories('.') -config_data.set_quoted('APP_ID', meson.project_name()) -config_data.set_quoted('VERSION', meson.project_version()) +config = configuration_data() +config.set_quoted('APP_ID', app_id) +config.set_quoted('APP_NAME', app_name) +config.set_quoted('VERSION', meson.project_version()) +config.set_quoted('PROFILE', profile) config_file = configure_file( input: 'src/Config.vala.in', output: '@BASENAME@', - configuration: config_data + configuration: config ) -executable( - meson.project_name(), - 'src' / 'App.vala', - 'src' / 'MainWindow.vala', - 'src' / 'Widgets' / 'WebView.vala', - asresources, - config_file, - dependencies: [ - dependency('glib-2.0'), - dependency('gtk4'), - dependency('libadwaita-1', version: '>=1.5'), - dependency('webkitgtk-6.0'), - meson.get_compiler('vala').find_library('posix'), - ], - install: true -) +gnome = import('gnome') +add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(app_id), language:'c') subdir('data') +subdir('src') meson.add_install_script('build-aux' / 'meson'/ 'post_install.py') diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..338ba93 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('profile', type: 'combo', choices: ['development', 'release'], value: 'development', description: 'Whether this is an in-development or release build; affects app ID, icon, etc.') diff --git a/src/Config.vala.in b/src/Config.vala.in index 2ae91e2..e1e98b6 100644 --- a/src/Config.vala.in +++ b/src/Config.vala.in @@ -1,2 +1,4 @@ public const string APP_ID = @APP_ID@; +public const string APP_NAME = @APP_NAME@; public const string VERSION = @VERSION@; +public const string PROFILE = @PROFILE@; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index acb7477..bd6fb49 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -20,11 +20,13 @@ public class Butler.MainWindow : Adw.ApplicationWindow { private Butler.WebView web_view; - public MainWindow (Gtk.Application application) { + public MainWindow (Adw.Application app) { Object ( - application: application, + application: app, height_request: 294, + icon_name: APP_ID, resizable: true, + title: APP_NAME, width_request: 360 ); add_action_entries (ACTION_ENTRIES, this); @@ -35,7 +37,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow { fullscreened = App.settings.get_boolean ("window-fullscreened"); about_dialog = new Adw.AboutDialog.from_appdata ( - "/com/cassidyjames/butler/metainfo.xml", VERSION + "/com/cassidyjames/butler/metainfo.xml.in", VERSION ) { comments = _("Companion app to access your Home Assistant dashboard"), @@ -46,6 +48,8 @@ public class Butler.MainWindow : Adw.ApplicationWindow { "Tobias Bernard https://tobiasbernard.com/", }, }; + about_dialog.application_icon = APP_ID; + about_dialog.application_name = APP_NAME; about_dialog.copyright = "© 2020–%i %s".printf ( new DateTime.now_local ().get_year (), about_dialog.developer_name @@ -53,11 +57,6 @@ public class Butler.MainWindow : Adw.ApplicationWindow { about_dialog.add_link (_("About Home Assistant"), "https://www.home-assistant.io/"); about_dialog.add_link (_("Home Assistant Privacy Policy"), "https://www.home-assistant.io/privacy/"); - // Set MainWindow properties from the AppData already fetched and parsed - // by the AboutDialog construction - icon_name = about_dialog.application_icon; - title = about_dialog.application_name; - var home_button = new Gtk.Button.from_icon_name ("go-home-symbolic") { tooltip_text = _("Go Home") }; @@ -74,7 +73,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow { // TODO: How do I add shortcuts to the menu? app_menu.append (_("_Fullscreen"), "win.toggle_fullscreen"); app_menu.append (_("Change _Server…"), "win.set_server"); - app_menu.append (_("_About %s").printf (title), "win.about"); + app_menu.append (_("_About %s").printf (APP_NAME), "win.about"); var menu = new Menu (); menu.append_section (null, site_menu); diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..98ebadd --- /dev/null +++ b/src/meson.build @@ -0,0 +1,17 @@ +executable( + app_id, + 'App.vala', + 'MainWindow.vala', + 'Widgets' / 'WebView.vala', + asresources, + config_file, + include_directories: config_include, + dependencies: [ + dependency('glib-2.0'), + dependency('gtk4'), + dependency('libadwaita-1', version: '>=1.5'), + dependency('webkitgtk-6.0'), + meson.get_compiler('vala').find_library('posix'), + ], + install: true +) From 2e14b761b7be78a2771d4039147630553a21a7ba Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 27 Aug 2024 15:43:55 -0600 Subject: [PATCH 2/4] Workflows: only use Devel manifest --- .github/workflows/flatpak.yml | 8 ++++---- com.cassidyjames.butler.json | 30 ------------------------------ 2 files changed, 4 insertions(+), 34 deletions(-) delete mode 100644 com.cassidyjames.butler.json diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index 920945d..373c784 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -10,8 +10,8 @@ concurrency: cancel-in-progress: true jobs: - flatpak: - name: Flathub + flatpak-devel: + name: Flatpak (Devel) runs-on: ubuntu-latest container: image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-46 @@ -20,6 +20,6 @@ jobs: - uses: actions/checkout@v4 - uses: flathub-infra/flatpak-github-actions/flatpak-builder@master with: - bundle: butler.flatpak - manifest-path: com.cassidyjames.butler.json + bundle: com.cassidyjames.butler.Devel.flatpak + manifest-path: com.cassidyjames.butler.Devel.json cache-key: "flatpak-builder-${{ github.sha }}" diff --git a/com.cassidyjames.butler.json b/com.cassidyjames.butler.json deleted file mode 100644 index fec1243..0000000 --- a/com.cassidyjames.butler.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "app-id": "com.cassidyjames.butler", - "runtime": "org.gnome.Platform", - "runtime-version": "46", - "sdk": "org.gnome.Sdk", - "command": "com.cassidyjames.butler", - "finish-args": [ - "--socket=wayland", - "--socket=fallback-x11", - "--share=ipc", - "--share=network", - "--device=dri" - ], - "modules": [ - { - "name": "butler", - "buildsystem": "meson", - "run-tests": true, - "config-opts": [ - "-Dprofile=release" - ], - "sources": [ - { - "type": "dir", - "path": "." - } - ] - } - ] -} From c6b6c89cd3962d3ab1cbf9f42404270dad2d17b9 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 27 Aug 2024 15:51:18 -0600 Subject: [PATCH 3/4] Meson: bump minimum Meson version --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 04eea98..42f06ac 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'com.cassidyjames.butler', 'vala', 'c', version: '1.2.0', - meson_version: '>=0.58', + meson_version: '>=1.1', ) app_id = meson.project_name() From 2d4284cc998cf8e4d1bb266bc9493103bb66bb45 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Tue, 27 Aug 2024 15:59:45 -0600 Subject: [PATCH 4/4] Use as profile name, add CSS class --- com.cassidyjames.butler.Devel.json | 2 +- data/icons/{development.svg => devel.svg} | 0 data/icons/{com.cassidyjames.butler.Source.svg => source.svg} | 0 meson.build | 2 +- meson.options | 2 +- src/MainWindow.vala | 1 + 6 files changed, 4 insertions(+), 3 deletions(-) rename data/icons/{development.svg => devel.svg} (100%) rename data/icons/{com.cassidyjames.butler.Source.svg => source.svg} (100%) diff --git a/com.cassidyjames.butler.Devel.json b/com.cassidyjames.butler.Devel.json index cff8070..1aefb83 100644 --- a/com.cassidyjames.butler.Devel.json +++ b/com.cassidyjames.butler.Devel.json @@ -17,7 +17,7 @@ "buildsystem": "meson", "run-tests": true, "config-opts": [ - "-Dprofile=development" + "-Dprofile=devel" ], "sources": [ { diff --git a/data/icons/development.svg b/data/icons/devel.svg similarity index 100% rename from data/icons/development.svg rename to data/icons/devel.svg diff --git a/data/icons/com.cassidyjames.butler.Source.svg b/data/icons/source.svg similarity index 100% rename from data/icons/com.cassidyjames.butler.Source.svg rename to data/icons/source.svg diff --git a/meson.build b/meson.build index 42f06ac..0803b65 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,7 @@ app_id = meson.project_name() app_name = 'Butler' profile = get_option('profile') -if profile == 'development' +if profile == 'devel' app_id += '.Devel' app_name += ' (Devel)' endif diff --git a/meson.options b/meson.options index 338ba93..b9e4ae2 100644 --- a/meson.options +++ b/meson.options @@ -1 +1 @@ -option('profile', type: 'combo', choices: ['development', 'release'], value: 'development', description: 'Whether this is an in-development or release build; affects app ID, icon, etc.') +option('profile', type: 'combo', choices: ['devel', 'release'], value: 'devel', description: 'Whether this is an in-development or release build; affects app ID, icon, etc.') diff --git a/src/MainWindow.vala b/src/MainWindow.vala index bd6fb49..b7e1c97 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -35,6 +35,7 @@ public class Butler.MainWindow : Adw.ApplicationWindow { construct { maximized = App.settings.get_boolean ("window-maximized"); fullscreened = App.settings.get_boolean ("window-fullscreened"); + this.add_css_class (PROFILE); about_dialog = new Adw.AboutDialog.from_appdata ( "/com/cassidyjames/butler/metainfo.xml.in", VERSION