vala r1688 - in trunk: . gobject vala vapi vapigen



Author: rasa
Date: Wed Jul  9 09:17:43 2008
New Revision: 1688
URL: http://svn.gnome.org/viewvc/vala?rev=1688&view=rev

Log:
2008-07-09  Raffaele Sandrini  <raffaele sandrini ch>

	* gobject/valaccodegenerator.vala:
	* gobject/valaccodemethodbinding.vala:
	* vala/valacreationmethod.vala:
	* vala/valainterfacewriter.vala:
	* vapigen/valagidlparser.vala:

	Add support for creation methods with a different (mostly super) type
	than the type of the object it creates. Add a `type' parameter to the
	CCode attribute which will be used to get the casts right for such
	creation methods.

	* vapi/gio-2.0.vapi:
	* vapi/gtk+-2.0.vapi:

	Regenerated, fixes bug 540661


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegenerator.vala
   trunk/gobject/valaccodemethodbinding.vala
   trunk/vala/valacreationmethod.vala
   trunk/vala/valainterfacewriter.vala
   trunk/vapi/gio-2.0.vapi
   trunk/vapi/gtk+-2.0.vapi
   trunk/vapigen/valagidlparser.vala

Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala	(original)
+++ trunk/gobject/valaccodegenerator.vala	Wed Jul  9 09:17:43 2008
@@ -3083,7 +3083,7 @@
 		expr.accept_children (this);
 
 		CCodeExpression instance = null;
-		CCodeFunctionCall creation_call = null;
+		CCodeExpression creation_expr = null;
 
 		var st = expr.type_reference.data_type as Struct;
 		if ((st != null && !st.is_simple_type ()) || expr.get_object_initializer ().size > 0) {
@@ -3095,6 +3095,8 @@
 		}
 
 		if (expr.symbol_reference == null) {
+			CCodeFunctionCall creation_call;
+
 			// no creation method
 			if (expr.type_reference.data_type == glist_type ||
 			    expr.type_reference.data_type == gslist_type) {
@@ -3116,10 +3118,13 @@
 				creation_call.add_argument (new CCodeConstant ("0"));
 				creation_call.add_argument (new CCodeIdentifier ("sizeof (%s)".printf (expr.type_reference.get_cname ())));
 			}
+
+			creation_expr = creation_call;
 		} else if (expr.symbol_reference is Method) {
 			// use creation method
 			var m = (Method) expr.symbol_reference;
 			var params = m.get_parameters ();
+			CCodeFunctionCall creation_call;
 
 			creation_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_cname ()));
 
@@ -3230,9 +3235,18 @@
 				// ensure variable argument list ends with NULL
 				creation_call.add_argument (new CCodeConstant ("NULL"));
 			}
+
+			creation_expr = creation_call;
+
+			// cast the return value of the creation method back to the intended type if
+			// it requested a special C return type
+			if (method_binding (m).get_custom_creturn_type () != null) {
+				creation_expr = new CCodeCastExpression (creation_expr, expr.type_reference.get_cname ());
+			}
 		} else if (expr.symbol_reference is ErrorCode) {
 			var ecode = (ErrorCode) expr.symbol_reference;
 			var edomain = (ErrorDomain) ecode.parent_symbol;
+			CCodeFunctionCall creation_call;
 
 			creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_error_new"));
 			creation_call.add_argument (new CCodeIdentifier (edomain.get_upper_case_cname ()));
@@ -3241,6 +3255,8 @@
 			foreach (Expression arg in expr.get_argument_list ()) {
 				creation_call.add_argument ((CCodeExpression) arg.ccodenode);
 			}
+
+			creation_expr = creation_call;
 		} else {
 			assert (false);
 		}
@@ -3249,9 +3265,9 @@
 			var ccomma = new CCodeCommaExpression ();
 
 			if (expr.type_reference.data_type is Struct) {
-				ccomma.append_expression (creation_call);
+				ccomma.append_expression (creation_expr);
 			} else {
-				ccomma.append_expression (new CCodeAssignment (instance, creation_call));
+				ccomma.append_expression (new CCodeAssignment (instance, creation_expr));
 			}
 
 			foreach (MemberInitializer init in expr.get_object_initializer ()) {
@@ -3278,8 +3294,8 @@
 			ccomma.append_expression (instance);
 
 			expr.ccodenode = ccomma;
-		} else if (creation_call != null) {
-			expr.ccodenode = creation_call;
+		} else if (creation_expr != null) {
+			expr.ccodenode = creation_expr;
 		}
 	}
 

Modified: trunk/gobject/valaccodemethodbinding.vala
==============================================================================
--- trunk/gobject/valaccodemethodbinding.vala	(original)
+++ trunk/gobject/valaccodemethodbinding.vala	Wed Jul  9 09:17:43 2008
@@ -18,6 +18,7 @@
  *
  * Author:
  * 	JÃrg Billeter <j bitron ch>
+ *	Raffaele Sandrini <raffaele sandrini ch>
  */
 
 using GLib;
@@ -33,6 +34,25 @@
 		get { return (method.get_attribute ("NoWrapper") == null); }
 	}
 
+	public string? get_custom_creturn_type () {
+		var attr = method.get_attribute ("CCode");
+		if (attr != null) {
+			string type = attr.get_string ("type");
+			if (type != null) {
+				return type;
+			}
+		}
+		return null;
+	}
+
+	string get_creturn_type (string default_value) {
+		string type = get_custom_creturn_type ();
+		if (type == null) {
+			return default_value;
+		}
+		return type;
+	}
+
 	public CCodeMethodBinding (CCodeGenerator codegen, Method method) {
 		this.method = method;
 		this.codegen = codegen;
@@ -127,7 +147,7 @@
 			}
 		}
 
-		codegen.function = new CCodeFunction (m.get_real_cname (), creturn_type.get_cname ());
+		codegen.function = new CCodeFunction (m.get_real_cname (), get_creturn_type (creturn_type.get_cname ()));
 		m.ccodenode = codegen.function;
 
 		if (m.is_inline) {
@@ -166,7 +186,7 @@
 			cparam_map.set (codegen.get_param_pos (m.cinstance_parameter_position), instance_param);
 
 			if (m.is_abstract || m.is_virtual) {
-				var vdecl = new CCodeDeclaration (creturn_type.get_cname ());
+				var vdecl = new CCodeDeclaration (get_creturn_type (creturn_type.get_cname ()));
 				vdeclarator = new CCodeFunctionDeclarator (m.vfunc_name);
 				vdecl.add_declarator (vdeclarator);
 				codegen.type_struct.add_declaration (vdecl);
@@ -498,7 +518,7 @@
 				cstmt = new CCodeReturnStatement (vcall);
 			} else {
 				/* store method return value for postconditions */
-				var cdecl = new CCodeDeclaration (creturn_type.get_cname ());
+				var cdecl = new CCodeDeclaration (get_creturn_type (creturn_type.get_cname ()));
 				cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("result", vcall));
 				cstmt = cdecl;
 			}
@@ -549,8 +569,13 @@
 			}
 
 			if (codegen.current_type_symbol is Class) {
+				CCodeExpression cresult = new CCodeIdentifier ("self");
+				if (get_custom_creturn_type () != null) {
+					cresult = new CCodeCastExpression (cresult, get_custom_creturn_type ());
+				}
+
 				var creturn = new CCodeReturnStatement ();
-				creturn.return_expression = new CCodeIdentifier ("self");
+				creturn.return_expression = cresult;
 				codegen.function.block.add_statement (creturn);
 			}
 		}

Modified: trunk/vala/valacreationmethod.vala
==============================================================================
--- trunk/vala/valacreationmethod.vala	(original)
+++ trunk/vala/valacreationmethod.vala	Wed Jul  9 09:17:43 2008
@@ -38,6 +38,14 @@
 	public int n_construction_params { get; set; }
 
 	/**
+	 * Specifies a custom C return type for that creation method.
+	 * Only the idl parser and the interface writer should use this.
+	 * FIXME: remove this as soon the compiler has a decent attribute
+	 * handling.
+	 */
+	public string? custom_return_type_cname { get; set; }
+
+	/**
 	 * Creates a new method.
 	 *
 	 * @param name             method name

Modified: trunk/vala/valainterfacewriter.vala
==============================================================================
--- trunk/vala/valainterfacewriter.vala	(original)
+++ trunk/vala/valainterfacewriter.vala	Wed Jul  9 09:17:43 2008
@@ -769,6 +769,9 @@
 			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);
+		}
 
 		if (ccode_params.len > 0) {
 			write_indent ();

Modified: trunk/vapi/gio-2.0.vapi
==============================================================================
--- trunk/vapi/gio-2.0.vapi	(original)
+++ trunk/vapi/gio-2.0.vapi	Wed Jul  9 09:17:43 2008
@@ -254,7 +254,9 @@
 	public class BufferedInputStream : GLib.FilterInputStream {
 		public ulong get_available ();
 		public ulong get_buffer_size ();
+		[CCode (type = "GInputStream*")]
 		public BufferedInputStream (GLib.InputStream base_stream);
+		[CCode (type = "GInputStream*")]
 		public BufferedInputStream.sized (GLib.InputStream base_stream, ulong size);
 		public ulong peek (void* buffer, ulong offset, ulong count);
 		public void* peek_buffer (ulong count);
@@ -269,7 +271,9 @@
 	public class BufferedOutputStream : GLib.FilterOutputStream {
 		public bool get_auto_grow ();
 		public ulong get_buffer_size ();
+		[CCode (type = "GOutputStream*")]
 		public BufferedOutputStream (GLib.OutputStream base_stream);
+		[CCode (type = "GOutputStream*")]
 		public BufferedOutputStream.sized (GLib.OutputStream base_stream, ulong size);
 		public void set_auto_grow (bool auto_grow);
 		public void set_buffer_size (ulong size);
@@ -340,6 +344,7 @@
 	[CCode (cheader_filename = "gio/gio.h")]
 	public class FileIcon : GLib.Object, GLib.Icon, GLib.LoadableIcon {
 		public weak GLib.File get_file ();
+		[CCode (type = "GIcon*")]
 		public FileIcon (GLib.File file);
 	}
 	[CCode (cheader_filename = "gio/gio.h")]
@@ -494,7 +499,9 @@
 	[CCode (cheader_filename = "gio/gio.h")]
 	public class MemoryInputStream : GLib.InputStream, GLib.Seekable {
 		public void add_data (void* data, long len, GLib.DestroyNotify? destroy);
+		[CCode (type = "GInputStream*")]
 		public MemoryInputStream ();
+		[CCode (type = "GInputStream*")]
 		public MemoryInputStream.from_data (void* data, long len, GLib.DestroyNotify? destroy);
 	}
 	[CCode (cheader_filename = "gio/gio.h")]
@@ -502,6 +509,7 @@
 		public void* get_data ();
 		public ulong get_data_size ();
 		public ulong get_size ();
+		[CCode (type = "GOutputStream*")]
 		public MemoryOutputStream (void* data, ulong len, GLib.ReallocFunc realloc_fn, GLib.DestroyNotify? destroy);
 	}
 	[CCode (cheader_filename = "gio/gio.h")]
@@ -584,8 +592,11 @@
 	public class ThemedIcon : GLib.Object, GLib.Icon {
 		public void append_name (string iconname);
 		public weak string get_names ();
+		[CCode (type = "GIcon*")]
 		public ThemedIcon (string iconname);
+		[CCode (type = "GIcon*")]
 		public ThemedIcon.from_names (string[] iconnames, int len);
+		[CCode (type = "GIcon*")]
 		public ThemedIcon.with_default_fallbacks (string iconname);
 		public void prepend_name (string iconname);
 		[NoAccessorMethod]

Modified: trunk/vapi/gtk+-2.0.vapi
==============================================================================
--- trunk/vapi/gtk+-2.0.vapi	(original)
+++ trunk/vapi/gtk+-2.0.vapi	Wed Jul  9 09:17:43 2008
@@ -1745,6 +1745,7 @@
 		public weak string get_website ();
 		public weak string get_website_label ();
 		public bool get_wrap_license ();
+		[CCode (type = "GtkWidget*")]
 		public AboutDialog ();
 		[NoArrayLength]
 		public void set_artists (string[] artists);
@@ -1809,6 +1810,7 @@
 		public ushort accel_string_width;
 		public weak Gtk.Widget get_accel_widget ();
 		public uint get_accel_width ();
+		[CCode (type = "GtkWidget*")]
 		public AccelLabel (string str);
 		public bool refetch ();
 		public void set_accel_closure (GLib.Closure accel_closure);
@@ -1927,6 +1929,7 @@
 	public class Adjustment : Gtk.Object {
 		public void clamp_page (double lower, double upper);
 		public double get_value ();
+		[CCode (type = "GtkObject*")]
 		public Adjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size);
 		public void set_value (double value);
 		[NoAccessorMethod]
@@ -1948,6 +1951,7 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class Alignment : Gtk.Bin, Atk.Implementor, Gtk.Buildable {
 		public void get_padding (uint padding_top, uint padding_bottom, uint padding_left, uint padding_right);
+		[CCode (type = "GtkWidget*")]
 		public Alignment (float xalign, float yalign, float xscale, float yscale);
 		public void set (float xalign, float yalign, float xscale, float yscale);
 		public void set_padding (uint padding_top, uint padding_bottom, uint padding_left, uint padding_right);
@@ -1970,6 +1974,7 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class Arrow : Gtk.Misc, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public Arrow (Gtk.ArrowType arrow_type, Gtk.ShadowType shadow_type);
 		public void set (Gtk.ArrowType arrow_type, Gtk.ShadowType shadow_type);
 		[NoAccessorMethod]
@@ -1980,6 +1985,7 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class AspectFrame : Gtk.Frame, Atk.Implementor, Gtk.Buildable {
 		public Gtk.Allocation center_allocation;
+		[CCode (type = "GtkWidget*")]
 		public AspectFrame (string label, float xalign, float yalign, float ratio, bool obey_child);
 		public void set (float xalign, float yalign, float ratio, bool obey_child);
 		[NoAccessorMethod]
@@ -2007,6 +2013,7 @@
 		public weak string get_page_title (Gtk.Widget page);
 		public Gtk.AssistantPageType get_page_type (Gtk.Widget page);
 		public int insert_page (Gtk.Widget page, int position);
+		[CCode (type = "GtkWidget*")]
 		public Assistant ();
 		public int prepend_page (Gtk.Widget page);
 		public void remove_action_widget (Gtk.Widget child);
@@ -2080,9 +2087,13 @@
 		public Gtk.ReliefStyle get_relief ();
 		public bool get_use_stock ();
 		public bool get_use_underline ();
+		[CCode (type = "GtkWidget*")]
 		public Button ();
+		[CCode (type = "GtkWidget*")]
 		public Button.from_stock (string stock_id);
+		[CCode (type = "GtkWidget*")]
 		public Button.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public Button.with_mnemonic (string label);
 		public void set_alignment (float xalign, float yalign);
 		public void set_focus_on_click (bool focus_on_click);
@@ -2155,6 +2166,7 @@
 		public int get_detail_width_chars ();
 		public Gtk.CalendarDisplayOptions get_display_options ();
 		public bool mark_day (uint day);
+		[CCode (type = "GtkWidget*")]
 		public Calendar ();
 		public void select_day (uint day);
 		public bool select_month (uint month, uint year);
@@ -2236,6 +2248,7 @@
 		public weak Gtk.Widget edit_widget;
 		public weak Gtk.Widget grab_widget;
 		public weak Gtk.Widget sizing_label;
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererAccel ();
 		[NoAccessorMethod]
 		public uint accel_key { get; set; }
@@ -2251,6 +2264,7 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class CellRendererCombo : Gtk.CellRendererText {
 		public uint focus_out_id;
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererCombo ();
 		[NoAccessorMethod]
 		public bool has_entry { get; set; }
@@ -2262,6 +2276,7 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class CellRendererPixbuf : Gtk.CellRenderer {
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererPixbuf ();
 		[NoAccessorMethod]
 		public bool follow_state { get; set; }
@@ -2282,6 +2297,7 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class CellRendererProgress : Gtk.CellRenderer {
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererProgress ();
 		[NoAccessorMethod]
 		public Gtk.ProgressBarOrientation orientation { get; set; }
@@ -2298,6 +2314,7 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class CellRendererSpin : Gtk.CellRendererText {
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererSpin ();
 		[NoAccessorMethod]
 		public Gtk.Adjustment adjustment { get; set; }
@@ -2313,6 +2330,7 @@
 		public Pango.Underline underline_style;
 		public int fixed_height_rows;
 		public uint calc_fixed_height;
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererText ();
 		public void set_fixed_height_from_font (int number_of_rows);
 		[NoAccessorMethod]
@@ -2409,6 +2427,7 @@
 	public class CellRendererToggle : Gtk.CellRenderer {
 		public bool get_active ();
 		public bool get_radio ();
+		[CCode (type = "GtkCellRenderer*")]
 		public CellRendererToggle ();
 		public void set_active (bool setting);
 		public void set_radio (bool radio);
@@ -2427,9 +2446,13 @@
 		public weak GLib.List get_cell_renderers ();
 		public weak Gtk.TreePath get_displayed_row ();
 		public bool get_size_of_row (Gtk.TreePath path, out Gtk.Requisition requisition);
+		[CCode (type = "GtkWidget*")]
 		public CellView ();
+		[CCode (type = "GtkWidget*")]
 		public CellView.with_markup (string markup);
+		[CCode (type = "GtkWidget*")]
 		public CellView.with_pixbuf (Gdk.Pixbuf pixbuf);
+		[CCode (type = "GtkWidget*")]
 		public CellView.with_text (string text);
 		public void set_background_color (Gdk.Color color);
 		public void set_displayed_row (Gtk.TreePath path);
@@ -2445,8 +2468,11 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class CheckButton : Gtk.ToggleButton, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public CheckButton ();
+		[CCode (type = "GtkWidget*")]
 		public CheckButton.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public CheckButton.with_mnemonic (string label);
 		[NoWrapper]
 		public virtual void draw_indicator (Gdk.Rectangle area);
@@ -2457,8 +2483,11 @@
 		public bool get_active ();
 		public bool get_draw_as_radio ();
 		public bool get_inconsistent ();
+		[CCode (type = "GtkWidget*")]
 		public CheckMenuItem ();
+		[CCode (type = "GtkWidget*")]
 		public CheckMenuItem.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public CheckMenuItem.with_mnemonic (string label);
 		public void set_active (bool is_active);
 		public void set_draw_as_radio (bool draw_as_radio);
@@ -2506,7 +2535,9 @@
 		public void get_color (out Gdk.Color color);
 		public weak string get_title ();
 		public bool get_use_alpha ();
+		[CCode (type = "GtkWidget*")]
 		public ColorButton ();
+		[CCode (type = "GtkWidget*")]
 		public ColorButton.with_color (Gdk.Color color);
 		public void set_alpha (ushort alpha);
 		public void set_color (Gdk.Color color);
@@ -2527,6 +2558,7 @@
 		public ushort get_previous_alpha ();
 		public void get_previous_color (out Gdk.Color color);
 		public bool is_adjusting ();
+		[CCode (type = "GtkWidget*")]
 		public ColorSelection ();
 		public static bool palette_from_string (string str, Gdk.Color[] colors);
 		public static weak string palette_to_string (Gdk.Color[] colors);
@@ -2549,6 +2581,7 @@
 		public weak Gtk.Widget ok_button;
 		public weak Gtk.Widget cancel_button;
 		public weak Gtk.Widget help_button;
+		[CCode (type = "GtkWidget*")]
 		public ColorSelectionDialog (string title);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -2566,8 +2599,11 @@
 		public weak string get_title ();
 		public int get_wrap_width ();
 		public void insert_text (int position, string text);
+		[CCode (type = "GtkWidget*")]
 		public ComboBox ();
+		[CCode (type = "GtkWidget*")]
 		public ComboBox.text ();
+		[CCode (type = "GtkWidget*")]
 		public ComboBox.with_model (Gtk.TreeModel model);
 		public void prepend_text (string text);
 		public void remove_text (int position);
@@ -2605,8 +2641,11 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class ComboBoxEntry : Gtk.ComboBox, Atk.Implementor, Gtk.Buildable, Gtk.CellEditable, Gtk.CellLayout {
 		public int get_text_column ();
+		[CCode (type = "GtkWidget*")]
 		public ComboBoxEntry ();
+		[CCode (type = "GtkWidget*")]
 		public ComboBoxEntry.text ();
+		[CCode (type = "GtkWidget*")]
 		public ComboBoxEntry.with_model (Gtk.TreeModel model, int text_column);
 		public void set_text_column (int text_column);
 		public int text_column { get; set; }
@@ -2678,6 +2717,7 @@
 		[NoArrayLength]
 		public weak float[] ctlpoint;
 		public void get_vector (int veclen, float[] vector);
+		[CCode (type = "GtkWidget*")]
 		public Curve ();
 		public void reset ();
 		public void set_curve_type (Gtk.CurveType type);
@@ -2706,7 +2746,9 @@
 		public void add_buttons (...);
 		public bool get_has_separator ();
 		public int get_response_for_widget (Gtk.Widget widget);
+		[CCode (type = "GtkWidget*")]
 		public Dialog ();
+		[CCode (type = "GtkWidget*")]
 		public Dialog.with_buttons (string? title, Gtk.Window? parent, Gtk.DialogFlags flags, ...);
 		public int run ();
 		[CCode (sentinel = "-1")]
@@ -2723,6 +2765,7 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class DrawingArea : Gtk.Widget, Atk.Implementor, Gtk.Buildable {
 		public void* draw_data;
+		[CCode (type = "GtkWidget*")]
 		public DrawingArea ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -2773,6 +2816,7 @@
 		public bool get_visibility ();
 		public int get_width_chars ();
 		public int layout_index_to_text_index (int layout_index);
+		[CCode (type = "GtkWidget*")]
 		public Entry ();
 		public void set_activates_default (bool setting);
 		public void set_alignment (float xalign);
@@ -2865,6 +2909,7 @@
 	public class EventBox : Gtk.Bin, Atk.Implementor, Gtk.Buildable {
 		public bool get_above_child ();
 		public bool get_visible_window ();
+		[CCode (type = "GtkWidget*")]
 		public EventBox ();
 		public void set_above_child (bool above_child);
 		public void set_visible_window (bool visible_window);
@@ -2879,7 +2924,9 @@
 		public int get_spacing ();
 		public bool get_use_markup ();
 		public bool get_use_underline ();
+		[CCode (type = "GtkWidget*")]
 		public Expander (string label);
+		[CCode (type = "GtkWidget*")]
 		public Expander.with_mnemonic (string label);
 		public void set_expanded (bool expanded);
 		public void set_label (string label);
@@ -2900,8 +2947,11 @@
 		public bool get_focus_on_click ();
 		public weak string get_title ();
 		public int get_width_chars ();
+		[CCode (type = "GtkWidget*")]
 		public FileChooserButton (string title, Gtk.FileChooserAction action);
+		[CCode (type = "GtkWidget*")]
 		public FileChooserButton.with_backend (string title, Gtk.FileChooserAction action, string backend);
+		[CCode (type = "GtkWidget*")]
 		public FileChooserButton.with_dialog (Gtk.Widget dialog);
 		public void set_focus_on_click (bool focus_on_click);
 		public void set_title (string title);
@@ -2915,12 +2965,16 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class FileChooserDialog : Gtk.Dialog, Atk.Implementor, Gtk.Buildable, Gtk.FileChooser {
+		[CCode (type = "GtkWidget*")]
 		public FileChooserDialog (string? title, Gtk.Window? parent, Gtk.FileChooserAction action, ...);
+		[CCode (type = "GtkWidget*")]
 		public FileChooserDialog.with_backend (string? title, Gtk.Window? parent, Gtk.FileChooserAction action, string backend, ...);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class FileChooserWidget : Gtk.VBox, Atk.Implementor, Gtk.Buildable, Gtk.FileChooser, Gtk.FileChooserEmbed {
+		[CCode (type = "GtkWidget*")]
 		public FileChooserWidget (Gtk.FileChooserAction action);
+		[CCode (type = "GtkWidget*")]
 		public FileChooserWidget.with_backend (Gtk.FileChooserAction action, string backend);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -2940,6 +2994,7 @@
 		public weak GLib.List children;
 		public bool get_has_window ();
 		public void move (Gtk.Widget widget, int x, int y);
+		[CCode (type = "GtkWidget*")]
 		public Fixed ();
 		public void put (Gtk.Widget widget, int x, int y);
 		public void set_has_window (bool has_window);
@@ -2952,7 +3007,9 @@
 		public weak string get_title ();
 		public bool get_use_font ();
 		public bool get_use_size ();
+		[CCode (type = "GtkWidget*")]
 		public FontButton ();
+		[CCode (type = "GtkWidget*")]
 		public FontButton.with_font (string fontname);
 		public bool set_font_name (string fontname);
 		public void set_show_size (bool show_size);
@@ -2985,6 +3042,7 @@
 		public int size;
 		public weak string get_font_name ();
 		public weak string get_preview_text ();
+		[CCode (type = "GtkWidget*")]
 		public FontSelection ();
 		public bool set_font_name (string fontname);
 		public void set_preview_text (string text);
@@ -3005,6 +3063,7 @@
 		public bool auto_resize;
 		public weak string get_font_name ();
 		public weak string get_preview_text ();
+		[CCode (type = "GtkWidget*")]
 		public FontSelectionDialog (string title);
 		public bool set_font_name (string fontname);
 		public void set_preview_text (string text);
@@ -3016,6 +3075,7 @@
 		public void get_label_align (float xalign, float yalign);
 		public weak Gtk.Widget get_label_widget ();
 		public Gtk.ShadowType get_shadow_type ();
+		[CCode (type = "GtkWidget*")]
 		public Frame (string? label);
 		public void set_label (string label);
 		public void set_label_align (float xalign, float yalign);
@@ -3042,35 +3102,44 @@
 		public float gamma;
 		public weak Gtk.Widget gamma_dialog;
 		public weak Gtk.Widget gamma_text;
+		[CCode (type = "GtkWidget*")]
 		public GammaCurve ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HBox : Gtk.Box, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HBox (bool homogeneous, int spacing);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HButtonBox : Gtk.ButtonBox, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HButtonBox ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HPaned : Gtk.Paned, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HPaned ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HRuler : Gtk.Ruler, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HRuler ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HScale : Gtk.Scale, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HScale (Gtk.Adjustment adjustment);
+		[CCode (type = "GtkWidget*")]
 		public HScale.with_range (double min, double max, double step);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HScrollbar : Gtk.Scrollbar, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HScrollbar (Gtk.Adjustment adjustment);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class HSeparator : Gtk.Separator, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public HSeparator ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -3087,6 +3156,7 @@
 		public Gtk.PositionType get_handle_position ();
 		public Gtk.ShadowType get_shadow_type ();
 		public Gtk.PositionType get_snap_edge ();
+		[CCode (type = "GtkWidget*")]
 		public HandleBox ();
 		public void set_handle_position (Gtk.PositionType position);
 		public void set_shadow_type (Gtk.ShadowType type);
@@ -3131,6 +3201,7 @@
 		public uint in_hex_sequence;
 		public uint modifiers_dropped;
 		public void add_table (ushort data, int max_seq_len, int n_seqs);
+		[CCode (type = "GtkIMContext*")]
 		public IMContextSimple ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -3138,6 +3209,7 @@
 		public weak Gtk.IMContext slave;
 		public weak string context_id;
 		public void append_menuitems (Gtk.MenuShell menushell);
+		[CCode (type = "GtkIMContext*")]
 		public IMMulticontext ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -3203,7 +3275,9 @@
 		public int get_tooltip_column ();
 		public bool get_tooltip_context (int x, int y, bool keyboard_tip, out weak Gtk.TreeModel model, out weak Gtk.TreePath path, out Gtk.TreeIter iter);
 		public bool get_visible_range (out weak Gtk.TreePath start_path, out weak Gtk.TreePath end_path);
+		[CCode (type = "GtkWidget*")]
 		public IconView ();
+		[CCode (type = "GtkWidget*")]
 		public IconView.with_model (Gtk.TreeModel model);
 		public bool path_is_selected (Gtk.TreePath path);
 		public void scroll_to_path (Gtk.TreePath path, bool use_align, float row_align, float col_align);
@@ -3268,15 +3342,25 @@
 		public void get_pixmap (out weak Gdk.Pixmap pixmap, out weak Gdk.Bitmap mask);
 		public void get_stock (out weak string stock_id, out Gtk.IconSize size);
 		public Gtk.ImageType get_storage_type ();
+		[CCode (type = "GtkWidget*")]
 		public Image ();
+		[CCode (type = "GtkWidget*")]
 		public Image.from_animation (Gdk.PixbufAnimation animation);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_file (string filename);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_gicon (GLib.Icon icon, Gtk.IconSize size);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_icon_name (string icon_name, Gtk.IconSize size);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_icon_set (Gtk.IconSet icon_set, Gtk.IconSize size);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_image (Gdk.Image image, Gdk.Bitmap mask);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_pixbuf (Gdk.Pixbuf pixbuf);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_pixmap (Gdk.Pixmap pixmap, Gdk.Bitmap mask);
+		[CCode (type = "GtkWidget*")]
 		public Image.from_stock (string stock_id, Gtk.IconSize size);
 		public void set_from_animation (Gdk.PixbufAnimation animation);
 		public void set_from_file (string filename);
@@ -3316,9 +3400,13 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class ImageMenuItem : Gtk.MenuItem, Atk.Implementor, Gtk.Buildable {
 		public weak Gtk.Widget get_image ();
+		[CCode (type = "GtkWidget*")]
 		public ImageMenuItem ();
+		[CCode (type = "GtkWidget*")]
 		public ImageMenuItem.from_stock (string stock_id, Gtk.AccelGroup? accel_group);
+		[CCode (type = "GtkWidget*")]
 		public ImageMenuItem.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public ImageMenuItem.with_mnemonic (string label);
 		public void set_image (Gtk.Widget image);
 		public Gtk.Widget image { get; set; }
@@ -3335,6 +3423,7 @@
 		public weak Gdk.Device current_device;
 		public weak Gtk.Widget keys_list;
 		public weak Gtk.Widget keys_listbox;
+		[CCode (type = "GtkWidget*")]
 		public InputDialog ();
 		public virtual signal void disable_device (Gdk.Device device);
 		public virtual signal void enable_device (Gdk.Device device);
@@ -3343,7 +3432,9 @@
 	public class Invisible : Gtk.Widget, Atk.Implementor, Gtk.Buildable {
 		public bool has_user_ref_count;
 		public weak Gdk.Screen get_screen ();
+		[CCode (type = "GtkWidget*")]
 		public Invisible ();
+		[CCode (type = "GtkWidget*")]
 		public Invisible.for_screen (Gdk.Screen screen);
 		public void set_screen (Gdk.Screen screen);
 		public Gdk.Screen screen { get; set; }
@@ -3388,7 +3479,9 @@
 		public bool get_use_markup ();
 		public bool get_use_underline ();
 		public int get_width_chars ();
+		[CCode (type = "GtkWidget*")]
 		public Label (string? str);
+		[CCode (type = "GtkWidget*")]
 		public Label.with_mnemonic (string str);
 		public void select_region (int start_offset, int end_offset);
 		public void set_angle (double angle);
@@ -3448,6 +3541,7 @@
 		public void get_size (out uint width, out uint height);
 		public weak Gtk.Adjustment get_vadjustment ();
 		public void move (Gtk.Widget child_widget, int x, int y);
+		[CCode (type = "GtkWidget*")]
 		public Layout (Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment);
 		public void put (Gtk.Widget child_widget, int x, int y);
 		public void set_hadjustment (Gtk.Adjustment adjustment);
@@ -3464,7 +3558,9 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class LinkButton : Gtk.Button, Atk.Implementor, Gtk.Buildable {
 		public weak string get_uri ();
+		[CCode (type = "GtkWidget*")]
 		public LinkButton (string uri);
+		[CCode (type = "GtkWidget*")]
 		public LinkButton.with_label (string uri, string label);
 		public void set_uri (string uri);
 		public static weak Gtk.LinkButtonUriFunc set_uri_hook (Gtk.LinkButtonUriFunc func, void* data, GLib.DestroyNotify destroy);
@@ -3549,6 +3645,7 @@
 		public static weak GLib.List get_for_attach_widget (Gtk.Widget widget);
 		public bool get_tearoff_state ();
 		public weak string get_title ();
+		[CCode (type = "GtkWidget*")]
 		public Menu ();
 		public void popdown ();
 		public void popup (Gtk.Widget? parent_menu_shell, Gtk.Widget? parent_menu_item, Gtk.MenuPositionFunc? func, uint button, uint activate_time);
@@ -3570,6 +3667,7 @@
 	public class MenuBar : Gtk.MenuShell, Atk.Implementor, Gtk.Buildable {
 		public Gtk.PackDirection get_child_pack_direction ();
 		public Gtk.PackDirection get_pack_direction ();
+		[CCode (type = "GtkWidget*")]
 		public MenuBar ();
 		public void set_child_pack_direction (Gtk.PackDirection child_pack_dir);
 		public void set_pack_direction (Gtk.PackDirection pack_dir);
@@ -3591,8 +3689,11 @@
 		public uint timer;
 		public bool get_right_justified ();
 		public weak Gtk.Widget get_submenu ();
+		[CCode (type = "GtkWidget*")]
 		public MenuItem ();
+		[CCode (type = "GtkWidget*")]
 		public MenuItem.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public MenuItem.with_mnemonic (string label);
 		public void set_accel_path (string accel_path);
 		public void set_right_justified (bool right_justified);
@@ -3644,7 +3745,9 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class MenuToolButton : Gtk.ToolButton, Atk.Implementor, Gtk.Buildable {
 		public weak Gtk.Widget get_menu ();
+		[CCode (type = "GtkToolItem*")]
 		public MenuToolButton (Gtk.Widget icon_widget, string label);
+		[CCode (type = "GtkToolItem*")]
 		public MenuToolButton.from_stock (string stock_id);
 		public void set_arrow_tooltip_markup (string markup);
 		public void set_arrow_tooltip_text (string text);
@@ -3657,7 +3760,9 @@
 		public weak Gtk.Widget label;
 		public void format_secondary_markup (string message_format);
 		public void format_secondary_text (string message_format);
+		[CCode (type = "GtkWidget*")]
 		public MessageDialog (Gtk.Window? parent, Gtk.DialogFlags flags, Gtk.MessageType type, Gtk.ButtonsType buttons, string message_format, ...);
+		[CCode (type = "GtkWidget*")]
 		public MessageDialog.with_markup (Gtk.Window? parent, Gtk.DialogFlags flags, Gtk.MessageType type, Gtk.ButtonsType buttons, string message_format, ...);
 		public void set_image (Gtk.Widget image);
 		public void set_markup (string str);
@@ -3695,6 +3800,7 @@
 	public class MountOperation : GLib.MountOperation {
 		public weak Gtk.Window get_parent ();
 		public weak Gdk.Screen get_screen ();
+		[CCode (type = "GMountOperation*")]
 		public MountOperation (Gtk.Window parent);
 		public void set_parent (Gtk.Window parent);
 		public void set_screen (Gdk.Screen screen);
@@ -3739,6 +3845,7 @@
 		public Gtk.PositionType get_tab_pos ();
 		public bool get_tab_reorderable (Gtk.Widget child);
 		public int insert_page_menu (Gtk.Widget child, Gtk.Widget tab_label, Gtk.Widget menu_label, int position);
+		[CCode (type = "GtkWidget*")]
 		public Notebook ();
 		public void next_page ();
 		public void popup_disable ();
@@ -3889,7 +3996,9 @@
 		public void @construct (Gdk.NativeWindow socket_id);
 		public void construct_for_display (Gdk.Display display, Gdk.NativeWindow socket_id);
 		public Gdk.NativeWindow get_id ();
+		[CCode (type = "GtkWidget*")]
 		public Plug (Gdk.NativeWindow socket_id);
+		[CCode (type = "GtkWidget*")]
 		public Plug.for_display (Gdk.Display display, Gdk.NativeWindow socket_id);
 		[NoAccessorMethod]
 		public bool embedded { get; }
@@ -4048,6 +4157,7 @@
 		public Gtk.ProgressBarOrientation get_orientation ();
 		public double get_pulse_step ();
 		public weak string get_text ();
+		[CCode (type = "GtkWidget*")]
 		public ProgressBar ();
 		public void pulse ();
 		public void set_ellipsize (Pango.EllipsizeMode mode);
@@ -4087,11 +4197,17 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RadioButton : Gtk.CheckButton, Atk.Implementor, Gtk.Buildable {
 		public weak GLib.SList get_group ();
+		[CCode (type = "GtkWidget*")]
 		public RadioButton (GLib.SList? group);
+		[CCode (type = "GtkWidget*")]
 		public RadioButton.from_widget (Gtk.RadioButton radio_group_member);
+		[CCode (type = "GtkWidget*")]
 		public RadioButton.with_label (GLib.SList? group, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioButton.with_label_from_widget (Gtk.RadioButton radio_group_member, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioButton.with_mnemonic (GLib.SList? group, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioButton.with_mnemonic_from_widget (Gtk.RadioButton radio_group_member, string label);
 		public void set_group (GLib.SList group);
 		public Gtk.RadioButton group { set; }
@@ -4100,11 +4216,17 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RadioMenuItem : Gtk.CheckMenuItem, Atk.Implementor, Gtk.Buildable {
 		public weak GLib.SList get_group ();
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem (GLib.SList group);
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem.from_widget (Gtk.RadioMenuItem group);
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem.with_label (GLib.SList group, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem.with_label_from_widget (Gtk.RadioMenuItem group, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem.with_mnemonic (GLib.SList group, string label);
+		[CCode (type = "GtkWidget*")]
 		public RadioMenuItem.with_mnemonic_from_widget (Gtk.RadioMenuItem group, string label);
 		public void set_group (GLib.SList group);
 		public Gtk.RadioMenuItem group { set; }
@@ -4113,9 +4235,13 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RadioToolButton : Gtk.ToggleToolButton, Atk.Implementor, Gtk.Buildable {
 		public weak GLib.SList get_group ();
+		[CCode (type = "GtkToolItem*")]
 		public RadioToolButton (GLib.SList group);
+		[CCode (type = "GtkToolItem*")]
 		public RadioToolButton.from_stock (GLib.SList group, string stock_id);
+		[CCode (type = "GtkToolItem*")]
 		public RadioToolButton.from_widget (Gtk.RadioToolButton group);
+		[CCode (type = "GtkToolItem*")]
 		public RadioToolButton.with_stock_from_widget (Gtk.RadioToolButton group, string stock_id);
 		public void set_group (GLib.SList group);
 		public Gtk.RadioToolButton group { set; }
@@ -4214,20 +4340,26 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RecentAction : Gtk.Action, Gtk.Buildable, Gtk.RecentChooser {
 		public bool get_show_numbers ();
+		[CCode (type = "GtkAction*")]
 		public RecentAction (string name, string label, string tooltip, string stock_id);
+		[CCode (type = "GtkAction*")]
 		public RecentAction.for_manager (string name, string label, string tooltip, string stock_id, Gtk.RecentManager manager);
 		public void set_show_numbers (bool show_numbers);
 		public bool show_numbers { get; set; }
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RecentChooserDialog : Gtk.Dialog, Atk.Implementor, Gtk.Buildable, Gtk.RecentChooser {
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserDialog (string title, Gtk.Window parent, ...);
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserDialog.for_manager (string title, Gtk.Window parent, Gtk.RecentManager manager, ...);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RecentChooserMenu : Gtk.Menu, Atk.Implementor, Gtk.Buildable, Gtk.RecentChooser {
 		public bool get_show_numbers ();
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserMenu ();
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserMenu.for_manager (Gtk.RecentManager manager);
 		public void set_show_numbers (bool show_numbers);
 		[NoWrapper]
@@ -4242,7 +4374,9 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class RecentChooserWidget : Gtk.VBox, Atk.Implementor, Gtk.Buildable, Gtk.RecentChooser {
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserWidget ();
+		[CCode (type = "GtkWidget*")]
 		public RecentChooserWidget.for_manager (Gtk.RecentManager manager);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -4326,6 +4460,7 @@
 		public weak Gtk.Widget minus_button;
 		public weak Gtk.Adjustment get_adjustment ();
 		public double get_value ();
+		[CCode (type = "GtkWidget*")]
 		public ScaleButton (Gtk.IconSize size, double min, double max, double step, string[] icons);
 		public void set_adjustment (Gtk.Adjustment adjustment);
 		public void set_icons (string[] icons);
@@ -4358,6 +4493,7 @@
 		public Gtk.ShadowType get_shadow_type ();
 		public weak Gtk.Adjustment get_vadjustment ();
 		public weak Gtk.Widget get_vscrollbar ();
+		[CCode (type = "GtkWidget*")]
 		public ScrolledWindow (Gtk.Adjustment? hadjustment, Gtk.Adjustment? vadjustment);
 		public void set_hadjustment (Gtk.Adjustment hadjustment);
 		public void set_placement (Gtk.CornerType window_placement);
@@ -4384,11 +4520,13 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class SeparatorMenuItem : Gtk.MenuItem, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public SeparatorMenuItem ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class SeparatorToolItem : Gtk.ToolItem, Atk.Implementor, Gtk.Buildable {
 		public bool get_draw ();
+		[CCode (type = "GtkToolItem*")]
 		public SeparatorToolItem ();
 		public void set_draw (bool draw);
 		public bool draw { get; set; }
@@ -4539,6 +4677,7 @@
 		public weak Gtk.Widget toplevel;
 		public void add_id (Gdk.NativeWindow window_id);
 		public Gdk.NativeWindow get_id ();
+		[CCode (type = "GtkWidget*")]
 		public Socket ();
 		public virtual signal void plug_added ();
 		public virtual signal bool plug_removed ();
@@ -4564,7 +4703,9 @@
 		public double get_value ();
 		public int get_value_as_int ();
 		public bool get_wrap ();
+		[CCode (type = "GtkWidget*")]
 		public SpinButton (Gtk.Adjustment adjustment, double climb_rate, uint digits);
+		[CCode (type = "GtkWidget*")]
 		public SpinButton.with_range (double min, double max, double step);
 		public void set_adjustment (Gtk.Adjustment adjustment);
 		public void set_digits (uint digits);
@@ -4651,6 +4792,7 @@
 		public weak Gdk.Window grip_window;
 		public uint get_context_id (string context_description);
 		public bool get_has_resize_grip ();
+		[CCode (type = "GtkWidget*")]
 		public Statusbar ();
 		public void pop (uint context_id);
 		public uint push (uint context_id, string text);
@@ -4782,6 +4924,7 @@
 		public uint get_default_row_spacing ();
 		public bool get_homogeneous ();
 		public uint get_row_spacing (uint row);
+		[CCode (type = "GtkWidget*")]
 		public Table (uint rows, uint columns, bool homogeneous);
 		public void resize (uint rows, uint columns);
 		public void set_col_spacing (uint column, uint spacing);
@@ -4801,6 +4944,7 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class TearoffMenuItem : Gtk.MenuItem, Atk.Implementor, Gtk.Buildable {
 		public uint torn_off;
+		[CCode (type = "GtkWidget*")]
 		public TearoffMenuItem ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -5161,7 +5305,9 @@
 		public void move_child (Gtk.Widget child, int xpos, int ypos);
 		public bool move_mark_onscreen (Gtk.TextMark mark);
 		public bool move_visually (Gtk.TextIter iter, int count);
+		[CCode (type = "GtkWidget*")]
 		public TextView ();
+		[CCode (type = "GtkWidget*")]
 		public TextView.with_buffer (Gtk.TextBuffer buffer);
 		public bool place_cursor_onscreen ();
 		public void scroll_mark_onscreen (Gtk.TextMark mark);
@@ -5233,8 +5379,11 @@
 		public bool get_active ();
 		public bool get_inconsistent ();
 		public bool get_mode ();
+		[CCode (type = "GtkWidget*")]
 		public ToggleButton ();
+		[CCode (type = "GtkWidget*")]
 		public ToggleButton.with_label (string label);
+		[CCode (type = "GtkWidget*")]
 		public ToggleButton.with_mnemonic (string label);
 		public void set_active (bool is_active);
 		public void set_inconsistent (bool setting);
@@ -5249,7 +5398,9 @@
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class ToggleToolButton : Gtk.ToolButton, Atk.Implementor, Gtk.Buildable {
 		public bool get_active ();
+		[CCode (type = "GtkToolItem*")]
 		public ToggleToolButton ();
+		[CCode (type = "GtkToolItem*")]
 		public ToggleToolButton.from_stock (string stock_id);
 		public void set_active (bool is_active);
 		public bool active { get; set; }
@@ -5263,7 +5414,9 @@
 		public weak Gtk.Widget get_label_widget ();
 		public weak string get_stock_id ();
 		public bool get_use_underline ();
+		[CCode (type = "GtkToolItem*")]
 		public ToolButton (Gtk.Widget icon_widget, string label);
+		[CCode (type = "GtkToolItem*")]
 		public ToolButton.from_stock (string stock_id);
 		public void set_icon_name (string icon_name);
 		public void set_icon_widget (Gtk.Widget icon_widget);
@@ -5325,6 +5478,7 @@
 		public bool get_show_arrow ();
 		public bool get_tooltips ();
 		public void insert (Gtk.ToolItem item, int pos);
+		[CCode (type = "GtkWidget*")]
 		public Toolbar ();
 		public void set_drop_highlight_item (Gtk.ToolItem tool_item, int index_);
 		public void set_icon_size (Gtk.IconSize icon_size);
@@ -5366,6 +5520,7 @@
 		public void convert_iter_to_child_iter (out Gtk.TreeIter child_iter, Gtk.TreeIter filter_iter);
 		public weak Gtk.TreePath convert_path_to_child_path (Gtk.TreePath filter_path);
 		public weak Gtk.TreeModel get_model ();
+		[CCode (type = "GtkTreeModel*")]
 		public TreeModelFilter (Gtk.TreeModel child_model, Gtk.TreePath? root);
 		public void refilter ();
 		public void set_modify_func (int n_columns, GLib.Type[] types, Gtk.TreeModelFilterModifyFunc func, void* data, Gtk.DestroyNotify destroy);
@@ -5401,6 +5556,7 @@
 		public weak Gtk.TreePath convert_path_to_child_path (Gtk.TreePath sorted_path);
 		public weak Gtk.TreeModel get_model ();
 		public bool iter_is_valid (Gtk.TreeIter iter);
+		[CCode (type = "GtkTreeModel*")]
 		public TreeModelSort.with_model (Gtk.TreeModel child_model);
 		public void reset_default_sort_func ();
 		[NoAccessorMethod]
@@ -5536,7 +5692,9 @@
 		public bool is_rubber_banding_active ();
 		public void map_expanded_rows (Gtk.TreeViewMappingFunc func, void* data);
 		public void move_column_after (Gtk.TreeViewColumn column, Gtk.TreeViewColumn base_column);
+		[CCode (type = "GtkWidget*")]
 		public TreeView ();
+		[CCode (type = "GtkWidget*")]
 		public TreeView.with_model (Gtk.TreeModel model);
 		public int remove_column (Gtk.TreeViewColumn column);
 		public void scroll_to_cell (Gtk.TreePath? path, Gtk.TreeViewColumn? column, bool use_align, float row_align, float col_align);
@@ -5712,6 +5870,7 @@
 		public weak string get_ui ();
 		public void insert_action_group (Gtk.ActionGroup action_group, int pos);
 		public UIManager ();
+		[CCode (type = "guint")]
 		public UIManager.merge_id (Gtk.UIManager self);
 		public void remove_action_group (Gtk.ActionGroup action_group);
 		public void remove_ui (uint merge_id);
@@ -5729,31 +5888,39 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VBox : Gtk.Box, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VBox (bool homogeneous, int spacing);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VButtonBox : Gtk.ButtonBox, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VButtonBox ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VPaned : Gtk.Paned, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VPaned ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VRuler : Gtk.Ruler, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VRuler ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VScale : Gtk.Scale, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VScale (Gtk.Adjustment adjustment);
+		[CCode (type = "GtkWidget*")]
 		public VScale.with_range (double min, double max, double step);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VScrollbar : Gtk.Scrollbar, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VScrollbar (Gtk.Adjustment adjustment);
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VSeparator : Gtk.Separator, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VSeparator ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -5763,6 +5930,7 @@
 		public weak Gtk.Adjustment get_hadjustment ();
 		public Gtk.ShadowType get_shadow_type ();
 		public weak Gtk.Adjustment get_vadjustment ();
+		[CCode (type = "GtkWidget*")]
 		public Viewport (Gtk.Adjustment hadjustment, Gtk.Adjustment vadjustment);
 		public void set_hadjustment (Gtk.Adjustment adjustment);
 		public void set_shadow_type (Gtk.ShadowType type);
@@ -5774,6 +5942,7 @@
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
 	public class VolumeButton : Gtk.ScaleButton, Atk.Implementor, Gtk.Buildable {
+		[CCode (type = "GtkWidget*")]
 		public VolumeButton ();
 	}
 	[CCode (cheader_filename = "gtk/gtk.h")]
@@ -5848,6 +6017,7 @@
 		public void maximize ();
 		public bool mnemonic_activate (uint keyval, Gdk.ModifierType modifier);
 		public void move (int x, int y);
+		[CCode (type = "GtkWidget*")]
 		public Window (Gtk.WindowType type);
 		public bool parse_geometry (string geometry);
 		public void present ();

Modified: trunk/vapigen/valagidlparser.vala
==============================================================================
--- trunk/vapigen/valagidlparser.vala	(original)
+++ trunk/vapigen/valagidlparser.vala	Wed Jul  9 09:17:43 2008
@@ -1257,6 +1257,15 @@
 			} else if (m.name.has_prefix ("new_")) {
 				m.name = m.name.offset ("new_".len ());
 			}
+			// For classes, check whether a creation method return type equals to the
+			// type of the class created. If the types do not match (e.g. in most
+			// gtk widgets) add an attribute to the creation method indicating the used
+			// return type.
+			if (current_data_type is Class && res != null) {
+				if ("%s*".printf (current_data_type.get_cname()) != res.type.unparsed) {
+					((CreationMethod)m).custom_return_type_cname = res.type.unparsed;
+				}
+			}
 		} else {
 			m = new Method (name, return_type, current_source_reference);
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]