further fixes for HamPack
This commit is contained in:
@@ -487,6 +487,7 @@ type mainWin struct {
|
||||
state map[string]bool
|
||||
rows map[string]*gtk.Switch
|
||||
applyBtn *gtk.Button
|
||||
updateBtn *gtk.Button
|
||||
}
|
||||
|
||||
func newMainWin(app *adw.Application) *mainWin {
|
||||
@@ -516,6 +517,10 @@ func newMainWin(app *adw.Application) *mainWin {
|
||||
w.applyBtn.ConnectClicked(func() { w.onApply() })
|
||||
header.PackEnd(w.applyBtn)
|
||||
|
||||
w.updateBtn = gtk.NewButtonWithLabel("Run Update")
|
||||
w.updateBtn.ConnectClicked(func() { w.onUpdate() })
|
||||
header.PackStart(w.updateBtn)
|
||||
|
||||
page := adw.NewPreferencesPage()
|
||||
toolbar.SetContent(page)
|
||||
|
||||
@@ -542,6 +547,7 @@ func (w *mainWin) makeGroup(page *adw.PreferencesPage, title, cat string, names
|
||||
group.SetTitle(title)
|
||||
page.Add(group)
|
||||
|
||||
var actionRows []*adw.ActionRow
|
||||
for _, name := range names {
|
||||
key := cat + ":" + name
|
||||
row := adw.NewActionRow()
|
||||
@@ -553,7 +559,26 @@ func (w *mainWin) makeGroup(page *adw.PreferencesPage, title, cat string, names
|
||||
row.SetActivatableWidget(sw)
|
||||
group.Add(row)
|
||||
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() {
|
||||
@@ -581,6 +606,21 @@ func (w *mainWin) onApply() {
|
||||
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 ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in New Issue
Block a user