Date: Tue, 3 Oct 2006 14:37:55 -0300 From: j.romildo at gmail.com To: caml-list at inria.fr Cc: lablgtk at math.nagoya-u.ac.jp Subject: Re: missing gtk_button_set_image in lablgtk Message-ID: <20061003173755.GA28749 at malaquias.gwiceb1> Mail-Followup-To: caml-list at inria.fr, lablgtk at math.nagoya-u.ac.jp References: <20061003133439.GA2593 at malaquias.gwiceb1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20061003133439.GA2593 at malaquias.gwiceb1> Content-Type: multipart/mixed; boundary="vtzGhvizbBRQ85DL" Content-Length: 4224 --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 03, 2006 at 10:34:39AM -0300, j.romildo@gmail.com wrote: > Hello. > > I am using lablgtk to write the GUI for an application I am > developing. Currently I want to set the image associated with a button, > but it seems that lablgtk does not have support for the Gtk API function > gtk_button_set_image. So I am writing to request this support in the > next version of lablgtk. I have written the attached to add the methos image and set_image to class Button of gtklabel. But I did not get the types correct for the GtkWidget* from the Gtk+ API. Maybe someone has a clue on how those methods should be typed. In Gtk+ the functions have the prototypes: GtkWidget* gtk_button_get_image (GtkButton *button); void gtk_button_set_image (GtkButton *button, GtkWidget *image); The idea is to have two new methods in the class button (files gButton.mli and gButton.ml): image : option set_image : -> unit and two extern functions in module Button of file gtkButton.ml: external set_image : [>`button] obj -> -> unit = "ml_gtk_button_set_image" external image : [>`button] obj -> option = "ml_gtk_button_get_image" Any help is welcome. Romildo --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lablgtk-2.6.0-button_image.patch" diff -ur lablgtk-2.6.0.orig/src/gButton.ml lablgtk-2.6.0.new/src/gButton.ml --- lablgtk-2.6.0.orig/src/gButton.ml 2004-06-01 09:06:42.000000000 -0300 +++ lablgtk-2.6.0.new/src/gButton.ml 2006-10-03 12:19:56.000000000 -0300 @@ -14,6 +14,8 @@ inherit button_props method private obj = obj method clicked () = Button.clicked obj + method image = Button.image obj + method set_image image = Button.set_image obj image method grab_default () = set Widget.P.can_default obj true; set Widget.P.has_default obj true diff -ur lablgtk-2.6.0.orig/src/gButton.mli lablgtk-2.6.0.new/src/gButton.mli --- lablgtk-2.6.0.orig/src/gButton.mli 2004-07-05 07:05:47.000000000 -0300 +++ lablgtk-2.6.0.new/src/gButton.mli 2006-10-03 12:20:24.000000000 -0300 @@ -14,6 +14,8 @@ inherit GContainer.bin constraint 'a = [> button] val obj : 'a obj + method image : Gtk.widget option + method set_image : Gtk.widget -> unit method clicked : unit -> unit method set_relief : Tags.relief_style -> unit method relief : Tags.relief_style diff -ur lablgtk-2.6.0.orig/src/gtkButton.ml lablgtk-2.6.0.new/src/gtkButton.ml --- lablgtk-2.6.0.orig/src/gtkButton.ml 2004-05-09 11:39:14.000000000 -0300 +++ lablgtk-2.6.0.new/src/gtkButton.ml 2006-10-03 12:15:32.000000000 -0300 @@ -17,6 +17,8 @@ match stock with None -> label, None | Some id -> Some (GtkStock.convert_id id), Some true in make_params ~cont p ?label ?use_underline:use_mnemonic ?use_stock + external set_image : [>`button] obj -> Gtk.widget -> unit = "ml_gtk_button_set_image" + external image : [>`button] obj -> Gtk.widget option = "ml_gtk_button_get_image" external pressed : [>`button] obj -> unit = "ml_gtk_button_pressed" external released : [>`button] obj -> unit = "ml_gtk_button_released" external clicked : [>`button] obj -> unit = "ml_gtk_button_clicked" diff -ur lablgtk-2.6.0.orig/src/ml_gtkbutton.c lablgtk-2.6.0.new/src/ml_gtkbutton.c --- lablgtk-2.6.0.orig/src/ml_gtkbutton.c 2004-05-09 11:39:14.000000000 -0300 +++ lablgtk-2.6.0.new/src/ml_gtkbutton.c 2006-10-03 12:14:54.000000000 -0300 @@ -58,6 +58,16 @@ ML_2 (gtk_button_set_label, GtkButton_val, String_val, Unit) ML_1 (gtk_button_get_label, GtkButton_val, Val_optstring) */ +ML_2 (gtk_button_set_image, GtkButton_val, GtkWidget_val, Unit) +CAMLprim value ml_gtk_button_get_image (value b) +{ + CAMLparam1(b); + CAMLlocal1(res); + GtkWidget* tmp; + tmp = gtk_button_get_image(GtkButton_val(b)); + res = Val_option(tmp,Val_GtkWidget); + CAMLreturn(res); +} /* gtktogglebutton.h */ --vtzGhvizbBRQ85DL--