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: Patch available for missing gtk_button_set_image in lablgtk
Date: Tue, 3 Oct 2006 15:52:50 -0300	[thread overview]
Message-ID: <20061003185250.GB28749@malaquias.gwiceb1> (raw)
In-Reply-To: <20061003173755.GA28749@malaquias.gwiceb1>

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

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

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

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

  parent reply	other threads:[~2006-10-03 18:53 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
2006-10-03 18:08   ` [Caml-list] " Eric Cooper
2006-10-03 18:52   ` j.romildo [this message]
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=20061003185250.GB28749@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).