// main.go
package main
import (
"fmt"
"github.com/gotk3/gotk3/gtk"
)
func main() {
gtk.Init(nil)
// Create the first screen
firstScreen, err := createFirstScreen()
if err != nil {
fmt.Println("Error creating first screen:", err)
return
}
// Show the first screen
showScreen(firstScreen)
gtk.Main()
}
func createFirstScreen() (*gtk.Window, error) {
// Create a new GTK window
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return nil, err
}
// Set window properties
win.SetTitle("First Screen")
win.SetDefaultSize(400, 300)
// Handle the destroy event to close the application
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a button to navigate to the second screen
button, err := gtk.ButtonNewWithLabel("Go to Second Screen")
if err != nil {
return nil, err
}
// Handle button click to show the second screen
button.Connect("clicked", func() {
secondScreen, err := createSecondScreen()
if err != nil {
fmt.Println("Error creating second screen:", err)
return
}
showScreen(secondScreen)
})
// Add the button to the window
win.Add(button)
return win, nil
}
func createSecondScreen() (*gtk.Window, error) {
// Create a new GTK window
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return nil, err
}
// Set window properties
win.SetTitle("Second Screen")
win.SetDefaultSize(400, 300)
// Handle the destroy event to close the application
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Create a button to navigate to the third screen
button, err := gtk.ButtonNewWithLabel("Go to Third Screen")
if err != nil {
return nil, err
}
// Handle button click to show the third screen
button.Connect("clicked", func() {
thirdScreen, err := createThirdScreen()
if err != nil {
fmt.Println("Error creating third screen:", err)
return
}
showScreen(thirdScreen)
})
// Add the button to the window
win.Add(button)
return win, nil
}
func createThirdScreen() (*gtk.Window, error) {
// Create a new GTK window
win, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
if err != nil {
return nil, err
}
// Set window properties
win.SetTitle("Third Screen")
win.SetDefaultSize(400, 300)
// Handle the destroy event to close the application
win.Connect("destroy", func() {
gtk.MainQuit()
})
// Add content or controls specific to the third screen as needed
return win, nil
}
func showScreen(win *gtk.Window) {
// Show the window and all its components
win.ShowAll()
}