Delivered-To: lablgtk at yquem.inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; bh=ZyTnRi5YOPGt11EnVr2Po32kgj/rdgswupTvnUw4OXk=; b=T2P+BfrBQa+lq4EcnuaQl48Sok9BhcWPa2GBsmF29HBdXcwzhIXiLLrNR9x+lIRRj0ERiGvZYDFbH/mhff7aKUx6ZHR7frQjbzJhC3ScXMDScUuDUAGvGs0PIXeFi4LL0SQhfITvC7mkX1PD38jViit+b/f6drbCSX4zT70FkNs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=iJHWKVRvW32SlO0VoJxcnAqnYqjMJfoq4zPG6bYNnRgWQq9mjMTQuaTkKIqFRBIQbEiCAVTb2wNiSy9TqMnG75SbjDWdBZ8ywWS4PMpKwFPxCi7wcl4yn2Rnaim6+AsCO/UnEiaD0cnIqexwspvivJbwxYicdwnukNp1CmCNAeg= Date: Tue, 30 Oct 2007 05:48:41 +0100 To: lablgtk at yquem.inria.fr Subject: Re: [Lablgtk] Signals - how to inherit GObj.gobject_signals properly? Message-ID: <20071030044841.GB29836 at localhost> Mail-Followup-To: Julien Moutinho , lablgtk@yquem.inria.fr References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: From: Julien Moutinho Content-Type: multipart/mixed; boundary="bg08WKrSYDhXBjb5" Content-Length: 20854 --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 30, 2007 at 02:23:30AM +0100, Dawid Toton wrote: > I have stuck trying to understand the following error message: > ...... > [...] > (other source files are in=20 > http://www.toton.2-0.pl/OCaml/LablGTK/src/GtkPrintOperation/Output/ ) You have forgotten to put http://www.toton.2-0.pl/OCaml/LablGTK/src/gtkPrin= tOperation_types.mli > I believe there is something wrong with my interface part, but I don't kn= ow=20 > what's going on at all. I thought that the compiler should know that 'b a= nd=20 > 'd types (as in the error message) should be the same type. I don't know= =20 > any way to force it to think so. Use the [as 'obj] Luke :) A simple ocamlc -i would have told you. > One thing more I don't understand worries me: why it is legal to write > inherit [[> GtkPrintOperation_types.print_operation]] GObj.gobject_signa= ls > > when "[[> GtkPrintOperation_types.print_operation]] GObj.gobject_signals"= =20 > is sort of Gobject.obj->object and needs to be feeded with some obj to=20 > become an OCaml object (that surely can be inherited). > Now it looks as if it inherits "Gobject.obj->object" function. It is only authorized in signatures where the types of the class' arguments (a.k.a. implicit instance variables) are abstracted by the class' parameters (i.e. the types before the class' name, those between '[' ']')). So if arguments' types are already abstrated (understand bound or known), no need to write them right. Also, see the attached files, I have modified the classes so they are no longer recursive, which is ugly. It now uses {< obj =3D obj >} hence the need of val obj =3D obj, which is much more =C3=A9l=C3=A9gant. Note also that *_skel take now a [closed polymorphic variant type] Gobject.= obj, this is due to *.copy which closes the p.v.t.. Besides a few Gobject.obj were missing after several p.v.t. in #as_*. That's all, keep up the good work :) Julien. --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="gPrintOperation.ml" (*module GtkPrintOperation = GtkPrintOperationProps open GtkPrintOperation *) open GtkPrintOperationProps open GtkPrintOperation_types (* Additional call to initialization code - in case one uses only GPrintOperation module (and not GtkPrintOperation): *) let _ = GtkPrintOperation._gtk_print_operation_init () let mapsome f = function | Some x -> Some (f x) | None -> None (*----------------------------------------------------------------------------------------------------*) class page_setup_skel (obj: 'obj) = object val obj = obj method private obj = obj constraint 'obj = GtkPrintOperation_types.page_setup Gobject.obj (*inherit OgtkPrintOperationProps.page_setup_props*) method as_page_setup = obj (*GtkPageSetup*) method copy = (mapsome (fun obj -> {< obj = obj >}) (PageSetup.copy obj)) method get_orientation = PageSetup.get_orientation obj method set_orientation (orientation:GtkPrintOperationEnums.page_orientation) = PageSetup.set_orientation obj orientation method get_paper_size = PageSetup.get_paper_size obj method set_paper_size (size:paper_size option) = PageSetup.set_paper_size obj size method get_top_margin (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_top_margin obj gtkunit method set_top_margin (margin:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.set_top_margin obj margin gtkunit method get_bottom_margin (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_bottom_margin obj gtkunit method set_bottom_margin (margin:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.set_bottom_margin obj margin gtkunit method get_left_margin (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_left_margin obj gtkunit method set_left_margin (margin:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.set_left_margin obj margin gtkunit method get_right_margin (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_right_margin obj gtkunit method set_right_margin (margin:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.set_right_margin obj margin gtkunit method set_paper_size_and_default_margins (size:paper_size option) = PageSetup.set_paper_size_and_default_margins obj size method get_paper_width (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_paper_width obj gtkunit method get_paper_height (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_paper_height obj gtkunit method get_page_width (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_page_width obj gtkunit method get_page_height (gtkunit:GtkPrintOperationEnums.gtk_unit) = PageSetup.get_page_height obj gtkunit method to_file (file_name:string option) = PageSetup.to_file obj file_name end class page_setup obj = object inherit page_setup_skel (obj :> GtkPrintOperation_types.page_setup Gobject.obj) end (*----------------------------------------------------------------------------------------------------*) class print_settings_skel (obj: 'obj) = object val obj = obj method private obj = obj (* what??? *) constraint 'obj = GtkPrintOperation_types.print_settings Gobject.obj method as_print_settings = obj (*GtkPrintSettings*) method copy = (mapsome (fun obj -> {< obj = obj >}) (PrintSettings.copy obj)) method has_key (key:string option) = PrintSettings.has_key obj key method get (key:string option) = PrintSettings.get obj key method set (key:string option) (value:string option) = PrintSettings.set obj key value method unset (key:string option) = PrintSettings.unset obj key method get_bool (key:string option) = PrintSettings.get_bool obj key method set_bool (key:string option) (value:bool) = PrintSettings.set_bool obj key value method get_double (key:string option) = PrintSettings.get_double obj key method get_double_with_default (key:string option) (def:float) = PrintSettings.get_double_with_default obj key def method set_double (key:string option) (value:float) = PrintSettings.set_double obj key value method get_length (key:string option) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.get_length obj key gtkunit method set_length (key:string option) (value:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.set_length obj key value gtkunit method get_int (key:string option) = PrintSettings.get_int obj key method get_int_with_default (key:string option) (def:int) = PrintSettings.get_int_with_default obj key def method set_int (key:string option) (value:int) = PrintSettings.set_int obj key value method get_printer = PrintSettings.get_printer obj method set_printer (printer:string option) = PrintSettings.set_printer obj printer method get_orientation = PrintSettings.get_orientation obj method set_orientation (orientation:GtkPrintOperationEnums.page_orientation) = PrintSettings.set_orientation obj orientation method get_paper_size = PrintSettings.get_paper_size obj method set_paper_size (paper_size:paper_size option) = PrintSettings.set_paper_size obj paper_size method get_paper_width (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.get_paper_width obj gtkunit method set_paper_width (width:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.set_paper_width obj width gtkunit method get_paper_height (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.get_paper_height obj gtkunit method set_paper_height (height:float) (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintSettings.set_paper_height obj height gtkunit method get_use_color = PrintSettings.get_use_color obj method set_use_color (use_color:bool) = PrintSettings.set_use_color obj use_color method get_collate = PrintSettings.get_collate obj method set_collate (collate:bool) = PrintSettings.set_collate obj collate method get_reverse = PrintSettings.get_reverse obj method set_reverse (reverse:bool) = PrintSettings.set_reverse obj reverse method get_duplex = PrintSettings.get_duplex obj method set_duplex (duplex:GtkPrintOperationEnums.duplex) = PrintSettings.set_duplex obj duplex method get_quality = PrintSettings.get_quality obj method set_quality (quality:GtkPrintOperationEnums.quality) = PrintSettings.set_quality obj quality method get_n_copies = PrintSettings.get_n_copies obj method set_n_copies (num_copies:int) = PrintSettings.set_n_copies obj num_copies method get_number_up = PrintSettings.get_number_up obj method set_number_up (number_up:int) = PrintSettings.set_number_up obj number_up method get_resolution = PrintSettings.get_resolution obj method set_resolution (resolution:int) = PrintSettings.set_resolution obj resolution method get_scale = PrintSettings.get_scale obj method set_scale (scale:float) = PrintSettings.set_scale obj scale method get_print_pages = PrintSettings.get_print_pages obj method set_print_pages (pages:GtkPrintOperationEnums.print_pages) = PrintSettings.set_print_pages obj pages method get_page_set = PrintSettings.get_page_set obj method set_page_set (page_set:GtkPrintOperationEnums.page_set) = PrintSettings.set_page_set obj page_set method get_default_source = PrintSettings.get_default_source obj method set_default_source (default_source:string option) = PrintSettings.set_default_source obj default_source method get_media_type = PrintSettings.get_media_type obj method set_media_type (media_type:string option) = PrintSettings.set_media_type obj media_type method get_dither = PrintSettings.get_dither obj method set_dither (dither:string option) = PrintSettings.set_dither obj dither method get_finishings = PrintSettings.get_finishings obj method set_finishings (finishings:string option) = PrintSettings.set_finishings obj finishings method get_output_bin = PrintSettings.get_output_bin obj method set_output_bin (output_bin:string option) = PrintSettings.set_output_bin obj output_bin method to_file (file_name:string option) = PrintSettings.to_file obj file_name end and print_settings obj = object inherit print_settings_skel (obj :> GtkPrintOperation_types.print_settings Gobject.obj) end (*----------------------------------------------------------------------------------------------------*) class print_operation_signals obj = object inherit [[> GtkPrintOperation_types.print_operation]] GObj.gobject_signals obj inherit OgtkPrintOperationProps.print_operation_sigs end class print_operation_skel obj = object (* val obj = obj (* why? *) *) method private obj = obj (*inherit OgtkPrintOperationProps.print_operation_props*) method as_print_operation = (obj :> GtkPrintOperation_types.print_operation Gobject.obj) (*GtkPrintOperation*) method set_allow_async (allow_async:bool) = PrintOperation.set_allow_async obj allow_async method set_default_page_setup (default_page_setup:page_setup option) = PrintOperation.set_default_page_setup obj (mapsome (fun x->x#as_page_setup) (default_page_setup)) method get_default_page_setup = (mapsome (new page_setup) (PrintOperation.get_default_page_setup obj)) method set_print_settings (print_settings:print_settings option) = PrintOperation.set_print_settings obj (mapsome (fun x->x#as_print_settings) (print_settings)) method get_print_settings = (mapsome (new print_settings) (PrintOperation.get_print_settings obj)) method set_job_name (job_name:string option) = PrintOperation.set_job_name obj job_name method set_n_pages (n_pages:int) = PrintOperation.set_n_pages obj n_pages method set_current_page (current_page:int) = PrintOperation.set_current_page obj current_page method set_use_full_page (full_page:bool) = PrintOperation.set_use_full_page obj full_page method set_unit (gtkunit:GtkPrintOperationEnums.gtk_unit) = PrintOperation.set_unit obj gtkunit method set_export_filename (filename:string option) = PrintOperation.set_export_filename obj filename method set_show_progress (show_progress:bool) = PrintOperation.set_show_progress obj show_progress method set_track_print_status (track_status:bool) = PrintOperation.set_track_print_status obj track_status method set_custom_tab_label (label:string option) = PrintOperation.set_custom_tab_label obj label method run (action:GtkPrintOperationEnums.action) (parent:GWindow.window option) = PrintOperation.run obj action (mapsome (fun x->x#as_window) (parent)) method cancel () = PrintOperation.cancel obj method get_status = PrintOperation.get_status obj method get_status_string = PrintOperation.get_status_string obj method is_finished = PrintOperation.is_finished obj end class print_operation obj = object inherit print_operation_skel obj method connect = new print_operation_signals obj end (*----------------------------------------------------------------------------------------------------*) let print_operation () = new print_operation (PrintOperation.create []) --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="gPrintOperation.mli" (* TODO: avoid openings *) open GWindow open GtkPrintOperation_types (*----------------------------------------------------------------------------------------------------*) class page_setup_skel : 'obj Gobject.obj -> object ('self) constraint 'obj = GtkPrintOperation_types.page_setup (*inherit OgtkPrintOperationProps.page_setup_props*) method as_page_setup : GtkPrintOperation_types.page_setup Gobject.obj (*GtkPageSetup*) method copy : 'self option method get_orientation : GtkPrintOperationEnums.page_orientation method set_orientation : GtkPrintOperationEnums.page_orientation -> unit method get_paper_size : paper_size option method set_paper_size : paper_size option -> unit method get_top_margin : GtkPrintOperationEnums.gtk_unit -> float method set_top_margin : float -> GtkPrintOperationEnums.gtk_unit -> unit method get_bottom_margin : GtkPrintOperationEnums.gtk_unit -> float method set_bottom_margin : float -> GtkPrintOperationEnums.gtk_unit -> unit method get_left_margin : GtkPrintOperationEnums.gtk_unit -> float method set_left_margin : float -> GtkPrintOperationEnums.gtk_unit -> unit method get_right_margin : GtkPrintOperationEnums.gtk_unit -> float method set_right_margin : float -> GtkPrintOperationEnums.gtk_unit -> unit method set_paper_size_and_default_margins : paper_size option -> unit method get_paper_width : GtkPrintOperationEnums.gtk_unit -> float method get_paper_height : GtkPrintOperationEnums.gtk_unit -> float method get_page_width : GtkPrintOperationEnums.gtk_unit -> float method get_page_height : GtkPrintOperationEnums.gtk_unit -> float method to_file : string option -> bool end class page_setup : 'obj Gobject.obj -> object constraint 'obj = [>GtkPrintOperation_types.page_setup] inherit page_setup_skel end (*----------------------------------------------------------------------------------------------------*) class print_settings_skel : 'obj Gobject.obj -> object ('self) constraint 'obj = GtkPrintOperation_types.print_settings method as_print_settings : GtkPrintOperation_types.print_settings Gobject.obj (*GtkPrintSettings*) method copy : 'self option method has_key : string option -> bool method get : string option -> string option method set : string option -> string option -> unit method unset : string option -> unit method get_bool : string option -> bool method set_bool : string option -> bool -> unit method get_double : string option -> float method get_double_with_default : string option -> float -> float method set_double : string option -> float -> unit method get_length : string option -> GtkPrintOperationEnums.gtk_unit -> float method set_length : string option -> float -> GtkPrintOperationEnums.gtk_unit -> unit method get_int : string option -> int method get_int_with_default : string option -> int -> int method set_int : string option -> int -> unit method get_printer : string option method set_printer : string option -> unit method get_orientation : GtkPrintOperationEnums.page_orientation method set_orientation : GtkPrintOperationEnums.page_orientation -> unit method get_paper_size : paper_size option method set_paper_size : paper_size option -> unit method get_paper_width : GtkPrintOperationEnums.gtk_unit -> float method set_paper_width : float -> GtkPrintOperationEnums.gtk_unit -> unit method get_paper_height : GtkPrintOperationEnums.gtk_unit -> float method set_paper_height : float -> GtkPrintOperationEnums.gtk_unit -> unit method get_use_color : bool method set_use_color : bool -> unit method get_collate : bool method set_collate : bool -> unit method get_reverse : bool method set_reverse : bool -> unit method get_duplex : GtkPrintOperationEnums.duplex method set_duplex : GtkPrintOperationEnums.duplex -> unit method get_quality : GtkPrintOperationEnums.quality method set_quality : GtkPrintOperationEnums.quality -> unit method get_n_copies : int method set_n_copies : int -> unit method get_number_up : int method set_number_up : int -> unit method get_resolution : int method set_resolution : int -> unit method get_scale : float method set_scale : float -> unit method get_print_pages : GtkPrintOperationEnums.print_pages method set_print_pages : GtkPrintOperationEnums.print_pages -> unit method get_page_set : GtkPrintOperationEnums.page_set method set_page_set : GtkPrintOperationEnums.page_set -> unit method get_default_source : string option method set_default_source : string option -> unit method get_media_type : string option method set_media_type : string option -> unit method get_dither : string option method set_dither : string option -> unit method get_finishings : string option method set_finishings : string option -> unit method get_output_bin : string option method set_output_bin : string option -> unit method to_file : string option -> bool end class print_settings : 'obj Gobject.obj -> object constraint 'obj = [>GtkPrintOperation_types.print_settings] inherit print_settings_skel end (*----------------------------------------------------------------------------------------------------*) class print_operation_signals : ([>GtkPrintOperation_types.print_operation] as 'a) Gobject.obj -> object inherit ['a] GObj.gobject_signals inherit OgtkPrintOperationProps.print_operation_sigs end class print_operation_skel : [>GtkPrintOperation_types.print_operation] Gobject.obj -> object (*inherit OgtkPrintOperationProps.print_operation_props*) method as_print_operation : GtkPrintOperation_types.print_operation Gobject.obj (*GtkPrintOperation*) method set_allow_async : bool -> unit method set_default_page_setup : page_setup option -> unit method get_default_page_setup : page_setup option method set_print_settings : print_settings option -> unit method get_print_settings : print_settings option method set_job_name : string option -> unit method set_n_pages : int -> unit method set_current_page : int -> unit method set_use_full_page : bool -> unit method set_unit : GtkPrintOperationEnums.gtk_unit -> unit method set_export_filename : string option -> unit method set_show_progress : bool -> unit method set_track_print_status : bool -> unit method set_custom_tab_label : string option -> unit method run : GtkPrintOperationEnums.action -> GWindow.window option -> GtkPrintOperationEnums.result method cancel : unit -> unit method get_status : GtkPrintOperationEnums.status method get_status_string : string option method is_finished : bool end (** @gtkdoc gtk GtkPrintOperation *) class print_operation : [>GtkPrintOperation_types.print_operation] Gobject.obj -> object inherit print_operation_skel method connect : print_operation_signals end (*----------------------------------------------------------------------------------------------------*) val print_operation : unit -> print_operation --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk --bg08WKrSYDhXBjb5--