summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-04 04:12:14 -0600
committerJeff Carr <[email protected]>2025-03-04 04:12:14 -0600
commit6cb34ae52cbbeb21f00ca2129d8494002b096d29 (patch)
treeeb162e5aee18bf3f06a039603d48cf68ba0876aa
parenteca95a62fc9cc5ebb079fc7c4d0d5028f72c2cae (diff)
use gadgets.GenericWindow()
-rw-r--r--doGui.go12
-rw-r--r--windowGeneric.go107
-rw-r--r--windowHowto.go5
3 files changed, 9 insertions, 115 deletions
diff --git a/doGui.go b/doGui.go
index 46eed56..45e29c9 100644
--- a/doGui.go
+++ b/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()
diff --git a/windowGeneric.go b/windowGeneric.go
deleted file mode 100644
index a487574..0000000
--- a/windowGeneric.go
+++ /dev/null
@@ -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
-}
diff --git a/windowHowto.go b/windowHowto.go
index 907e65f..71af7c4 100644
--- a/windowHowto.go
+++ b/windowHowto.go
@@ -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):