Date: Tue, 3 Oct 2006 15:52:50 -0300 From: j.romildo at gmail.com To: caml-list at inria.fr Cc: lablgtk at math.nagoya-u.ac.jp Subject: Patch available for missing gtk_button_set_image in lablgtk Message-ID: <20061003185250.GB28749 at malaquias.gwiceb1> Mail-Followup-To: caml-list at inria.fr, lablgtk at math.nagoya-u.ac.jp References: <20061003133439.GA2593 at malaquias.gwiceb1> <20061003173755.GA28749 at malaquias.gwiceb1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20061003173755.GA28749 at malaquias.gwiceb1> Content-Type: multipart/mixed; boundary="EuxKj2iCbKjpUGkD" Content-Length: 3879 --EuxKj2iCbKjpUGkD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 03, 2006 at 02:37:55PM -0300, j.romildo@gmail.com wrote: > 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. I have reworked the patch and it is working now. So I will be glad if it as accepted upstream. Regards. Romildo --EuxKj2iCbKjpUGkD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="lablgtk-2.6.0-button_image.patch" Only in lablgtk-2.6.0.new: config.log Only in lablgtk-2.6.0.new: config.make Only in lablgtk-2.6.0.new: config.status 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 15:39:02.000000000 -0300 @@ -14,6 +14,11 @@ inherit button_props method private obj = obj method clicked () = Button.clicked obj + method image = + match Button.image obj with + | Some x -> Some (new widget x) + | None -> None + method set_image w = Button.set_image obj (as_widget w) 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 15:36:36.000000000 -0300 @@ -14,6 +14,8 @@ inherit GContainer.bin constraint 'a = [> button] val obj : 'a obj + method image : widget option + method set_image : 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 15:36:36.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 image : [>`button] obj -> (Gtk.widget Gtk.obj) option = "ml_gtk_button_get_image" + external set_image : [>`button] obj -> Gtk.widget Gtk.obj -> unit = "ml_gtk_button_set_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 15:36:36.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 */ --EuxKj2iCbKjpUGkD--