Version française
Home     About     Download     Resources     Contact us    
Browse thread
GtkHRuler and GtkVRuler properties on new widgets
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: j.romildo@g...
Subject: GtkHRuler and GtkVRuler properties on new widgets
Hi.

I am still working on the port of GtkDatabox to lablgtk. This time I am
having difficults with two properties of the GtkDatabox widget: "hruler"
and "vruler". Probably the difficults come from the fact that lablgtk
does not have one class for each of GtkRuler, GtkHRuler and GtkVRuler,
but only a single class: GRange.ruler.

So far I have the following definitions. Please, look where I have
annoted with the comment (* is this correct? *), and see if I am doing it
right.


(* gtkDatabox.props *)

   prefix "Gtk"

   header {
     type databox_t = [Gtk.drawing_area|`databox]
   }

   classes {
     GtkAdjustment "Gtk.adjustment obj"
     GtkHRuler "Gtk.ruler Gtk.obj"         (* is this correct? *)
     GtkVRuler "Gtk.ruler Gtk.obj"         (* is this correct? *)
   }

   class Databox type "databox_t Gtk.obj" set wrap wrapsig : DrawingArea {
     "enable-selection"   gboolean        : Read / Write
     "enable-zoom"        gboolean        : Read / Write
     "hadjustment"        GtkAdjustment   : Read / Write
     "vadjustment"        GtkAdjustment   : Read / Write
     "hruler"             GtkHRuler       : Read / Write     (* is this correct? *)
     "vruler"             GtkVRuler       : Read / Write     (* is this correct? *)

     signal selection_changed
   }


(* gDatabox.mli *)

   class databox_signals : 'a Gtk.obj ->
   object
     inherit GObj.widget_signals
     constraint 'a = [> GtkDatabox.databox]
     val obj : 'a Gtk.obj
     method selection_changed : callback:(unit -> unit) -> GtkSignal.id
   end
     
   class databox : 'a Gtk.obj ->
   object
     inherit GObj.widget
     constraint 'a = [> GtkDatabox.databox]
     val obj : 'a Gtk.obj
     method as_databox : GtkDatabox.databox Gtk.obj
     method enable_selection : bool
     method set_enable_selection : bool -> unit
     method enable_zoom : bool
     method set_enable_zoom : bool -> unit
     method hadjustment : GData.adjustment
     method set_hadjustment : GData.adjustment -> unit
     method vadjustment : GData.adjustment
     method set_vadjustment : GData.adjustment -> unit
     method hruler : GRange.ruler                          (* is this correct? *)
     method set_hruler : GRange.ruler -> unit              (* is this correct? *)
     method vruler : GRange.ruler                          (* is this correct? *)
     method set_vruler : GRange.ruler -> unit              (* is this correct? *)
     method event : GObj.event_ops
     method connect : databox_signals
   end

   val databox :
     ?packing:(GObj.widget -> unit) ->
     ?show:bool ->
     unit ->
     databox
      
(* gDatabox.ml *)

   open GObj

   open GtkDatabox
   open OgtkDataboxProps

   class databox_signals  (obj : [> GtkDatabox.databox] Gtk.obj) = object
     inherit GObj.widget_signals_impl obj
     inherit databox_sigs
   end

   class databox (obj : [> GtkDatabox.databox] Gtk.obj) = object
     inherit [_] GObj.widget_impl obj
     method as_databox : GtkDatabox.databox Gtk.obj =
        (obj :> GtkDatabox.databox Gobject.obj)
     inherit databox_props
     method event = new GObj.event_ops obj
     method connect = new databox_signals obj
   end

   let databox ?packing ?show () =
     let w = Databox.create [] in
       pack_return (new databox w) ~packing ~show

Compilation fails with the message:

   $ make opt
   [...]
   ocamlc.opt -I +lablGL  -w s -c gDatabox.ml
   The implementation gDatabox.ml does not match the interface gDatabox.cmi:
   Class declarations do not match:
     class databox :
       ([> GtkDataboxProps.databox_t ] as 'a) Gtk.obj ->
       object
         val obj : 'a Gtk.obj
         method add : graph -> bool
         method as_databox : GtkDatabox.databox Gtk.obj
         method as_widget : Gtk.widget Gtk.obj
         method coerce : GObj.widget
         method connect : databox_signals
         method destroy : unit -> unit
         method drag : GObj.drag_ops
         method enable_selection : bool
         method enable_zoom : bool
         method event : GObj.event_ops
         method get_oid : int
         method hadjustment : GData.adjustment
         method hruler : Gtk.ruler Gtk.obj
         method misc : GObj.misc_ops
         method private obj : 'a Gtk.obj
         method set_enable_selection : bool -> unit
         method set_enable_zoom : bool -> unit
         method set_hadjustment : GData.adjustment -> unit
         method set_hruler : Gtk.ruler Gtk.obj -> unit
         method set_vadjustment : GData.adjustment -> unit
         method set_vruler : Gtk.ruler Gtk.obj -> unit
         method vadjustment : GData.adjustment
         method vruler : Gtk.ruler Gtk.obj
       end
   does not match
     class databox :
       ([> GtkDatabox.databox ] as 'a) Gtk.obj ->
       object
         val obj : 'a Gtk.obj
         method add : graph -> bool
         method as_databox : GtkDatabox.databox Gtk.obj
         method as_widget : Gtk.widget Gtk.obj
         method coerce : GObj.widget
         method connect : databox_signals
         method destroy : unit -> unit
         method drag : GObj.drag_ops
         method enable_selection : bool
         method enable_zoom : bool
         method event : GObj.event_ops
         method get_oid : int
         method hadjustment : GData.adjustment
         method hruler : GRange.ruler
         method misc : GObj.misc_ops
         method set_enable_selection : bool -> unit
         method set_enable_zoom : bool -> unit
         method set_hadjustment : GData.adjustment -> unit
         method set_hruler : GRange.ruler -> unit
         method set_vadjustment : GData.adjustment -> unit
         method set_vruler : GRange.ruler -> unit
         method vadjustment : GData.adjustment
         method vruler : GRange.ruler
       end
   The method hruler has type Gtk.ruler Gtk.obj but is expected to have type
     GRange.ruler
   Type Gtk.ruler Gtk.obj = Gtk.ruler Gobject.obj is not compatible with type
     GRange.ruler =
       < as_widget : Gtk.widget Gtk.obj; coerce : GObj.widget;
         connect : GObj.widget_signals; destroy : unit -> unit;
         drag : GObj.drag_ops; event : GObj.event_ops; get_oid : int;
         lower : float; max_size : float; misc : GObj.misc_ops;
         position : float; set_lower : float -> unit;
         set_max_size : float -> unit;
         set_metric : Gtk.Tags.metric_type -> unit;
         set_position : float -> unit; set_upper : float -> unit;
         upper : float > 
   make: *** [gDatabox.cmo] Error 2
      
I will be grateful for any help on this problem.

Regards,

Romildo