Skip to content

Commit

Permalink
feat: Use Adwaita AboutDialog instead of AboutWindow, create `Abo…
Browse files Browse the repository at this point in the history
…utDialog` from AppStream metadata instead of manually

Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
  • Loading branch information
pojntfx committed Jul 18, 2024
1 parent 0065569 commit 2ced1b7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 34 deletions.
2 changes: 1 addition & 1 deletion com.pojtinger.felicitas.Multiplex.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
16 changes: 5 additions & 11 deletions internal/components/main_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions internal/resources/about.ui

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<file>warning.ui</file>
<file>error.ui</file>
<file>menu.ui</file>
<file>about.ui</file>
<file>preferences.ui</file>
<file>subtitles.ui</file>
<file>audiotracks.ui</file>
<file>preparing.ui</file>
<file>style.css</file>
<file>com.pojtinger.felicitas.Multiplex.metainfo.xml</file>
</gresource>
</gresources>
2 changes: 1 addition & 1 deletion internal/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit 2ced1b7

Please sign in to comment.