]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gtk+-2.0, gtk+-3.0: Fix gtk_widget_new binding
authorJürg Billeter <j@bitron.ch>
Thu, 12 Aug 2010 14:35:36 +0000 (16:35 +0200)
committerJürg Billeter <j@bitron.ch>
Thu, 12 Aug 2010 14:35:36 +0000 (16:35 +0200)
vala/valacodewriter.vala
vala/valacreationmethod.vala
vapi/gtk+-2.0.vapi
vapi/gtk+-3.0.vapi
vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala
vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala

index e3ca81b148fcf2683589f09ec24fd668ac4ec3db..5b8ada0bbfd3b6806d0515d41c0801b1bee3938e 100644 (file)
@@ -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) {
index 10891d3bd2c4c93a1a708eddd738ec2c6e549e2e..5dbd6f0e5f9d7cd0d75a577e1ae2052417a9a14a 100644 (file)
@@ -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) {
index aafd6e5304c5c9bb7b1e3ebe6391ff1e89fa7672..d8e430776c92f33ab0b489a23452843558223d39 100644 (file)
@@ -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);
index 3165e4e1408fcda288f83984a58982729fd82ba1..0846d8c4d029b16d7e4f8d2a323aadb95f40c27a 100644 (file)
@@ -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);
index fc803003ebf84e2ae14c8be41e12dd14ed7d2653..591a660fabfb6e0ccd10bf8fa50c0925dbaadbad 100644 (file)
@@ -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 ();
index feabb3491e21a8d0a3dd5e589a124e554f8957df..89f1419451ed5e5cf7310135c7ea38a6f0c2cd3c 100644 (file)
@@ -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 {