{"id":24546610,"url":"https://github.com/devops-kung-fu/meadow","last_synced_at":"2025-09-06T04:44:44.838Z","repository":{"id":65211611,"uuid":"587935128","full_name":"devops-kung-fu/meadow","owner":"devops-kung-fu","description":"Create user interfaces in Go! Meadow generates Go code which connects to GTK objects as defined in a Glade file for easy use by gotk3","archived":false,"fork":false,"pushed_at":"2023-05-19T13:02:26.000Z","size":1294,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-11T02:36:33.744Z","etag":null,"topics":["code-generator","glade","glade-files","go","golang","gtk","gtk3"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devops-kung-fu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null}},"created_at":"2023-01-11T23:38:19.000Z","updated_at":"2024-11-04T17:20:42.000Z","dependencies_parsed_at":"2023-01-15T15:15:16.792Z","dependency_job_id":"2f8c0996-4693-4f19-b65e-17f08f3504c0","html_url":"https://github.com/devops-kung-fu/meadow","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"120dc1e4db694a4ea6aa1bb6d2f97a302131427e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devops-kung-fu/meadow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-kung-fu%2Fmeadow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-kung-fu%2Fmeadow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-kung-fu%2Fmeadow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-kung-fu%2Fmeadow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devops-kung-fu","download_url":"https://codeload.github.com/devops-kung-fu/meadow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devops-kung-fu%2Fmeadow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273755859,"owners_count":25162241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","glade","glade-files","go","golang","gtk","gtk3"],"created_at":"2025-01-22T22:16:03.372Z","updated_at":"2025-09-06T04:44:44.808Z","avatar_url":"https://github.com/devops-kung-fu.png","language":"Go","readme":"\n![](img/meadow128x128.png)\n\n# meadow\n[![](https://img.shields.io/badge/Status-ALPHA-red)](CONTRIBUTING.md)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/devops-kung-fu/meadow) \n[![Go Report Card](https://goreportcard.com/badge/github.com/devops-kung-fu/meadow)](https://goreportcard.com/report/github.com/devops-kung-fu/meadow) \n[![codecov](https://codecov.io/gh/devops-kung-fu/meadow/branch/main/graph/badge.svg?token=P9WBOBQTOB)](https://codecov.io/gh/devops-kung-fu/meadow) \n[![SBOM](https://img.shields.io/badge/CyloneDX-SBOM-informational)](sbom/meadow.cyclonedx.json)\n\n\n```meadow``` is an application that generates ```go``` code which connects to [GTK](https://www.gtk.org/) objects as defined in a [Glade](https://glade.gnome.org/) file.\n\n## Overview\n\nBuilding user interfaces with ```go``` hasn't been the easiest thing to accomplish without a big lift. While searching around the internet for ways to create user interfaces with ```go``` we quickly realized that we could do some cool things with [GTK](https://www.gtk.org/) using [gotk3](https://github.com/gotk3/gotk3). [gotk3](https://github.com/gotk3/gotk3) provides [GTK](https://www.gtk.org/) bindings that allow developers to build user interfaces.\n\nMany of the demos focused on creating user interfaces in code, which seemed a bit tedious. There's a better way to lay things out, and that's with [Glade](https://glade.gnome.org/), which provides a graphical way to build user interfaces and produce and XML file that can be consumed by [gotk3](https://github.com/gotk3/gotk3).\n\nSo why did we write ```meadow```? Simply because wiring up all the objects created in [Glade](https://glade.gnome.org/) to usable code was a complete pain. The more complex the interface, the more code that would have to be written to get specific objects from the  [Glade](https://glade.gnome.org/) file and interact with them. ```meadow``` simplifies this by generating beautiful ```go``` code that provides an easy way to interact with the [GTK](https://www.gtk.org/) bindings provided by [gotk3](https://github.com/gotk3/gotk3).\n\n## Glade\n\n[Glade](https://glade.gnome.org/) is a RAD tool to enable quick \u0026 easy development of user interfaces for the [GTK](https://www.gtk.org/) toolkit and the GNOME desktop environment.\n\nThe user interfaces designed in [Glade](https://glade.gnome.org/) are saved as XML, and by using the GtkBuilder [GTK](https://www.gtk.org/) object these can be loaded by applications dynamically as needed.\n\n![glade](img/glade.png)\n\n\n```meadow``` reads the XML files output by [Glade](https://glade.gnome.org/) and renders ```go``` code that developers can use to interact with [gotk3](https://github.com/gotk3/gotk3).\n\n## Installation\n\n### Mac\n\nYou can use [Homebrew](https://brew.sh) to install ```meadow``` using the following:\n\n``` bash\nbrew tap devops-kung-fu/homebrew-tap\nbrew install devops-kung-fu/homebrew-tap/meadow\n```\n\nIf you do not have Homebrew, you can still [download the latest release](https://github.com/devops-kung-fu/meadow/releases) (ex: ```meadow_0.1.0_darwin_all.tar.gz```), extract the files from the archive, and use the ```meadow``` binary.  \n\nIf you wish, you can move the ```meadow``` binary to your ```/usr/local/bin``` directory or anywhere on your path.\n\n### Linux\n\nTo install ```meadow```,  [download the latest release](https://github.com/devops-kung-fu/meadow/releases) for your platform and install locally. For example, install ```meadow``` on Ubuntu:\n\n```bash\ndpkg -i meadow_0.1.0_linux_arm64.deb\n```\n\n## Using ```meadow```\n\n### Validation\n\nIn order for ```meadow``` to generate syntactically correct ```go``` code, there are specific requirements that the XML files from [Glade](https://glade.gnome.org/) need to adhere to. The biggest of these is that *every* object needs to have an identifier.\n\nYou can check to see if your XML file is valid by running the following command:\n\n``` bash\nmeadow validate sourcefile.glade\n```\n\n### Generation\n\nTo generate code for your XML file, simply run the following:\n\n``` bash\nmeadow generate sourcefile.glade\n```\nThis will create code and by default, place it in a sub-folder of your current working directory (```ui```), name the file ```glade.go```, and the ```glade.go``` file will have a package defined as ```package ui```.\n\n### Flags\n\nThere are ways to alter the destination, name, and package name of the generated files. You can do so with the following flags:\n\n| Flag | Description |\n|---|---|\n| --output-path | Saves the generated ```go``` source to the provided path. (default: ```ui```)|\n| --output-file | Saves the generated ```go``` source to the provided file name. (default: ```glade.go```) |\n| --package | If defined the ```package``` directive in the source file will be the provided name. (default: ```ui```) |\n| --debug | Ouptuts debug information to the terminal while ```meadow``` is running. |\n\nExample:\n\n``` bash\nmeadow generate --output-path gen --output-filename dkfm.go --package gen sourcefile.glade\n```\nThis will generate a file named ```dkfm.go``` in a subfolder named ```gen``` with a package set to ```package gen```.\n\n## Working with ```meadow```\n\nSample XML file:\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!-- Generated with glade 3.40.0 --\u003e\n\u003cinterface\u003e\n  \u003crequires lib=\"gtk+\" version=\"3.24\"/\u003e\n  \u003cobject class=\"GtkWindow\" id=\"window\"\u003e\n    \u003cproperty name=\"can-focus\"\u003eFalse\u003c/property\u003e\n    \u003cproperty name=\"default-width\"\u003e300\u003c/property\u003e\n    \u003cproperty name=\"default-height\"\u003e400\u003c/property\u003e\n    \u003cchild\u003e\n      \u003cplaceholder/\u003e\n    \u003c/child\u003e\n  \u003c/object\u003e\n\u003c/interface\u003e\n```\n\n```meadow``` generated code:\n\n``` go\n\npackage ui                                                                              \n\n//\n// CAUTION: This file was generated by meadow.\n//\n// Changes made to this file may be overwritten if meadow is run again.\n// For more information, check out https://github.com/devops-kung-fu/meadow\n//\n\nimport (\n\t\"github.com/gotk3/gotk3/gtk\"\n)\n\n// GtkBuilder returns *gtk.getBuilder loaded with glade resource (if resource is given)\nfunc GtkBuilder(filename string) (*gtk.Builder, error) {\n\n\tb, err := gtk.BuilderNew()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif filename != \"\" {\n\t\terr = b.AddFromFile(filename)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn b, nil\n}\n\n//Window returns the object represented by window in the glade file\nfunc Window(b *gtk.Builder) (*gtk.Window, error) {\n\n\tobj, err := b.GetObject(\"window\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\twindow, ok := obj.(*gtk.Window)\n\tif !ok {\n\t\treturn nil, err\n\t}\n\n\treturn window, nil\n}\n\n```\n\nWorking with the generated code (```main.go```):\n\n``` go\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/gotk3/gotk3/gtk\"\n\n\t\"github.com/devops-kung-fu/hello-meadow/ui\"\n)\n\nconst sourcefile = \"glade/ui.glade\"\n\nfunc main() {\n\n\tgtk.Init(\u0026os.Args)\n\n\tpath := filepath.Dir(os.Args[0])\n\tfilename := filepath.Join(path, sourcefile)\n\n\tbuilder, err := ui.GtkBuilder(filename) // gets a builder from the generated code\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\twindow, err := ui.Window(builder) //gets a handle to the Window object\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\twindow.SetTitle(\"Meadow Demo\")\n\twindow.SetDefaultSize(365, 490)\n\t_ = window.Connect(\"destroy\", func() {\n\t\tgtk.MainQuit()\n\t})\n\n\twindow.ShowAll() // shows the window\n\tgtk.Main()\n}\n\n```\n\n## Credits\n\nA big thank-you to our friends at [IconJam](https://www.flaticon.com/authors/iconjam) for the ```meadow``` logo.\n\nDescription of Glade courtesy provided by [Glade](https://glade.gnome.org/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevops-kung-fu%2Fmeadow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevops-kung-fu%2Fmeadow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevops-kung-fu%2Fmeadow/lists"}