fix all the GTK errorrs

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-07 16:58:44 -07:00
parent 369a8941a8
commit 3f2645e4b0
1 changed files with 15 additions and 4 deletions

View File

@ -3,6 +3,7 @@
package main
import "fmt"
// import "os"
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
@ -36,6 +37,7 @@ type modelHandler struct {
yellowRow int
checkStates []int
vms []vmRowData
columnTypes string
}
func newDefaultModelHandler() *modelHandler {
@ -54,6 +56,7 @@ func newDefaultModelHandler() *modelHandler {
func newJcarrModelHandler() *modelHandler {
mh := new(modelHandler)
mh.rows = 10
mh.columnTypes = "standard"
mh.bgcolorColumn = 0
mh.checkStates = make([]int, mh.rows)
mh.vms = make([]vmRowData, mh.rows)
@ -76,9 +79,16 @@ func standardColumnTypes() []ui.TableValue {
func (mh *modelHandler) ColumnTypes(m *ui.TableModel) []ui.TableValue {
// log.Println("ColumnTypes() with m=", m, "mh=", mh)
if (mh.name == "jcarrTable") {
// log.Println("ColumnTypes() with m=", m, "mh=", mh)
if (mh.columnTypes == "standard") {
return standardColumnTypes()
/*
return []ui.TableValue{
ui.TableColor{}, // row background color
ui.TableString(""), // column 0 text
ui.TableColor{}, // column 0 text color
ui.TableString("test"), // column 1 button text
}
*/
}
return []ui.TableValue{
ui.TableString(""), // column 0 text
@ -98,7 +108,7 @@ var img [2]*ui.Image
func (mh *modelHandler) CellValue(m *ui.TableModel, row, column int) ui.TableValue {
// TODO: Figure out why this is being called 1000 times a second (10 times for each row & column)
// log.Println("CallValue() row=", row, "column=", column)
if (mh.name == "jcarrTable") {
if (mh.columnTypes == "standard") {
switch column {
case 0:
if (row % 2) == 1 {
@ -164,7 +174,7 @@ func (mh *modelHandler) SetCellValue(m *ui.TableModel, row, column int, value ui
log.Println("SetCallValue() START")
spew.Dump(m)
spew.Dump(mh)
if (mh.name == "jcarrTable") {
if (mh.columnTypes == "standard") {
if column == 3 { // button row (?)
log.Println("Button was pressed START", row, column)
}
@ -237,6 +247,7 @@ func makeJcarrtable(name string) (*ui.Table, *modelHandler, *ui.TableModel) {
func newModelHandler(rows int) *modelHandler {
mh := new(modelHandler)
mh.rows = rows
mh.columnTypes = "standard"
mh.bgcolorColumn = 0
mh.checkStates = make([]int, mh.rows)
mh.vms = make([]vmRowData, mh.rows)