Merge pull request #217 from zii-dmg/style-properties

Support style properties
This commit is contained in:
lytico 2021-07-01 21:05:54 +02:00 committed by GitHub
commit 7eb100a2ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 193 additions and 33 deletions

View file

@ -1023,4 +1023,135 @@
<!-- Mark reserved fields as padding -->
<attr path="//*[contains(@cname, 'gtk_reserved')]" name="padding">true</attr>
<attr path="//*[contains(@vm, 'gtk_reserved')]" name="padding">true</attr>
<!-- Style properties -->
<attr path="/api/namespace/object[@cname='GtkAssistant']/property[@name='ContentPadding']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkAssistant']/property[@name='ContentPadding']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkAssistant']/property[@name='HeaderPadding']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkAssistant']/property[@name='HeaderPadding']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ChildDisplacementX']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ChildDisplacementX']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ChildDisplacementY']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ChildDisplacementY']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DefaultBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DefaultBorder']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DefaultOutsideBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DefaultOutsideBorder']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DisplaceFocus']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='DisplaceFocus']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ImageSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='InnerBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='InnerBorder']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='AppearsAsList']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ArrowScaling']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ArrowScaling']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ArrowSize']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ArrowSize']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ShadowType']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkComboBox']/property[@name='ShadowType']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkDialog']/property[@name='ActionAreaBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkDialog']/property[@name='ButtonSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkDialog']/property[@name='ContentAreaBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkDialog']/property[@name='ContentAreaSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='IconPrelight']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='IconPrelight']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='InvisibleChar']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='ProgressBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='ProgressBorder']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkMessageDialog']/property[@name='MessageBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='ArrowSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='ArrowSpacing']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasBackwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasForwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasSecondaryBackwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasSecondaryForwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasTabGap']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='HasTabGap']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='InitialGap']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='InitialGap']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='TabCurvature']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='TabCurvature']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='TabOverlap']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkNotebook']/property[@name='TabOverlap']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowDisplacementX']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowDisplacementX']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowDisplacementY']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowDisplacementY']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowScaling']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='ArrowScaling']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='SliderWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='SliderWidth']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='StepperSize']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='StepperSize']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='StepperSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='StepperSpacing']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='TroughBorder']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='TroughBorder']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='TroughUnderSteppers']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkRange']/property[@name='TroughUnderSteppers']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='FixedSliderLength']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='HasBackwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='HasForwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='HasSecondaryBackwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='HasSecondaryForwardStepper']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='MinSliderLength']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrollbar']/property[@name='MinSliderLength']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrolledWindow']/property[@name='ScrollbarSpacing']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrolledWindow']/property[@name='ScrollbarsWithinBevel']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkScrolledWindow']/property[@name='ScrollbarsWithinBevel']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkTextView']/property[@name='ErrorUnderlineColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='AllowRules']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='EvenRowColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='ExpanderSize']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='GridLinePattern']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='GridLineWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='HorizontalSeparator']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='IndentExpanders']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='OddRowColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='TreeLinePattern']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='TreeLineWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='VerticalSeparator']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='CursorAspectRatio']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='CursorColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='CursorColor']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusLinePattern']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusLinePattern']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusLineWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusLineWidth']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusPadding']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='FocusPadding']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='InteriorFocus']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='InteriorFocus']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='LinkColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='LinkColor']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='ScrollArrowHlength']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='ScrollArrowVlength']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SecondaryCursorColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SecondaryCursorColor']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SeparatorHeight']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SeparatorHeight']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SeparatorWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='SeparatorWidth']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='TextHandleHeight']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='TextHandleWidth']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='VisitedLinkColor']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='VisitedLinkColor']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='WideSeparators']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='WideSeparators']" name="deprecated">true</attr>
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='WindowDragging']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWindow']/property[@name='DecorationButtonLayout']" name="style">true</attr>
<attr path="/api/namespace/object[@cname='GtkWindow']/property[@name='DecorationResizeHandle']" name="style">true</attr>
</metadata>

View file

@ -63,6 +63,12 @@ namespace GtkSharp.Generation {
}
}
bool IsStyle {
get {
return elem.GetAttributeAsBoolean("style");
}
}
protected virtual string PropertyAttribute (string qpname) {
return "[GLib.Property (" + qpname + ")]";
}
@ -134,8 +140,15 @@ namespace GtkSharp.Generation {
(Getter != null && Getter.IsDeprecated) ||
(Setter != null && Setter.IsDeprecated))
sw.WriteLine (indent + "[Obsolete]");
if (!IsStyle) {
sw.WriteLine(indent + PropertyAttribute(qpname));
sw.WriteLine(indent + "public " + modifiers + CSType + " " + name + " {");
}
else {
string csType = CSType + (table.IsBoxed(CType) ? "?" : "");
sw.WriteLine(indent + "public " + modifiers + csType + " " + name + " {");
}
indent += "\t";
if (Getter != null) {
@ -143,17 +156,22 @@ namespace GtkSharp.Generation {
Getter.GenerateBody(gen_info, implementor, "\t");
sw.WriteLine();
} else if (Readable) {
sw.WriteLine(indent + "get {");
if (!IsStyle) {
sw.WriteLine(indent + "\tGLib.Value val = " + RawGetter(qpname) + ";");
if (table.IsOpaque(CType) || table.IsBoxed(CType)) {
sw.WriteLine(indent + "\t" + CSType + " ret = (" + CSType + ") val;");
} else if (table.IsInterface (CType)) {
}
else if (table.IsInterface(CType)) {
var igen = table.GetInterfaceGen(CType);
// Do we have to dispose the GLib.Object from the GLib.Value?
sw.WriteLine(indent + "\t{0} ret = {1}.GetObject ((GLib.Object) val);",
igen.QualifiedName, igen.QualifiedAdapterName);
} else {
}
else {
sw.Write(indent + "\t" + CSType + " ret = ");
sw.Write("(" + CSType + ") ");
if (v_type != "") {
@ -164,6 +182,13 @@ namespace GtkSharp.Generation {
sw.WriteLine(indent + "\tval.Dispose ();");
sw.WriteLine(indent + "\treturn ret;");
}
else {
string csType = CSType + (table.IsBoxed(CType) ? "?" : "");
sw.WriteLine(indent + "\tvar val = (" + csType + ")StyleGetProperty(" + qpname + ");");
sw.WriteLine(indent + "\treturn val;");
}
sw.WriteLine(indent + "}");
}
@ -172,13 +197,16 @@ namespace GtkSharp.Generation {
Setter.GenerateBody(gen_info, implementor, "\t");
sw.WriteLine();
} else if (Writable) {
if (!IsStyle) { // style properties is writable only through CSS
sw.WriteLine(indent + "set {");
sw.Write(indent + "\tGLib.Value val = ");
if (table.IsBoxed(CType)) {
sw.WriteLine("(GLib.Value) value;");
} else if (table.IsOpaque (CType)) {
}
else if (table.IsOpaque(CType)) {
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
} else {
}
else {
sw.Write("new GLib.Value(");
if (v_type != "" && !(table.IsObject(CType) || table.IsInterface(CType) || table.IsOpaque(CType))) {
sw.Write(v_type + " ");
@ -189,6 +217,7 @@ namespace GtkSharp.Generation {
sw.WriteLine(indent + "\tval.Dispose ();");
sw.WriteLine(indent + "}");
}
}
sw.WriteLine(indent.Substring (1) + "}");
sw.WriteLine();