Created
December 4, 2018 11:58
-
-
Save tslocum/444a08a331c85934d105e3e5e6cdc049 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package main | |
| import ( | |
| "github.com/gotk3/gotk3/glib" | |
| "github.com/gotk3/gotk3/gtk" | |
| "log" | |
| "os" | |
| ) | |
| func main() { | |
| const appID = "space.rocketnine.swayexample" | |
| application, err := gtk.ApplicationNew(appID, glib.APPLICATION_FLAGS_NONE) | |
| // Check to make sure no errors when creating Gtk Application | |
| if err != nil { | |
| log.Fatal("Could not create application.", err) | |
| } | |
| // Application signals available | |
| // startup -> sets up the application when it first starts | |
| // activate -> shows the default first window of the application (like a new document). This corresponds to the application being launched by the desktop environment. | |
| // open -> opens files and shows them in a new window. This corresponds to someone trying to open a document (or documents) using the application from the file browser, or similar. | |
| // shutdown -> performs shutdown tasks | |
| // Setup Gtk Application callback signals | |
| application.Connect("activate", func() { onActivate(application) }) | |
| // Run Gtk application | |
| os.Exit(application.Run(os.Args)) | |
| } | |
| // Callback signal from Gtk Application | |
| func onActivate(application *gtk.Application) { | |
| // Create ApplicationWindow | |
| appWindow, err := gtk.ApplicationWindowNew(application) | |
| if err != nil { | |
| log.Fatal("Could not create application window.", err) | |
| } | |
| // Set ApplicationWindow Properties | |
| appWindow.SetTitle("Basic Application.") | |
| appWindow.SetDefaultSize(400, 400) | |
| appWindow.SetResizable(false) | |
| appWindow.Move(0, 0) | |
| appWindow.Show() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment