diff --git a/blueprintcompiler/decompiler.py b/blueprintcompiler/decompiler.py index 7e6c53b..12741a5 100644 --- a/blueprintcompiler/decompiler.py +++ b/blueprintcompiler/decompiler.py @@ -118,6 +118,15 @@ class DecompileCtx: if type is None: self.print(f"{name}: {escape_quote(value)};") + elif type.assignable_to(UIntType()): + try: + val = int(value) + self.print(f"{name}: {value};") + except: + # Properties like 'invisible-char' are a unicode char + # in a guint, so we convert manually. Unlike in format. + val = ord(value) + self.print(f"{name}: {val};") elif type.assignable_to(FloatType()): self.print(f"{name}: {value};") elif type.assignable_to(BoolType()): diff --git a/tests/samples/entry.blp b/tests/samples/entry.blp new file mode 100644 index 0000000..f7b8339 --- /dev/null +++ b/tests/samples/entry.blp @@ -0,0 +1,5 @@ +using Gtk 4.0; + +Entry { + invisible-char: 9679; +} diff --git a/tests/samples/entry.ui b/tests/samples/entry.ui new file mode 100644 index 0000000..dcd2ce1 --- /dev/null +++ b/tests/samples/entry.ui @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/test_samples.py b/tests/test_samples.py index 0a525ca..4508ca2 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -174,6 +174,9 @@ class TestSamples(unittest.TestCase): for sample in samples: REQUIRE_ADW_1_4 = ["adw_breakpoint"] REQUIRE_ADW_1_5 = ["adw_alertdialog_responses"] + # Those test case that don't round trip due to ambiguous notation. + # So `assert_sample` fail on these. + AMBIGUOUS = ["entry"] SKIP_RUN = [ "expr_closure", @@ -195,6 +198,8 @@ class TestSamples(unittest.TestCase): continue if sample in REQUIRE_ADW_1_5 and not self.have_adw_1_5: continue + if sample in AMBIGUOUS: + continue with self.subTest(sample): self.assert_sample(sample, skip_run=sample in SKIP_RUN) @@ -222,6 +227,7 @@ class TestSamples(unittest.TestCase): self.assert_decompile("adw_alertdialog_responses") self.assert_decompile("adw_messagedialog_responses") self.assert_decompile("child_type") + self.assert_decompile("entry") self.assert_decompile("file_filter") self.assert_decompile("flags") self.assert_decompile("id_prop")