Commit c456ba93 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

app/[all tool related files] app/commands.c app/disp_callbacks.c

1999-06-26  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/[all tool related files]
	* app/commands.c
	* app/disp_callbacks.c
	* app/gdisplay.c
	* app/gimage.c
	* app/interface.c: hopefully fixed the bugs that appeared with my
	last fix. And some more changes...

	- Slightly changed the conditions which cause the tools to be
	  re-initialized on button_press events and the global
	  initialisation functions.
	- The dialog tools now explicitly set tool->gdisp_ptr so they can
	  be properly hidden on display deletion.
	- Create the crop info dialog only once and avoid ugly redraw bugs
	  by blocking the sizeentries' signal when initializing them.
	- Standardized the tools_new_<tool>() functions. They are
	  scheduled to be moved to a common constructor in tools.c
	- Various stuff...
parent a7a46648
1999-06-26 Sven Neumann <sven@gimp.org>
1999-06-26 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/[all tool related files]
* app/commands.c
* app/disp_callbacks.c
* app/gdisplay.c
* app/gimage.c
* app/interface.c: hopefully fixed the bugs that appeared with my
last fix. And some more changes...
- Slightly changed the conditions which cause the tools to be
re-initialized on button_press events and the global
initialisation functions.
- The dialog tools now explicitly set tool->gdisp_ptr so they can
be properly hidden on display deletion.
- Create the crop info dialog only once and avoid ugly redraw bugs
by blocking the sizeentries' signal when initializing them.
- Standardized the tools_new_<tool>() functions. They are
scheduled to be moved to a common constructor in tools.c
- Various stuff...
1999-06-26 Sven Neumann <sven@gimp.org>
Michael Natterer <mitschel@cs.tu-berlin.de>
* app/app_procs.c
......@@ -12,8 +33,9 @@ Fri Jun 25 22:09:04 BST 1999 Andy Thomas <alt@gimp.org>
dialog and then the busy cursors stuff tried to change
the cursor on a dialog that has been removed. (ie
the LCP dialog should be unregistered when it is destroyed)
Small previews in LCP dialog image menu do not get created when no preview preference is set.
Small previews in LCP dialog image menu do not get created when
no preview preference is set.
Thu Jun 24 18:13:35 PDT 1999 Manish Singh <yosh@gimp.org>
......
......@@ -976,20 +976,30 @@ tools_select_cmd_callback (GtkWidget *widget,
GDisplay * gdisp;
gdisp = gdisplay_active ();
/* Activate the approriate widget.
/* Activate the appropriate widget.
* Implicitly calls tools_select()
*/
gtk_widget_activate (tool_info[callback_action].tool_widget);
/* Paranoia */
active_tool->drawable = NULL;
/* Complete the initialisation by doing the same stuff
* tools_initialize() does after it did what tools_select() does
*/
if (tool_info[callback_action].init_func && gdisp)
if (tool_info[callback_action].init_func)
{
(* tool_info[callback_action].init_func) (gdisp);
active_tool->gdisp_ptr = gdisp;
active_tool->drawable = gimage_active_drawable (gdisp->gimage);
}
/* setting the gdisp_ptr here is a HACK to allow the tools'
* dialog windows being hidden if the tool was selected from
* a tear-off-menu and there was no mouse click in the display
* before deleting it
*/
active_tool->gdisp_ptr = gdisp;
}
void
......
......@@ -34,10 +34,10 @@
#include "libgimp/gimpintl.h"
/* The maximum amount of pressure that can be exerted */
#define MAX_PRESSURE 0.075
#define MAX_PRESSURE 0.075
#define OFF 0
#define ON 1
#define OFF 0
#define ON 1
/* the airbrush structures */
......
......@@ -157,6 +157,8 @@ color_balance_button_press (Tool *tool,
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
}
......@@ -204,13 +206,7 @@ color_balance_control (Tool *tool,
case HALT:
if (color_balance_dialog)
{
active_tool->preserve = TRUE;
image_map_abort (color_balance_dialog->image_map);
active_tool->preserve = FALSE;
color_balance_dialog->image_map = NULL;
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
}
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
break;
default:
......@@ -237,18 +233,20 @@ tools_new_color_balance ()
tool->type = COLOR_BALANCE;
tool->state = INACTIVE;
tool->scroll_lock = 1; /* Disallow scrolling */
tool->private = (void *) private;
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = color_balance_button_press;
tool->button_release_func = color_balance_button_release;
tool->motion_func = color_balance_motion;
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
tool->arrow_keys_func = standard_arrow_keys_func;
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool;
}
......@@ -294,22 +292,18 @@ color_balance_initialize (GDisplay *gdisp)
color_balance_dialog->yellow_blue[i] = 0.0;
}
color_balance_dialog->drawable = gimage_active_drawable (gdisp->gimage);
color_balance_dialog->image_map = image_map_create (gdisp, color_balance_dialog->drawable);
color_balance_dialog->image_map =
image_map_create (gdisp, color_balance_dialog->drawable);
color_balance_update (color_balance_dialog, ALL);
}
/****************************/
/* Select by Color dialog */
/****************************/
/**************************/
/* Color Balance dialog */
/**************************/
/* the action area structure */
static ActionAreaItem action_items[] =
{
{ N_("OK"), color_balance_ok_callback, NULL, NULL },
{ N_("Cancel"), color_balance_cancel_callback, NULL, NULL }
};
static ColorBalanceDialog *
color_balance_new_dialog ()
{
......@@ -326,13 +320,21 @@ color_balance_new_dialog ()
GtkObject *data;
GSList *group = NULL;
int i;
char *appl_mode_names[3] =
static ActionAreaItem action_items[] =
{
{ N_("OK"), color_balance_ok_callback, NULL, NULL },
{ N_("Cancel"), color_balance_cancel_callback, NULL, NULL }
};
char *appl_mode_names[] =
{
N_("Shadows"),
N_("Midtones"),
N_("Highlights")
};
ActionCallback appl_mode_callbacks[3] =
ActionCallback appl_mode_callbacks[] =
{
color_balance_shadows_callback,
color_balance_midtones_callback,
......@@ -657,6 +659,9 @@ color_balance_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
cbd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......@@ -684,10 +689,13 @@ color_balance_cancel_callback (GtkWidget *widget,
active_tool->preserve = TRUE;
image_map_abort (cbd->image_map);
active_tool->preserve = FALSE;
gdisplays_flush ();
cbd->image_map = NULL;
}
cbd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static void
......
......@@ -177,12 +177,17 @@ curves_button_press (Tool *tool,
gdisp = gdisp_ptr;
drawable = gimage_active_drawable (gdisp->gimage);
tool->gdisp_ptr = gdisp;
if (drawable != tool->drawable)
{
active_tool->preserve = TRUE;
image_map_abort (curves_dialog->image_map);
active_tool->preserve = FALSE;
curves_dialog->drawable = tool->drawable = drawable;
tool->drawable = drawable;
curves_dialog->drawable = drawable;
curves_dialog->color = drawable_color (drawable);
curves_dialog->image_map = image_map_create (gdisp, drawable);
}
......@@ -380,6 +385,10 @@ tools_new_curves ()
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = curves_button_press;
tool->button_release_func = curves_button_release;
tool->motion_func = curves_motion;
......@@ -388,8 +397,6 @@ tools_new_curves ()
tool->cursor_update_func = curves_cursor_update;
tool->control_func = curves_control;
tool->preserve = FALSE;
return tool;
}
......@@ -471,12 +478,11 @@ curves_initialize (GDisplay *gdisp)
gtk_widget_set_sensitive( channel_items[i].widget, FALSE);
/* set the current selection */
gtk_option_menu_set_history ( GTK_OPTION_MENU (curves_dialog->channel_menu), 0);
gtk_option_menu_set_history (GTK_OPTION_MENU (curves_dialog->channel_menu), 0);
if (!GTK_WIDGET_VISIBLE (curves_dialog->shell))
gtk_widget_show (curves_dialog->shell);
curves_update (curves_dialog, GRAPH | DRAW);
}
......@@ -1174,6 +1180,9 @@ curves_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
cd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static void
......@@ -1192,9 +1201,12 @@ curves_cancel_callback (GtkWidget *widget,
image_map_abort (cd->image_map);
active_tool->preserve = FALSE;
cd->image_map = NULL;
gdisplays_flush ();
cd->image_map = NULL;
}
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......
......@@ -237,6 +237,8 @@ hue_saturation_button_press (Tool *tool,
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
}
......@@ -310,6 +312,10 @@ tools_new_hue_saturation ()
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = hue_saturation_button_press;
tool->button_release_func = hue_saturation_button_release;
tool->motion_func = hue_saturation_motion;
......@@ -317,9 +323,6 @@ tools_new_hue_saturation ()
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = hue_saturation_cursor_update;
tool->control_func = hue_saturation_control;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool;
}
......@@ -744,6 +747,9 @@ hue_saturation_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
hsd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......@@ -772,9 +778,12 @@ hue_saturation_cancel_callback (GtkWidget *widget,
image_map_abort (hsd->image_map);
active_tool->preserve = FALSE;
hsd->image_map = NULL;
gdisplays_flush ();
hsd->image_map = NULL;
}
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static void
......
......@@ -166,6 +166,8 @@ threshold_button_press (Tool *tool,
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
}
......@@ -246,6 +248,10 @@ tools_new_threshold ()
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = threshold_button_press;
tool->button_release_func = threshold_button_release;
tool->motion_func = threshold_motion;
......@@ -254,8 +260,6 @@ tools_new_threshold ()
tool->cursor_update_func = threshold_cursor_update;
tool->control_func = threshold_control;
tool->preserve = FALSE;
return tool;
}
......@@ -291,16 +295,18 @@ threshold_initialize (GDisplay *gdisp)
threshold_dialog->drawable = gimage_active_drawable (gdisp->gimage);
threshold_dialog->color = drawable_color (threshold_dialog->drawable);
threshold_dialog->image_map = image_map_create (gdisp, threshold_dialog->drawable);
threshold_dialog->image_map =
image_map_create (gdisp, threshold_dialog->drawable);
gimp_histogram_calculate_drawable(threshold_dialog->hist,
threshold_dialog->drawable);
gimp_histogram_calculate_drawable (threshold_dialog->hist,
threshold_dialog->drawable);
histogram_widget_update (threshold_dialog->histogram,
threshold_dialog->hist);
histogram_widget_range (threshold_dialog->histogram,
threshold_dialog->low_threshold,
threshold_dialog->high_threshold);
if (threshold_dialog->preview)
threshold_preview (threshold_dialog);
}
......@@ -453,6 +459,9 @@ threshold_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
td->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......@@ -484,6 +493,9 @@ threshold_cancel_callback (GtkWidget *widget,
td->image_map = NULL;
gdisplays_flush ();
}
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static void
......
......@@ -202,7 +202,7 @@ Tool*
tools_new_bezier_select ()
{
Tool * tool;
BezierSelect * bezier_sel;
BezierSelect * private;
/* The tool options */
if (! bezier_options)
......@@ -213,19 +213,23 @@ tools_new_bezier_select ()
}
tool = g_malloc (sizeof (Tool));
private = g_malloc (sizeof (BezierSelect));
bezier_sel = g_new0(BezierSelect,1);
bezier_sel->num_points = 0;
bezier_sel->mask = NULL;
bezier_sel->core = draw_core_new (bezier_select_draw);
bezier_select_reset (bezier_sel);
private->num_points = 0;
private->mask = NULL;
private->core = draw_core_new (bezier_select_draw);
bezier_select_reset (private);
tool->type = BEZIER_SELECT;
tool->state = INACTIVE;
tool->scroll_lock = 1; /* Do not allow scrolling */
tool->auto_snap_to = TRUE;
tool->private = (void *) bezier_sel;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = bezier_select_button_press;
tool->button_release_func = bezier_select_button_release;
tool->motion_func = bezier_select_motion;
......@@ -233,13 +237,12 @@ tools_new_bezier_select ()
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = bezier_select_cursor_update;
tool->control_func = bezier_select_control;
tool->preserve = FALSE;
curCore = bezier_sel->core;
curSel = bezier_sel;
curCore = private->core;
curSel = private;
curTool = tool;
paths_new_bezier_select_tool();
paths_new_bezier_select_tool ();
return tool;
}
......@@ -834,6 +837,9 @@ bezier_select_button_press (Tool *tool,
int halfwidth, dummy;
gdisp = (GDisplay *) gdisp_ptr;
tool->drawable = gimage_active_drawable (gdisp->gimage);
bezier_sel = tool->private;
grab_pointer = 0;
......
......@@ -1741,7 +1741,11 @@ tools_new_blend ()
tool->state = INACTIVE;
tool->scroll_lock = 1; /* Disallow scrolling */
tool->auto_snap_to = TRUE;
tool->private = private;
tool->private = (void *) private;
tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = blend_button_press;
tool->button_release_func = blend_button_release;
......@@ -1750,7 +1754,6 @@ tools_new_blend ()
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = blend_cursor_update;
tool->control_func = blend_control;
tool->preserve = TRUE;
return tool;
}
......
......@@ -112,6 +112,8 @@ brightness_contrast_button_press (Tool *tool,
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
}
......@@ -186,6 +188,10 @@ tools_new_brightness_contrast ()
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = brightness_contrast_button_press;
tool->button_release_func = brightness_contrast_button_release;
tool->motion_func = brightness_contrast_motion;
......@@ -193,9 +199,6 @@ tools_new_brightness_contrast ()
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = brightness_contrast_cursor_update;
tool->control_func = brightness_contrast_control;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool;
}
......@@ -236,8 +239,8 @@ brightness_contrast_initialize (GDisplay *gdisp)
brightness_contrast_dialog->contrast = 0.0;
brightness_contrast_dialog->drawable = gimage_active_drawable (gdisp->gimage);
brightness_contrast_dialog->image_map = image_map_create (gdisp,
brightness_contrast_dialog->drawable);
brightness_contrast_dialog->image_map =
image_map_create (gdisp, brightness_contrast_dialog->drawable);
brightness_contrast_update (brightness_contrast_dialog, ALL);
}
......@@ -454,6 +457,9 @@ brightness_contrast_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
bcd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......@@ -485,6 +491,9 @@ brightness_contrast_cancel_callback (GtkWidget *widget,
bcd->image_map = NULL;
gdisplays_flush ();
}
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static void
......
......@@ -611,7 +611,11 @@ tools_new_bucket_fill (void)
tool->state = INACTIVE;
tool->scroll_lock = 1; /* Disallow scrolling */
tool->auto_snap_to = TRUE;
tool->private = private;
tool->private = (void *) private;
tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = bucket_fill_button_press;
tool->button_release_func = bucket_fill_button_release;
......@@ -620,7 +624,6 @@ tools_new_bucket_fill (void)
tool->modifier_key_func = bucket_fill_modifier_key_func;
tool->cursor_update_func = bucket_fill_cursor_update;
tool->control_func = bucket_fill_control;
tool->preserve = TRUE;
return tool;
}
......
......@@ -483,6 +483,10 @@ tools_new_by_color_select ()
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = TRUE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = by_color_select_button_press;
tool->button_release_func = by_color_select_button_release;
tool->motion_func = by_color_select_motion;
......@@ -490,9 +494,6 @@ tools_new_by_color_select ()
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = by_color_select_cursor_update;
tool->control_func = by_color_select_control;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->preserve = TRUE;
return tool;
}
......
......@@ -157,6 +157,8 @@ color_balance_button_press (Tool *tool,
GDisplay *gdisp;
gdisp = gdisp_ptr;
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
}
......@@ -204,13 +206,7 @@ color_balance_control (Tool *tool,
case HALT:
if (color_balance_dialog)
{
active_tool->preserve = TRUE;
image_map_abort (color_balance_dialog->image_map);
active_tool->preserve = FALSE;
color_balance_dialog->image_map = NULL;
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
}
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
break;
default:
......@@ -237,18 +233,20 @@ tools_new_color_balance ()
tool->type = COLOR_BALANCE;
tool->state = INACTIVE;
tool->scroll_lock = 1; /* Disallow scrolling */
tool->private = (void *) private;
tool->auto_snap_to = TRUE;
tool->private = (void *) private;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->button_press_func = color_balance_button_press;
tool->button_release_func = color_balance_button_release;
tool->motion_func = color_balance_motion;
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
tool->arrow_keys_func = standard_arrow_keys_func;
tool->modifier_key_func = standard_modifier_key_func;
tool->cursor_update_func = color_balance_cursor_update;
tool->control_func = color_balance_control;
tool->preserve = FALSE;
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
return tool;
}
......@@ -294,22 +292,18 @@ color_balance_initialize (GDisplay *gdisp)
color_balance_dialog->yellow_blue[i] = 0.0;
}
color_balance_dialog->drawable = gimage_active_drawable (gdisp->gimage);
color_balance_dialog->image_map = image_map_create (gdisp, color_balance_dialog->drawable);
color_balance_dialog->image_map =
image_map_create (gdisp, color_balance_dialog->drawable);
color_balance_update (color_balance_dialog, ALL);
}
/****************************/
/* Select by Color dialog */
/****************************/
/**************************/
/* Color Balance dialog */
/**************************/
/* the action area structure */
static ActionAreaItem action_items[] =
{
{ N_("OK"), color_balance_ok_callback, NULL, NULL },
{ N_("Cancel"), color_balance_cancel_callback, NULL, NULL }
};
static ColorBalanceDialog *
color_balance_new_dialog ()
{
......@@ -326,13 +320,21 @@ color_balance_new_dialog ()
GtkObject *data;
GSList *group = NULL;
int i;
char *appl_mode_names[3] =
static ActionAreaItem action_items[] =
{
{ N_("OK"), color_balance_ok_callback, NULL, NULL },
{ N_("Cancel"), color_balance_cancel_callback, NULL, NULL }
};
char *appl_mode_names[] =
{
N_("Shadows"),
N_("Midtones"),
N_("Highlights")
};
ActionCallback appl_mode_callbacks[3] =
ActionCallback appl_mode_callbacks[] =
{
color_balance_shadows_callback,
color_balance_midtones_callback,
......@@ -657,6 +659,9 @@ color_balance_ok_callback (GtkWidget *widget,
active_tool->preserve = FALSE;
cbd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
}
static gint
......@@ -684,10 +689,13 @@ color_balance_cancel_callback (GtkWidget *widget,
active_tool->preserve = TRUE;
image_map_abort (