Patch available for missing gtk_button_set_image in lablgtk

j.romildo at gmail.com j.romildo at gmail.com
Tue Oct 3 20:52:50 CEST 2006


On Tue, Oct 03, 2006 at 02:37:55PM -0300, j.romildo at gmail.com wrote:
> On Tue, Oct 03, 2006 at 10:34:39AM -0300, j.romildo at 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
-------------- next part --------------
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 */
 


More information about the Lablgtk-list mailing list