{"id":19325399,"url":"https://github.com/krypt0nn/gtk-ui-builder","last_synced_at":"2025-08-30T16:06:15.619Z","repository":{"id":44964176,"uuid":"512894772","full_name":"krypt0nn/gtk-ui-builder","owner":"krypt0nn","description":":crab: Rust library to parse Blueprint files and convert them into GTK UI files","archived":false,"fork":false,"pushed_at":"2023-01-27T20:38:01.000Z","size":35,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-06T04:13:22.525Z","etag":null,"topics":["gtk","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krypt0nn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-11T20:08:40.000Z","updated_at":"2025-07-11T18:44:13.000Z","dependencies_parsed_at":"2023-02-15T12:25:30.461Z","dependency_job_id":null,"html_url":"https://github.com/krypt0nn/gtk-ui-builder","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/krypt0nn/gtk-ui-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fgtk-ui-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fgtk-ui-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fgtk-ui-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fgtk-ui-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krypt0nn","download_url":"https://codeload.github.com/krypt0nn/gtk-ui-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krypt0nn%2Fgtk-ui-builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272872015,"owners_count":25007289,"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-08-30T02:00:09.474Z","response_time":77,"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":["gtk","rust"],"created_at":"2024-11-10T02:09:56.827Z","updated_at":"2025-08-30T16:06:15.585Z","avatar_url":"https://github.com/krypt0nn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🦀 gtk-ui-builder\u003c/h1\u003e\n\nA Rust library to parse Blueprint files and convert them into GTK UI files\n\nInspired by the [Blueprint](https://gitlab.gnome.org/jwestman/blueprint-compiler) project\n\n# Example 1 - blueprints translation\n\n## Blueprint file\n\n```\nusing Gtk 4.0;\nusing Adw 1;\n\nAdw.ApplicationWindow window {\n    default-width: 600;\n    default-height: 500;\n\n    content: Gtk.Box {\n        orientation: vertical;\n\n        Adw.HeaderBar {\n            title-widget: Adw.WindowTitle {\n                title: \"Example app\";\n            };\n        }\n\n        Adw.PreferencesPage {\n            Adw.PreferencesGroup {\n                vexpand: true;\n                valign: center;\n\n                Gtk.Button {\n                    label: \"Hello, World!\";\n                }\n            }\n        }\n    };\n}\n```\n\n## Translation into XML format\n\n```rs\nuse gtk_ui_builder::prelude::*;\n\nfn main() {\n    // Read main.blp file\n    let pattern = std::fs::read_to_string(\"assets/ui/main.blp\")\n        .expect(\"Failed to read pattern\");\n\n    // Parse AST\n    let tree = Parser::parse(pattern)\n        .expect(\"Failed to parse blueprint\");\n\n    // Output prettified AST\n    println!(\"{}\", tree.root.dbg());\n\n    // Get XML representation of this AST\n    let ui = tree.get_xml();\n\n    // Write this representation to the file\n    // now you can import it as any GTK UI file\n    std::fs::write(\"assets/ui/main.ui\", \u0026ui);\n}\n```\n\n## Importing blueprint in GTK app\n\n```rs\n// We're using gtk-builder feature here\nuse gtk_ui_builder::prelude::*;\n\nfn main() {\n    gtk4::init().expect(\"GTK initialization failed\");\n    libadwaita::init();\n\n    // Create app\n    let application = gtk::Application::new(\n        Some(\"com.github.krypt0nn.gtk-ui-builder\"),\n        Default::default()\n    );\n\n    // Init app window and show it\n    application.connect_activate(|app| {\n        // You also can parse blueprint with Parser::parse\n        // and then use it in gtk4::Builder\n        let builder = Builder::new(include_str!(\"../assets/ui/main.blp\"))\n            .expect(\"Failed to parse blueprint\");\n\n        let window = builder.object::\u003cadw::ApplicationWindow\u003e(\"window\").unwrap();\n\n        window.set_application(Some(app));\n        window.show();\n    });\n\n    // Run app\n    application.run();\n}\n```\n\n# Example 2 - rhai events integration\n\n```\nusing Gtk 4.0;\nusing Adw 1;\n\nAdw.ApplicationWindow window {\n    default-width: 600;\n    default-height: 500;\n\n    content: Gtk.Box {\n        orientation: vertical;\n\n        Adw.HeaderBar {\n            title-widget: Adw.WindowTitle window_title {\n                title: \"Example app\";\n            };\n        }\n\n        Adw.PreferencesPage {\n            Adw.PreferencesGroup {\n                vexpand: true;\n                valign: center;\n\n                Gtk.Button {\n                    label: \"Hello, World!\";\n\n                    clicked =\u003e {\n                        window_title.set_str(\"title\", \"Button clicked: \" + self.get_str(\"label\"));\n                    }\n                }\n            }\n        }\n    };\n}\n```\n\nThis example requires `rhai-events` for parsing and `gtk-builder` for interpreting. Events are automatically applied by the `Builder` struct\n\nAuthor: [Nikita Podvirnyy](https://github.com/krypt0nn)\n\nLicensed under [GNU GPL 3.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fgtk-ui-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrypt0nn%2Fgtk-ui-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrypt0nn%2Fgtk-ui-builder/lists"}