From e8c74bb6e81c398a4a8ce41404e009babf2ea95e Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 25 Jan 2001 14:38:10 +0000 Subject: [PATCH] cleanup 2001-01-25 Sven Neumann * app/libgimp_glue.[ch]: cleanup * app/pdb/channel_cmds.c * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/app.pl * tools/pdbgen/lib.pl * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: fixed pdbgen code for color type. Seems to actually work now. * TODO.xml: updated * plug-ins/Makefile.am: disabled build of gimp-perl until it has catched up with the API changes in libgimp --- ChangeLog | 24 ++++++++++++++++++-- TODO.xml | 4 ++-- app/libgimp_glue.c | 26 ++++++++++----------- app/libgimp_glue.h | 4 ++-- app/pdb/channel_cmds.c | 13 +++++------ app/pdb/palette_cmds.c | 34 ++++++++++++---------------- app/pdb/tools_cmds.c | 11 ++++----- plug-ins/Makefile.am | 5 ++++ tools/pdbgen/app.pl | 3 ++- tools/pdbgen/lib.pl | 1 + tools/pdbgen/pdb.pl | 7 ++++-- tools/pdbgen/pdb/channel.pdb | 9 ++++---- tools/pdbgen/pdb/misc_tools.pdb | 9 +++----- tools/pdbgen/pdb/paint_tools.pdb | 9 +++----- tools/pdbgen/pdb/palette.pdb | 11 ++++----- tools/pdbgen/pdb/tools.pdb | 9 +++----- tools/pdbgen/pdb/transform_tools.pdb | 9 +++----- 17 files changed, 97 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d3011bf95..8dc12524c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2001-01-25 Sven Neumann + + * app/libgimp_glue.[ch]: cleanup + + * app/pdb/channel_cmds.c + * app/pdb/palette_cmds.c + * app/pdb/tools_cmds.c + * tools/pdbgen/app.pl + * tools/pdbgen/lib.pl + * tools/pdbgen/pdb.pl + * tools/pdbgen/pdb/channel.pdb + * tools/pdbgen/pdb/palette.pdb + * tools/pdbgen/pdb/tools.pdb: fixed pdbgen code for color type. Seems + to actually work now. + + * TODO.xml: updated + + * plug-ins/Makefile.am: disabled build of gimp-perl until it has + catched up with the API changes in libgimp + 2001-01-25 Sven Neumann * libgimpwidgets/gimpwidgets.c (gimp_mem_size_entry_new): merged fix @@ -9,8 +29,8 @@ * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/palette.pdb - * tools/pdbgen/pdb/tools.pdb: changed these with the help of - Yosh. PDB functions take GimpRGB as color type now. + * tools/pdbgen/pdb/tools.pdb: changed these with the help of Yosh. + PDB functions take GimpRGB as color type now. * app/plug_in.c * app/pdb/channel_cmds.c diff --git a/TODO.xml b/TODO.xml index 4805b663f2..47aa607c73 100644 --- a/TODO.xml +++ b/TODO.xml @@ -58,7 +58,7 @@ - + Unify color data types

@@ -173,7 +173,7 @@

LibGimp - + Restructure LibGimp

