-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gtk4-macros: Add blueprint support (#1238)
* blueprint: Add blueprint support
- Loading branch information
Showing
5 changed files
with
118 additions
and
5 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
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,28 @@ | ||
// Take a look at the license at the top of the repository in the LICENSE file. | ||
|
||
use anyhow::{bail, Result}; | ||
use std::io::{Read, Write}; | ||
use std::process::{Command, Stdio}; | ||
|
||
pub(crate) fn compile_blueprint(blueprint: &[u8]) -> Result<String> { | ||
let mut compiler = Command::new("blueprint-compiler") | ||
.args(["compile", "-"]) | ||
.stdin(Stdio::piped()) | ||
.stdout(Stdio::piped()) | ||
.spawn() | ||
.unwrap_or_else(|_| panic!("blueprint-compiler not found")); | ||
|
||
let mut stdin = compiler.stdin.take().unwrap(); | ||
stdin.write_all(b"using Gtk 4.0;\n")?; | ||
stdin.write_all(blueprint)?; | ||
drop(stdin); | ||
|
||
let mut buf = String::new(); | ||
compiler.stdout.unwrap().read_to_string(&mut buf)?; | ||
|
||
if !buf.starts_with('<') { | ||
bail!(buf); | ||
} | ||
|
||
Ok(buf) | ||
} |
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
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
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