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>
* app/gimage.c
......
......@@ -57,6 +57,8 @@
#include "undo.h"
#include "config.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \
......@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean);
static void image_resize_callback (GtkWidget *, gpointer);
static void image_scale_callback (GtkWidget *, gpointer);
static void image_cancel_callback (GtkWidget *, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_border_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_border_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
/* local variables */
static gdouble selection_feather_radius = 5.0;
......@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget,
static void
gimage_mask_feather_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_feather_radius = *(gdouble *) call_data;
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_feather_radius = size;
radius_x = radius_y = selection_feather_radius;
......@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget,
static void
gimage_mask_border_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_border_radius = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_border_radius = ROUND (size);
radius_x = radius_y = selection_border_radius;
......@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget,
static void
gimage_mask_grow_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_grow_pixels = ROUND (size);
radius_x = radius_y = selection_grow_pixels;
......@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget,
static void
gimage_mask_shrink_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gint radius_x;
gint radius_y;
GImage *gimage;
gint radius_x;
gint radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_shrink_pixels = ROUND (size);
radius_x = radius_y = selection_shrink_pixels;
......
......@@ -57,6 +57,8 @@
#include "undo.h"
#include "config.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpintl.h"
#define return_if_no_display(gdisp) \
......@@ -76,10 +78,14 @@ extern void layers_dialog_layer_merge_query (GImage *, gboolean);
static void image_resize_callback (GtkWidget *, gpointer);
static void image_scale_callback (GtkWidget *, gpointer);
static void image_cancel_callback (GtkWidget *, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_border_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gpointer, gpointer);
static void gimage_mask_feather_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_border_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_grow_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
static void gimage_mask_shrink_callback (GtkWidget *, gdouble, GimpUnit,
gpointer);
/* local variables */
static gdouble selection_feather_radius = 5.0;
......@@ -1404,19 +1410,17 @@ image_cancel_callback (GtkWidget *widget,
static void
gimage_mask_feather_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_feather_radius = *(gdouble *) call_data;
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_feather_radius = size;
radius_x = radius_y = selection_feather_radius;
......@@ -1439,19 +1443,17 @@ gimage_mask_feather_callback (GtkWidget *widget,
static void
gimage_mask_border_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_border_radius = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_border_radius = ROUND (size);
radius_x = radius_y = selection_border_radius;
......@@ -1474,19 +1476,17 @@ gimage_mask_border_callback (GtkWidget *widget,
static void
gimage_mask_grow_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gdouble radius_x;
gdouble radius_y;
GImage *gimage;
gdouble radius_x;
gdouble radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_grow_pixels = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_grow_pixels = ROUND (size);
radius_x = radius_y = selection_grow_pixels;
......@@ -1509,19 +1509,17 @@ gimage_mask_grow_callback (GtkWidget *widget,
static void
gimage_mask_shrink_callback (GtkWidget *widget,
gpointer client_data,
gpointer call_data)
gdouble size,
GimpUnit unit,
gpointer data)
{
GImage *gimage;
GimpUnit unit;
gint radius_x;
gint radius_y;
GImage *gimage;
gint radius_x;
gint radius_y;
gimage = GIMP_IMAGE (client_data);
gimage = GIMP_IMAGE (data);
selection_shrink_pixels = (gint) (*(gdouble *) call_data + 0.5);
g_free (call_data);
unit = (GimpUnit) gtk_object_get_data (GTK_OBJECT (widget), "size_query_unit");
selection_shrink_pixels = ROUND (size);
radius_x = radius_y = selection_shrink_pixels;
......
......@@ -59,35 +59,35 @@ typedef struct _named_buffer NamedBuffer;
struct _named_buffer
{
TileManager * buf;
char * name;
TileManager *buf;
gchar *name;
};
/* The named buffer list */
GSList * named_buffers = NULL;
static GSList *named_buffers = NULL;
/* The global edit buffer */
TileManager * global_buf = NULL;
TileManager *global_buf = NULL;
/* Crop the buffer to the size of pixels with non-zero transparency */
TileManager *
crop_buffer (TileManager *tiles,
int border)
gboolean border)
{
PixelRegion PR;
PixelRegion PR;
TileManager *new_tiles;
int bytes, alpha;
unsigned char * data;
int empty;
int x1, y1, x2, y2;
int x, y;
int ex, ey;
int found;
void * pr;
unsigned char black[MAX_CHANNELS] = { 0, 0, 0, 0 };
gint bytes, alpha;
guchar *data;
gint empty;
gint x1, y1, x2, y2;
gint x, y;
gint ex, ey;
gint found;
void *pr;
guchar black[MAX_CHANNELS] = { 0, 0, 0, 0 };
bytes = tiles->bpp;
alpha = bytes - 1;
......@@ -175,12 +175,12 @@ crop_buffer (TileManager *tiles,
}
TileManager *
edit_cut (GImage *gimage,
edit_cut (GImage *gimage,
GimpDrawable *drawable)
{
TileManager *cut;
TileManager *cropped_cut;
int empty;
gint empty;
if (!gimage || drawable == NULL)
return NULL;
......@@ -229,12 +229,12 @@ edit_cut (GImage *gimage,
}
TileManager *
edit_copy (GImage *gimage,
edit_copy (GImage *gimage,
GimpDrawable *drawable)
{
TileManager * copy;
TileManager * cropped_copy;
int empty;
TileManager *copy;
TileManager *cropped_copy;
gint empty;
if (!gimage || drawable == NULL)
return NULL;
......@@ -276,24 +276,32 @@ edit_copy (GImage *gimage,
return NULL;
}
GimpLayer*
GimpLayer *
edit_paste (GImage *gimage,
GimpDrawable *drawable,
TileManager *paste,
int paste_into)
gboolean paste_into)
{
Layer * layer;
int x1, y1, x2, y2;
int cx, cy;
/* 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);
Layer *layer;
gint x1, y1, x2, y2;
gint cx, cy;
/* 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);
else
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
layer = layer_new_from_tiles (gimage,
gimp_image_base_type_with_alpha (gimage),
paste,
_("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
{
......@@ -314,8 +322,8 @@ edit_paste (GImage *gimage,
cy = gimage->height >> 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_x = cx - (GIMP_DRAWABLE (layer)->width >> 1);
GIMP_DRAWABLE (layer)->offset_y = cy - (GIMP_DRAWABLE (layer)->height >> 1);
/* If there is a selection mask clear it--
* this might not always be desired, but in general,
......@@ -340,18 +348,17 @@ edit_paste (GImage *gimage,
return layer;
}
else
return NULL;
return NULL;
}
int
edit_paste_as_new (GImage *invoke,
TileManager *paste)
gboolean
edit_paste_as_new (GImage *invoke,
TileManager *paste)
{
GImage *gimage;
Layer *layer;
GDisplay *gdisp;
GImage *gimage;
Layer *layer;
GDisplay *gdisp;
if (!global_buf)
return FALSE;
......@@ -362,10 +369,13 @@ edit_paste_as_new (GImage *invoke,
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
layer = layer_new_from_tiles (gimage,
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 */
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
......@@ -378,17 +388,18 @@ edit_paste_as_new (GImage *invoke,
return TRUE;
}
else return FALSE;
return FALSE;
}
gboolean
edit_clear (GImage *gimage,
edit_clear (GImage *gimage,
GimpDrawable *drawable)
{
TileManager *buf_tiles;
PixelRegion bufPR;
int x1, y1, x2, y2;
unsigned char col[MAX_CHANNELS];
PixelRegion bufPR;
gint x1, y1, x2, y2;
guchar col[MAX_CHANNELS];
if (!gimage || drawable == NULL)
return FALSE;
......@@ -420,13 +431,13 @@ edit_clear (GImage *gimage,
}
gboolean
edit_fill (GImage *gimage,
edit_fill (GImage *gimage,
GimpDrawable *drawable)
{
TileManager *buf_tiles;
PixelRegion bufPR;
int x1, y1, x2, y2;
unsigned char col[MAX_CHANNELS];
PixelRegion bufPR;
gint x1, y1, x2, y2;
guchar col[MAX_CHANNELS];
if (!gimage || drawable == NULL)
return FALSE;
......@@ -457,77 +468,62 @@ edit_fill (GImage *gimage,
return TRUE;
}
int
global_edit_cut (void *gdisp_ptr)
gboolean
global_edit_cut (GDisplay *gdisp)
{
GDisplay *gdisp;
/* stop any active tool */
gdisp = (GDisplay *) gdisp_ptr;
active_tool_control (HALT, gdisp_ptr);
active_tool_control (HALT, gdisp);
if (!edit_cut (gdisp->gimage, gimage_active_drawable (gdisp->gimage)))
return FALSE;
else
{
/* flush the display */
gdisplays_flush ();
return TRUE;
}
}
int
global_edit_copy (void *gdisp_ptr)
{
GDisplay *gdisp;
/* flush the display */
gdisplays_flush ();
gdisp = (GDisplay *) gdisp_ptr;
return TRUE;
}
gboolean
global_edit_copy (GDisplay *gdisp)
{
if (!edit_copy (gdisp->gimage, gimage_active_drawable (gdisp->gimage)))
return FALSE;
else
return TRUE;
return TRUE;
}
int
global_edit_paste (void *gdisp_ptr,
int paste_into)
gboolean
global_edit_paste (GDisplay *gdisp,
gboolean paste_into)
{
GDisplay *gdisp;
/* stop any active tool */
gdisp = (GDisplay *) gdisp_ptr;
active_tool_control (HALT, gdisp_ptr);
active_tool_control (HALT, gdisp);
if (!edit_paste (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
global_buf, paste_into))
return FALSE;
else
{
/* flush the display */
gdisplays_update_title (gdisp->gimage);
gdisplays_flush ();
return TRUE;
}
/* flush the display */
gdisplays_update_title (gdisp->gimage);
gdisplays_flush ();
return TRUE;
}
int
global_edit_paste_as_new (void *gdisp_ptr)
gboolean
global_edit_paste_as_new (GDisplay *gdisp)
{
GDisplay *gdisp;
if (!global_buf)
return FALSE;
/* stop any active tool */
gdisp = (GDisplay *) gdisp_ptr;
active_tool_control (HALT, gdisp_ptr);
active_tool_control (HALT, gdisp);
return (edit_paste_as_new (gdisp->gimage, global_buf));
return edit_paste_as_new (gdisp->gimage, global_buf);
}
void
global_edit_free ()
global_edit_free (void)
{
if (global_buf)
tile_manager_destroy (global_buf);
......@@ -541,51 +537,53 @@ global_edit_free ()
static void
set_list_of_named_buffers (GtkWidget *list_widget)
{
GSList *list;
GSList *list;
NamedBuffer *nb;
GtkWidget *list_item;
GtkWidget *list_item;
gtk_list_clear_items (GTK_LIST (list_widget), 0, -1);
list = named_buffers;
while (list)
for (list = named_buffers; list; list = g_slist_next (list))
{
nb = (NamedBuffer *) list->data;
list = g_slist_next (list);
list_item = gtk_list_item_new_with_label (nb->name);
gtk_container_add (GTK_CONTAINER (list_widget), list_item);
gtk_widget_show (list_item);
gtk_object_set_user_data (GTK_OBJECT (list_item), (gpointer) nb);
gtk_widget_show (list_item);
}
}
static void
named_buffer_paste_foreach (GtkWidget *w,
gpointer client_data)
named_buffer_paste_foreach (GtkWidget *widget,
gpointer data)
{
PasteNamedDlg *pn_dlg;
NamedBuffer *nb;
NamedBuffer *nb;
if (w->state == GTK_STATE_SELECTED)
if (widget->state == GTK_STATE_SELECTED)
{
pn_dlg = (PasteNamedDlg *) client_data;
nb = (NamedBuffer *) gtk_object_get_user_data (GTK_OBJECT (w));
pn_dlg = (PasteNamedDlg *) data;
nb = (NamedBuffer *) gtk_object_get_user_data (GTK_OBJECT (widget));
switch (pn_dlg->action)
{
case PASTE:
edit_paste (pn_dlg->gdisp->gimage,
gimage_active_drawable (pn_dlg->gdisp->gimage),
nb->buf, FALSE);
gimage_active_drawable (pn_dlg->gdisp->gimage),
nb->buf, FALSE);
break;
case PASTE_INTO:
edit_paste (pn_dlg->gdisp->gimage,
gimage_active_drawable (pn_dlg->gdisp->gimage),
nb->buf, TRUE);
gimage_active_drawable (pn_dlg->gdisp->gimage),
nb->buf, TRUE);
break;
case PASTE_AS_NEW:
edit_paste_as_new (pn_dlg->gdisp->gimage, nb->buf);
break;
default:
break;
}
......@@ -593,16 +591,16 @@ named_buffer_paste_foreach (GtkWidget *w,
}
static void
named_buffer_paste_callback (GtkWidget *w,
gpointer client_data)
named_buffer_paste_callback (GtkWidget *widget,
gpointer data)
{
PasteNamedDlg *pn_dlg;
pn_dlg = (PasteNamedDlg *) client_data;
pn_dlg = (PasteNamedDlg *) data;
pn_dlg->action = PASTE_INTO;
gtk_container_foreach ((GtkContainer*) pn_dlg->list,
named_buffer_paste_foreach, client_data);
gtk_container_foreach ((GtkContainer *) pn_dlg->list,
named_buffer_paste_foreach, data);
/* Destroy the box */
gtk_widget_destroy (pn_dlg->shell);
......@@ -614,16 +612,16 @@ named_buffer_paste_callback (GtkWidget *w,
}
static void
named_buffer_paste_into_callback (GtkWidget *w,
gpointer client_data)
named_buffer_paste_into_callback (GtkWidget *widget,
gpointer data)
{
PasteNamedDlg *pn_dlg;
pn_dlg = (PasteNamedDlg *) client_data;
pn_dlg = (PasteNamedDlg *) data;