Commit 5437f54a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

changed gimp_channel_get_color() to not return the color but take a second



2002-03-08  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel.[ch]: changed gimp_channel_get_color() to
	not return the color but take a second GimpRGB* parameter like all
	other _get_color() functions. Reordered some functions to make
	more sense, added some g_return_if_fail().

	* app/core/gimppalette.[ch]: added gimp_palette_[set|get]_n_columns()

	* app/gui/menus.c: added a "<PaletteEditor>" item factory.

	* app/gui/Makefile.am
	* app/gui/palette-editor-commands.[ch]: callbacks for the factory.

	* app/widgets/gimppaletteeditor.[ch]: removed the menu stuff here,
	added a spinbutton to adjust the number of columns.

	* app/gui/gradient-editor-commands.c: removed usage of "the_gimp".

	* app/widgets/gimpgradienteditor.c: minor cleanup.

	* app/widgets/gimpbrusheditor.h
	* app/widgets/gimpgradienteditor.h
	* app/widgets/gimppaletteeditor.h: forgot to declare the _get_type()
	functions publically.
parent 7453a660
2002-03-08 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.[ch]: changed gimp_channel_get_color() to
not return the color but take a second GimpRGB* parameter like all
other _get_color() functions. Reordered some functions to make
more sense, added some g_return_if_fail().
* app/core/gimppalette.[ch]: added gimp_palette_[set|get]_n_columns()
* app/gui/menus.c: added a "<PaletteEditor>" item factory.
* app/gui/Makefile.am
* app/gui/palette-editor-commands.[ch]: callbacks for the factory.
* app/widgets/gimppaletteeditor.[ch]: removed the menu stuff here,
added a spinbutton to adjust the number of columns.
* app/gui/gradient-editor-commands.c: removed usage of "the_gimp".
* app/widgets/gimpgradienteditor.c: minor cleanup.
* app/widgets/gimpbrusheditor.h
* app/widgets/gimpgradienteditor.h
* app/widgets/gimppaletteeditor.h: forgot to declare the _get_type()
functions publically.
2002-03-08 Sven Neumann <sven@gimp.org> 2002-03-08 Sven Neumann <sven@gimp.org>
Handle gtk-doc just like GTK+ does it now: Handle gtk-doc just like GTK+ does it now:
......
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "color-notebook.h" #include "color-notebook.h"
#include "gradient-editor-commands.h" #include "gradient-editor-commands.h"
#include "app_procs.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
...@@ -113,7 +111,7 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget, ...@@ -113,7 +111,7 @@ gradient_editor_load_left_cmd_callback (GtkWidget *widget,
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
user_context = gimp_get_user_context (the_gimp); user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
i = (gint) action; i = (gint) action;
...@@ -236,7 +234,7 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget, ...@@ -236,7 +234,7 @@ gradient_editor_load_right_cmd_callback (GtkWidget *widget,
gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data); gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
user_context = gimp_get_user_context (the_gimp); user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
i = (gint) action; i = (gint) action;
...@@ -947,9 +945,9 @@ gradient_editor_menu_update (GtkItemFactory *factory, ...@@ -947,9 +945,9 @@ gradient_editor_menu_update (GtkItemFactory *factory,
gboolean selection; gboolean selection;
gboolean delete; gboolean delete;
editor = (GimpGradientEditor *) data; editor = GIMP_GRADIENT_EDITOR (data);
user_context = gimp_get_user_context (the_gimp); user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
if (editor->control_sel_l->prev) if (editor->control_sel_l->prev)
left_seg = editor->control_sel_l->prev; left_seg = editor->control_sel_l->prev;
......
/* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimppalette.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpwidgets-utils.h"
#include "color-area.h"
#include "color-notebook.h"
#include "palette-editor-commands.h"
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
/* public functions */
void
palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor;
GimpPalette *palette;
GimpContext *user_context;
GimpRGB color;
editor = (GimpPaletteEditor *) gimp_widget_get_callback_context (widget);
if (! editor)
return;
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
if (! palette)
return;
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
if (active_color == FOREGROUND)
gimp_context_get_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (user_context, &color);
editor->color = gimp_palette_add_entry (palette, NULL, &color);
}
void
palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor;
GimpPalette *palette;
editor = (GimpPaletteEditor *) gimp_widget_get_callback_context (widget);
if (! editor)
return;
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
if (! (palette && editor->color))
return;
if (! editor->color_notebook)
{
editor->color_notebook =
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &editor->color->color,
palette_editor_color_notebook_callback,
editor,
FALSE,
FALSE);
editor->color_notebook_active = TRUE;
}
else
{
if (! editor->color_notebook_active)
{
color_notebook_show (editor->color_notebook);
editor->color_notebook_active = TRUE;
}
color_notebook_set_color (editor->color_notebook,
&editor->color->color);
}
}
void
palette_editor_delete_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor;
GimpPalette *palette;
editor = (GimpPaletteEditor *) gimp_widget_get_callback_context (widget);
if (! editor)
return;
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
if (! (palette && editor->color))
return;
gimp_palette_delete_entry (palette, editor->color);
}
void
palette_editor_menu_update (GtkItemFactory *factory,
gpointer data)
{
GimpPaletteEditor *editor;
editor = GIMP_PALETTE_EDITOR (data);
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/New Color", TRUE);
SET_SENSITIVE ("/Edit Color...", editor->color);
SET_SENSITIVE ("/Delete Color", editor->color);
#undef SET_SENSITIVE
}
/* private functions */
static void
palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
{
GimpPaletteEditor *editor;
GimpPalette *palette;
GimpContext *user_context;
editor = GIMP_PALETTE_EDITOR (data);
palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
user_context = gimp_get_user_context (GIMP_DATA_EDITOR (editor)->gimp);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
break;
case COLOR_NOTEBOOK_OK:
if (editor->color)
{
editor->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, color);
gimp_data_dirty (GIMP_DATA (palette));
}
/* Fallthrough */
case COLOR_NOTEBOOK_CANCEL:
if (editor->color_notebook_active)
{
color_notebook_hide (editor->color_notebook);
editor->color_notebook_active = FALSE;
}
}
}
/* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PALETTE_EDITOR_COMMANDS_H__
#define __PALETTE_EDITOR_COMMANDS_H__
void palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_delete_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_menu_update (GtkItemFactory *factory,
gpointer data);
#endif /* __PALETTE_EDITOR_COMMANDS_H__ */
...@@ -250,12 +250,14 @@ gimp_channel_set_color (GimpChannel *channel, ...@@ -250,12 +250,14 @@ gimp_channel_set_color (GimpChannel *channel,
} }
} }
const GimpRGB * void
gimp_channel_get_color (const GimpChannel *channel) gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color)
{ {
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL); g_return_if_fail (GIMP_IS_CHANNEL (channel));
g_return_if_fail (color != NULL);
return &channel->color; *color = channel->color;
} }
gdouble gdouble
...@@ -1195,6 +1197,28 @@ gimp_channel_feather (GimpChannel *mask, ...@@ -1195,6 +1197,28 @@ gimp_channel_feather (GimpChannel *mask,
mask->bounds_known = FALSE; mask->bounds_known = FALSE;
} }
void
gimp_channel_sharpen (GimpChannel *mask)
{
PixelRegion maskPR;
GimpLut *lut;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE);
lut = threshold_lut_new (0.5, 1);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline,
lut, 1, &maskPR);
gimp_lut_free (lut);
}
void void
gimp_channel_push_undo (GimpChannel *mask) gimp_channel_push_undo (GimpChannel *mask)
{ {
...@@ -1262,31 +1286,34 @@ gimp_channel_clear (GimpChannel *mask) ...@@ -1262,31 +1286,34 @@ gimp_channel_clear (GimpChannel *mask)
} }
void void
gimp_channel_invert (GimpChannel *mask) gimp_channel_all (GimpChannel *mask)
{ {
PixelRegion maskPR; PixelRegion maskPR;
GimpLut *lut; guchar bg = 255;
g_return_if_fail (GIMP_IS_CHANNEL (mask)); g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */ /* push the current channel onto the undo stack */
gimp_channel_push_undo (mask); gimp_channel_push_undo (mask);
/* clear the mask */
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles, pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0, 0, 0,
GIMP_DRAWABLE (mask)->width, GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE); GIMP_DRAWABLE (mask)->height, TRUE);
color_region (&maskPR, &bg);
lut = invert_lut_new (1); /* we know the bounds */
mask->bounds_known = TRUE;
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, mask->empty = FALSE;
lut, 1, &maskPR); mask->x1 = 0;
gimp_lut_free (lut); mask->y1 = 0;
mask->bounds_known = FALSE; mask->x2 = GIMP_DRAWABLE (mask)->width;
mask->y2 = GIMP_DRAWABLE (mask)->height;
} }
void void
gimp_channel_sharpen (GimpChannel *mask) gimp_channel_invert (GimpChannel *mask)
{ {
PixelRegion maskPR; PixelRegion maskPR;
GimpLut *lut; GimpLut *lut;
...@@ -1300,38 +1327,13 @@ gimp_channel_sharpen (GimpChannel *mask) ...@@ -1300,38 +1327,13 @@ gimp_channel_sharpen (GimpChannel *mask)
0, 0, 0, 0,
GIMP_DRAWABLE (mask)->width, GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE); GIMP_DRAWABLE (mask)->height, TRUE);
lut = threshold_lut_new (0.5, 1);
lut = invert_lut_new (1);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, pixel_regions_process_parallel ((p_func) gimp_lut_process_inline,
lut, 1, &maskPR); lut, 1, &maskPR);
gimp_lut_free (lut); gimp_lut_free (lut);
} mask->bounds_known = FALSE;
void
gimp_channel_all (GimpChannel *mask)
{
PixelRegion maskPR;
guchar bg = 255;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
/* clear the mask */
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
GIMP_DRAWABLE (mask)->width,
GIMP_DRAWABLE (mask)->height, TRUE);
color_region (&maskPR, &bg);
/* we know the bounds */
mask->bounds_known = TRUE;
mask->empty = FALSE;
mask->x1 = 0;
mask->y1 = 0;
mask->x2 = GIMP_DRAWABLE (mask)->width;
mask->y2 = GIMP_DRAWABLE (mask)->height;
} }
void void
...@@ -1601,6 +1603,7 @@ gimp_channel_layer_alpha (GimpChannel *mask, ...@@ -1601,6 +1603,7 @@ gimp_channel_layer_alpha (GimpChannel *mask,
g_return_if_fail (GIMP_IS_CHANNEL (mask)); g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GIMP_IS_LAYER (layer)); g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)));
/* push the current mask onto the undo stack */ /* push the current mask onto the undo stack */
gimp_channel_push_undo (mask); gimp_channel_push_undo (mask);
...@@ -1640,6 +1643,7 @@ gimp_channel_layer_mask (GimpChannel *mask, ...@@ -1640,6 +1643,7 @@ gimp_channel_layer_mask (GimpChannel *mask,
g_return_if_fail (GIMP_IS_CHANNEL (mask)); g_return_if_fail (GIMP_IS_CHANNEL (mask));
g_return_if_fail (GIMP_IS_LAYER (layer)); g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (gimp_layer_get_mask (layer));
/* push the current mask onto the undo stack */ /* push the current mask onto the undo stack */
gimp_channel_push_undo (mask); gimp_channel_push_undo (mask);
......
...@@ -80,7 +80,8 @@ gdouble gimp_channel_get_opacity (const GimpChannel *channel); ...@@ -80,7 +80,8 @@ gdouble gimp_channel_get_opacity (const GimpChannel *channel);
void gimp_channel_set_opacity (GimpChannel *channel, void gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity); gdouble opacity);
const GimpRGB * gimp_channel_get_color (const GimpChannel *channel); void gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color);
void gimp_channel_set_color (GimpChannel *channel, void gimp_channel_set_color (GimpChannel *channel,
const GimpRGB *color); const GimpRGB *color);
...@@ -100,6 +101,7 @@ void gimp_channel_resize (GimpChannel *channel, ...@@ -100,6 +101,7 @@ void gimp_channel_resize (GimpChannel *channel,
GimpChannel * gimp_channel_new_mask (GimpImage *gimage, GimpChannel * gimp_channel_new_mask (GimpImage *gimage,
gint width, gint width,
gint height); gint height);
gboolean gimp_channel_boundary (GimpChannel *mask, gboolean gimp_channel_boundary (GimpChannel *mask,
BoundSeg **segs_in, BoundSeg **segs_in,
BoundSeg **segs_out, BoundSeg **segs_out,
...@@ -118,6 +120,7 @@ gint gimp_channel_value (GimpChannel *mask, ...@@ -118,6 +120,7 @@ gint gimp_channel_value (GimpChannel *mask,
gint x, gint x,
gint y); gint y);
gboolean gimp_channel_is_empty (GimpChannel *mask); gboolean gimp_channel_is_empty (GimpChannel *mask);
void gimp_channel_add_segment (GimpChannel *mask, void gimp_channel_add_segment (GimpChannel *mask,
gint x, gint x,
gint y, gint y,
...@@ -146,16 +149,18 @@ void gimp_channel_combine_mask (GimpChannel *mask, ...@@ -146,16 +149,18 @@ void gimp_channel_combine_mask (GimpChannel *mask,
ChannelOps op, ChannelOps op,
gint off_x, gint off_x,
gint off_y); gint off_y);
void gimp_channel_feather (GimpChannel *mask, void gimp_channel_feather (GimpChannel *mask,
gdouble radius_x, gdouble radius_x,
gdouble radius_y, gdouble radius_y,
gboolean push_undo); gboolean push_undo);
void gimp_channel_sharpen (GimpChannel *mask);
void gimp_channel_push_undo (GimpChannel *mask); void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask); void gimp_channel_clear (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask);
void gimp_channel_sharpen (GimpChannel *mask);
void gimp_channel_all (GimpChannel *mask); void gimp_channel_all (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask);
void gimp_channel_border (GimpChannel *mask, void gimp_channel_border (GimpChannel *mask,
gint radius_x, gint radius_x,
......
...@@ -250,12 +250,14 @@ gimp_channel_set_color (GimpChannel *channel, ...@@ -250,12 +250,14 @@ gimp_channel_set_color (GimpChannel *channel,
} }
} }
const GimpRGB * void
gimp_channel_get_color (const GimpChannel *channel) gimp_channel_get_color (const GimpChannel *channel,
GimpRGB *color)
{ {
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), NULL); g_return_if_fail (GIMP_IS_CHANNEL (channel));