Commit 9ffed655 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed the query boxes.

2000-02-10  Michael Natterer  <mitch@gimp.org>

	* app/gimpui.[ch]: removed the query boxes.

	* po-libgimp/POTFILES.in
	* libgimp/Makefile.am
	* libgimp/gimpui.h
	* libgimp/gimpquerybox.[ch]: new files. Added a boolean query box
	to get rid of all those handmade "yes/no" query dialogs. Changed
	the query box callback prototypes to return the entered value
	instead of a pointer to it.

	* app/commands.c
	* app/display_ops.c
	* app/gradient.c
	* app/palette.c
	* app/paths_dialog.c: correctly call the new query box functions
	and use the boolean query box instead of inventing this wheel over
	and over again.

	* app/global_edit.[ch]: same as above and cleaned up the public
	interface.
parent 4490df91
2000-02-10 Michael Natterer <mitch@gimp.org>
* app/gimpui.[ch]: removed the query boxes.
* po-libgimp/POTFILES.in
* libgimp/Makefile.am
* libgimp/gimpui.h
* libgimp/gimpquerybox.[ch]: new files. Added a boolean query box
to get rid of all those handmade "yes/no" query dialogs. Changed
the query box callback prototypes to return the entered value
instead of a pointer to it.
* app/commands.c
* app/display_ops.c
* app/gradient.c
* app/palette.c
* app/paths_dialog.c: correctly call the new query box functions
and use the boolean query box instead of inventing this wheel over
and over again.
* app/global_edit.[ch]: same as above and cleaned up the public
interface.
Thu Feb 10 17:20:05 CET 2000 Sven Neumann <sven@gimp.org> Thu Feb 10 17:20:05 CET 2000 Sven Neumann <sven@gimp.org>
* app/gimage.c * app/gimage.c
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include "undo.h" #include "undo.h"
#include "config.h" #include "config.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \ #define return_if_no_display(gdisp) \
...@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean); ...@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean);
static void image_resize_callback (GtkWidget *, gpointer); static void image_resize_callback (GtkWidget *, gpointer);
static void image_scale_callback (GtkWidget *, gpointer); static void image_scale_callback (GtkWidget *, gpointer);
static void image_cancel_callback (GtkWidget *, gpointer); static void image_cancel_callback (GtkWidget *, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gpointer, gpointer); static void gimage_mask_feather_callback (GtkWidget *, gdouble, GimpUnit,
static void gimage_mask_border_callback (GtkWidget *, gpointer, gpointer); gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gpointer, gpointer); static void gimage_mask_border_callback (GtkWidget *, gdouble, GimpUnit,
static void gimage_mask_shrink_callback (GtkWidget *, gpointer, gpointer); gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
/* local variables */ /* local variables */
static gdouble selection_feather_radius = 5.0; static gdouble selection_feather_radius = 5.0;
...@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget, ...@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget,
static void static void
gimage_mask_feather_callback (GtkWidget *widget, gimage_mask_feather_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_feather_radius = *(gdouble *) call_data; selection_feather_radius = size;
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_feather_radius; radius_x = radius_y = selection_feather_radius;
...@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget, ...@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget,
static void static void
gimage_mask_border_callback (GtkWidget *widget, gimage_mask_border_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); selection_border_radius = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_border_radius; radius_x = radius_y = selection_border_radius;
...@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget, ...@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget,
static void static void
gimage_mask_grow_callback (GtkWidget *widget, gimage_mask_grow_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); selection_grow_pixels = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_grow_pixels; radius_x = radius_y = selection_grow_pixels;
...@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget, ...@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget,
static void static void
gimage_mask_shrink_callback (GtkWidget *widget, gimage_mask_shrink_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gint radius_x;
gint radius_x; gint radius_y;
gint radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); selection_shrink_pixels = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_shrink_pixels; radius_x = radius_y = selection_shrink_pixels;
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include "undo.h" #include "undo.h"
#include "config.h" #include "config.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpintl.h" #include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \ #define return_if_no_display(gdisp) \
...@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean); ...@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean);
static void image_resize_callback (GtkWidget *, gpointer); static void image_resize_callback (GtkWidget *, gpointer);
static void image_scale_callback (GtkWidget *, gpointer); static void image_scale_callback (GtkWidget *, gpointer);
static void image_cancel_callback (GtkWidget *, gpointer); static void image_cancel_callback (GtkWidget *, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gpointer, gpointer); static void gimage_mask_feather_callback (GtkWidget *, gdouble, GimpUnit,
static void gimage_mask_border_callback (GtkWidget *, gpointer, gpointer); gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gpointer, gpointer); static void gimage_mask_border_callback (GtkWidget *, gdouble, GimpUnit,
static void gimage_mask_shrink_callback (GtkWidget *, gpointer, gpointer); gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
/* local variables */ /* local variables */
static gdouble selection_feather_radius = 5.0; static gdouble selection_feather_radius = 5.0;
...@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget, ...@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget,
static void static void
gimage_mask_feather_callback (GtkWidget *widget, gimage_mask_feather_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_feather_radius = *(gdouble *) call_data; selection_feather_radius = size;
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_feather_radius; radius_x = radius_y = selection_feather_radius;
...@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget, ...@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget,
static void static void
gimage_mask_border_callback (GtkWidget *widget, gimage_mask_border_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_border_radius = (gint) (*(gdouble *) call_data + 0.5); selection_border_radius = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_border_radius; radius_x = radius_y = selection_border_radius;
...@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget, ...@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget,
static void static void
gimage_mask_grow_callback (GtkWidget *widget, gimage_mask_grow_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gdouble radius_x;
gdouble radius_x; gdouble radius_y;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5); selection_grow_pixels = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_grow_pixels; radius_x = radius_y = selection_grow_pixels;
...@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget, ...@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget,
static void static void
gimage_mask_shrink_callback (GtkWidget *widget, gimage_mask_shrink_callback (GtkWidget *widget,
gpointer client_data, gdouble size,
gpointer call_data) GimpUnit unit,
gpointer data)
{ {
GImage *gimage; GImage *gimage;
GimpUnit unit; gint radius_x;
gint radius_x; gint radius_y;
gint radius_y;
gimage = GIMP_IMAGE (client_data); gimage = GIMP_IMAGE (data);
selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5); selection_shrink_pixels = ROUND (size);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
radius_x = radius_y = selection_shrink_pixels; radius_x = radius_y = selection_shrink_pixels;
......
...@@ -59,35 +59,35 @@ typedef struct _named_buffer NamedBuffer; ...@@ -59,35 +59,35 @@ typedef struct _named_buffer NamedBuffer;
struct _named_buffer struct _named_buffer
{ {
TileManager * buf; TileManager *buf;
char * name; gchar *name;
}; };
/* The named buffer list */ /* The named buffer list */
GSList * named_buffers = NULL; static GSList *named_buffers = NULL;
/* The global edit buffer */ /* The global edit buffer */
TileManager * global_buf = NULL; TileManager *global_buf = NULL;
/* Crop the buffer to the size of pixels with non-zero transparency */ /* Crop the buffer to the size of pixels with non-zero transparency */
TileManager * TileManager *
crop_buffer (TileManager *tiles, crop_buffer (TileManager *tiles,
int border) gboolean border)
{ {
PixelRegion PR; PixelRegion PR;
TileManager *new_tiles; TileManager *new_tiles;
int bytes, alpha; gint bytes, alpha;
unsigned char * data; guchar *data;
int empty; gint empty;
int x1, y1, x2, y2; gint x1, y1, x2, y2;
int x, y; gint x, y;
int ex, ey; gint ex, ey;
int found; gint found;
void * pr; void *pr;
unsigned char black[MAX_CHANNELS] = { 0, 0, 0, 0 }; guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
bytes = tiles->bpp; bytes = tiles->bpp;
alpha = bytes - 1; alpha = bytes - 1;
...@@ -175,12 +175,12 @@ crop_buffer (TileManager *tiles, ...@@ -175,12 +175,12 @@ crop_buffer (TileManager *tiles,
} }
TileManager * TileManager *
edit_cut (GImage *gimage, edit_cut (GImage *gimage,
GimpDrawable *drawable) GimpDrawable *drawable)
{ {
TileManager *cut; TileManager *cut;
TileManager *cropped_cut; TileManager *cropped_cut;
int empty; gint empty;
if (!gimage || drawable == NULL) if (!gimage || drawable == NULL)
return NULL; return NULL;
...@@ -229,12 +229,12 @@ edit_cut (GImage *gimage, ...@@ -229,12 +229,12 @@ edit_cut (GImage *gimage,
} }
TileManager * TileManager *
edit_copy (GImage *gimage, edit_copy (GImage *gimage,
GimpDrawable *drawable) GimpDrawable *drawable)
{ {
TileManager * copy; TileManager *copy;
TileManager * cropped_copy; TileManager *cropped_copy;
int empty; gint empty;
if (!gimage || drawable == NULL) if (!gimage || drawable == NULL)
return NULL; return NULL;
...@@ -276,24 +276,32 @@ edit_copy (GImage *gimage, ...@@ -276,24 +276,32 @@ edit_copy (GImage *gimage,
return NULL; return NULL;
} }
GimpLayer* GimpLayer *
edit_paste (GImage *gimage, edit_paste (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
TileManager *paste, TileManager *paste,
int paste_into) gboolean paste_into)
{ {
Layer * layer; Layer *layer;
int x1, y1, x2, y2; gint x1, y1, x2, y2;
int cx, cy; gint cx, cy;
/* Make a new layer: iff drawable == NULL, user is pasting into an empty display. */ /* Make a new layer: iff drawable == NULL,
* user is pasting into an empty display.
if(drawable != NULL) */
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); if (drawable != NULL)
layer = layer_new_from_tiles (gimage,
gimp_drawable_type_with_alpha (drawable),
paste,
_("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
else else
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste, layer = layer_new_from_tiles (gimage,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); gimp_image_base_type_with_alpha (gimage),
paste,
_("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
if (layer) if (layer)
{ {
...@@ -314,8 +322,8 @@ edit_paste (GImage *gimage, ...@@ -314,8 +322,8 @@ edit_paste (GImage *gimage,
cy = gimage->height >> 1; cy = gimage->height >> 1;
} }
GIMP_DRAWABLE(layer)->offset_x = cx - (GIMP_DRAWABLE(layer)->width >> 1); GIMP_DRAWABLE (layer)->offset_x = cx - (GIMP_DRAWABLE (layer)->width >> 1);
GIMP_DRAWABLE(layer)->offset_y = cy - (GIMP_DRAWABLE(layer)->height >> 1); GIMP_DRAWABLE (layer)->offset_y = cy - (GIMP_DRAWABLE (layer)->height >> 1);
/* If there is a selection mask clear it-- /* If there is a selection mask clear it--
* this might not always be desired, but in general, * this might not always be desired, but in general,
...@@ -340,18 +348,17 @@ edit_paste (GImage *gimage, ...@@ -340,18 +348,17 @@ edit_paste (GImage *gimage,
return layer; return layer;
} }
else
return NULL; return NULL;
} }
gboolean
int edit_paste_as_new (GImage *invoke,
edit_paste_as_new (GImage *invoke, TileManager *paste)
TileManager *paste)
{ {
GImage *gimage; GImage *gimage;
Layer *layer; Layer *layer;
GDisplay *gdisp; GDisplay *gdisp;
if (!global_buf) if (!global_buf)
return FALSE; return FALSE;
...@@ -362,10 +369,13 @@ edit_paste_as_new (GImage *invoke, ...@@ -362,10 +369,13 @@ edit_paste_as_new (GImage *invoke,
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution); gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit); gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste, layer = layer_new_from_tiles (gimage,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); gimp_image_base_type_with_alpha (gimage),
paste,
_("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
if(layer) if (layer)
{ {
/* add the new layer to the image */ /* add the new layer to the image */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage); gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
...@@ -378,17 +388,18 @@ edit_paste_as_new (GImage *invoke, ...@@ -378,17 +388,18 @@ edit_paste_as_new (GImage *invoke,
return TRUE; return TRUE;
} }
else return FALSE;
return FALSE;
} }
gboolean gboolean
edit_clear (GImage *gimage, edit_clear (GImage *gimage,
GimpDrawable *drawable) GimpDrawable *drawable)
{ {
TileManager *buf_tiles; TileManager *buf_tiles;
PixelRegion bufPR; PixelRegion bufPR;
int x1, y1, x2, y2; gint x1, y1, x2, y2;
unsigned char col[MAX_CHANNELS]; guchar col[MAX_CHANNELS];
if (!gimage || drawable == NULL) if (!gimage || drawable == NULL)
return FALSE; return FALSE;
...@@ -420,13 +431,13 @@ edit_clear (GImage *gimage, ...@@ -420,13 +431,13 @@ edit_clear (GImage *gimage,
} }
gboolean gboolean
edit_fill (GImage *gimage, edit_fill (GImage *gimage,
GimpDrawable *drawable) GimpDrawable *drawable)
{ {
TileManager *buf_tiles; TileManager *buf_tiles;
PixelRegion bufPR; PixelRegion bufPR;
int x1, y1, x2, y2; gint x1, y1, x2, y2;
unsigned char col[MAX_CHANNELS]; guchar col[MAX_CHANNELS];
if (!gimage || drawable == NULL) if (!gimage || drawable == NULL)
return FALSE; return FALSE;
...@@ -457,77 +468,62 @@ edit_fill (GImage *gimage, ...@@ -457,77 +468,62 @@ edit_fill (GImage *gimage,
return TRUE; return TRUE;
} }
int gboolean
global_edit_cut (void *gdisp_ptr) global_edit_cut (GDisplay *gdisp)
{ {
GDisplay *gdisp;
/* stop any active tool */ /* stop any active tool */
gdisp = (GDisplay *) gdisp_ptr; active_tool_control (HALT, gdisp);
active_tool_control (HALT, gdisp_ptr);
if (!edit_cut (gdisp->gimage, gimage_active_drawable (gdisp->gimage))) if (!edit_cut (gdisp->gimage, gimage_active_drawable (gdisp->gimage)))
return FALSE; return FALSE;
else
{
/* flush the display */
gdisplays_flush ();
return TRUE;
}
}
int