diff --git a/ChangeLog b/ChangeLog index a59c5be39b..1f65b16625 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sun Mar 1 20:28:54 MET 1998 Sven Neumann + + * app/internal_procs.c + * app/palette.c + * app/palette.h + * app/commands.c + * app/commands.h + * app/menus.c + * libgimp/gimppalette.c: + implemented gimp_palette_set_default_colors and + gimp_palette_swap_colors as pdb-calls and bound menu-entries and + keybindings to them (gimp-sven-980216-0.patch) + Sat Feb 28 22:05:15 PST 1998 Manish Singh * autoconfed the data stuff diff --git a/app/actions/help-commands.c b/app/actions/help-commands.c index 547888b668..bf8f89280f 100644 --- a/app/actions/help-commands.c +++ b/app/actions/help-commands.c @@ -2278,6 +2278,20 @@ layers_mask_select_cmd_callback (GtkWidget *widget, gdisplays_flush (); } +void +tools_default_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_set_default_colors (); +} + +void +tools_swap_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_swap_colors (); +} + void tools_select_cmd_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/actions/help-commands.h b/app/actions/help-commands.h index e200e4b8d4..5c79260fbd 100644 --- a/app/actions/help-commands.h +++ b/app/actions/help-commands.h @@ -77,6 +77,8 @@ void layers_merge_cmd_callback (GtkWidget *, gpointer); void layers_flatten_cmd_callback (GtkWidget *, gpointer); void layers_alpha_select_cmd_callback (GtkWidget *, gpointer); void layers_mask_select_cmd_callback (GtkWidget *, gpointer); +void tools_default_colors_cmd_callback (GtkWidget *, gpointer); +void tools_swap_colors_cmd_callback (GtkWidget *, gpointer); void tools_select_cmd_callback (GtkWidget *, gpointer); void filters_repeat_cmd_callback (GtkWidget *, gpointer); void dialogs_brushes_cmd_callback (GtkWidget *, gpointer); diff --git a/app/color_area.c b/app/color_area.c index 26cdce9a09..3a1bc0e782 100644 --- a/app/color_area.c +++ b/app/color_area.c @@ -1,4 +1,4 @@ -/* The GIMP -- an image manipulation program +#/* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * This program is free software; you can redistribute it and/or modify @@ -205,8 +205,6 @@ color_area_events (GtkWidget *widget, { GdkEventButton *bevent; int target; - unsigned char fg_r, fg_g, fg_b; - unsigned char bg_r, bg_g, bg_b; switch (event->type) { @@ -239,18 +237,11 @@ color_area_events (GtkWidget *widget, } break; case SWAP_AREA: - palette_get_foreground (&fg_r, &fg_g, &fg_b); - palette_get_background (&bg_r, &bg_g, &bg_b); - - palette_set_foreground (bg_r, bg_g, bg_b); - palette_set_background (fg_r, fg_g, fg_b); - + palette_swap_colors(); color_area_draw (); break; case DEF_AREA: - palette_set_foreground (0, 0, 0); - palette_set_background (255, 255, 255); - + palette_set_default_colors(); color_area_draw (); break; } diff --git a/app/commands.c b/app/commands.c index 547888b668..bf8f89280f 100644 --- a/app/commands.c +++ b/app/commands.c @@ -2278,6 +2278,20 @@ layers_mask_select_cmd_callback (GtkWidget *widget, gdisplays_flush (); } +void +tools_default_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_set_default_colors (); +} + +void +tools_swap_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_swap_colors (); +} + void tools_select_cmd_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/commands.h b/app/commands.h index e200e4b8d4..5c79260fbd 100644 --- a/app/commands.h +++ b/app/commands.h @@ -77,6 +77,8 @@ void layers_merge_cmd_callback (GtkWidget *, gpointer); void layers_flatten_cmd_callback (GtkWidget *, gpointer); void layers_alpha_select_cmd_callback (GtkWidget *, gpointer); void layers_mask_select_cmd_callback (GtkWidget *, gpointer); +void tools_default_colors_cmd_callback (GtkWidget *, gpointer); +void tools_swap_colors_cmd_callback (GtkWidget *, gpointer); void tools_select_cmd_callback (GtkWidget *, gpointer); void filters_repeat_cmd_callback (GtkWidget *, gpointer); void dialogs_brushes_cmd_callback (GtkWidget *, gpointer); diff --git a/app/gui/color-area.c b/app/gui/color-area.c index 26cdce9a09..3a1bc0e782 100644 --- a/app/gui/color-area.c +++ b/app/gui/color-area.c @@ -1,4 +1,4 @@ -/* The GIMP -- an image manipulation program +#/* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * This program is free software; you can redistribute it and/or modify @@ -205,8 +205,6 @@ color_area_events (GtkWidget *widget, { GdkEventButton *bevent; int target; - unsigned char fg_r, fg_g, fg_b; - unsigned char bg_r, bg_g, bg_b; switch (event->type) { @@ -239,18 +237,11 @@ color_area_events (GtkWidget *widget, } break; case SWAP_AREA: - palette_get_foreground (&fg_r, &fg_g, &fg_b); - palette_get_background (&bg_r, &bg_g, &bg_b); - - palette_set_foreground (bg_r, bg_g, bg_b); - palette_set_background (fg_r, fg_g, fg_b); - + palette_swap_colors(); color_area_draw (); break; case DEF_AREA: - palette_set_foreground (0, 0, 0); - palette_set_background (255, 255, 255); - + palette_set_default_colors(); color_area_draw (); break; } diff --git a/app/gui/commands.c b/app/gui/commands.c index 547888b668..bf8f89280f 100644 --- a/app/gui/commands.c +++ b/app/gui/commands.c @@ -2278,6 +2278,20 @@ layers_mask_select_cmd_callback (GtkWidget *widget, gdisplays_flush (); } +void +tools_default_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_set_default_colors (); +} + +void +tools_swap_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_swap_colors (); +} + void tools_select_cmd_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/gui/commands.h b/app/gui/commands.h index e200e4b8d4..5c79260fbd 100644 --- a/app/gui/commands.h +++ b/app/gui/commands.h @@ -77,6 +77,8 @@ void layers_merge_cmd_callback (GtkWidget *, gpointer); void layers_flatten_cmd_callback (GtkWidget *, gpointer); void layers_alpha_select_cmd_callback (GtkWidget *, gpointer); void layers_mask_select_cmd_callback (GtkWidget *, gpointer); +void tools_default_colors_cmd_callback (GtkWidget *, gpointer); +void tools_swap_colors_cmd_callback (GtkWidget *, gpointer); void tools_select_cmd_callback (GtkWidget *, gpointer); void filters_repeat_cmd_callback (GtkWidget *, gpointer); void dialogs_brushes_cmd_callback (GtkWidget *, gpointer); diff --git a/app/gui/help-commands.c b/app/gui/help-commands.c index 547888b668..bf8f89280f 100644 --- a/app/gui/help-commands.c +++ b/app/gui/help-commands.c @@ -2278,6 +2278,20 @@ layers_mask_select_cmd_callback (GtkWidget *widget, gdisplays_flush (); } +void +tools_default_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_set_default_colors (); +} + +void +tools_swap_colors_cmd_callback (GtkWidget *widget, + gpointer client_data) +{ + palette_swap_colors (); +} + void tools_select_cmd_callback (GtkWidget *widget, gpointer client_data) diff --git a/app/gui/help-commands.h b/app/gui/help-commands.h index e200e4b8d4..5c79260fbd 100644 --- a/app/gui/help-commands.h +++ b/app/gui/help-commands.h @@ -77,6 +77,8 @@ void layers_merge_cmd_callback (GtkWidget *, gpointer); void layers_flatten_cmd_callback (GtkWidget *, gpointer); void layers_alpha_select_cmd_callback (GtkWidget *, gpointer); void layers_mask_select_cmd_callback (GtkWidget *, gpointer); +void tools_default_colors_cmd_callback (GtkWidget *, gpointer); +void tools_swap_colors_cmd_callback (GtkWidget *, gpointer); void tools_select_cmd_callback (GtkWidget *, gpointer); void filters_repeat_cmd_callback (GtkWidget *, gpointer); void dialogs_brushes_cmd_callback (GtkWidget *, gpointer); diff --git a/app/gui/menus.c b/app/gui/menus.c index 2481683ea8..f8444e52a4 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -177,6 +177,8 @@ static GtkMenuEntry menu_items[] = { "/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH }, { "/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE }, { "/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE }, + { "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL}, + { "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL}, { "/Tools/", NULL, NULL, NULL }, { "/Tools/Toolbox", NULL, toolbox_raise_callback, NULL }, diff --git a/app/gui/palette-editor.c b/app/gui/palette-editor.c index b372934f47..31580e3744 100644 --- a/app/gui/palette-editor.c +++ b/app/gui/palette-editor.c @@ -357,6 +357,27 @@ palette_set_background (int r, } } +void +palette_set_default_colors (void) +{ + palette_set_foreground (0, 0, 0); + palette_set_background (255, 255, 255); +} + + +void +palette_swap_colors (void) +{ + unsigned char fg_r, fg_g, fg_b; + unsigned char bg_r, bg_g, bg_b; + + palette_get_foreground (&fg_r, &fg_g, &fg_b); + palette_get_background (&bg_r, &bg_g, &bg_b); + + palette_set_foreground (bg_r, bg_g, bg_b); + palette_set_background (fg_r, fg_g, fg_b); +} + void palette_init_palettes (void) { @@ -1616,3 +1637,81 @@ ProcRecord palette_set_background_proc = /* Exec method */ { { palette_set_background_invoker } }, }; + +/*******************************/ +/* PALETTE_SET_DEFAULT_COLORS */ + +static Argument * +palette_set_default_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_set_default_colors (); + + return procedural_db_return_args (&palette_set_background_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_set_default_colors_proc = +{ + "gimp_palette_set_default_colors", + "Set the current GIMP foreground and background colors to black and white", + "This procedure sets the current GIMP foreground and background colors to their initial default values, black and white.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_set_default_colors_invoker } }, +}; + +/************************/ +/* PALETTE_SWAP_COLORS */ + +static Argument * +palette_swap_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_swap_colors (); + + return procedural_db_return_args (&palette_swap_colors_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_swap_colors_proc = +{ + "gimp_palette_swap_colors", + "Swap the current GIMP foreground and background colors", + "This procedure swaps the current GIMP foreground and background colors, so that the new foreground color becomes the old background color and vice versa.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_swap_colors_invoker } }, +}; diff --git a/app/gui/palette-editor.h b/app/gui/palette-editor.h index 82574cb8ce..a36ec48a7d 100644 --- a/app/gui/palette-editor.h +++ b/app/gui/palette-editor.h @@ -38,6 +38,8 @@ void palette_get_background (unsigned char *, unsigned char *, unsigned char *); void palette_set_foreground (int, int, int); void palette_set_background (int, int, int); void palette_set_active_color (int, int, int, int); +void palette_set_default_colors (void); +void palette_swap_colors (void); struct _PaletteEntries { char *name; @@ -64,5 +66,7 @@ extern ProcRecord palette_get_foreground_proc; extern ProcRecord palette_get_background_proc; extern ProcRecord palette_set_foreground_proc; extern ProcRecord palette_set_background_proc; +extern ProcRecord palette_set_default_colors_proc; +extern ProcRecord palette_swap_colors_proc; #endif /* __PALETTE_H__ */ diff --git a/app/internal_procs.c b/app/internal_procs.c index b64667c0b1..8fa1f56ef0 100644 --- a/app/internal_procs.c +++ b/app/internal_procs.c @@ -294,6 +294,8 @@ internal_procs_init () procedural_db_register (&palette_get_background_proc); pcount++; procedural_db_register (&palette_set_foreground_proc); pcount++; procedural_db_register (&palette_set_background_proc); pcount++; + procedural_db_register (&palette_set_default_colors_proc); pcount++; + procedural_db_register (&palette_swap_colors_proc); pcount++; app_init_update_status(NULL, "Interface procedures", pcount/total_pcount); diff --git a/app/menus.c b/app/menus.c index 2481683ea8..f8444e52a4 100644 --- a/app/menus.c +++ b/app/menus.c @@ -177,6 +177,8 @@ static GtkMenuEntry menu_items[] = { "/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH }, { "/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE }, { "/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE }, + { "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL}, + { "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL}, { "/Tools/", NULL, NULL, NULL }, { "/Tools/Toolbox", NULL, toolbox_raise_callback, NULL }, diff --git a/app/menus/menus.c b/app/menus/menus.c index 2481683ea8..f8444e52a4 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -177,6 +177,8 @@ static GtkMenuEntry menu_items[] = { "/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH }, { "/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE }, { "/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE }, + { "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL}, + { "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL}, { "/Tools/", NULL, NULL, NULL }, { "/Tools/Toolbox", NULL, toolbox_raise_callback, NULL }, diff --git a/app/palette.c b/app/palette.c index b372934f47..31580e3744 100644 --- a/app/palette.c +++ b/app/palette.c @@ -357,6 +357,27 @@ palette_set_background (int r, } } +void +palette_set_default_colors (void) +{ + palette_set_foreground (0, 0, 0); + palette_set_background (255, 255, 255); +} + + +void +palette_swap_colors (void) +{ + unsigned char fg_r, fg_g, fg_b; + unsigned char bg_r, bg_g, bg_b; + + palette_get_foreground (&fg_r, &fg_g, &fg_b); + palette_get_background (&bg_r, &bg_g, &bg_b); + + palette_set_foreground (bg_r, bg_g, bg_b); + palette_set_background (fg_r, fg_g, fg_b); +} + void palette_init_palettes (void) { @@ -1616,3 +1637,81 @@ ProcRecord palette_set_background_proc = /* Exec method */ { { palette_set_background_invoker } }, }; + +/*******************************/ +/* PALETTE_SET_DEFAULT_COLORS */ + +static Argument * +palette_set_default_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_set_default_colors (); + + return procedural_db_return_args (&palette_set_background_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_set_default_colors_proc = +{ + "gimp_palette_set_default_colors", + "Set the current GIMP foreground and background colors to black and white", + "This procedure sets the current GIMP foreground and background colors to their initial default values, black and white.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_set_default_colors_invoker } }, +}; + +/************************/ +/* PALETTE_SWAP_COLORS */ + +static Argument * +palette_swap_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_swap_colors (); + + return procedural_db_return_args (&palette_swap_colors_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_swap_colors_proc = +{ + "gimp_palette_swap_colors", + "Swap the current GIMP foreground and background colors", + "This procedure swaps the current GIMP foreground and background colors, so that the new foreground color becomes the old background color and vice versa.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_swap_colors_invoker } }, +}; diff --git a/app/palette.h b/app/palette.h index 82574cb8ce..a36ec48a7d 100644 --- a/app/palette.h +++ b/app/palette.h @@ -38,6 +38,8 @@ void palette_get_background (unsigned char *, unsigned char *, unsigned char *); void palette_set_foreground (int, int, int); void palette_set_background (int, int, int); void palette_set_active_color (int, int, int, int); +void palette_set_default_colors (void); +void palette_swap_colors (void); struct _PaletteEntries { char *name; @@ -64,5 +66,7 @@ extern ProcRecord palette_get_foreground_proc; extern ProcRecord palette_get_background_proc; extern ProcRecord palette_set_foreground_proc; extern ProcRecord palette_set_background_proc; +extern ProcRecord palette_set_default_colors_proc; +extern ProcRecord palette_swap_colors_proc; #endif /* __PALETTE_H__ */ diff --git a/app/widgets/gimpitemfactory.c b/app/widgets/gimpitemfactory.c index 2481683ea8..f8444e52a4 100644 --- a/app/widgets/gimpitemfactory.c +++ b/app/widgets/gimpitemfactory.c @@ -177,6 +177,8 @@ static GtkMenuEntry menu_items[] = { "/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH }, { "/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE }, { "/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE }, + { "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL}, + { "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL}, { "/Tools/", NULL, NULL, NULL }, { "/Tools/Toolbox", NULL, toolbox_raise_callback, NULL }, diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c index b372934f47..31580e3744 100644 --- a/app/widgets/gimppaletteeditor.c +++ b/app/widgets/gimppaletteeditor.c @@ -357,6 +357,27 @@ palette_set_background (int r, } } +void +palette_set_default_colors (void) +{ + palette_set_foreground (0, 0, 0); + palette_set_background (255, 255, 255); +} + + +void +palette_swap_colors (void) +{ + unsigned char fg_r, fg_g, fg_b; + unsigned char bg_r, bg_g, bg_b; + + palette_get_foreground (&fg_r, &fg_g, &fg_b); + palette_get_background (&bg_r, &bg_g, &bg_b); + + palette_set_foreground (bg_r, bg_g, bg_b); + palette_set_background (fg_r, fg_g, fg_b); +} + void palette_init_palettes (void) { @@ -1616,3 +1637,81 @@ ProcRecord palette_set_background_proc = /* Exec method */ { { palette_set_background_invoker } }, }; + +/*******************************/ +/* PALETTE_SET_DEFAULT_COLORS */ + +static Argument * +palette_set_default_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_set_default_colors (); + + return procedural_db_return_args (&palette_set_background_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_set_default_colors_proc = +{ + "gimp_palette_set_default_colors", + "Set the current GIMP foreground and background colors to black and white", + "This procedure sets the current GIMP foreground and background colors to their initial default values, black and white.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_set_default_colors_invoker } }, +}; + +/************************/ +/* PALETTE_SWAP_COLORS */ + +static Argument * +palette_swap_colors_invoker (Argument *args) +{ + int success; + + success = TRUE; + if (success) + palette_swap_colors (); + + return procedural_db_return_args (&palette_swap_colors_proc, success); +} + +/* The procedure definition */ + +ProcRecord palette_swap_colors_proc = +{ + "gimp_palette_swap_colors", + "Swap the current GIMP foreground and background colors", + "This procedure swaps the current GIMP foreground and background colors, so that the new foreground color becomes the old background color and vice versa.", + "Spencer Kimball & Peter Mattis", + "Spencer Kimball & Peter Mattis", + "1995-1996", + PDB_INTERNAL, + + /* Input arguments */ + 0, + NULL, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { palette_swap_colors_invoker } }, +}; diff --git a/app/widgets/gimppaletteeditor.h b/app/widgets/gimppaletteeditor.h index 82574cb8ce..a36ec48a7d 100644 --- a/app/widgets/gimppaletteeditor.h +++ b/app/widgets/gimppaletteeditor.h @@ -38,6 +38,8 @@ void palette_get_background (unsigned char *, unsigned char *, unsigned char *); void palette_set_foreground (int, int, int); void palette_set_background (int, int, int); void palette_set_active_color (int, int, int, int); +void palette_set_default_colors (void); +void palette_swap_colors (void); struct _PaletteEntries { char *name; @@ -64,5 +66,7 @@ extern ProcRecord palette_get_foreground_proc; extern ProcRecord palette_get_background_proc; extern ProcRecord palette_set_foreground_proc; extern ProcRecord palette_set_background_proc; +extern ProcRecord palette_set_default_colors_proc; +extern ProcRecord palette_swap_colors_proc; #endif /* __PALETTE_H__ */ diff --git a/app/widgets/gimptoolbox-color-area.c b/app/widgets/gimptoolbox-color-area.c index 26cdce9a09..3a1bc0e782 100644 --- a/app/widgets/gimptoolbox-color-area.c +++ b/app/widgets/gimptoolbox-color-area.c @@ -1,4 +1,4 @@ -/* The GIMP -- an image manipulation program +#/* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * This program is free software; you can redistribute it and/or modify @@ -205,8 +205,6 @@ color_area_events (GtkWidget *widget, { GdkEventButton *bevent; int target; - unsigned char fg_r, fg_g, fg_b; - unsigned char bg_r, bg_g, bg_b; switch (event->type) { @@ -239,18 +237,11 @@ color_area_events (GtkWidget *widget, } break; case SWAP_AREA: - palette_get_foreground (&fg_r, &fg_g, &fg_b); - palette_get_background (&bg_r, &bg_g, &bg_b); - - palette_set_foreground (bg_r, bg_g, bg_b); - palette_set_background (fg_r, fg_g, fg_b); - + palette_swap_colors(); color_area_draw (); break; case DEF_AREA: - palette_set_foreground (0, 0, 0); - palette_set_background (255, 255, 255); - + palette_set_default_colors(); color_area_draw (); break; } diff --git a/libgimp/gimppalette.c b/libgimp/gimppalette.c index e7be8ebc5c..f94cc356b1 100644 --- a/libgimp/gimppalette.c +++ b/libgimp/gimppalette.c @@ -103,3 +103,29 @@ gimp_palette_set_foreground (guchar red, gimp_destroy_params (return_vals, nreturn_vals); } + +void +gimp_palette_set_default_colors (void) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_palette_set_default_colors", + &nreturn_vals, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_palette_swap_colors (void) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_palette_swap_colors", + &nreturn_vals, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} diff --git a/libgimp/gimppalette_pdb.c b/libgimp/gimppalette_pdb.c index e7be8ebc5c..f94cc356b1 100644 --- a/libgimp/gimppalette_pdb.c +++ b/libgimp/gimppalette_pdb.c @@ -103,3 +103,29 @@ gimp_palette_set_foreground (guchar red, gimp_destroy_params (return_vals, nreturn_vals); } + +void +gimp_palette_set_default_colors (void) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_palette_set_default_colors", + &nreturn_vals, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_palette_swap_colors (void) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_palette_swap_colors", + &nreturn_vals, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +}