use gadgets.GenericWindow()
This commit is contained in:
parent
eca95a62fc
commit
6cb34ae52c
12
doGui.go
12
doGui.go
|
@ -107,7 +107,7 @@ func drawWindow(win *gadgets.GenericWindow) {
|
|||
grid := win.Group.RawGrid()
|
||||
me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home")
|
||||
grid.NewLabel("")
|
||||
var howtoWin *GenericWindow
|
||||
var howtoWin *gadgets.GenericWindow
|
||||
me.demoB = grid.NewButton("Howto", func() {
|
||||
if howtoWin != nil {
|
||||
howtoWin.Toggle()
|
||||
|
@ -211,13 +211,13 @@ func drawWindow(win *gadgets.GenericWindow) {
|
|||
me.modePatchW.Disable()
|
||||
|
||||
// the user mode "hack Window"
|
||||
var hackWin *GenericWindow
|
||||
var hackWin *gadgets.GenericWindow
|
||||
me.modeUserW = gridM.NewButton("Hack Window", func() {
|
||||
if hackWin != nil {
|
||||
hackWin.Toggle()
|
||||
return
|
||||
}
|
||||
hackWin := NewGenericWindow("Hack / User Mode Window", "Things that might be wrong")
|
||||
hackWin := gadgets.NewGenericWindow("Hack / User Mode Window", "Things that might be wrong")
|
||||
grid := hackWin.Group.RawGrid()
|
||||
grid.NewButton("git pull", func() {
|
||||
log.Info("todo: run git pull on each repo")
|
||||
|
@ -382,7 +382,7 @@ func makeReposWin() *gadgets.GenericWindow {
|
|||
})
|
||||
})
|
||||
|
||||
var writeWin *GenericWindow
|
||||
var writeWin *gadgets.GenericWindow
|
||||
me.repoWritableB = grid.NewButton("writable", func() {
|
||||
// if the window exists, just toggle it open or closed
|
||||
if writeWin != nil {
|
||||
|
@ -536,8 +536,8 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable,
|
|||
return t, box
|
||||
}
|
||||
|
||||
func makeWritableWindow(pb *gitpb.Repos) (*GenericWindow, *gitpb.ReposTable) {
|
||||
win := NewGenericWindow("Repos You have write access to", "Configure")
|
||||
func makeWritableWindow(pb *gitpb.Repos) (*gadgets.GenericWindow, *gitpb.ReposTable) {
|
||||
win := gadgets.NewGenericWindow("Repos You have write access to", "Configure")
|
||||
t := pb.NewTable("testForgeRepos")
|
||||
t.NewUuid()
|
||||
|
||||
|
|
107
windowGeneric.go
107
windowGeneric.go
|
@ -1,107 +0,0 @@
|
|||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
||||
// Use of this source code is governed by the GPL 3.0
|
||||
|
||||
package main
|
||||
|
||||
// This model works for 99.9% of all windows
|
||||
// This is the Default Standard Window Model
|
||||
|
||||
import (
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/gui"
|
||||
)
|
||||
|
||||
type GenericWindow struct {
|
||||
Win *gadgets.BasicWindow // the window widget itself
|
||||
Shelf *gui.Node // the overall box: the shelf
|
||||
Stack *gui.Node // the first box is a stack
|
||||
Top *gui.Node // the first item in the stack is always a shelf like box
|
||||
Group *gui.Node // the first item top box is always a group
|
||||
Middle *gui.Node // the middle box (shelf style)
|
||||
Bottom *gui.Node // the bottom box (stack style)
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Hidden() bool {
|
||||
if gw == nil {
|
||||
return true
|
||||
}
|
||||
if gw.Win == nil {
|
||||
return true
|
||||
}
|
||||
return gw.Win.Hidden()
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Toggle() {
|
||||
if gw.Hidden() {
|
||||
gw.Show()
|
||||
} else {
|
||||
gw.Hide()
|
||||
}
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Show() {
|
||||
if gw == nil {
|
||||
return
|
||||
}
|
||||
if gw.Win == nil {
|
||||
return
|
||||
}
|
||||
gw.Win.Show()
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Hide() {
|
||||
if gw == nil {
|
||||
return
|
||||
}
|
||||
if gw.Win == nil {
|
||||
return
|
||||
}
|
||||
gw.Win.Hide()
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Disable() {
|
||||
if gw == nil {
|
||||
return
|
||||
}
|
||||
if gw.Shelf == nil {
|
||||
return
|
||||
}
|
||||
gw.Shelf.Disable()
|
||||
}
|
||||
|
||||
func (gw *GenericWindow) Enable() {
|
||||
if gw == nil {
|
||||
return
|
||||
}
|
||||
if gw.Shelf == nil {
|
||||
return
|
||||
}
|
||||
gw.Shelf.Enable()
|
||||
}
|
||||
|
||||
func NewGenericWindow(title string, grouptxt string) *GenericWindow {
|
||||
gw := new(GenericWindow)
|
||||
gw.Win = gadgets.RawBasicWindow(title)
|
||||
gw.Win.Make()
|
||||
|
||||
gw.Win.Custom = func() {
|
||||
log.Warn("Found Window close. setting hidden=true")
|
||||
// sets the hidden flag to false so Toggle() works
|
||||
gw.Win.Hide()
|
||||
}
|
||||
gw.Shelf = gw.Win.Box()
|
||||
// gw.Shelf.Vertical().SetProgName("ShelfBox")
|
||||
gw.Stack = gw.Shelf.NewVerticalBox("Stackbox")
|
||||
|
||||
gw.Top = gw.Stack.NewVerticalBox("Stackbox")
|
||||
gw.Middle = gw.Stack.Box()
|
||||
gw.Bottom = gw.Stack.Box()
|
||||
|
||||
gw.Group = gw.Top.NewGroup(grouptxt)
|
||||
|
||||
gw.Show()
|
||||
|
||||
return gw
|
||||
}
|
|
@ -9,12 +9,13 @@ import (
|
|||
"os"
|
||||
|
||||
"go.wit.com/lib/fhelp"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func makeHowtoWin() *GenericWindow {
|
||||
howtoWin := NewGenericWindow("Howto", "forge -- a GUI tool for git repostories")
|
||||
func makeHowtoWin() *gadgets.GenericWindow {
|
||||
howtoWin := gadgets.NewGenericWindow("Howto", "forge -- a GUI tool for git repostories")
|
||||
tmp := `A good way to see how forge works is to download forge
|
||||
|
||||
This will 'git clone' a few things (~50 repos):
|
||||
|
|
Loading…
Reference in New Issue