-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5716be9
Showing
4 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go.sum | ||
physettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/gotk3/gotk3/gtk" | ||
) | ||
|
||
// Setup the TextView, put it in a ScrolledWindow, and add both to box. | ||
func setupTextView(box *gtk.Box) *gtk.TextView { | ||
sw, _ := gtk.ScrolledWindowNew(nil, nil) | ||
tv, _ := gtk.TextViewNew() | ||
sw.Add(tv) | ||
box.PackStart(sw, true, true, 0) | ||
return tv | ||
} | ||
|
||
// func setupPropertyCheckboxes(tv *gtk.TextView, outer *gtk.Box, props []*BoolProperty) { | ||
// box, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0) | ||
// for _, prop := range props { | ||
// chk, _ := gtk.CheckButtonNewWithLabel(prop.Name) | ||
// // initialize the checkbox with the property's current value | ||
// chk.SetActive(prop.Get()) | ||
// p := prop // w/o this all the checkboxes will toggle the last property in props | ||
// chk.Connect("toggled", func() { | ||
// p.Set(chk.GetActive()) | ||
// }) | ||
// box.PackStart(chk, true, true, 0) | ||
// } | ||
// outer.PackStart(box, false, false, 0) | ||
// } | ||
|
||
func setupAnimationsTab() *gtk.Box{ | ||
box := boxNew(gtk.ORIENTATION_VERTICAL, 0) | ||
|
||
// tv := setupTextView(box) | ||
|
||
chkGlx, _ := gtk.CheckButtonNewWithLabel("Use GLX:") | ||
chkVsync, _ := gtk.CheckButtonNewWithLabel("Enable VSync:") | ||
chkAnimations, _ := gtk.CheckButtonNewWithLabel("Enable Animations:") | ||
chkFading, _ := gtk.CheckButtonNewWithLabel("Enable Fading:") | ||
chkNextTagFading, _ := gtk.CheckButtonNewWithLabel("Next Tag Fading:") | ||
chkPrevTagFading, _ := gtk.CheckButtonNewWithLabel("Prev Tag Fading:") | ||
|
||
box.Add(chkGlx) | ||
box.Add(chkVsync) | ||
box.Add(chkAnimations) | ||
box.Add(chkFading) | ||
box.Add(chkNextTagFading) | ||
box.Add(chkPrevTagFading) | ||
|
||
return box | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module physettings | ||
|
||
go 1.21.3 | ||
|
||
require github.com/gotk3/gotk3 v0.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package main | ||
|
||
|
||
import ( | ||
"github.com/gotk3/gotk3/gtk" | ||
"log" | ||
) | ||
|
||
const ( | ||
width = 800 | ||
height = 600 | ||
spacing = 25 | ||
logo_path = "/usr/share/pixmaps/phyOS-logo-128x128.png" | ||
) | ||
|
||
func boxNew(o gtk.Orientation, spc int) *gtk.Box { | ||
|
||
box, err := gtk.BoxNew(o, spc) | ||
|
||
if err != nil { | ||
log.Fatal("Error: Can not create box", err) | ||
} | ||
|
||
return box | ||
} | ||
|
||
|
||
func imageNew(path string) *gtk.Image { | ||
|
||
img, err := gtk.ImageNewFromFile(path) | ||
|
||
if err != nil { | ||
log.Fatal("Error: can not load image file", err) | ||
} | ||
|
||
return img | ||
} | ||
|
||
func labelNew(text string) *gtk.Label { | ||
|
||
label, err := gtk.LabelNew(text) | ||
|
||
if err != nil { | ||
log.Fatal("Error: Can not create label", text) | ||
} | ||
|
||
return label | ||
} | ||
|
||
func windowNew(title string) *gtk.Window { | ||
|
||
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) | ||
|
||
if err != nil { | ||
log.Fatal("Error: Can not create window", err) | ||
} | ||
|
||
win.SetTitle(title) | ||
win.Connect("destroy", func() { | ||
gtk.MainQuit() | ||
}) | ||
|
||
win.SetSizeRequest(width, height) | ||
win.SetDefaultSize(width, height) | ||
win.SetPosition(gtk.WIN_POS_CENTER) | ||
|
||
return win | ||
} | ||
|
||
|
||
func main() { | ||
|
||
gtk.Init(nil) | ||
|
||
nb, err := gtk.NotebookNew() | ||
if err != nil { | ||
log.Fatal("Unable to create notebook:", err) | ||
} | ||
win := windowNew("phy") | ||
win.Add(nb) | ||
nb.SetHExpand(true) | ||
nb.SetVExpand(true) | ||
|
||
logo := imageNew(logo_path) | ||
box := boxNew(gtk.ORIENTATION_VERTICAL, 15) | ||
logo.SetHAlign(gtk.ALIGN_CENTER) | ||
box.SetMarginStart(spacing) | ||
box.SetMarginTop(spacing) | ||
box.Add(logo) | ||
|
||
|
||
// Add a child widget and tab label to the notebook so it renders. | ||
nbChild, err := gtk.LabelNew("Notebook content") | ||
if err != nil { | ||
log.Fatal("Unable to create button:", err) | ||
} | ||
nbInfo := labelNew("INFO") | ||
nbOptions := labelNew("OPTIONS") | ||
nbAnimations := labelNew("ANIMATIONS") | ||
nb.SetTabPos(gtk.POS_BOTTOM) | ||
nb.AppendPage(box, nbInfo) | ||
nb.AppendPage(nbChild, nbOptions) | ||
|
||
animationsBox := setupAnimationsTab() | ||
nb.AppendPage(animationsBox, nbAnimations) | ||
|
||
win.ShowAll() | ||
|
||
gtk.Main() | ||
} |