mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 20:55:27 +00:00
Support style properties
Added support for style properties and marked some style properties in GtkSharp.metadata.
This commit is contained in:
parent
cd47acba85
commit
d3687a9370
|
@ -1006,7 +1006,100 @@
|
|||
<remove-node path="/api/namespace/struct[@cname='IconSize']" />
|
||||
<remove-node path="/api/namespace/struct[@cname='Range']" />
|
||||
|
||||
<!-- 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>
|
||||
<!-- 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='HeaderPadding']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkAssistant']/property[@name='ContentPadding']" name="style">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='DefaultOutsideBorder']" name="style">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='ChildDisplacementY']" name="style">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='InnerBorder']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkButton']/property[@name='ImageSpacing']" name="style">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='ArrowSize']" 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='ShadowType']" 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='GtkDialog']/property[@name='ButtonSpacing']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkDialog']/property[@name='ActionAreaBorder']" 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='ProgressBorder']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkEntry']/property[@name='InvisibleChar']" name="style">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='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='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='TabOverlap']" name="style">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='ArrowSpacing']" name="style">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='HasTabGap']" name="style">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='TroughBorder']" name="style">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='StepperSpacing']" name="style">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='ArrowDisplacementY']" name="style">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='ArrowScaling']" 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='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='GtkScrolledWindow']/property[@name='ScrollbarsWithinBevel']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkScrolledWindow']/property[@name='ScrollbarSpacing']" name="style">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='ExpanderSize']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='VerticalSeparator']" 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='AllowRules']" 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='EvenRowColor']" 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='GridLineWidth']" 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='GridLinePattern']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkTreeView']/property[@name='TreeLinePattern']" name="style">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='FocusLineWidth']" name="style">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='FocusPadding']" 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='SecondaryCursorColor']" 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='WindowDragging']" name="style">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='VisitedLinkColor']" name="style">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='SeparatorWidth']" name="style">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='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='TextHandleWidth']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='TextHandleHeight']" name="style">true</attr>
|
||||
|
||||
<attr path="/api/namespace/object[@cname='GtkWindow']/property[@name='DecorationButtonLayout']" name="style">true</attr>
|
||||
<attr path="/api/namespace/object[@cname='GtkWidget']/property[@name='DecorationResizeHandle']" name="style">true</attr>
|
||||
|
||||
</metadata>
|
||||
|
|
|
@ -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]");
|
||||
sw.WriteLine (indent + PropertyAttribute (qpname));
|
||||
sw.WriteLine (indent + "public " + modifiers + CSType + " " + name + " {");
|
||||
|
||||
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,27 +156,39 @@ namespace GtkSharp.Generation {
|
|||
Getter.GenerateBody(gen_info, implementor, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (Readable) {
|
||||
sw.WriteLine(indent + "get {");
|
||||
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)) {
|
||||
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 {
|
||||
sw.Write(indent + "\t" + CSType + " ret = ");
|
||||
sw.Write ("(" + CSType + ") ");
|
||||
if (v_type != "") {
|
||||
sw.Write(v_type + " ");
|
||||
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;");
|
||||
}
|
||||
sw.WriteLine("val;");
|
||||
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 {
|
||||
sw.Write(indent + "\t" + CSType + " ret = ");
|
||||
sw.Write("(" + CSType + ") ");
|
||||
if (v_type != "") {
|
||||
sw.Write(v_type + " ");
|
||||
}
|
||||
sw.WriteLine("val;");
|
||||
}
|
||||
|
||||
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 + "\tval.Dispose ();");
|
||||
sw.WriteLine(indent + "\treturn ret;");
|
||||
sw.WriteLine(indent + "}");
|
||||
}
|
||||
|
||||
|
@ -172,22 +197,26 @@ namespace GtkSharp.Generation {
|
|||
Setter.GenerateBody(gen_info, implementor, "\t");
|
||||
sw.WriteLine();
|
||||
} else if (Writable) {
|
||||
sw.WriteLine(indent + "set {");
|
||||
sw.Write(indent + "\tGLib.Value val = ");
|
||||
if (table.IsBoxed (CType)) {
|
||||
sw.WriteLine("(GLib.Value) value;");
|
||||
} else if (table.IsOpaque (CType)) {
|
||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
|
||||
} else {
|
||||
sw.Write("new GLib.Value(");
|
||||
if (v_type != "" && !(table.IsObject (CType) || table.IsInterface (CType) || table.IsOpaque (CType))) {
|
||||
sw.Write(v_type + " ");
|
||||
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;");
|
||||
}
|
||||
sw.WriteLine("value);");
|
||||
else if (table.IsOpaque(CType)) {
|
||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", CType);
|
||||
}
|
||||
else {
|
||||
sw.Write("new GLib.Value(");
|
||||
if (v_type != "" && !(table.IsObject(CType) || table.IsInterface(CType) || table.IsOpaque(CType))) {
|
||||
sw.Write(v_type + " ");
|
||||
}
|
||||
sw.WriteLine("value);");
|
||||
}
|
||||
sw.WriteLine(indent + "\t" + RawSetter(qpname) + ";");
|
||||
sw.WriteLine(indent + "\tval.Dispose ();");
|
||||
sw.WriteLine(indent + "}");
|
||||
}
|
||||
sw.WriteLine(indent + "\t" + RawSetter (qpname) + ";");
|
||||
sw.WriteLine(indent + "\tval.Dispose ();");
|
||||
sw.WriteLine(indent + "}");
|
||||
}
|
||||
|
||||
sw.WriteLine(indent.Substring (1) + "}");
|
||||
|
|
Loading…
Reference in a new issue