Commit 380deeb2 authored by Adrian Likins's avatar Adrian Likins

Fixed up --no-data so that the various *_init() routines always get

 * app/app_procs.c app/brush_select.c app/brushes.c
        app/brushes.h app/convert.c app/gradient.c app/gradient.h
        app/palette.c app/palette.h app/pattern_select.c app/patterns.c
        app/patterns.h:   Fixed up --no-data so that the various *_init()
        routines always get called, and so that when in interactive mode
        the data can be loaded by the user even when started with --no-data.
        Fixes the blend bug too...

	yeah, sven scooped me... but i think this is still a needed patch...

-adrian
parent b1a30ca8
Thu Mar 26 13:03:18 EST 1998 Adrian Likins <adrian@gimp.org>
* app/app_procs.c app/brush_select.c app/brushes.c
app/brushes.h app/convert.c app/gradient.c app/gradient.h
app/palette.c app/palette.h app/pattern_select.c app/patterns.c
app/patterns.h: Fixed up --no-data so that the various *_init()
routines always get called, and so that when in interactive mode
the data can be loaded by the user even when started with --no-data.
Fixes the blend bug too...
Thu Mar 26 18:38:54 MET 1998 Sven Neumann <sven@gimp.org>
app/gradient.c: fixed another --no-data problem; also the
......
......@@ -463,17 +463,17 @@ app_init ()
file_ops_pre_init (); /* pre-initialize the file types */
RESET_BAR();
xcf_init (); /* initialize the xcf file format routines */
if (no_data == FALSE)
{
RESET_BAR();
brushes_init (); /* initialize the list of gimp brushes */
RESET_BAR();
patterns_init (); /* initialize the list of gimp patterns */
RESET_BAR();
palettes_init (); /* initialize the list of gimp palettes */
RESET_BAR();
gradients_init (); /* initialize the list of gimp gradients */
}
RESET_BAR();
brushes_init (no_data); /* initialize the list of gimp brushes */
RESET_BAR();
patterns_init (no_data); /* initialize the list of gimp patterns */
RESET_BAR();
palettes_init (no_data); /* initialize the list of gimp palettes */
RESET_BAR();
gradients_init (no_data); /* initialize the list of gimp gradients */
RESET_BAR();
plug_in_init (); /* initialize the plug in structures */
RESET_BAR();
......
......@@ -133,6 +133,7 @@ brush_select_new ()
bsp = g_malloc (sizeof (_BrushSelect));
bsp->redraw = TRUE;
bsp->scroll_offset = 0;
bsp->brush_popup = NULL;
/* The shell and main vbox */
......@@ -269,8 +270,12 @@ brush_select_new ()
gtk_widget_show (bsp->shell);
/* calculate the scrollbar */
if(no_data)
brushes_init(FALSE);
/* This is done by size_allocate anyway, which is much better */
preview_calc_scrollbar (bsp);
/* render the brushes into the newly created image structure */
display_brushes (bsp);
......@@ -597,16 +602,28 @@ preview_calc_scrollbar (BrushSelectP bsp)
int num_rows;
int page_size;
int max;
int offs;
int rowy;
bsp->scroll_offset = 0;
offs = bsp->scroll_offset;
num_rows = (num_brushes + NUM_BRUSH_COLUMNS - 1) / NUM_BRUSH_COLUMNS;
max = num_rows * bsp->cell_width;
if (!num_rows) num_rows = 1;
page_size = bsp->preview->allocation.height;
page_size = ((page_size < max) ? page_size : max);
/*
rowy = (get_active_brush()->index / NUM_BRUSH_COLUMNS) * bsp->cell_width
+ bsp->cell_width/2;
if((rowy < offs) || (rowy > (offs + page_size)))
offs = rowy - page_size/2;
offs = MIN(MAX(offs, 0), max - page_size);
*/
bsp->scroll_offset = offs;
bsp->sbar_data->value = bsp->scroll_offset;
bsp->sbar_data->upper = max;
bsp->sbar_data->page_size = (page_size < max) ? page_size : max;
/* bsp->sbar_data->page_size = page_size; */
bsp->sbar_data->page_size = ((page_size < max) ? page_size : max);
bsp->sbar_data->page_increment = (page_size >> 1);
bsp->sbar_data->step_increment = bsp->cell_width;
......@@ -764,7 +781,12 @@ brush_select_refresh_callback (GtkWidget *w,
bsp = (BrushSelectP) client_data;
/* re-init the brush list */
brushes_init ();
brushes_init(FALSE);
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
/* recalculate scrollbar extents */
preview_calc_scrollbar (bsp);
......@@ -772,10 +794,7 @@ brush_select_refresh_callback (GtkWidget *w,
/* render the brushes into the newly created image structure */
display_brushes (bsp);
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
/* update the display */
if (bsp->redraw)
......
......@@ -62,7 +62,7 @@ static gint brush_compare_func (gpointer, gpointer);
/* function declarations */
void
brushes_init ()
brushes_init (int no_data)
{
GSList * list;
GBrushP gb_start = NULL;
......@@ -76,7 +76,7 @@ brushes_init ()
if (!brush_path)
create_default_brush ();
else
if(!no_data)
datafiles_read_directories (brush_path, load_brush, 0);
/* assign indexes to the loaded brushes */
......@@ -469,7 +469,7 @@ brushes_refresh_brush_invoker (Argument *args)
*/
success = TRUE ;
brushes_init();
brushes_init(TRUE);
return procedural_db_return_args (&brushes_refresh_brush_proc, success);
}
......
......@@ -40,7 +40,7 @@ extern int num_brushes;
/* function declarations */
void brushes_init (void);
void brushes_init (int no_data);
void brushes_free (void);
void brush_select_dialog_free (void);
void select_brush (GBrushP);
......
......@@ -469,7 +469,7 @@ build_palette_menu(int *default_palette){
if(!palette_entries_list) {
/* fprintf(stderr, "no palette_entries_list, building...\n");*/
palette_init_palettes();
palette_init_palettes(FALSE);
}
list = palette_entries_list;
......@@ -3068,7 +3068,7 @@ convert_indexed_palette_invoker (Argument *args)
case CUSTOM_PALETTE:
palette_name = args[4].value.pdb_pointer;
/* fprintf(stderr, "looking for palette `%s'\n", palette_name); */
if (!palette_entries_list) palette_init_palettes();
if (!palette_entries_list) palette_init_palettes(FALSE);
for(list = palette_entries_list;
list;
list = g_slist_next(list)) {
......
......@@ -469,7 +469,7 @@ build_palette_menu(int *default_palette){
if(!palette_entries_list) {
/* fprintf(stderr, "no palette_entries_list, building...\n");*/
palette_init_palettes();
palette_init_palettes(FALSE);
}
list = palette_entries_list;
......@@ -3068,7 +3068,7 @@ convert_indexed_palette_invoker (Argument *args)
case CUSTOM_PALETTE:
palette_name = args[4].value.pdb_pointer;
/* fprintf(stderr, "looking for palette `%s'\n", palette_name); */
if (!palette_entries_list) palette_init_palettes();
if (!palette_entries_list) palette_init_palettes(FALSE);
for(list = palette_entries_list;
list;
list = g_slist_next(list)) {
......
......@@ -469,7 +469,7 @@ build_palette_menu(int *default_palette){
if(!palette_entries_list) {
/* fprintf(stderr, "no palette_entries_list, building...\n");*/
palette_init_palettes();
palette_init_palettes(FALSE);
}
list = palette_entries_list;
......@@ -3068,7 +3068,7 @@ convert_indexed_palette_invoker (Argument *args)
case CUSTOM_PALETTE:
palette_name = args[4].value.pdb_pointer;
/* fprintf(stderr, "looking for palette `%s'\n", palette_name); */
if (!palette_entries_list) palette_init_palettes();
if (!palette_entries_list) palette_init_palettes(FALSE);
for(list = palette_entries_list;
list;
list = g_slist_next(list)) {
......
......@@ -591,15 +591,17 @@ static char *coloring_types[] = {
/*****/
void
gradients_init(void)
gradients_init(int no_data)
{
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if(!no_data)
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
curr_gradient = grad_create_default_gradient();
curr_gradient->name = g_strdup("Default");
curr_gradient->filename = build_user_filename(curr_gradient->name, gradient_path);
......@@ -774,6 +776,8 @@ grad_create_gradient_editor(void)
/* Create editor */
if(no_data)
gradients_init(FALSE);
g_editor = g_malloc(sizeof(gradient_editor_t));
/* Shell and main vbox */
......@@ -1592,7 +1596,7 @@ ed_refresh_callback(GtkWidget *widget, gpointer client_data)
grad_free_gradients();
gradients_init();
gradients_init(FALSE);
ed_set_list_of_gradients();
......
......@@ -29,7 +29,7 @@
/***** Functions *****/
void gradients_init(void);
void gradients_init(int no_data);
void gradients_free(void);
void grad_get_color_at(double pos, double *r, double *g, double *b, double *a);
......
......@@ -591,15 +591,17 @@ static char *coloring_types[] = {
/*****/
void
gradients_init(void)
gradients_init(int no_data)
{
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if(!no_data)
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
curr_gradient = grad_create_default_gradient();
curr_gradient->name = g_strdup("Default");
curr_gradient->filename = build_user_filename(curr_gradient->name, gradient_path);
......@@ -774,6 +776,8 @@ grad_create_gradient_editor(void)
/* Create editor */
if(no_data)
gradients_init(FALSE);
g_editor = g_malloc(sizeof(gradient_editor_t));
/* Shell and main vbox */
......@@ -1592,7 +1596,7 @@ ed_refresh_callback(GtkWidget *widget, gpointer client_data)
grad_free_gradients();
gradients_init();
gradients_init(FALSE);
ed_set_list_of_gradients();
......
......@@ -29,7 +29,7 @@
/***** Functions *****/
void gradients_init(void);
void gradients_init(int no_data);
void gradients_free(void);
void grad_get_color_at(double pos, double *r, double *g, double *b, double *a);
......
......@@ -133,6 +133,7 @@ brush_select_new ()
bsp = g_malloc (sizeof (_BrushSelect));
bsp->redraw = TRUE;
bsp->scroll_offset = 0;
bsp->brush_popup = NULL;
/* The shell and main vbox */
......@@ -269,8 +270,12 @@ brush_select_new ()
gtk_widget_show (bsp->shell);
/* calculate the scrollbar */
if(no_data)
brushes_init(FALSE);
/* This is done by size_allocate anyway, which is much better */
preview_calc_scrollbar (bsp);
/* render the brushes into the newly created image structure */
display_brushes (bsp);
......@@ -597,16 +602,28 @@ preview_calc_scrollbar (BrushSelectP bsp)
int num_rows;
int page_size;
int max;
int offs;
int rowy;
bsp->scroll_offset = 0;
offs = bsp->scroll_offset;
num_rows = (num_brushes + NUM_BRUSH_COLUMNS - 1) / NUM_BRUSH_COLUMNS;
max = num_rows * bsp->cell_width;
if (!num_rows) num_rows = 1;
page_size = bsp->preview->allocation.height;
page_size = ((page_size < max) ? page_size : max);
/*
rowy = (get_active_brush()->index / NUM_BRUSH_COLUMNS) * bsp->cell_width
+ bsp->cell_width/2;
if((rowy < offs) || (rowy > (offs + page_size)))
offs = rowy - page_size/2;
offs = MIN(MAX(offs, 0), max - page_size);
*/
bsp->scroll_offset = offs;
bsp->sbar_data->value = bsp->scroll_offset;
bsp->sbar_data->upper = max;
bsp->sbar_data->page_size = (page_size < max) ? page_size : max;
/* bsp->sbar_data->page_size = page_size; */
bsp->sbar_data->page_size = ((page_size < max) ? page_size : max);
bsp->sbar_data->page_increment = (page_size >> 1);
bsp->sbar_data->step_increment = bsp->cell_width;
......@@ -764,7 +781,12 @@ brush_select_refresh_callback (GtkWidget *w,
bsp = (BrushSelectP) client_data;
/* re-init the brush list */
brushes_init ();
brushes_init(FALSE);
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
/* recalculate scrollbar extents */
preview_calc_scrollbar (bsp);
......@@ -772,10 +794,7 @@ brush_select_refresh_callback (GtkWidget *w,
/* render the brushes into the newly created image structure */
display_brushes (bsp);
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
/* update the display */
if (bsp->redraw)
......
......@@ -591,15 +591,17 @@ static char *coloring_types[] = {
/*****/
void
gradients_init(void)
gradients_init(int no_data)
{
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if(!no_data)
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
curr_gradient = grad_create_default_gradient();
curr_gradient->name = g_strdup("Default");
curr_gradient->filename = build_user_filename(curr_gradient->name, gradient_path);
......@@ -774,6 +776,8 @@ grad_create_gradient_editor(void)
/* Create editor */
if(no_data)
gradients_init(FALSE);
g_editor = g_malloc(sizeof(gradient_editor_t));
/* Shell and main vbox */
......@@ -1592,7 +1596,7 @@ ed_refresh_callback(GtkWidget *widget, gpointer client_data)
grad_free_gradients();
gradients_init();
gradients_init(FALSE);
ed_set_list_of_gradients();
......
......@@ -29,7 +29,7 @@
/***** Functions *****/
void gradients_init(void);
void gradients_init(int no_data);
void gradients_free(void);
void grad_get_color_at(double pos, double *r, double *g, double *b, double *a);
......
......@@ -130,9 +130,9 @@ static MenuItem palette_ops[] =
};
void
palettes_init ()
palettes_init (int no_data)
{
palette_init_palettes ();
palette_init_palettes (no_data);
}
void
......@@ -256,6 +256,9 @@ palette_create ()
gtk_widget_show (frame);
gtk_widget_show (hbox);
if(no_data)
palettes_init(FALSE);
/* The action area */
action_items[0].user_data = palette;
action_items[1].user_data = palette;
......@@ -380,9 +383,11 @@ palette_swap_colors (void)
}
void
palette_init_palettes (void)
palette_init_palettes (int no_data)
{
datafiles_read_directories (palette_path, palette_entries_load, 0);
if(!no_data)
datafiles_read_directories (palette_path, palette_entries_load, 0);
}
......@@ -856,7 +861,7 @@ palette_refresh_callback (GtkWidget *w,
if(palette)
{
palette_free_palettes ();
palette_init_palettes();
palette_init_palettes(FALSE);
palette_create_palette_menu (palette, default_palette_entries);
palette_calc_scrollbar (palette);
palette_draw_entries (palette);
......@@ -865,7 +870,7 @@ palette_refresh_callback (GtkWidget *w,
else
{
palette_free_palettes ();
palette_init_palettes();
palette_init_palettes(FALSE);
}
}
......@@ -1040,7 +1045,7 @@ palette_delete_entries_callback (GtkWidget *w,
palette->entries = NULL;
palette_free_palettes (); /* free palettes, don't save any modified versions */
palette_init_palettes (); /* load in brand new palettes */
palette_init_palettes (FALSE); /* load in brand new palettes */
palette_create_palette_menu (palette, default_palette_entries);
}
......@@ -1475,7 +1480,7 @@ palette_refresh_invoker (Argument *args)
int success = TRUE ;
palette_free_palettes();
palette_init_palettes();
palette_init_palettes(FALSE);
return procedural_db_return_args (&palette_refresh_proc, success);
}
......
......@@ -29,7 +29,7 @@
#define COLOR_UPDATE_NEW 1
#define COLOR_UPDATE 2
void palettes_init (void);
void palettes_init (int no_data);
void palettes_free (void);
void palette_create (void);
void palette_free (void);
......@@ -58,7 +58,7 @@ struct _PaletteEntry {
typedef struct _PaletteEntry _PaletteEntry, *PaletteEntryP;
extern GSList * palette_entries_list;
void palette_init_palettes (void);
void palette_init_palettes (int no_data);
void palette_free_palettes (void);
/* Procedure definition and marshalling function */
......
......@@ -169,9 +169,12 @@ pattern_select_new ()
gtk_widget_show (vbox);
gtk_widget_show (psp->shell);
if(no_data) /* if patterns are already loaded, dont do it now... */
patterns_init(FALSE);
preview_calc_scrollbar (psp);
display_patterns (psp);
/* update the active selection */
active = get_active_pattern ();
if (active)
......@@ -676,7 +679,7 @@ pattern_select_refresh_callback (GtkWidget *w,
psp = (PatternSelectP) client_data;
/* re-init the pattern list */
patterns_init ();
patterns_init (FALSE);
/* recalculate scrollbar extents */
preview_calc_scrollbar (psp);
......
......@@ -130,9 +130,9 @@ static MenuItem palette_ops[] =
};
void
palettes_init ()
palettes_init (int no_data)
{
palette_init_palettes ();
palette_init_palettes (no_data);
}
void
......@@ -256,6 +256,9 @@ palette_create ()
gtk_widget_show (frame);
gtk_widget_show (hbox);
if(no_data)
palettes_init(FALSE);
/* The action area */
action_items[0].user_data = palette;
action_items[1].user_data = palette;
......@@ -380,9 +383,11 @@ palette_swap_colors (void)
}
void
palette_init_palettes (void)
palette_init_palettes (int no_data)
{
datafiles_read_directories (palette_path, palette_entries_load, 0);
if(!no_data)
datafiles_read_directories (palette_path, palette_entries_load, 0);
}
......@@ -856,7 +861,7 @@ palette_refresh_callback (GtkWidget *w,
if(palette)
{
palette_free_palettes ();
palette_init_palettes();
palette_init_palettes(FALSE);
palette_create_palette_menu (palette, default_palette_entries);
palette_calc_scrollbar (palette);
palette_draw_entries (palette);
......@@ -865,7 +870,7 @@ palette_refresh_callback (GtkWidget *w,
else
{
palette_free_palettes ();
palette_init_palettes();
palette_init_palettes(FALSE);
}
}
......@@ -1040,7 +1045,7 @@ palette_delete_entries_callback (GtkWidget *w,
palette->entries = NULL;
palette_free_palettes (); /* free palettes, don't save any modified versions */
palette_init_palettes (); /* load in brand new palettes */
palette_init_palettes (FALSE); /* load in brand new palettes */
palette_create_palette_menu (palette, default_palette_entries);
}
......@@ -1475,7 +1480,7 @@ palette_refresh_invoker (Argument *args)
int success = TRUE ;
palette_free_palettes();
palette_init_palettes();
palette_init_palettes(FALSE);
return procedural_db_return_args (&palette_refresh_proc, success);
}
......
......@@ -29,7 +29,7 @@
#define COLOR_UPDATE_NEW 1
#define COLOR_UPDATE 2
void palettes_init (void);
void palettes_init (int no_data);
void palettes_free (void);
void palette_create (void);
void palette_free (void);
......@@ -58,7 +58,7 @@ struct _PaletteEntry {
typedef struct _PaletteEntry _PaletteEntry, *PaletteEntryP;
extern GSList * palette_entries_list;
void palette_init_palettes (void);
void palette_init_palettes (int no_data);
void palette_free_palettes (void);
/* Procedure definition and marshalling function */
......
......@@ -169,9 +169,12 @@ pattern_select_new ()
gtk_widget_show (vbox);
gtk_widget_show (psp->shell);
if(no_data) /* if patterns are already loaded, dont do it now... */
patterns_init(FALSE);
preview_calc_scrollbar (psp);
display_patterns (psp);
/* update the active selection */
active = get_active_pattern ();
if (active)
......@@ -676,7 +679,7 @@ pattern_select_refresh_callback (GtkWidget *w,
psp = (PatternSelectP) client_data;
/* re-init the pattern list */
patterns_init ();
patterns_init (FALSE);
/* recalculate scrollbar extents */
preview_calc_scrollbar (psp);
......
......@@ -58,7 +58,7 @@ static gint pattern_compare_func (gpointer, gpointer);
/* function declarations */
void
patterns_init ()
patterns_init (int no_data)
{
GSList *list;
......@@ -70,8 +70,8 @@ patterns_init ()
if (!pattern_path)
return;
datafiles_read_directories (pattern_path, load_pattern, 0);
if(!no_data)
datafiles_read_directories (pattern_path, load_pattern, 0);
/* assign indexes to the loaded patterns */
......
......@@ -33,7 +33,7 @@ struct _GPattern
};
/* function declarations */
void patterns_init (void);
void patterns_init (int no_data);
void patterns_free (void);
void pattern_select_dialog_free (void);
void select_pattern (GPatternP);
......
......@@ -591,15 +591,17 @@ static char *coloring_types[] = {
/*****/
void
gradients_init(void)
gradients_init(int no_data)
{
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if(!no_data)
datafiles_read_directories(gradient_path, grad_load_gradient, 0);
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
if (grad_default_gradient != NULL)
curr_gradient = grad_default_gradient;
else if (gradients_list != NULL)
curr_gradient = (gradient_t *) gradients_list->data;
else {
curr_gradient = grad_create_default_gradient();
curr_gradient->name = g_strdup("Default");
curr_gradient->filename = build_user_filename(curr_gradient->name, gradient_path);
......@@ -774,6 +776,8 @@ grad_create_gradient_editor(void)
/* Create editor */
if(no_data)
gradients_init(FALSE);
g_editor = g_malloc(sizeof(gradient_editor_t));
/* Shell and main vbox */
......@@ -1592,7 +1596,7 @@ ed_refresh_callback(GtkWidget *widget, gpointer client_data)
grad_free_gradients();
gradients_init();
gradients_init(FALSE);
ed_set_list_of_gradients();
......
......@@ -29,7 +29,7 @@
/***** Functions *****/
void gradients_init(void);
void gradients_init(int no_data);
void gradients_free(void);
void grad_get_color_at(double pos, double *r, double *g, double *b, double *a);
......
......@@ -130,9 +130,9 @@ static MenuItem palette_ops[] =
};