Commit 89b600d2 authored by Manish Singh's avatar Manish Singh

removed all usage of linked.[ch] and switched to GSLists

-Yosh
parent 9af736f2
Thu Jan 29 00:00:54 PST 1998 Manish Singh <yosh@gimp.org>
* removed all usage of linked.[ch] and switched to GSLists
Wed Jan 28 22:03:42 EST 1998 Adrian Likins <adrian@gimp.org>
* Fixed carve-it.scm and circuit.scm (circuit broke due
......
......@@ -179,8 +179,6 @@ gimp_SOURCES = \
layers_dialogP.h \
levels.c \
levels.h \
linked.h \
linked.c \
magnify.c \
magnify.h \
main.c \
......
......@@ -2,5 +2,4 @@ convert to using gtk+
remove traces of autodialog
remove traces of action areas
remove use of mem chunks from memutils.[ch]
remove use of linked.[ch]
remove use of xmalloc and xfree (use g_malloc and g_free instead)
......@@ -20,7 +20,6 @@
#include <stdarg.h>
#include <string.h>
#include "appenv.h"
#include "linked.h"
#include "pixel_region.h"
#include "tile_manager_pvt.h"
......@@ -40,7 +39,7 @@ typedef struct _PixelRegionIterator PixelRegionIterator;
struct _PixelRegionIterator
{
link_ptr pixel_regions;
GSList *pixel_regions;
int region_width;
int region_height;
int portion_width;
......@@ -292,7 +291,7 @@ pixel_regions_register (int num_regions, ...)
}
/* Add the pixel region holder to the list */
PRI->pixel_regions = add_to_list (PRI->pixel_regions, PRH);
PRI->pixel_regions = g_slist_prepend (PRI->pixel_regions, PRH);
}
va_end (ap);
......@@ -305,7 +304,7 @@ void *
pixel_regions_process (PRI_ptr)
void *PRI_ptr;
{
link_ptr list;
GSList *list;
PixelRegionHolder *PRH;
PixelRegionIterator *PRI;
......@@ -342,7 +341,7 @@ pixel_regions_process (PRI_ptr)
}
}
list = next_item (list);
list = g_slist_next (list);
}
return pixel_regions_configure (PRI);
......@@ -352,7 +351,7 @@ void
pixel_regions_process_stop (PRI_ptr)
void *PRI_ptr;
{
link_ptr list;
GSList *list;
PixelRegionHolder *PRH;
PixelRegionIterator *PRI;
......@@ -381,7 +380,7 @@ pixel_regions_process_stop (PRI_ptr)
}
}
list = next_item (list);
list = g_slist_next (list);
}
if (PRI->pixel_regions)
......@@ -390,9 +389,9 @@ pixel_regions_process_stop (PRI_ptr)
while (list)
{
g_free (list->data);
list = next_item (list);
list = g_slist_next (list);
}
free_list (PRI->pixel_regions);
g_slist_free (PRI->pixel_regions);
g_free (PRI);
}
}
......@@ -405,7 +404,7 @@ static int
get_portion_height (PRI)
PixelRegionIterator *PRI;
{
link_ptr list;
GSList *list;
PixelRegionHolder *PRH;
int min_height = G_MAXINT;
int height;
......@@ -437,7 +436,7 @@ get_portion_height (PRI)
min_height = height;
}
list = next_item (list);
list = g_slist_next (list);
}
return min_height;
......@@ -448,7 +447,7 @@ static int
get_portion_width (PRI)
PixelRegionIterator *PRI;
{
link_ptr list;
GSList *list;
PixelRegionHolder *PRH;
int min_width = G_MAXINT;
int width;
......@@ -480,7 +479,7 @@ get_portion_width (PRI)
min_width = width;
}
list = next_item (list);
list = g_slist_next (list);
}
return min_width;
......@@ -492,7 +491,7 @@ pixel_regions_configure (PRI)
PixelRegionIterator *PRI;
{
PixelRegionHolder *PRH;
link_ptr list;
GSList *list;
/* Determine the portion width and height */
PRI->portion_width = get_portion_width (PRI);
......@@ -507,9 +506,9 @@ pixel_regions_configure (PRI)
while (list)
{
g_free (list->data);
list = next_item (list);
list = g_slist_next (list);
}
free_list (PRI->pixel_regions);
g_slist_free (PRI->pixel_regions);
g_free (PRI);
}
......@@ -529,7 +528,7 @@ pixel_regions_configure (PRI)
pixel_region_configure (PRH, PRI);
}
list = next_item (list);
list = g_slist_next (list);
}
return PRI;
......
......@@ -25,7 +25,6 @@
#include "errors.h"
#include "gdisplay.h"
#include "gimage_mask.h"
#include "linked.h"
#include "rect_select.h"
#define BEZIER_START 1
......@@ -71,7 +70,7 @@ struct _bezier_select
BezierPoint *last_point; /* the last point on the curve */
int num_points; /* number of points in the curve */
Channel *mask; /* null if the curve is open */
link_ptr *scanlines; /* used in converting a curve */
GSList **scanlines; /* used in converting a curve */
};
static void bezier_select_reset (BezierSelect *);
......@@ -95,8 +94,8 @@ static void bezier_compose (BezierMatrix, BezierMatrix, BezierMa
static void bezier_convert (BezierSelect *, GDisplay *, int, int);
static void bezier_convert_points (BezierSelect *, GdkPoint *, int);
static void bezier_convert_line (link_ptr *, int, int, int, int);
static link_ptr bezier_insert_in_list (link_ptr, int);
static void bezier_convert_line (GSList **, int, int, int, int);
static GSList * bezier_insert_in_list (GSList *, int);
static BezierMatrix basis =
{
......@@ -1042,7 +1041,7 @@ bezier_convert (BezierSelect *bezier_sel,
PixelRegion maskPR;
BezierPoint * points;
BezierPoint * start_pt;
link_ptr list;
GSList * list;
unsigned char *buf, *b;
int draw_type;
int * vals, val;
......@@ -1084,7 +1083,7 @@ bezier_convert (BezierSelect *bezier_sel,
gdisp->gimage->height);
/* allocate room for the scanlines */
bezier_sel->scanlines = g_malloc (sizeof (link_ptr) * height);
bezier_sel->scanlines = g_malloc (sizeof (GSList *) * height);
/* zero out the scanlines */
for (i = 0; i < height; i++)
......@@ -1146,7 +1145,7 @@ bezier_convert (BezierSelect *bezier_sel,
for (j = 0; j < w; j++)
vals[j + x] += 255;
list = next_item (list);
list = g_slist_next (list);
}
}
......@@ -1168,7 +1167,7 @@ bezier_convert (BezierSelect *bezier_sel,
drawable_width (GIMP_DRAWABLE(bezier_sel->mask)), buf);
}
free_list (bezier_sel->scanlines[i]);
g_slist_free (bezier_sel->scanlines[i]);
}
if (antialias)
......@@ -1207,7 +1206,7 @@ bezier_convert_points (BezierSelect *bezier_sel,
}
static void
bezier_convert_line (link_ptr *scanlines,
bezier_convert_line (GSList ** scanlines,
int x1,
int y1,
int x2,
......@@ -1323,32 +1322,32 @@ bezier_convert_line (link_ptr *scanlines,
}
}
static link_ptr
bezier_insert_in_list (link_ptr list,
static GSList *
bezier_insert_in_list (GSList * list,
int x)
{
link_ptr orig = list;
link_ptr rest;
GSList * orig = list;
GSList * rest;
if (!list)
return add_to_list (list, (void *) ((long) x));
return g_slist_prepend (list, (void *) ((long) x));
while (list)
{
rest = next_item (list);
rest = g_slist_next (list);
if (x < (long) list->data)
{
rest = add_to_list (rest, list->data);
rest = g_slist_prepend (rest, list->data);
list->next = rest;
list->data = (void *) ((long) x);
return orig;
}
else if (!rest)
{
append_to_list (list, (void *) ((long) x));
g_slist_append (list, (void *) ((long) x));
return orig;
}
list = next_item (list);
list = g_slist_next (list);
}
return orig;
......
......@@ -468,7 +468,7 @@ display_setup (BrushSelectP bsp)
static void
display_brushes (BrushSelectP bsp)
{
link_ptr list = brush_list; /* the global brush list */
GSList * list = brush_list; /* the global brush list */
int row, col;
GBrushP brush;
......@@ -500,7 +500,7 @@ display_brushes (BrushSelectP bsp)
col = 0;
}
list = next_item (list);
list = g_slist_next (list);
}
}
......
......@@ -32,13 +32,12 @@
#include "errors.h"
#include "general.h"
#include "gimprc.h"
#include "linked.h"
#include "menus.h"
/* global variables */
GBrushP active_brush = NULL;
link_ptr brush_list = NULL;
GSList * brush_list = NULL;
int num_brushes = 0;
double opacity = 1.0;
......@@ -54,19 +53,21 @@ static Argument *return_args;
static int have_default_brush = 0;
/* static function prototypes */
static link_ptr insert_brush_in_list (link_ptr, GBrushP);
static GSList * insert_brush_in_list (GSList *, GBrushP);
static void create_default_brush (void);
static void load_brush (char *filename);
static void free_brush (GBrushP);
static void brushes_free_one (gpointer, gpointer);
static gint brush_compare_func (gpointer, gpointer);
/* function declarations */
void
brushes_init ()
{
link_ptr list;
GSList * list;
if (brush_list)
brushes_free ();
brushes_free();
brush_list = NULL;
num_brushes = 0;
......@@ -81,30 +82,34 @@ brushes_init ()
list = brush_list;
while (list) {
/* Set the brush index */
((GBrush *) list->data)->index = num_brushes++;
list = next_item (list);
/* Set the brush index */
((GBrush *) list->data)->index = num_brushes++;
list = g_slist_next (list);
}
}
void
brushes_free ()
static void
brushes_free_one (gpointer data, gpointer dummy)
{
link_ptr list;
GBrushP brush;
free_brush ((GBrushP) data);
}
list = brush_list;
while (list)
{
brush = (GBrushP) list->data;
free_brush (brush);
list = next_item (list);
}
static gint
brush_compare_func (gpointer first, gpointer second)
{
return strcmp (((GBrushP)first)->name, ((GBrushP)second)->name);
}
free_list (list);
void
brushes_free ()
{
if (brush_list) {
g_slist_foreach (brush_list, brushes_free_one, NULL);
g_slist_free (brush_list);
}
have_default_brush = 0;
active_brush = NULL;
......@@ -140,67 +145,10 @@ get_active_brush ()
}
static link_ptr
insert_brush_in_list (list, brush)
link_ptr list;
GBrushP brush;
static GSList *
insert_brush_in_list (GSList *list, GBrushP brush)
{
link_ptr tmp;
link_ptr prev;
link_ptr new_link;
GBrushP b;
int val;
/* Insert the item in the list */
if (list)
{
prev = NULL;
tmp = list;
do {
if (tmp)
{
b = (GBrushP) tmp->data;
/* do the comparison needed for the insertion sort */
val = strcmp (brush->name, b->name);
}
else
val = -1;
if (val <= 0)
{
/* this is the place the item goes */
/* Insert the item into the list. We'll have to create
* a new link and then do a little insertion.
*/
new_link = alloc_list ();
if (!new_link)
fatal_error ("Unable to allocate memory");
new_link->data = brush;
new_link->next = tmp;
if (prev)
prev->next = new_link;
if (tmp == list)
list = new_link;
return list;
}
/* Advance to the next item in the list.
*/
prev = tmp;
tmp = next_item (tmp);
} while (prev);
}
else
/* There are no items in the brush list, so we'll just start
* one right now.
*/
list = add_to_list (list, brush);
return list;
return g_slist_insert_sorted (list, brush, brush_compare_func);
}
static void
......@@ -341,29 +289,21 @@ load_brush(char *filename)
GBrushP
get_brush_by_index (index)
int index;
get_brush_by_index (int index)
{
link_ptr list;
GBrushP brush;
GSList *list;
GBrushP brush = NULL;
list = brush_list;
while (list)
{
brush = (GBrushP) list->data;
if (brush->index == index)
return brush;
list = next_item (list);
}
list = g_slist_nth (brush_list, index);
if (list)
brush = (GBrushP) list->data;
return NULL;
return brush;
}
void
select_brush (brush)
GBrushP brush;
select_brush (GBrushP brush)
{
/* Make sure the active brush is swapped before we get a new one... */
if (stingy_memory_use)
......@@ -579,7 +519,7 @@ static Argument *
brushes_set_brush_invoker (Argument *args)
{
GBrushP brushp;
link_ptr list;
GSList *list;
char *name;
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
......@@ -600,7 +540,7 @@ brushes_set_brush_invoker (Argument *args)
break;
}
list = next_item (list);
list = g_slist_next (list);
}
}
......@@ -925,7 +865,7 @@ static Argument *
brushes_list_invoker (Argument *args)
{
GBrushP brushp;
link_ptr list;
GSList *list;
char **brushes;
int i;
......@@ -939,7 +879,7 @@ brushes_list_invoker (Argument *args)
brushp = (GBrushP) list->data;
brushes[i++] = g_strdup (brushp->name);
list = next_item (list);
list = g_slist_next (list);
}
return_args = procedural_db_return_args (&brushes_list_proc, success);
......
......@@ -18,7 +18,7 @@
#ifndef __BRUSHES_H__
#define __BRUSHES_H__
#include "linked.h"
#include <glib.h>
#include "procedural_db.h"
#include "temp_buf.h"
......@@ -35,7 +35,7 @@ struct _GBrush
};
/* global variables */
extern link_ptr brush_list;
extern GSList * brush_list;
extern int num_brushes;
......
......@@ -26,7 +26,6 @@
#include "errors.h"
#include "gimage_mask.h"
#include "layer.h"
#include "linked.h"
#include "paint_funcs.h"
#include "temp_buf.h"
#include "undo.h"
......@@ -412,7 +411,7 @@ channel_preview (Channel *channel, int width, int height)
void
channel_invalidate_previews (int gimage_id)
{
link_ptr tmp;
GSList * tmp;
Channel * channel;
GImage * gimage;
......@@ -425,7 +424,7 @@ channel_invalidate_previews (int gimage_id)
{
channel = (Channel *) tmp->data;
drawable_invalidate_preview (GIMP_DRAWABLE(channel));
tmp = next_item (tmp);
tmp = g_slist_next (tmp);
}
}
......
......@@ -94,7 +94,7 @@ struct _ChannelsDialog {
int gimage_id;
Channel * active_channel;
Layer *floating_sel;
link_ptr channel_widgets;
GSList *channel_widgets;
};
/* channels dialog widget routines */
......@@ -230,7 +230,7 @@ channels_dialog_flush ()
GImage *gimage;
Channel *channel;
ChannelWidget *cw;
link_ptr list;
GSList *list;
int gimage_pos;
int pos;
......@@ -255,7 +255,7 @@ channels_dialog_flush ()
{
cw = (ChannelWidget *) list->data;
cw->visited = FALSE;
list = next_item (list);
list = g_slist_next (list);
}
/* Add any missing channels */
......@@ -271,7 +271,7 @@ channels_dialog_flush ()
else
cw->visited = TRUE;
list = next_item (list);
list = g_slist_next (list);
}
/* Remove any extraneous auxillary channels */
......@@ -279,7 +279,7 @@ channels_dialog_flush ()
while (list)
{
cw = (ChannelWidget *) list->data;
list = next_item (list);
list = g_slist_next (list);
if (cw->visited == FALSE && cw->type == Auxillary)
/* will only be true for auxillary channels */
......@@ -292,7 +292,7 @@ channels_dialog_flush ()
while (list)
{
cw = (ChannelWidget *) list->data;
list = next_item (list);
list = g_slist_next (list);
if (cw->type == Auxillary)
if ((gimage_pos = gimage_get_channel_index (gimage, cw->channel)) != pos)
......@@ -326,7 +326,7 @@ channels_dialog_update (int gimage_id)
ChannelWidget *cw;
GImage *gimage;
Channel *channel;
link_ptr list;
GSList *list;
GList *item_list;
if (!channelsD)
......@@ -345,7 +345,7 @@ channels_dialog_update (int gimage_id)
while (list)
{
cw = (ChannelWidget *) list->data;
list = next_item(list);
list = g_slist_next (list);
channel_widget_delete (cw);
}
channelsD->channel_widgets = NULL;
......@@ -365,17 +365,17 @@ channels_dialog_update (int gimage_id)
{
case RGB:
cw = create_channel_widget (gimage, NULL, Red);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
channelsD->components[0] = Red;
cw = create_channel_widget (gimage, NULL, Green);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
channelsD->components[1] = Green;
cw = create_channel_widget (gimage, NULL, Blue);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
channelsD->components[2] = Blue;
......@@ -384,7 +384,7 @@ channels_dialog_update (int gimage_id)
case GRAY:
cw = create_channel_widget (gimage, NULL, Gray);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
channelsD->components[0] = Gray;
......@@ -393,7 +393,7 @@ channels_dialog_update (int gimage_id)
case INDEXED:
cw = create_channel_widget (gimage, NULL, Indexed);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
channelsD->components[0] = Indexed;
......@@ -408,10 +408,10 @@ channels_dialog_update (int gimage_id)
/* create a channel list item */
channel = (Channel *) list->data;
cw = create_channel_widget (gimage, channel, Auxillary);
channelsD->channel_widgets = append_to_list (channelsD->channel_widgets, cw);
channelsD->channel_widgets = g_slist_append (channelsD->channel_widgets, cw);
item_list = g_list_append (item_list, cw->list_item);
list = next_item (list);
list = g_slist_next (list);
}
/* get the index of the active channel */
......@@ -431,7 +431,7 @@ channels_dialog_clear ()
void
channels_dialog_free ()
{
link_ptr list;
GSList *list;
ChannelWidget *cw;
if (channelsD == NULL)
......@@ -446,7 +446,7 @@ channels_dialog_free ()
while (list)
{
cw = (ChannelWidget *) list->data;
list = next_item(list);
list = g_slist_next (list);
channel_widget_delete (cw);
}
channelsD->channel_widgets = NULL;
......@@ -677,7 +677,7 @@ channels_dialog_add_channel (Channel *channel)
item_list = g_list_append (item_list, channel_widget->list_item);
position = gimage_get_channel_index (gimage, channel);
channelsD->channel_widgets = insert_in_list (channelsD->channel_widgets, channel_widget,
channelsD->channel_widgets = g_slist_insert (channelsD->channel_widgets, channel_widget,
position + channelsD->num_components);
gtk_list_insert_items (GTK_LIST (channelsD->channel_list), item_list,
position + channelsD->num_components);
......@@ -920,7 +920,7 @@ static ChannelWidget *
channel_widget_get_ID (Channel *channel)
{
ChannelWidget *lw;
link_ptr list;
GSList *list;
if (!channelsD)
return NULL;
......@@ -933,7 +933,7 @@ channel_widget_get_ID (Channel *channel)
if (lw->channel == channel)
return lw;
list = next_item(list);
list = g_slist_next (list);
}
return NULL;
......@@ -1042,7 +1042,7 @@ channel_widget_delete (ChannelWidget *channel_widget)
gdk_pixmap_unref (channel_widget->channel_pixmap);