Commit e56818c7 authored by Jürg Billeter's avatar Jürg Billeter

gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding

parent 3354f542
......@@ -1011,13 +1011,23 @@ public class Vala.CodeWriter : CodeVisitor {
ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel);
separator = ", ";
}
if (m is CreationMethod && ((CreationMethod)m).custom_return_type_cname != null) {
ccode_params.append_printf ("%stype = \"%s\"", separator, ((CreationMethod)m).custom_return_type_cname);
separator = ", ";
}
if (m is CreationMethod && !m.has_construct_function) {
ccode_params.append_printf ("%shas_construct_function = false", separator);
separator = ", ";
var cm = m as CreationMethod;
if (cm != null) {
if (cm.custom_return_type_cname != null) {
ccode_params.append_printf ("%stype = \"%s\"", separator, cm.custom_return_type_cname);
separator = ", ";
}
if (!m.has_new_function) {
ccode_params.append_printf ("%shas_new_function = false", separator);
separator = ", ";
}
if (!m.has_construct_function) {
ccode_params.append_printf ("%shas_construct_function = false", separator);
separator = ", ";
} else if (m.name == ".new" && m.get_real_cname () != cm.get_default_construct_function ()) {
ccode_params.append_printf ("%sconstruct_function = \"%s\"", separator, cm.get_default_construct_function ());
separator = ", ";
}
}
if (ccode_params.len > 0) {
......
......@@ -115,17 +115,21 @@ public class Vala.CreationMethod : Method {
}
public override string get_real_cname () {
var ccode_attribute = get_attribute ("CCode");
if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) {
return ccode_attribute.get_string ("construct_function");
}
return get_default_construct_function ();
}
public string get_default_construct_function () {
var parent = parent_symbol as Class;
if (parent == null || parent.is_compact) {
return get_cname ();
}
var ccode_attribute = get_attribute ("CCode");
if (ccode_attribute != null && ccode_attribute.has_argument ("construct_function")) {
return ccode_attribute.get_string ("construct_function");
}
string infix = "construct";
if (CodeContext.get ().profile == Profile.DOVA) {
......
......@@ -5188,7 +5188,8 @@ namespace Gtk {
public uchar saved_state;
public uchar state;
public Gdk.Window window;
public Widget (GLib.Type type, ...);
[CCode (has_new_function = false, construct_function = "gtk_widget_new")]
public Widget (...);
public bool activate ();
public void add_accelerator (string accel_signal, Gtk.AccelGroup accel_group, uint accel_key, Gdk.ModifierType accel_mods, Gtk.AccelFlags accel_flags);
public void add_events (int events);
......
......@@ -4689,7 +4689,8 @@ namespace Gtk {
}
[CCode (cheader_filename = "gtk/gtk.h")]
public class Widget : Gtk.Object, Atk.Implementor, Gtk.Buildable, Gtk.SizeRequest {
public Widget (GLib.Type type, ...);
[CCode (has_new_function = false, construct_function = "gtk_widget_new")]
public Widget (...);
public bool activate ();
public void add_accelerator (string accel_signal, Gtk.AccelGroup accel_group, uint accel_key, Gdk.ModifierType accel_mods, Gtk.AccelFlags accel_flags);
public void add_device_events (Gdk.Device device, Gdk.EventMask events);
......
......@@ -51,7 +51,8 @@ namespace Gtk {
}
public class Widget {
public extern Widget (GLib.Type type, ...);
[CCode (has_new_function = false, construct_function = "gtk_widget_new")]
public extern Widget (...);
[CCode (cname = "GTK_WIDGET_FLAGS")]
public extern WidgetFlags get_flags ();
......
......@@ -51,7 +51,8 @@ namespace Gtk {
}
public class Widget {
public extern Widget (GLib.Type type, ...);
[CCode (has_new_function = false, construct_function = "gtk_widget_new")]
public extern Widget (...);
}
public interface Editable {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment