Commit 1bc1419e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/core/Makefile.am new files.

2001-12-12  Michael Natterer  <mitch@gimp.org>

	* app/core/Makefile.am
	* app/core/gimpimage-pick-color.[ch]: new files.

	gimp_image_pick_color() doesn't set the FG or BG color and doesn't
	touch the current palettte.

	* app/tools/gimpcolorpickertool.[ch]: removed the actual picking
	code, set the user_context's FG or BG color here.

	* app/gui/palette-editor.[ch]:
	s/palette_set_active_color/palette_editor_update_color/, don't set
	the FG and BG color here. The function is still #if 0'ed.

	* app/gui/toolbox.c: fixed WM resize hints in toolbox_style_set(),
	code cleanup.

	* app/tools/gimppainttool.[ch]: some cleanup before chopping.

	* app/tools/gimpsmudgetool.c: changed accordingly.

	* tools/pdbgen/pdb/misc_tools.pdb: removed the possibility to set
	the FG or BG color or add the picked color to the active palette
	bacause it doesn't belong here. Palette PDB wrappers are on the
	TODO anyway.

	* app/pdb/misc_tools_cmds.c
	* libgimp/gimpmisctools_pdb.[ch]: regenerated.

	* plug-ins/perl/examples/image_tile
	* plug-ins/perl/examples/logulator
	* plug-ins/script-fu/scripts/hsv-graph.scm
	* plug-ins/script-fu/scripts/title-header.scm: changed accordingly.