diff --git a/app/libgimp_glue.c b/app/libgimp_glue.c index 9d30f886d4..bc1a3a4b98 100644 --- a/app/libgimp_glue.c +++ b/app/libgimp_glue.c @@ -18,7 +18,7 @@ #include "config.h" -#include +#include #include "libgimpcolor/gimpcolor.h" @@ -29,41 +29,41 @@ gboolean -gimp_palette_set_foreground (const GimpRGB *rgb) +gimp_palette_set_foreground (const GimpRGB *color) { - g_return_val_if_fail (rgb != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); - gimp_context_set_foreground (NULL, rgb); + gimp_context_set_foreground (NULL, color); return TRUE; } gboolean -gimp_palette_get_foreground (GimpRGB *rgb) +gimp_palette_get_foreground (GimpRGB *color) { - g_return_val_if_fail (rgb != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); - gimp_context_get_foreground (NULL, rgb); + gimp_context_get_foreground (NULL, color); return TRUE; } gboolean -gimp_palette_set_background (const GimpRGB *rgb) +gimp_palette_set_background (const GimpRGB *color) { - g_return_val_if_fail (rgb != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); - gimp_context_set_background (NULL, rgb); + gimp_context_set_background (NULL, color); return TRUE; } gboolean -gimp_palette_get_background (GimpRGB *rgb) +gimp_palette_get_background (GimpRGB *color) { - g_return_val_if_fail (rgb != NULL, FALSE); + g_return_val_if_fail (color != NULL, FALSE); - gimp_context_get_background (NULL, rgb); + gimp_context_get_background (NULL, color); return TRUE; } diff --git a/app/libgimp_glue.h b/app/libgimp_glue.h index e2650cfcd0..8a2ba4d436 100644 --- a/app/libgimp_glue.h +++ b/app/libgimp_glue.h @@ -27,9 +27,9 @@ gboolean gimp_palette_set_foreground (const GimpRGB *color); -gboolean gimp_palette_get_foreground (GimpRGB *rgb); +gboolean gimp_palette_get_foreground (GimpRGB *color); gboolean gimp_palette_set_background (const GimpRGB *color); -gboolean gimp_palette_get_background (GimpRGB *rgb); +gboolean gimp_palette_get_background (GimpRGB *color); #endif /* __LIBGIMP_GLUE_H__ */ diff --git a/app/pdb/channel_cmds.c b/app/pdb/channel_cmds.c index fa5eec5cc0..81f8de4b9f 100644 --- a/app/pdb/channel_cmds.c +++ b/app/pdb/channel_cmds.c @@ -76,7 +76,7 @@ channel_new_invoker (Argument *args) gint32 height; gchar *name; gdouble opacity; - GimpRGB *color; + GimpRGB color; Channel *channel = NULL; gimage = pdb_id_to_image (args[0].value.pdb_int); @@ -99,11 +99,11 @@ channel_new_invoker (Argument *args) if (opacity < 0.0 || opacity > 100.0) success = FALSE; - color = (GimpRGB *) args[5].value.pdb_pointer; + color = args[5].value.pdb_color; if (success) { - GimpRGB rgb_color = *color; + GimpRGB rgb_color = color; rgb_color.a = opacity / 100.0; channel = channel_new (gimage, width, height, name, &rgb_color); @@ -693,7 +693,7 @@ channel_get_color_invoker (Argument *args) gboolean success = TRUE; Argument *return_args; Channel *channel; - GimpRGB *color = NULL; + GimpRGB color; channel = (GimpChannel *) gimp_drawable_get_by_ID (args[0].value.pdb_int); if (channel == NULL) @@ -701,14 +701,13 @@ channel_get_color_invoker (Argument *args) if (success) { - color = g_new (GimpRGB, 1); - *color = channel->color; + color = channel->color; } return_args = procedural_db_return_args (&channel_get_color_proc, success); if (success) - return_args[1].value.pdb_pointer = color; + return_args[1].value.pdb_color = color; return return_args; } diff --git a/app/pdb/palette_cmds.c b/app/pdb/palette_cmds.c index 880d7f5419..32943bd26f 100644 --- a/app/pdb/palette_cmds.c +++ b/app/pdb/palette_cmds.c @@ -56,13 +56,12 @@ static Argument * palette_get_foreground_invoker (Argument *args) { Argument *return_args; - GimpRGB *color; + GimpRGB color; - color = g_new (GimpRGB, 1); - gimp_context_get_foreground (NULL, color); + gimp_context_get_foreground (NULL, &color); return_args = procedural_db_return_args (&palette_get_foreground_proc, TRUE); - return_args[1].value.pdb_pointer = color; + return_args[1].value.pdb_color = color; return return_args; } @@ -96,13 +95,12 @@ static Argument * palette_get_background_invoker (Argument *args) { Argument *return_args; - GimpRGB *color; + GimpRGB color; - color = g_new (GimpRGB, 1); - gimp_context_get_background (NULL, color); + gimp_context_get_background (NULL, &color); return_args = procedural_db_return_args (&palette_get_background_proc, TRUE); - return_args[1].value.pdb_pointer = color; + return_args[1].value.pdb_color = color; return return_args; } @@ -135,14 +133,12 @@ static ProcRecord palette_get_background_proc = static Argument * palette_set_foreground_invoker (Argument *args) { - GimpRGB *color; - GimpRGB rgb_color; + GimpRGB color; - color = (GimpRGB *) args[0].value.pdb_pointer; + color = args[0].value.pdb_color; - rgb_color = *color; - rgb_color.a = 1.0; - gimp_context_set_foreground (NULL, &rgb_color); + gimp_rgb_set_alpha (&color, 1.0); + gimp_context_set_foreground (NULL, &color); return procedural_db_return_args (&palette_set_foreground_proc, TRUE); } @@ -175,14 +171,12 @@ static ProcRecord palette_set_foreground_proc = static Argument * palette_set_background_invoker (Argument *args) { - GimpRGB *color; - GimpRGB rgb_color; + GimpRGB color; - color = (GimpRGB *) args[0].value.pdb_pointer; + color = args[0].value.pdb_color; - rgb_color = *color; - rgb_color.a = 1.0; - gimp_context_set_background (NULL, &rgb_color); + gimp_rgb_set_alpha (&color, 1.0); + gimp_context_set_background (NULL, &color); return procedural_db_return_args (&palette_set_background_proc, TRUE); } diff --git a/app/pdb/tools_cmds.c b/app/pdb/tools_cmds.c index d56d6a7c97..4b8bf9e0fc 100644 --- a/app/pdb/tools_cmds.c +++ b/app/pdb/tools_cmds.c @@ -537,7 +537,7 @@ by_color_select_invoker (Argument *args) { gboolean success = TRUE; GimpDrawable *drawable; - GimpRGB *color; + GimpRGB color; gint32 threshold; gint32 operation; gboolean antialias; @@ -551,7 +551,7 @@ by_color_select_invoker (Argument *args) if (drawable == NULL) success = FALSE; - color = (GimpRGB *) args[1].value.pdb_pointer; + color = args[1].value.pdb_color; threshold = args[2].value.pdb_int; if (threshold < 0 || threshold > 255) @@ -812,7 +812,7 @@ color_picker_invoker (Argument *args) gboolean sample_average; gdouble average_radius; gboolean save_color; - GimpRGB *color = NULL; + GimpRGB color; gimage = pdb_id_to_image (args[0].value.pdb_int); if (gimage == NULL) @@ -846,8 +846,7 @@ color_picker_invoker (Argument *args) save_color); if (success) { - color = g_new (GimpRGB, 1); - gimp_rgba_set_uchar (color, + gimp_rgba_set_uchar (&color, col_value[RED_PIX], col_value[GREEN_PIX], col_value[BLUE_PIX], @@ -858,7 +857,7 @@ color_picker_invoker (Argument *args) return_args = procedural_db_return_args (&color_picker_proc, success); if (success) - return_args[1].value.pdb_pointer = color; + return_args[1].value.pdb_color = color; return return_args; } diff --git a/plug-ins/Makefile.am b/plug-ins/Makefile.am index 5cfb17fd03..1dbe765367 100644 --- a/plug-ins/Makefile.am +++ b/plug-ins/Makefile.am @@ -28,6 +28,11 @@ EXTRA_DIST = \ ## pygimp= ## endif +## gimp-perl is disabled for the moment +## until it has catched up with the API +## changes in libgimp +GIMP_PERL= + SUBDIRS = \ libgck \ dbbrowser \ diff --git a/tools/pdbgen/app.pl b/tools/pdbgen/app.pl index 78a73739df..5c0192d368 100644 --- a/tools/pdbgen/app.pl +++ b/tools/pdbgen/app.pl @@ -139,7 +139,8 @@ sub declare_args { my $type = exists $_->{no_id_lookup} ? 'gint32 ' : $arg->{type}; $result .= ' ' x 2 . $type . &arg_vname($_); - if (!exists $_->{no_init} && exists $_->{init}) { + if (!exists $_->{no_init} && exists $_->{init} && + !exists $arg->{struct}) { for ($arg->{type}) { /\*$/ && do { $result .= ' = NULL'; last }; /boolean/ && do { $result .= ' = FALSE'; last }; diff --git a/tools/pdbgen/lib.pl b/tools/pdbgen/lib.pl index 9ace072fc9..44ff5c4ca2 100644 --- a/tools/pdbgen/lib.pl +++ b/tools/pdbgen/lib.pl @@ -67,6 +67,7 @@ sub generate { my $rettype = $argtype->{type}; $rettype =~ s/int32/int/ unless exists $arg->{keep_size}; + $rettype .= '*' if exists $argtype->{struct}; return $rettype; } diff --git a/tools/pdbgen/pdb.pl b/tools/pdbgen/pdb.pl index 51eedf3c58..26db573550 100644 --- a/tools/pdbgen/pdb.pl +++ b/tools/pdbgen/pdb.pl @@ -31,8 +31,10 @@ package Gimp::CodeGen::pdb; floatarray => { name => 'FLOATARRAY' , type => 'gdouble *', array => 1 }, stringarray => { name => 'STRINGARRAY', type => 'gchar **' , array => 1 }, - color => { name => 'COLOR' , type => 'GimpRGB *', struct => 1 }, - + color => { name => 'COLOR' , + type => 'GimpRGB ', + headers => [ qw("libgimpcolor/gimpcolor.h") ], + struct => 1 }, display => { name => 'DISPLAY', type => 'GDisplay *', headers => [ qw("gdisplay.h") ], @@ -138,6 +140,7 @@ sub arg_ptype { elsif ($arg->{type} =~ /GimpUnit/) { 'int' } elsif ($arg->{type} =~ /int/) { 'int' } elsif ($arg->{type} =~ /double/) { 'float' } + elsif ($arg->{type} =~ /GimpRGB/) { 'color' } else { 'pointer' } }; } diff --git a/tools/pdbgen/pdb/channel.pdb b/tools/pdbgen/pdb/channel.pdb index 5729088963..625201b9ec 100644 --- a/tools/pdbgen/pdb/channel.pdb +++ b/tools/pdbgen/pdb/channel.pdb @@ -51,8 +51,7 @@ sub channel_get_prop_proc { $invoke{code} = <<'CODE' { - color = g_new (GimpRGB, 1); - *color = channel->color; + color = channel->color; } CODE } @@ -84,7 +83,7 @@ sub channel_set_prop_proc { %invoke = ( code => <<'CODE' { - GimpRGB rgb_color = *color; + GimpRGB rgb_color = color; rgb_color.a = channel->color.a; channel_set_color(channel, &rgb_color); @@ -159,7 +158,7 @@ HELP %invoke = ( code => <<'CODE' { - GimpRGB rgb_color = *color; + GimpRGB rgb_color = color; rgb_color.a = opacity / 100.0; channel = channel_new (gimage, width, height, name, &rgb_color); @@ -244,7 +243,7 @@ HELP $date = '1998'; CODE -@headers = qw("libgimpcolor/gimpcolor.h" "channel.h"); +@headers = qw("channel.h"); unshift @procs, qw(channel_new channel_copy channel_delete); %exports = (app => [@procs], lib => [@procs]); diff --git a/tools/pdbgen/pdb/misc_tools.pdb b/tools/pdbgen/pdb/misc_tools.pdb index a61311f931..e7330bdd5b 100644 --- a/tools/pdbgen/pdb/misc_tools.pdb +++ b/tools/pdbgen/pdb/misc_tools.pdb @@ -283,8 +283,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/by_color_select.h") ], + headers => [ qw("tools/by_color_select.h") ], vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ], code => <<'CODE' { @@ -413,8 +412,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/color_picker.h") ], + headers => [ qw("tools/color_picker.h") ], code => <<'CODE' { if (!sample_merged) @@ -427,8 +425,7 @@ HELP save_color); if (success) { - color = g_new (GimpRGB, 1); - gimp_rgba_set_uchar (color, + gimp_rgba_set_uchar (&color, col_value[RED_PIX], col_value[GREEN_PIX], col_value[BLUE_PIX], diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb index a61311f931..e7330bdd5b 100644 --- a/tools/pdbgen/pdb/paint_tools.pdb +++ b/tools/pdbgen/pdb/paint_tools.pdb @@ -283,8 +283,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/by_color_select.h") ], + headers => [ qw("tools/by_color_select.h") ], vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ], code => <<'CODE' { @@ -413,8 +412,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/color_picker.h") ], + headers => [ qw("tools/color_picker.h") ], code => <<'CODE' { if (!sample_merged) @@ -427,8 +425,7 @@ HELP save_color); if (success) { - color = g_new (GimpRGB, 1); - gimp_rgba_set_uchar (color, + gimp_rgba_set_uchar (&color, col_value[RED_PIX], col_value[GREEN_PIX], col_value[BLUE_PIX], diff --git a/tools/pdbgen/pdb/palette.pdb b/tools/pdbgen/pdb/palette.pdb index bec57e4bb0..e52b3b41dd 100644 --- a/tools/pdbgen/pdb/palette.pdb +++ b/tools/pdbgen/pdb/palette.pdb @@ -37,8 +37,7 @@ sub invoke_get { headers => [ qw("gimpimage.h" "gimpcontext.h") ], code => < [ qw("gimpimage.h") ], - vars => [ 'GimpRGB rgb_color' ], code => < [ qw("libgimpcolor/gimpcolor.h" - "tools/by_color_select.h") ], + headers => [ qw("tools/by_color_select.h") ], vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ], code => <<'CODE' { @@ -413,8 +412,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/color_picker.h") ], + headers => [ qw("tools/color_picker.h") ], code => <<'CODE' { if (!sample_merged) @@ -427,8 +425,7 @@ HELP save_color); if (success) { - color = g_new (GimpRGB, 1); - gimp_rgba_set_uchar (color, + gimp_rgba_set_uchar (&color, col_value[RED_PIX], col_value[GREEN_PIX], col_value[BLUE_PIX], diff --git a/tools/pdbgen/pdb/transform_tools.pdb b/tools/pdbgen/pdb/transform_tools.pdb index a61311f931..e7330bdd5b 100644 --- a/tools/pdbgen/pdb/transform_tools.pdb +++ b/tools/pdbgen/pdb/transform_tools.pdb @@ -283,8 +283,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/by_color_select.h") ], + headers => [ qw("tools/by_color_select.h") ], vars => [ 'GimpImage *gimage', 'guchar fixme[3]' ], code => <<'CODE' { @@ -413,8 +412,7 @@ HELP ); %invoke = ( - headers => [ qw("libgimpcolor/gimpcolor.h" - "tools/color_picker.h") ], + headers => [ qw("tools/color_picker.h") ], code => <<'CODE' { if (!sample_merged) @@ -427,8 +425,7 @@ HELP save_color); if (success) { - color = g_new (GimpRGB, 1); - gimp_rgba_set_uchar (color, + gimp_rgba_set_uchar (&color, col_value[RED_PIX], col_value[GREEN_PIX], col_value[BLUE_PIX],