From c69a597c3c304f8680a9e3beddcd11fb2828fd6f Mon Sep 17 00:00:00 2001
From: Per Hedbor <ph@opera.com>
Date: Fri, 19 Nov 1999 23:46:33 +0100
Subject: [PATCH] Since it is now possible to have optional last arguments, we
 can now use COMPLEX_FUNCTION instead of a manually generated FUNCTION()

Rev: src/post_modules/GTK/source/gtkimage.pre:1.3
Rev: src/post_modules/GTK/source/gtkpixmap.pre:1.3
---
 src/post_modules/GTK/source/gtkimage.pre  | 55 +++--------------------
 src/post_modules/GTK/source/gtkpixmap.pre | 44 ++----------------
 2 files changed, 9 insertions(+), 90 deletions(-)

diff --git a/src/post_modules/GTK/source/gtkimage.pre b/src/post_modules/GTK/source/gtkimage.pre
index 92d5638778..71273c1814 100644
--- a/src/post_modules/GTK/source/gtkimage.pre
+++ b/src/post_modules/GTK/source/gtkimage.pre
@@ -5,40 +5,15 @@ PROGRAM(image);
 //<p>
 // IMG: GTK.Image( GDK.Image(0)->set(Image.image(200,200)->test() ) );
 INHERIT(misc);
-FUNCTION(create, "function(object,object|void:void)");
-ARGS(GDK.Image,GDK.Bitmap|void);
+
+COMPLEX_FUNCTION(create, GdkImage, ?GdkBitmap);
 NAME_ARGS(image,mask);
 // You can skip the mask. The mask is used to mask the drawing of the image
 // on it's background. It will not make the container transparent, though.
 // Use shape_combine_mask on the container with the mask for that.
-{
-  struct object *a, *b;
-  GdkImage *img;
-  GdkBitmap *mask = NULL;
-  if(THIS->obj) error("GTK.Image->create() can only be called once.\n");
-  if(args == 2)
-    get_all_args("GDK.Image", args, "%o%o", &a, &b);
-  else
-  {
-    get_all_args("GDK.Image", args, "%o", &a);
-    b = 0;
-  }
- add_ref(a);
-  img = get_gdkobject( a,Image );
-  if(b)
-  {
-    mask = get_gdkobject( b,Bitmap );
- add_ref(b);
-  }
-  THIS->obj = GTK_OBJECT( gtk_image_new( img, mask ) );
-  pgtk__init_this_object();
-  my_pop_n_elems(args);
-}
 
-FUNCTION(set, "function(object,object|void:object)")
-ARGS(GDK.Image,GDK.Bitmap|void);
+COMPLEX_FUNCTION(set, GdkImage, ?GdkBitmap);
 NAME_ARGS(image,mask);
-RETURNS(GTK.Image);
 // Args: GDK.Image and GDK.Bitmap, respectively.
 // You can skip the mask. The mask is used to mask the drawing of the image
 // on it's background. It will not make the container transparent, though.
@@ -46,29 +21,11 @@ RETURNS(GTK.Image);
 // <p>
 // There is no need to call 'set' with the same GDK.Image again if
 // you have modified the image. You must, however, use -&gt;queue_draw()
-// to redraw the image. Otherwise the old contens would be show until
-// it an refresh is done for any other reason.
-{
-  struct object *a, *b;
-  GdkImage *img;
-  GdkBitmap *mask = NULL;
-  if(args == 2)
-    get_all_args("GDK.Image", args, "%o%o", &a, &b);
-  else
-  {
-    get_all_args("GDK.Image", args, "%o", &a);
-    b = 0;
-  }
-  
-  img = get_gdkobject( a,Image );
-  if(mask)
-    mask = get_gdkobject( a,Bitmap );
-  gtk_image_set( GTK_IMAGE( THIS->obj ), img, mask );
-  RETURN_THIS();
-}
+// to redraw the image. Otherwise the old contens will be shown until
+// an refresh of the widget is done for any other reason.
 
 FUNCTION(get, "function(void:mapping)");
-// returns ([ "image":GDK.Image img, "mask":GDK.Bitmap m ])
+// returns ([ "image":GDK.Image img, "mask":GDK.Bitmap mask ])
 {
   GdkImage *v;
   GdkBitmap *m;
diff --git a/src/post_modules/GTK/source/gtkpixmap.pre b/src/post_modules/GTK/source/gtkpixmap.pre
index e1185c112e..0f1a11faa2 100644
--- a/src/post_modules/GTK/source/gtkpixmap.pre
+++ b/src/post_modules/GTK/source/gtkpixmap.pre
@@ -20,52 +20,14 @@ INHERIT(misc);
 // IMG: GTK.Pixmap( GDK.Pixmap( Image.image(100,100)->test()) )
 // IMG: GTK.Pixmap( GDK.Pixmap( Image.image(100,100)->test()), GDK.Bitmap(Image.image(100,100,255,255,255)->box(10,10,80,80, 0,0,0) ))
 
-FUNCTION(create, "function(object,object|void:void)");
-ARGS(GDK.Pixmap,GDK.Bitmap);
+COMPLEX_FUNCTION(create, GdkPixmap, ?GdkBitmap);
 NAME_ARGS(pixmap,mask);
-// Create a new pixmap object.
-{
-  struct object *a, *b;
-  GdkPixmap *img;
-  GdkBitmap *mask = NULL;
-  if(args == 2)
-    get_all_args("GDK.Pixmap", args, "%o%o", &a, &b);
-  else
-  {
-    get_all_args("GDK.Pixmap", args, "%o", &a);
-    b = 0;
-  }
-  img = get_gdkobject( a, Pixmap );
-  if(b)
-    mask = get_gdkobject( b, Bitmap );
-  THIS->obj = GTK_OBJECT( gtk_pixmap_new( img, mask ) );
-  pgtk__init_this_object();
-  my_pop_n_elems(args);
-}
+// Create a new pixmap object, and sets the image and the mask.
 
-FUNCTION(set, "function(object,object|void:object)")
+COMPLEX_FUNCTION(set, GdkPixmap, ?GdkBitmap);
 ARGS(GDK.Pixmap,GDK.Bitmap);
 NAME_ARGS(pixmap,mask);
 // Sets the GDK.Pixmap image and the optinal GDK.Bitmap mask
-{
-  struct object *a, *b;
-  GdkPixmap *img;
-  GdkBitmap *mask = NULL;
-  if(args == 2)
-    get_all_args("GDK.Pixmap->set", args, "%o%o", &a, &b);
-  else
-  {
-    get_all_args("GDK.Pixmap->set", args, "%o", &a);
-    b = 0;
-  }
-  img = get_gdkobject( a, Pixmap );
-  if(b)
-    mask = get_gdkobject( b, Bitmap );
-  /* TODO: Free refs for pixmap & mask! */
-  gtk_pixmap_set( GTK_PIXMAP(THIS->obj), img, mask );
-
-  RETURN_THIS();
-}
 
 CLASSMEMBER(build_insensitive, int);
 
-- 
GitLab