Commit 5c5c73f3 authored by Lauri Alanko's avatar Lauri Alanko
Browse files

Misc cleaning up here and there. Note that since the ids were used

to detect if an image still exists, some things may, for now,
access freed images and break. This will be fixed once proper
destroy handlers are added.
parent 69a60a9f
Tue Jun 30 04:00:38 EEST 1998 Lauri Alanko <nether@gimp.org>
* app/commands.c:
* app/edit_cmds.c:
* app/gdisplay.c:
* app/gimage.c:
* app/gimage.h:
* app/gimpimage.c:
* app/gimpimage.h:
* app/gimpimageP.h:
* app/gimpobject.c:
* app/gimpobject.h:
* app/gimpobjectP.h:
* app/global_edit.c:
* app/global_edit.h:
* app/indexed_palette.c:
* app/layer.c:
* app/layers_dialog.c:
* app/move.c:
* app/undo.c:
* app/undo.h:
Misc cleaning up here and there. Note that since the ids were used
to detect if an image still exists, some things may, for now,
access freed images and break. This will be fixed once proper
destroy handlers are added.
Sun Jun 28 19:32:06 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* app/tile_swap.c: Added a mutex on the swapfile to avoid a
......
......@@ -358,7 +358,7 @@ select_border_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_border_radius);
query_string_box ("Border Selection", "Border selection by:", initial,
gimage_mask_border_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_border_callback, gdisp->gimage);
}
void
......@@ -372,7 +372,7 @@ select_feather_cmd_callback (GtkWidget *widget,
sprintf (initial, "%f", gimage_mask_feather_radius);
query_string_box ("Feather Selection", "Feather selection by:", initial,
gimage_mask_feather_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_feather_callback, gdisp->gimage);
}
void
......@@ -386,7 +386,7 @@ select_grow_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_grow_pixels);
query_string_box ("Grow Selection", "Grow selection by:", initial,
gimage_mask_grow_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_grow_callback, gdisp->gimage);
}
void
......@@ -400,7 +400,7 @@ select_shrink_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_shrink_pixels);
query_string_box ("Shrink Selection", "Shrink selection by:", initial,
gimage_mask_shrink_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_shrink_callback, gdisp->gimage);
}
void
......@@ -1135,12 +1135,9 @@ gimage_mask_feather_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
double feather_radius;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
feather_radius = atof (call_data);
gimage_mask_feather (gimage, feather_radius);
......@@ -1156,9 +1153,8 @@ gimage_mask_border_callback (GtkWidget *w,
GImage *gimage;
int border_radius;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
gimage=GIMP_IMAGE(client_data);
border_radius = atoi (call_data);
gimage_mask_border (gimage, border_radius);
......@@ -1171,12 +1167,9 @@ gimage_mask_grow_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
int grow_pixels;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
grow_pixels = atoi (call_data);
gimage_mask_grow (gimage, grow_pixels);
......@@ -1189,12 +1182,9 @@ gimage_mask_shrink_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
int shrink_pixels;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
shrink_pixels = atoi (call_data);
gimage_mask_shrink (gimage, shrink_pixels);
......
......@@ -358,7 +358,7 @@ select_border_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_border_radius);
query_string_box ("Border Selection", "Border selection by:", initial,
gimage_mask_border_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_border_callback, gdisp->gimage);
}
void
......@@ -372,7 +372,7 @@ select_feather_cmd_callback (GtkWidget *widget,
sprintf (initial, "%f", gimage_mask_feather_radius);
query_string_box ("Feather Selection", "Feather selection by:", initial,
gimage_mask_feather_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_feather_callback, gdisp->gimage);
}
void
......@@ -386,7 +386,7 @@ select_grow_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_grow_pixels);
query_string_box ("Grow Selection", "Grow selection by:", initial,
gimage_mask_grow_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_grow_callback, gdisp->gimage);
}
void
......@@ -400,7 +400,7 @@ select_shrink_cmd_callback (GtkWidget *widget,
sprintf (initial, "%d", gimage_mask_shrink_pixels);
query_string_box ("Shrink Selection", "Shrink selection by:", initial,
gimage_mask_shrink_callback, (gpointer) gdisp->gimage->ID);
gimage_mask_shrink_callback, gdisp->gimage);
}
void
......@@ -1135,12 +1135,9 @@ gimage_mask_feather_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
double feather_radius;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
feather_radius = atof (call_data);
gimage_mask_feather (gimage, feather_radius);
......@@ -1156,9 +1153,8 @@ gimage_mask_border_callback (GtkWidget *w,
GImage *gimage;
int border_radius;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
gimage=GIMP_IMAGE(client_data);
border_radius = atoi (call_data);
gimage_mask_border (gimage, border_radius);
......@@ -1171,12 +1167,9 @@ gimage_mask_grow_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
int grow_pixels;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
grow_pixels = atoi (call_data);
gimage_mask_grow (gimage, grow_pixels);
......@@ -1189,12 +1182,9 @@ gimage_mask_shrink_callback (GtkWidget *w,
gpointer client_data,
gpointer call_data)
{
GImage *gimage;
GImage *gimage=GIMP_IMAGE(client_data);
int shrink_pixels;
if (!(gimage = gimage_get_ID ((int)client_data)))
return;
shrink_pixels = atoi (call_data);
gimage_mask_shrink (gimage, shrink_pixels);
......
......@@ -268,7 +268,7 @@ edit_copy (GImage *gimage,
return NULL;
}
int
GimpLayer*
edit_paste (GImage *gimage,
GimpDrawable *drawable,
TileManager *paste,
......@@ -308,13 +308,13 @@ edit_paste (GImage *gimage,
/* end the group undo */
undo_push_group_end (gimage);
return GIMP_DRAWABLE(float_layer)->ID;
return float_layer;
}
else
return 0;
return NULL;
}
int
gboolean
edit_clear (GImage *gimage,
GimpDrawable *drawable)
{
......@@ -352,7 +352,7 @@ edit_clear (GImage *gimage,
return TRUE;
}
int
gboolean
edit_fill (GImage *gimage,
GimpDrawable *drawable)
{
......
......@@ -24,7 +24,8 @@
TileManager * crop_buffer (TileManager *, int);
TileManager * edit_cut (GImage *, GimpDrawable *);
TileManager * edit_copy (GImage *, GimpDrawable *);
int edit_paste (GImage *, GimpDrawable *, TileManager *, int);
GimpLayer* edit_paste (GImage *, GimpDrawable *,
TileManager *, int);
int edit_clear (GImage *, GimpDrawable *);
int edit_fill (GImage *, GimpDrawable *);
......
......@@ -268,7 +268,7 @@ edit_copy (GImage *gimage,
return NULL;
}
int
GimpLayer*
edit_paste (GImage *gimage,
GimpDrawable *drawable,
TileManager *paste,
......@@ -308,13 +308,13 @@ edit_paste (GImage *gimage,
/* end the group undo */
undo_push_group_end (gimage);
return GIMP_DRAWABLE(float_layer)->ID;
return float_layer;
}
else
return 0;
return NULL;
}
int
gboolean
edit_clear (GImage *gimage,
GimpDrawable *drawable)
{
......@@ -352,7 +352,7 @@ edit_clear (GImage *gimage,
return TRUE;
}
int
gboolean
edit_fill (GImage *gimage,
GimpDrawable *drawable)
{
......
......@@ -24,7 +24,8 @@
TileManager * crop_buffer (TileManager *, int);
TileManager * edit_cut (GImage *, GimpDrawable *);
TileManager * edit_copy (GImage *, GimpDrawable *);
int edit_paste (GImage *, GimpDrawable *, TileManager *, int);
GimpLayer* edit_paste (GImage *, GimpDrawable *,
TileManager *, int);
int edit_clear (GImage *, GimpDrawable *);
int edit_fill (GImage *, GimpDrawable *);
......
......@@ -15,12 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpimageP.h"
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"
#include "general.h"
#include "gimpimageP.h"
#include "gimpimage.h"
#include "gimage_mask.h"
#include "paint_funcs.h"
#include "palette.h"
......@@ -75,8 +74,6 @@ int valid_combinations[][MAX_CHANNELS + 1] =
/*
* Static variables
*/
GSList *image_list = NULL;
enum{
DIRTY,
......@@ -151,17 +148,12 @@ static void gimp_image_init (GimpImage *gimage)
GtkType gimp_image_get_type(void){
static GtkType type;
if(!type){
GtkTypeInfo info={
"GimpImage",
sizeof(GimpImage),
sizeof(GimpImageClass),
(GtkClassInitFunc)gimp_image_class_init,
(GtkObjectInitFunc)gimp_image_init,
NULL,
NULL};
type=gtk_type_unique(gimp_object_get_type(), &info);
}
GIMP_TYPE_INIT(type,
GimpImage,
GimpImageClass,
gimp_image_init,
gimp_image_class_init,
GIMP_TYPE_OBJECT);
return type;
}
......@@ -190,8 +182,7 @@ gimp_image_allocate_projection (GimpImage *gimage)
gimage->proj_type = GRAYA_GIMAGE;
break;
default:
g_message ("gimage type unsupported.\n");
break;
g_assert_not_reached();
}
/* allocate the new projection */
......@@ -299,11 +290,7 @@ gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
Layer *floating_layer;
GSList *list;
if (new_width <= 0 || new_height <= 0)
{
g_message ("gimp_image_resize: width and height must be positive");
return;
}
g_assert (new_width > 0 && new_height > 0);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -418,27 +405,6 @@ gimp_image_scale (GimpImage *gimage, int new_width, int new_height)
}
GimpImage *
gimp_image_get_named (char *name)
{
GSList *tmp = image_list;
GimpImage *gimage;
char *str;
while (tmp)
{
gimage = tmp->data;
str = prune_filename (gimp_image_filename (gimage));
if (strcmp (str, name) == 0)
return gimage;
tmp = g_slist_next (tmp);
}
return NULL;
}
TileManager *
gimp_image_shadow (GimpImage *gimage, int width, int height, int bpp)
......@@ -2901,17 +2867,3 @@ gimp_image_invalidate_preview (GimpImage *gimage)
gimage->comp_preview_valid[2] = FALSE;
}
void
gimp_image_invalidate_previews (void)
{
GSList *tmp = image_list;
GimpImage *gimage;
while (tmp)
{
gimage = (GimpImage *) tmp->data;
gimp_image_invalidate_preview (gimage);
tmp = g_slist_next (tmp);
}
}
......@@ -9,11 +9,13 @@
#include "layer.h"
#include "temp_buf.h"
#include "tile_manager.h"
#define GIMP_IMAGE(obj) GTK_CHECK_CAST (obj, gimp_image_get_type (), GimpImage)
#define GIMP_TYPE_IMAGE gimp_image_get_type()
#define GIMP_IMAGE(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_IMAGE, GimpImage)
#define GIMP_IS_GIMAGE(obj) GTK_CHECK_TYPE (obj, gimp_image_get_type())
#define GIMP_IS_GIMAGE(obj) GTK_CHECK_TYPE (obj, GIMP_TYPE_IMAGE)
/* the image types */
......
......@@ -15,12 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpimageP.h"
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"
#include "general.h"
#include "gimpimageP.h"
#include "gimpimage.h"
#include "gimage_mask.h"
#include "paint_funcs.h"
#include "palette.h"
......@@ -75,8 +74,6 @@ int valid_combinations[][MAX_CHANNELS + 1] =
/*
* Static variables
*/
GSList *image_list = NULL;
enum{
DIRTY,
......@@ -151,17 +148,12 @@ static void gimp_image_init (GimpImage *gimage)
GtkType gimp_image_get_type(void){
static GtkType type;
if(!type){
GtkTypeInfo info={
"GimpImage",
sizeof(GimpImage),
sizeof(GimpImageClass),
(GtkClassInitFunc)gimp_image_class_init,
(GtkObjectInitFunc)gimp_image_init,
NULL,
NULL};
type=gtk_type_unique(gimp_object_get_type(), &info);
}
GIMP_TYPE_INIT(type,
GimpImage,
GimpImageClass,
gimp_image_init,
gimp_image_class_init,
GIMP_TYPE_OBJECT);
return type;
}
......@@ -190,8 +182,7 @@ gimp_image_allocate_projection (GimpImage *gimage)
gimage->proj_type = GRAYA_GIMAGE;
break;
default:
g_message ("gimage type unsupported.\n");
break;
g_assert_not_reached();
}
/* allocate the new projection */
......@@ -299,11 +290,7 @@ gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
Layer *floating_layer;
GSList *list;
if (new_width <= 0 || new_height <= 0)
{
g_message ("gimp_image_resize: width and height must be positive");
return;
}
g_assert (new_width > 0 && new_height > 0);
/* Get the floating layer if one exists */
floating_layer = gimp_image_floating_sel (gimage);
......@@ -418,27 +405,6 @@ gimp_image_scale (GimpImage *gimage, int new_width, int new_height)
}
GimpImage *
gimp_image_get_named (char *name)
{
GSList *tmp = image_list;
GimpImage *gimage;
char *str;
while (tmp)
{
gimage = tmp->data;
str = prune_filename (gimp_image_filename (gimage));
if (strcmp (str, name) == 0)
return gimage;
tmp = g_slist_next (tmp);
}
return NULL;
}
TileManager *
gimp_image_shadow (GimpImage *gimage, int width, int height, int bpp)
......@@ -2901,17 +2867,3 @@ gimp_image_invalidate_preview (GimpImage *gimage)
gimage->comp_preview_valid[2] = FALSE;
}
void
gimp_image_invalidate_previews (void)
{
GSList *tmp = image_list;
GimpImage *gimage;
while (tmp)
{
gimage = (GimpImage *) tmp->data;
gimp_image_invalidate_preview (gimage);
tmp = g_slist_next (tmp);
}
}
......@@ -9,11 +9,13 @@
#include "layer.h"
#include "temp_buf.h"
#include "tile_manager.h"
#define GIMP_IMAGE(obj) GTK_CHECK_CAST (obj, gimp_image_get_type (), GimpImage)
#define GIMP_TYPE_IMAGE gimp_image_get_type()
#define GIMP_IMAGE(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_IMAGE, GimpImage)
#define GIMP_IS_GIMAGE(obj) GTK_CHECK_TYPE (obj, gimp_image_get_type())
#define GIMP_IS_GIMAGE(obj) GTK_CHECK_TYPE (obj, GIMP_TYPE_IMAGE)
/* the image types */
......
......@@ -15,12 +15,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpimageP.h"
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"
#include "general.h"
#include "gimpimageP.h"
#include "gimpimage.h"
#include "gimage_mask.h"
#include "paint_funcs.h"
#include "palette.h"
......@@ -75,8 +74,6 @@ int valid_combinations[][MAX_CHANNELS + 1] =
/*
* Static variables
*/
GSList *image_list = NULL;
enum{
DIRTY,
......@@ -151,17 +148,12 @@ static void gimp_image_init (GimpImage *gimage)
GtkType gimp_image_get_type(void){
static GtkType type;
if(!type){
GtkTypeInfo info={
"GimpImage",
sizeof(GimpImage),
sizeof(GimpImageClass),
(GtkClassInitFunc)gimp_image_class_init,
(GtkObjectInitFunc)gimp_image_init,
NULL,
NULL};
type=gtk_type_unique(gimp_object_get_type(), &info);
}
GIMP_TYPE_INIT(type,
GimpImage,
GimpImageClass,
gimp_image_init,
gimp_image_class_init,
GIMP_TYPE_OBJECT);
return type;
}
......@@ -190,8 +182,7 @@ gimp_image_allocate_projection (GimpImage *gimage)
gimage->proj_type = GRAYA_GIMAGE;
break;
default:
g_message ("gimage type unsupported.\n");
break;
g_assert_not_reached();
}
/* allocate the new projection */
......@@ -299,11 +290,7 @@ gimp_image_resize (GimpImage *gimage, int new_width, int new_height,
Layer *floating_layer;
GSList *list;
if (new_width <= 0 || new_height <= 0)
{
g_message ("gimp_image_resize: width and height must be positive");
return;
}
g_assert (new_width > 0 && new_height > 0);
/* Get the floating layer if one exists */