From 2ced1b72b05fee75204117fd5ce8876033841377 Mon Sep 17 00:00:00 2001 From: Felicitas Pojtinger Date: Wed, 17 Jul 2024 21:14:03 -0400 Subject: [PATCH] feat: Use Adwaita `AboutDialog` instead of `AboutWindow`, create `AboutDialog` from AppStream metadata instead of manually Signed-off-by: Felicitas Pojtinger --- com.pojtinger.felicitas.Multiplex.json | 2 +- internal/components/main_menu.go | 16 +++++---------- internal/resources/about.ui | 20 ------------------- ...ojtinger.felicitas.Multiplex.gresource.xml | 2 +- ...pojtinger.felicitas.Multiplex.metainfo.xml | 0 internal/resources/resources.go | 2 +- 6 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 internal/resources/about.ui rename com.pojtinger.felicitas.Multiplex.metainfo.xml => internal/resources/com.pojtinger.felicitas.Multiplex.metainfo.xml (100%) diff --git a/com.pojtinger.felicitas.Multiplex.json b/com.pojtinger.felicitas.Multiplex.json index 7fc828a..f4b38cc 100644 --- a/com.pojtinger.felicitas.Multiplex.json +++ b/com.pojtinger.felicitas.Multiplex.json @@ -24,7 +24,7 @@ "mkdir -p vendor && cp modules.txt vendor/modules.txt", ". /usr/lib/sdk/golang/enable.sh && export GOBIN=\"/app/bin\" && go generate ./... && go install -v -mod=vendor .", "desktop-file-install --dir=/app/share/applications $FLATPAK_ID.desktop", - "install -D -m 0644 $FLATPAK_ID.metainfo.xml /app/share/metainfo/$FLATPAK_ID.metainfo.xml", + "install -D -m 0644 internal/resources/$FLATPAK_ID.metainfo.xml /app/share/metainfo/$FLATPAK_ID.metainfo.xml", "for icon in 16x16 22x22 24x24 32x32 36x36 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512; do install -D -m 0644 docs/icon-${icon}.png /app/share/icons/hicolor/${icon}/apps/$FLATPAK_ID.png; done" ], "sources": [{ "type": "dir", "path": "." }, "dependencies.json"] diff --git a/internal/components/main_menu.go b/internal/components/main_menu.go index 3b3f15d..f9e984d 100644 --- a/internal/components/main_menu.go +++ b/internal/components/main_menu.go @@ -31,8 +31,10 @@ func AddMainMenu( menuBuilder := gtk.NewBuilderFromResource(resources.GResourceMenuPath) menu := menuBuilder.GetObject("main-menu").Cast().(*gio.Menu) - aboutBuilder := gtk.NewBuilderFromResource(resources.GResourceAboutPath) - aboutDialog := aboutBuilder.GetObject("about-dialog").Cast().(*adw.AboutWindow) + aboutDialog := adw.NewAboutDialogFromAppdata(resources.GResourceMetainfoPath, "0.1.4") + aboutDialog.SetDevelopers([]string{"Felicitas Pojtinger"}) + aboutDialog.SetArtists([]string{"Brage Fuglseth"}) + aboutDialog.SetCopyright("© 2024 Felicitas Pojtinger") preferencesBuilder := gtk.NewBuilderFromResource(resources.GResourcePreferencesPath) preferencesWindow := preferencesBuilder.GetObject("preferences-window").Cast().(*adw.PreferencesWindow) @@ -226,18 +228,10 @@ func AddMainMenu( aboutAction := gio.NewSimpleAction("about", nil) aboutAction.ConnectActivate(func(parameter *glib.Variant) { - aboutDialog.SetVisible(true) + aboutDialog.Present(&window.Window) }) window.AddAction(aboutAction) - aboutDialog.SetTransientFor(&window.Window) - aboutDialog.ConnectCloseRequest(func() (ok bool) { - aboutDialog.Close() - aboutDialog.SetVisible(false) - - return ok - }) - menuButton.SetMenuModel(menu) return preferencesWindow, mpvCommandInput diff --git a/internal/resources/about.ui b/internal/resources/about.ui deleted file mode 100644 index 3326936..0000000 --- a/internal/resources/about.ui +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - true - Felicitas Pojtinger - Felicitas Pojtinger - Brage Fuglseth - © 2024 Felicitas Pojtinger - GTK_LICENSE_AGPL_3_0 - com.pojtinger.felicitas.Multiplex - Multiplex - 0.1.2 - https://github.com/pojntfx/multiplex/issues/new/choose - https://matrix.to/#/#multiplex:matrix.org?via=matrix.org - https://github.com/pojntfx/multiplex - - \ No newline at end of file diff --git a/internal/resources/com.pojtinger.felicitas.Multiplex.gresource.xml b/internal/resources/com.pojtinger.felicitas.Multiplex.gresource.xml index e9ff0ff..2dc511f 100644 --- a/internal/resources/com.pojtinger.felicitas.Multiplex.gresource.xml +++ b/internal/resources/com.pojtinger.felicitas.Multiplex.gresource.xml @@ -7,11 +7,11 @@ warning.ui error.ui menu.ui - about.ui preferences.ui subtitles.ui audiotracks.ui preparing.ui style.css + com.pojtinger.felicitas.Multiplex.metainfo.xml \ No newline at end of file diff --git a/com.pojtinger.felicitas.Multiplex.metainfo.xml b/internal/resources/com.pojtinger.felicitas.Multiplex.metainfo.xml similarity index 100% rename from com.pojtinger.felicitas.Multiplex.metainfo.xml rename to internal/resources/com.pojtinger.felicitas.Multiplex.metainfo.xml diff --git a/internal/resources/resources.go b/internal/resources/resources.go index 638ccba..8adae11 100644 --- a/internal/resources/resources.go +++ b/internal/resources/resources.go @@ -40,10 +40,10 @@ var ( GResourceWarningPath = path.Join(gResourceAppPath, "warning.ui") GResourceErrorPath = path.Join(gResourceAppPath, "error.ui") GResourceMenuPath = path.Join(gResourceAppPath, "menu.ui") - GResourceAboutPath = path.Join(gResourceAppPath, "about.ui") GResourcePreferencesPath = path.Join(gResourceAppPath, "preferences.ui") GResourceSubtitlesPath = path.Join(gResourceAppPath, "subtitles.ui") GResourceAudiotracksPath = path.Join(gResourceAppPath, "audiotracks.ui") GResourcePreparingPath = path.Join(gResourceAppPath, "preparing.ui") GResourceStyleCSSPath = path.Join(gResourceAppPath, "style.css") + GResourceMetainfoPath = path.Join(gResourceAppPath, "com.pojtinger.felicitas.Multiplex.metainfo.xml") )