parent 30804a2d
2001-12-12 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
* app/core/gimpimage-pick-color.[ch]: new files.
gimp_image_pick_color() doesn't set the FG or BG color and doesn't
touch the current palettte.
* app/tools/gimpcolorpickertool.[ch]: removed the actual picking
code, set the user_context's FG or BG color here.
* app/gui/palette-editor.[ch]:
s/palette_set_active_color/palette_editor_update_color/, don't set
the FG and BG color here. The function is still #if 0'ed.
* app/gui/toolbox.c: fixed WM resize hints in toolbox_style_set(),
code cleanup.
* app/tools/gimppainttool.[ch]: some cleanup before chopping.
* app/tools/gimpsmudgetool.c: changed accordingly.
* tools/pdbgen/pdb/misc_tools.pdb: removed the possibility to set
the FG or BG color or add the picked color to the active palette
bacause it doesn't belong here. Palette PDB wrappers are on the
TODO anyway.
* app/pdb/misc_tools_cmds.c
* libgimp/gimpmisctools_pdb.[ch]: regenerated.
* plug-ins/perl/examples/image_tile
* plug-ins/perl/examples/logulator
* plug-ins/script-fu/scripts/hsv-graph.scm
* plug-ins/script-fu/scripts/title-header.scm: changed accordingly.
2001-12-12 Michael Natterer <mitch@gimp.org>
* docs/Wilber_Construction_Kit.xcf.gz: new version with additional
......
......@@ -96,6 +96,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
gimpimage-merge.h \
gimpimage-new.c \
gimpimage-new.h \
gimpimage-pick-color.c \
gimpimage-pick-color.h \
gimpimage-projection.c \
gimpimage-projection.h \
gimpimage-qmask.c \
......
This diff is collapsed.
/* 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 __GIMP_IMAGE_PICK_COLOR_H__
#define __GIMP_IMAGE_PICK_COLOR_H__
gboolean gimp_image_pick_color (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
gint x,
gint y,
gboolean sample_average,
gdouble average_radius,
GimpRGB *color,
GimpImageType *sample_type,
gint *color_index);
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */
......@@ -162,40 +162,32 @@ static GtkTargetEntry color_palette_target_table[] =
/* called from color_picker.h *********************************************/
void
palette_set_active_color (gint r,
gint g,
gint b,
gint state)
palette_editor_update_color (GimpContext *context,
const GimpRGB *color,
GimpUpdateColorState state)
{
#ifdef __GNUC__
#warning FIXME: palette_set_active_color()
#endif
#if 0
GimpPalette *palette;
GimpRGB color;
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (top_level_edit_palette)
{
GimpPalette *palette;
palette = gimp_context_get_palette (top_level_edit_palette->context);
if (palette)
{
switch (state)
{
case COLOR_NEW:
case GIMP_UPDATE_COLOR_STATE_NEW:
top_level_edit_palette->color = gimp_palette_add_entry (palette,
NULL,
&color);
color);
break;
case COLOR_UPDATE_NEW:
top_level_edit_palette->color->color = color;
case GIMP_UPDATE_COLOR_STATE_UPDATE_NEW:
top_level_edit_palette->color->color = *color;
gimp_data_dirty (GIMP_DATA (palette));
break;
......@@ -205,11 +197,6 @@ palette_set_active_color (gint r,
}
}
}
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_get_user_context (the_gimp), &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (gimp_get_user_context (the_gimp), &color);
#endif
}
......
......@@ -20,25 +20,26 @@
#define __PALETTE_EDITOR_H__
/* The states for updating a color in the palette via palette_set_* calls */
#define COLOR_NEW 0
#define COLOR_UPDATE_NEW 1
#define COLOR_UPDATE 2
typedef enum
{
GIMP_UPDATE_COLOR_STATE_NEW,
GIMP_UPDATE_COLOR_STATE_UPDATE_NEW,
GIMP_UPDATE_COLOR_STATE_UPDATE
} GimpUpdateColorState;
typedef struct _PaletteEditor PaletteEditor;
PaletteEditor * palette_editor_new (Gimp *gimp);
PaletteEditor * palette_editor_new (Gimp *gimp);
void palette_editor_set_palette (PaletteEditor *palette_editor,
GimpPalette *palette);
void palette_editor_free (PaletteEditor *palette_editor);
void palette_editor_set_palette (PaletteEditor *palette_editor,
GimpPalette *palette);
void palette_editor_free (PaletteEditor *palette_editor);
void palette_set_active_color (gint r,
gint g,
gint b,
gint state);
void palette_editor_update_color (GimpContext *context,
const GimpRGB *color,
GimpUpdateColorState state);
#endif /* __PALETTE_EDITOR_H__ */
......@@ -61,40 +61,48 @@
#include "pixmaps/swap.xpm"
/* local functions */
static void toolbox_tool_button_toggled (GtkWidget *widget,
gpointer data);
static gint toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static gint toolbox_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gint toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void toolbox_style_set_callback (GtkWidget *window,
GtkStyle *previous_style,
gpointer data);
static void toolbox_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void toolbox_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void toolbox_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
#define COLUMNS 3
#define ROWS 8
#define MARGIN 2
/* local function prototypes */
static void toolbox_create_tools (GtkWidget *wbox,
GimpContext *context);
static void toolbox_create_color_area (GtkWidget *wbox,
GimpContext *context);
static void toolbox_create_indicator_area (GtkWidget *wbox,
GimpContext *context);
static void toolbox_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data);
static void toolbox_tool_button_toggled (GtkWidget *widget,
gpointer data);
static gboolean toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static gboolean toolbox_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static void toolbox_style_set (GtkWidget *window,
GtkStyle *previous_style,
Gimp *gimp);
static void toolbox_drop_drawable (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void toolbox_drop_tool (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void toolbox_drop_buffer (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
/* local variables */
static GtkWidget * toolbox_shell = NULL;
static GtkWidget *toolbox_shell = NULL;
static GtkTargetEntry toolbox_target_table[] =
{
......@@ -109,204 +117,7 @@ static GtkTargetEntry toolbox_target_table[] =
};
static void
toolbox_tool_button_toggled (GtkWidget *widget,
gpointer data)
{
GimpToolInfo *tool_info;
tool_info = GIMP_TOOL_INFO (data);
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
}
static gint
toolbox_tool_button_press (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
gimp_dialog_factory_dialog_new (global_dialog_factory,
"gimp:tool-options-dialog", -1);
}
return FALSE;
}
static gint
toolbox_delete (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
app_exit (FALSE);
return TRUE;
}
static gint
toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
gimp_devices_check_change (GIMP (data), event);
return FALSE;
}
static void
create_indicator_area (GtkWidget *parent,
GimpContext *context)
{
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *ind_area;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
ind_area = indicator_area_create (context);
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
gtk_widget_show (ind_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
}
static void
create_color_area (GtkWidget *parent,
GimpContext *context)
{
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *col_area;
GdkPixmap *default_pixmap;
GdkBitmap *default_mask;
GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
if (! GTK_WIDGET_REALIZED (parent))
gtk_widget_realize (parent);
default_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
&default_mask,
&parent->style->bg[GTK_STATE_NORMAL],
default_xpm);
swap_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
&swap_mask,
&parent->style->bg[GTK_STATE_NORMAL],
swap_xpm);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (parent), frame,
TRUE, TRUE, TRUE, TRUE, TRUE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gimp_help_set_help_data (alignment, NULL, "#color_area");
col_area = color_area_create (context,
54, 42,
default_pixmap, default_mask,
swap_pixmap, swap_mask);
gtk_container_add (GTK_CONTAINER (alignment), col_area);
gimp_help_set_help_data
(col_area,
_("Foreground & background colors. The black "
"and white squares reset colors. The arrows swap colors. Double "
"click to select a color from a colorrequester."), NULL);
gtk_widget_show (col_area);
gtk_widget_show (alignment);
gtk_widget_show (frame);
}
static void
toolbox_tool_changed (GimpContext *context,
GimpToolInfo *tool_info,
gpointer data)
{
if (tool_info)
{
GtkWidget *toolbox_button;
toolbox_button =
g_object_get_data (G_OBJECT (tool_info), "toolbox_button");
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
{
g_signal_handlers_block_by_func (G_OBJECT (toolbox_button),
toolbox_tool_button_toggled,
tool_info);
gtk_widget_activate (toolbox_button);
g_signal_handlers_unblock_by_func (G_OBJECT (toolbox_button),
toolbox_tool_button_toggled,
tool_info);
}
}
}
static void
create_tools (GtkWidget *wbox,
GimpContext *context)
{
GList *list;
GSList *group = NULL;
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
list;
list = g_list_next (list))
{
GimpToolInfo *tool_info;
GtkWidget *button;
GtkWidget *image;
tool_info = (GimpToolInfo *) list->data;
button = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
FALSE, FALSE, FALSE, FALSE);
gtk_widget_show (button);
g_object_set_data (G_OBJECT (tool_info), "toolbox_button", button);
image = gtk_image_new_from_stock (tool_info->stock_id,
GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
g_signal_connect (G_OBJECT (button), "toggled",
G_CALLBACK (toolbox_tool_button_toggled),
tool_info);
g_signal_connect (G_OBJECT (button), "button_press_event",
G_CALLBACK (toolbox_tool_button_press),
tool_info);
gimp_help_set_help_data (button,
tool_info->help,
tool_info->help_data);
}
gtk_widget_show (wbox);
}
/* public functions */
GtkWidget *
toolbox_create (Gimp *gimp)
......@@ -332,8 +143,8 @@ toolbox_create (Gimp *gimp)
NULL);
g_signal_connect (G_OBJECT (window), "style_set",
G_CALLBACK (toolbox_style_set_callback),
NULL);
G_CALLBACK (toolbox_style_set),
gimp);
/* We need to know when the current device changes, so we can update
* the correct tool - to do this we connect to motion events.
......@@ -358,15 +169,14 @@ toolbox_create (Gimp *gimp)
gtk_widget_set_extension_events (window, GDK_EXTENSION_EVENTS_CURSOR);
}
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
gtk_widget_show (main_vbox);
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
gtk_box_pack_start (GTK_BOX (main_vbox), toolbox_factory->widget,
FALSE, TRUE, 0);
FALSE, FALSE, 0);
gtk_widget_show (toolbox_factory->widget);
gtk_window_add_accel_group (GTK_WINDOW (window), toolbox_factory->accel_group);
......@@ -384,17 +194,17 @@ toolbox_create (Gimp *gimp)
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
gtk_widget_show (wbox);
create_tools (wbox, context);
toolbox_create_tools (wbox, context);
g_signal_connect_object (G_OBJECT (context), "tool_changed",
G_CALLBACK (toolbox_tool_changed),
G_OBJECT (wbox),
0);
create_color_area (wbox, context);
toolbox_create_color_area (wbox, context);
if (gimprc.show_indicators)
create_indicator_area (wbox, context);
toolbox_create_indicator_area (wbox, context);
gtk_drag_dest_set (window,
GTK_DEST_DEFAULT_ALL,
......@@ -420,6 +230,8 @@ toolbox_create (Gimp *gimp)
toolbox_drop_buffer,
context);
toolbox_style_set (window, NULL, gimp);
gtk_widget_show (window);
toolbox_shell = window;
......@@ -435,25 +247,270 @@ toolbox_free (Gimp *gimp)
gtk_widget_destroy (toolbox_shell);
}
/* private functions */
static void
toolbox_create_tools (GtkWidget *wbox,
GimpContext *context)
{
GList *list;
GSList *group = NULL;
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
list;
list = g_list_next (list))
{
GimpToolInfo *tool_info;
GtkWidget *button;
GtkWidget *image;
tool_info = (GimpToolInfo *) list->data;
button = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
FALSE, FALSE, FALSE, FALSE);
gtk_widget_show (button);
g_object_set_data (G_OBJECT (tool_info), "toolbox-button", button);
image = gtk_image_new_from_stock (tool_info->stock_id,
GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
g_signal_connect (G_OBJECT (button), "toggled",
G_CALLBACK (toolbox_tool_button_toggled),
tool_info);
g_signal_connect (G_OBJECT (button), "button_press_event",
G_CALLBACK (toolbox_tool_button_press),
tool_info);
gimp_help_set_help_data (button,
tool_info->help,
tool_info->help_data);
}
}
static void
toolbox_create_color_area (GtkWidget *wbox,
GimpContext *context)
{
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *col_area;
GdkPixmap *default_pixmap;
GdkBitmap *default_mask;
GdkPixmap *swap_pixmap;
GdkBitmap *swap_mask;
if (! GTK_WIDGET_REALIZED (wbox))
gtk_widget_realize (wbox);
default_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
&default_mask,
&wbox->style->bg[GTK_STATE_NORMAL],
default_xpm);
swap_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
&swap_mask,
&wbox->style->bg[GTK_STATE_NORMAL],
swap_xpm);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (wbox), frame,
TRUE, TRUE, TRUE, TRUE, TRUE);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gimp_help_set_help_data (alignment, NULL, "#color_area");
col_area = color_area_create (context,
54, 42,
default_pixmap, default_mask,
swap_pixmap, swap_mask);
gtk_container_add (GTK_CONTAINER (alignment), col_area);