mod button highlighting works

This commit is contained in:
Jeff Carr 2025-03-04 00:27:15 -06:00
parent 7364eb1ebf
commit d35d0c16e7
3 changed files with 63 additions and 40 deletions

View File

@ -34,8 +34,8 @@ plugin:
rm -f resources/*.so
# -cp ../../toolkits/gocui/gocui.so resources/
andlabs: install
forge --gui andlabs --debugger
andlabs: clean install
forge --gui andlabs
gocui: install
forge --gui gocui --gui-verbose >/tmp/forge.log 2>&1

View File

@ -23,11 +23,7 @@ func debug() {
time.Sleep(2 * time.Second)
for {
now := time.Now()
if me.repoAllB == nil {
log.Printf("finished empty forge scan here in (%s)\n", shell.FormatDuration(time.Since(now)))
time.Sleep(90 * time.Second)
continue
}
if me.repoAllB != nil {
tmp := fmt.Sprintf("All (%d)", me.forge.Repos.Len())
me.repoAllB.SetLabel(tmp)
@ -55,13 +51,23 @@ func debug() {
me.repoWritableB.SetLabel(tmp)
}
doCheckDirtyAndConfigSave()
found := findDirty()
dirty := found.Len()
if me.repoDirtyB != nil {
doCheckDirtyAndConfigSave()
found := findDirty()
tmp := fmt.Sprintf("dirty (%d)", found.Len())
tmp := fmt.Sprintf("dirty (%d)", dirty)
me.repoDirtyB.SetLabel(tmp)
}
if me.reposWinB != nil {
tmp := fmt.Sprintf("Repos (%d)", me.forge.Repos.Len())
if dirty > 0 {
tmp = fmt.Sprintf("Repos (%d) (%d dirty)", me.forge.Repos.Len(), dirty)
}
me.reposWinB.SetLabel(tmp)
}
log.Printf("finished a forge scan here in (%s)\n", shell.FormatDuration(time.Since(now)))
time.Sleep(90 * time.Second)
}
@ -174,17 +180,6 @@ func drawWindow(win *gadgets.GenericWindow) {
})
me.setBranchB.Disable()
switch me.forge.Config.Mode {
case forgepb.ForgeMode_MASTER:
me.newBranch.SetText("master")
case forgepb.ForgeMode_DEVEL:
me.newBranch.SetText("devel")
case forgepb.ForgeMode_USER:
me.newBranch.SetText(me.forge.Config.GetUsername())
default:
me.newBranch.SetText(me.forge.Config.GetUsername())
}
grid.NextRow()
groupM := win.Stack.NewGroup("Mode Windows")
@ -324,10 +319,35 @@ func drawWindow(win *gadgets.GenericWindow) {
debugger.DebugWindow()
})
})
grid.NextRow()
group2 := win.Stack.NewGroup("Repos")
grid = group2.RawGrid()
var reposWin *gadgets.GenericWindow
me.reposWinB = gridM.NewButton("Repos", func() {
if reposWin != nil {
reposWin.Toggle()
return
}
reposWin = makeReposWin()
})
// set the initial button state based on the last
// forge mode the user saved in the config file
switch me.forge.Config.Mode {
case forgepb.ForgeMode_MASTER:
me.newBranch.SetText("master")
case forgepb.ForgeMode_DEVEL:
me.newBranch.SetText("devel")
case forgepb.ForgeMode_USER:
me.newBranch.SetText(me.forge.Config.GetUsername())
default:
me.newBranch.SetText(me.forge.Config.GetUsername())
}
forgeSwitchMode(me.forge.Config.Mode)
}
func makeReposWin() *gadgets.GenericWindow {
win := gadgets.NewGenericWindow("git repos", "All about git repos")
grid := win.Group.RawGrid()
me.repoDirtyB = grid.NewButton("dirty", func() {
doCheckDirtyAndConfigSave()
@ -395,17 +415,12 @@ func drawWindow(win *gadgets.GenericWindow) {
grid.NewButton("Configure", func() {
log.Info("add a forge config window here")
})
return win
}
// sets the text in the labels in the window
// and hides and shows the buttons
func forgeSwitchMode(newMode forgepb.ForgeMode) {
if newMode == me.forge.Config.Mode {
log.Info("you are already on", newMode.String())
return
}
me.forge.Config.Mode = newMode
// verify the GUI button disable/enable settings
func forgeVerifyGuiState() {
me.forgeMode.SetText(me.forge.GetMode())
me.argvCheckoutUser = false
@ -416,7 +431,7 @@ func forgeSwitchMode(newMode forgepb.ForgeMode) {
me.modePatchW.Disable()
me.modeUserW.Disable()
switch newMode {
switch me.forge.Config.Mode {
case forgepb.ForgeMode_MASTER:
me.argvCheckoutMaster = true
me.newBranch.SetText("master")
@ -434,15 +449,22 @@ func forgeSwitchMode(newMode forgepb.ForgeMode) {
me.argvCheckoutUser = true
me.modeUserW.Enable()
}
}
/*
if me.forge.Config.Mode != forgepb.ForgeMode_USER {
doDisableUserW()
}
*/
// sets the text in the labels in the window
// and hides and shows the buttons
func forgeSwitchMode(newMode forgepb.ForgeMode) {
if newMode == me.forge.Config.Mode {
log.Info("you are already on", newMode.String())
forgeVerifyGuiState() // doing this here initializes the button state
return
}
me.forge.Config.Mode = newMode
forgeVerifyGuiState() // update the button states
me.forge.SetConfigSave(true)
me.forge.ConfigSave()
me.forge.ConfigSave() // todo, only save the forge config
}
func doDisableUserW() {

View File

@ -61,6 +61,7 @@ type mainType struct {
// the repositories to them
newBranch *gui.Node // deprecate?
setBranchB *gui.Node // deprecate?
reposWinB *gui.Node // button that opens the repos window
repoAllB *gui.Node // "all" repos button
repoDirtyB *gui.Node // "dirty" repos button
repoDevelMergeB *gui.Node // "merge to devel" repos button