caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: j.romildo@gmail.com
To: caml-list@inria.fr
Cc: lablgtk@math.nagoya-u.ac.jp
Subject: Re: missing gtk_button_set_image in lablgtk
Date: Tue, 3 Oct 2006 14:37:55 -0300	[thread overview]
Message-ID: <20061003173755.GA28749@malaquias.gwiceb1> (raw)
In-Reply-To: <20061003133439.GA2593@malaquias.gwiceb1>

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

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 : <lablgtk type equivalent to GtkWidget*> option
    
    set_image : <lablgtk type equivalent to GtkWidget*> -> unit

and two extern functions in module Button of file gtkButton.ml:

    external set_image : [>`button] obj ->
                         <type equivalent to GtkWidget*> -> unit
      = "ml_gtk_button_set_image"

    external image : [>`button] obj ->
                     <type equivalent to GtkWidget*> option
      = "ml_gtk_button_get_image"

Any help is welcome.

Romildo

[-- Attachment #2: lablgtk-2.6.0-button_image.patch --]
[-- Type: text/plain, Size: 2580 bytes --]

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 */
 

       reply	other threads:[~2006-10-03 17:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20061003133439.GA2593@malaquias.gwiceb1>
2006-10-03 17:37 ` j.romildo [this message]
2006-10-03 18:08   ` [Caml-list] " Eric Cooper
2006-10-03 18:52   ` Patch available for " j.romildo
2006-10-03 19:01   ` Olivier Andrieu
2006-10-03 19:12     ` [Caml-list] " Olivier Andrieu
2006-10-04  9:29       ` j.romildo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061003173755.GA28749@malaquias.gwiceb1 \
    --to=j.romildo@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=lablgtk@math.nagoya-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).