Skip to content

Commit dbcd29f

Browse files
gtk4-macros: Stop appending using Gtk for blueprint
As that breaks language servers
1 parent 9f5e1c0 commit dbcd29f

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ yuraiz:
9393
```rust
9494
#[derive(Debug, Default, gtk::CompositeTemplate)]
9595
#[template(string = "
96+
using Gtk 4.0;
9697
template $MyWidget : Widget {
9798
Label label {
9899
label: 'foobar';

gtk4-macros/src/blueprint.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

33
use std::{
4-
io::{Error, ErrorKind, Read, Result, Write},
4+
io::{Error, ErrorKind, Result, Write},
55
process::{Command, Stdio},
66
};
77

@@ -12,14 +12,15 @@ pub(crate) fn compile_blueprint(blueprint: &[u8]) -> Result<String> {
1212
.stdout(Stdio::piped())
1313
.spawn()
1414
.unwrap_or_else(|_| panic!("blueprint-compiler not found"));
15-
1615
let mut stdin = compiler.stdin.take().unwrap();
17-
stdin.write_all(b"using Gtk 4.0;\n")?;
1816
stdin.write_all(blueprint)?;
1917
drop(stdin);
2018

21-
let mut buf = String::new();
22-
compiler.stdout.unwrap().read_to_string(&mut buf)?;
19+
let output = compiler
20+
.wait_with_output()
21+
.unwrap_or_else(|e| panic!("blueprint-compiler process failed {e}"));
22+
23+
let buf = String::from_utf8(output.stdout).unwrap();
2324

2425
if !buf.starts_with('<') {
2526
return Err(Error::new(ErrorKind::Other, buf));

gtk4-macros/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream {
158158
///
159159
/// #[derive(Debug, Default, gtk::CompositeTemplate)]
160160
/// #[template(string = "
161+
/// using Gtk 4.0;
161162
/// template $MyWidget : Widget {
162163
/// Label label {
163164
/// label: 'foobar';

gtk4-macros/tests/my_widget.blp

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Gtk 4.0;
12
template $MyWidget5 {
23
Label label {
34
label: 'foobar';

gtk4-macros/tests/templates.rs

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ mod imp4 {
212212

213213
#[derive(Debug, Default, gtk::CompositeTemplate)]
214214
#[template(string = "
215+
using Gtk 4.0;
215216
template $MyWidget4 : Widget {
216217
Label label {
217218
label: 'foobar';

0 commit comments

Comments
 (0)