further fixes for HamPack
This commit is contained in:
@@ -487,6 +487,7 @@ type mainWin struct {
|
|||||||
state map[string]bool
|
state map[string]bool
|
||||||
rows map[string]*gtk.Switch
|
rows map[string]*gtk.Switch
|
||||||
applyBtn *gtk.Button
|
applyBtn *gtk.Button
|
||||||
|
updateBtn *gtk.Button
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMainWin(app *adw.Application) *mainWin {
|
func newMainWin(app *adw.Application) *mainWin {
|
||||||
@@ -516,6 +517,10 @@ func newMainWin(app *adw.Application) *mainWin {
|
|||||||
w.applyBtn.ConnectClicked(func() { w.onApply() })
|
w.applyBtn.ConnectClicked(func() { w.onApply() })
|
||||||
header.PackEnd(w.applyBtn)
|
header.PackEnd(w.applyBtn)
|
||||||
|
|
||||||
|
w.updateBtn = gtk.NewButtonWithLabel("Run Update")
|
||||||
|
w.updateBtn.ConnectClicked(func() { w.onUpdate() })
|
||||||
|
header.PackStart(w.updateBtn)
|
||||||
|
|
||||||
page := adw.NewPreferencesPage()
|
page := adw.NewPreferencesPage()
|
||||||
toolbar.SetContent(page)
|
toolbar.SetContent(page)
|
||||||
|
|
||||||
@@ -542,6 +547,7 @@ func (w *mainWin) makeGroup(page *adw.PreferencesPage, title, cat string, names
|
|||||||
group.SetTitle(title)
|
group.SetTitle(title)
|
||||||
page.Add(group)
|
page.Add(group)
|
||||||
|
|
||||||
|
var actionRows []*adw.ActionRow
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
key := cat + ":" + name
|
key := cat + ":" + name
|
||||||
row := adw.NewActionRow()
|
row := adw.NewActionRow()
|
||||||
@@ -553,7 +559,26 @@ func (w *mainWin) makeGroup(page *adw.PreferencesPage, title, cat string, names
|
|||||||
row.SetActivatableWidget(sw)
|
row.SetActivatableWidget(sw)
|
||||||
group.Add(row)
|
group.Add(row)
|
||||||
w.rows[key] = sw
|
w.rows[key] = sw
|
||||||
|
actionRows = append(actionRows, row)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expanded := true
|
||||||
|
chevron := gtk.NewImageFromIconName("pan-down-symbolic")
|
||||||
|
toggleBtn := gtk.NewButton()
|
||||||
|
toggleBtn.SetChild(chevron)
|
||||||
|
toggleBtn.AddCSSClass("flat")
|
||||||
|
toggleBtn.ConnectClicked(func() {
|
||||||
|
expanded = !expanded
|
||||||
|
for _, row := range actionRows {
|
||||||
|
row.SetVisible(expanded)
|
||||||
|
}
|
||||||
|
if expanded {
|
||||||
|
chevron.SetFromIconName("pan-down-symbolic")
|
||||||
|
} else {
|
||||||
|
chevron.SetFromIconName("pan-end-symbolic")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
group.SetHeaderSuffix(toggleBtn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *mainWin) onApply() {
|
func (w *mainWin) onApply() {
|
||||||
@@ -581,6 +606,21 @@ func (w *mainWin) onApply() {
|
|||||||
out.Present()
|
out.Present()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *mainWin) onUpdate() {
|
||||||
|
w.updateBtn.SetSensitive(false)
|
||||||
|
w.applyBtn.SetSensitive(false)
|
||||||
|
|
||||||
|
ops := []Op{{
|
||||||
|
Label: "Run Update",
|
||||||
|
Cmds: [][]string{{"bash", "-c", "wget -qO- https://gitea.young.computer/david/hampack/raw/branch/main/install.sh | bash"}},
|
||||||
|
}}
|
||||||
|
|
||||||
|
newOutputWin(ops, func() {
|
||||||
|
w.updateBtn.SetSensitive(true)
|
||||||
|
w.applyBtn.SetSensitive(true)
|
||||||
|
}).Present()
|
||||||
|
}
|
||||||
|
|
||||||
// ── Main ──────────────────────────────────────────────────────────────────────
|
// ── Main ──────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user