mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
decompiler: Fix bug in signals with template object
If a signal handler had the template as its object, the decompiler would output the class name instead of the 'template' keyword.
This commit is contained in:
parent
a12d3f5c81
commit
2e42dc6848
4 changed files with 31 additions and 1 deletions
|
@ -225,8 +225,14 @@ class Signal(AstNode):
|
|||
|
||||
|
||||
@decompiler("signal")
|
||||
def decompile_signal(ctx, gir, name, handler, swapped=None, after="false", object=None):
|
||||
def decompile_signal(
|
||||
ctx: DecompileCtx, gir, name, handler, swapped=None, after="false", object=None
|
||||
):
|
||||
object_name = object or ""
|
||||
|
||||
if object_name == ctx.template_class:
|
||||
object_name = "template"
|
||||
|
||||
name = name.replace("_", "-")
|
||||
line = f"{name} => ${handler}({object_name})"
|
||||
|
||||
|
|
7
tests/samples/signal_template_object.blp
Normal file
7
tests/samples/signal_template_object.blp
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
template $MyTemplate {
|
||||
Button {
|
||||
clicked => $my_signal_handler(template);
|
||||
}
|
||||
}
|
16
tests/samples/signal_template_object.ui
Normal file
16
tests/samples/signal_template_object.ui
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
DO NOT EDIT!
|
||||
This file was @generated by blueprint-compiler. Instead, edit the
|
||||
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<template class="MyTemplate">
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<signal name="clicked" handler="my_signal_handler" object="MyTemplate"/>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
|
@ -198,6 +198,7 @@ class TestSamples(unittest.TestCase):
|
|||
"parseable",
|
||||
"signal",
|
||||
"signal_not_swapped",
|
||||
"signal_template_object",
|
||||
"template",
|
||||
"template_binding",
|
||||
"template_binding_extern",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue