Commit 5c86e639 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed the global "base_config" variable.

2002-11-30  Michael Natterer  <mitch@gimp.org>

	* app/base/base-types.h: removed the global "base_config" variable.

	* app/base/base.[ch]: added "gboolean use_mmx" to base_init().
	Don't #include "appenv.h". Pass around more parameters to reduce
	the usage of the global "paint_options" pointer.

	* app/app_procs.c: pass "use_mmx" to base_init().

	* app/base/temp-buf.c: pass "temp_path" around internally. Declare
	"base_config" extern and added a #warning.

	* app/core/gimpdata.[ch]
	* app/core/gimpbrush.[ch]
	* app/core/gimpbrushgenerated.[ch]
	* app/core/gimpbrushpipe.[ch]
	* app/core/gimpgradient.[ch]
	* app/core/gimppalette.[ch]
	* app/core/gimppattern.[ch]: added "gboolean stingy_memory_use"
	parameters to all _new(), _load() and _duplicate() functions.

	* app/core/gimpmarshal.list: GimpData::duplicate needs an
	OBJECT__BOOLEAN marshaller now.

	* app/core/gimpdatafactory.[ch]: added a "Gimp" pointer so the
	factory can find the config. Pass base_config->stingy_memory_use
	to the GimpData functions changed above.

	* app/core/gimp-gradients.c
	* app/core/gimp.c
	* app/core/gimppalette-import.c
	* app/gui/palettes-commands.c
	* app/widgets/gimpdatafactoryview.c: changed accordingly.

	* app/core/gimpcontext.c: get "stingy_memory_use" from
	context->gimp->config.
parent 64eb7d74
2002-11-30 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: removed the global "base_config" variable.
* app/base/base.[ch]: added "gboolean use_mmx" to base_init().
Don't #include "appenv.h". Pass around more parameters to reduce
the usage of the global "paint_options" pointer.
* app/app_procs.c: pass "use_mmx" to base_init().
* app/base/temp-buf.c: pass "temp_path" around internally. Declare
"base_config" extern and added a #warning.
* app/core/gimpdata.[ch]
* app/core/gimpbrush.[ch]
* app/core/gimpbrushgenerated.[ch]
* app/core/gimpbrushpipe.[ch]
* app/core/gimpgradient.[ch]
* app/core/gimppalette.[ch]
* app/core/gimppattern.[ch]: added "gboolean stingy_memory_use"
parameters to all _new(), _load() and _duplicate() functions.
* app/core/gimpmarshal.list: GimpData::duplicate needs an
OBJECT__BOOLEAN marshaller now.
* app/core/gimpdatafactory.[ch]: added a "Gimp" pointer so the
factory can find the config. Pass base_config->stingy_memory_use
to the GimpData functions changed above.
* app/core/gimp-gradients.c
* app/core/gimp.c
* app/core/gimppalette-import.c
* app/gui/palettes-commands.c
* app/widgets/gimpdatafactoryview.c: changed accordingly.
* app/core/gimpcontext.c: get "stingy_memory_use" from
context->gimp->config.
2002-11-30 Michael Natterer <mitch@gimp.org>
 
* app/core/gimp.[ch]: added gimp->edit_config which is a copy of
......
......@@ -155,7 +155,7 @@ palettes_merge_palettes_callback (GtkWidget *widget,
return;
}
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name));
new_palette = GIMP_PALETTE (gimp_palette_new (palette_name, FALSE));
while (sel_list)
{
......
......@@ -140,7 +140,7 @@ app_init (gint gimp_argc,
NULL);
/* initialize lowlevel stuff */
base_init (GIMP_BASE_CONFIG (gimprc));
base_init (GIMP_BASE_CONFIG (gimprc), use_mmx);
gimp_set_config (the_gimp, GIMP_CORE_CONFIG (gimprc));
......
......@@ -43,10 +43,6 @@
#define ALPHA_I_PIX 1
/* global config variable (temporary) */
GimpBaseConfig *base_config;
/* types */
typedef struct _BoundSeg BoundSeg;
......
......@@ -45,22 +45,21 @@
#include "tile-cache.h"
#include "tile-swap.h"
#include "appenv.h"
GimpBaseConfig *base_config = NULL;
static void base_toast_old_temp_files (void);
static void base_tile_cache_size_notify (GObject *config,
GParamSpec *param_spec,
gpointer data);
static void base_toast_old_temp_files (GimpBaseConfig *config);
static void base_tile_cache_size_notify (GObject *config,
GParamSpec *param_spec,
gpointer data);
/* public functions */
void
base_init (GimpBaseConfig *config)
base_init (GimpBaseConfig *config,
gboolean use_mmx)
{
gchar *swapfile;
gchar *path;
......@@ -83,15 +82,15 @@ base_init (GimpBaseConfig *config)
G_CALLBACK (base_tile_cache_size_notify),
NULL);
base_toast_old_temp_files ();
base_toast_old_temp_files (config);
/* Add the swap file */
if (!base_config->swap_path)
g_object_set (G_OBJECT (base_config), "swap_path", g_get_tmp_dir ());
if (! config->swap_path)
g_object_set (G_OBJECT (config), "swap_path", g_get_tmp_dir ());
swapfile = g_strdup_printf ("gimpswap.%lu", (unsigned long) getpid ());
path = g_build_filename (base_config->swap_path, swapfile, NULL);
path = g_build_filename (config->swap_path, swapfile, NULL);
g_free (swapfile);
......@@ -121,13 +120,13 @@ base_exit (void)
/* private functions */
static void
base_toast_old_temp_files (void)
base_toast_old_temp_files (GimpBaseConfig *config)
{
GDir *dir = NULL;
const char *entry;
if (base_config->swap_path)
dir = g_dir_open (base_config->swap_path, 0, NULL);
if (config->swap_path)
dir = g_dir_open (config->swap_path, 0, NULL);
if (!dir)
return;
......@@ -154,11 +153,8 @@ base_toast_old_temp_files (void)
{
gchar *filename;
filename = g_build_filename (base_config->swap_path, entry,
NULL);
filename = g_build_filename (config->swap_path, entry, NULL);
unlink (filename);
g_free (filename);
}
}
......
......@@ -19,7 +19,8 @@
#ifndef __BASE_H__
#define __BASE_H__
void base_init (GimpBaseConfig *config);
void base_init (GimpBaseConfig *config,
gboolean use_mmx);
void base_exit (void);
......
......@@ -51,6 +51,12 @@ static void temp_buf_to_gray (TempBuf *src_buf,
TempBuf *dest_buf);
#ifdef __GNUC__
#warning FIXME: extern GimpBaseConfig *base_config;
#endif
extern GimpBaseConfig *base_config;
/* Memory management */
static guchar *
......@@ -624,7 +630,7 @@ static TempBuf *cached_in_memory = NULL;
static gchar *
generate_unique_filename (void)
generate_unique_filename (const gchar *temp_path)
{
pid_t pid;
gchar *swapfile;
......@@ -636,7 +642,7 @@ generate_unique_filename (void)
(gint) pid,
swap_index++);
path = g_build_filename (base_config->temp_path, swapfile, NULL);
path = g_build_filename (temp_path, swapfile, NULL);
g_free (swapfile);
......@@ -673,7 +679,7 @@ temp_buf_swap (TempBuf *buf)
return;
/* Get a unique filename for caching the data to a UNIX file */
filename = generate_unique_filename ();
filename = generate_unique_filename (base_config->temp_path);
/* Check if generated filename is valid */
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
......
......@@ -27,6 +27,8 @@
#include "core-types.h"
#include "config/gimpbaseconfig.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
......@@ -104,9 +106,13 @@ gimp_gradients_add_gradient (Gimp *gimp,
const gchar *name,
const gchar *id)
{
GimpGradient *gradient;
GimpBaseConfig *base_config;
GimpGradient *gradient;
base_config = GIMP_BASE_CONFIG (gimp->config);
gradient = GIMP_GRADIENT (gimp_gradient_new (name));
gradient = GIMP_GRADIENT (gimp_gradient_new (name,
base_config->stingy_memory_use));
GIMP_DATA (gradient)->internal = TRUE;
......
......@@ -574,7 +574,8 @@ gimp_initialize (Gimp *gimp,
g_return_if_fail (GIMP_IS_CORE_CONFIG (gimp->config));
gimp->brush_factory =
gimp_data_factory_new (GIMP_TYPE_BRUSH,
gimp_data_factory_new (gimp,
GIMP_TYPE_BRUSH,
(const gchar **) &gimp->config->brush_path,
brush_loader_entries,
G_N_ELEMENTS (brush_loader_entries),
......@@ -583,7 +584,8 @@ gimp_initialize (Gimp *gimp,
gimp_object_set_name (GIMP_OBJECT (gimp->brush_factory), "brush factory");
gimp->pattern_factory =
gimp_data_factory_new (GIMP_TYPE_PATTERN,
gimp_data_factory_new (gimp,
GIMP_TYPE_PATTERN,
(const gchar **) &gimp->config->pattern_path,
pattern_loader_entries,
G_N_ELEMENTS (pattern_loader_entries),
......@@ -592,7 +594,8 @@ gimp_initialize (Gimp *gimp,
gimp_object_set_name (GIMP_OBJECT (gimp->pattern_factory), "pattern factory");
gimp->gradient_factory =
gimp_data_factory_new (GIMP_TYPE_GRADIENT,
gimp_data_factory_new (gimp,
GIMP_TYPE_GRADIENT,
(const gchar **) &gimp->config->gradient_path,
gradient_loader_entries,
G_N_ELEMENTS (gradient_loader_entries),
......@@ -601,7 +604,8 @@ gimp_initialize (Gimp *gimp,
gimp_object_set_name (GIMP_OBJECT (gimp->gradient_factory), "gradient factory");
gimp->palette_factory =
gimp_data_factory_new (GIMP_TYPE_PALETTE,
gimp_data_factory_new (gimp,
GIMP_TYPE_PALETTE,
(const gchar **) &gimp->config->palette_path,
palette_loader_entries,
G_N_ELEMENTS (palette_loader_entries),
......
......@@ -321,13 +321,15 @@ gimp_brush_get_extension (GimpData *data)
}
GimpData *
gimp_brush_new (const gchar *name)
gimp_brush_new (const gchar *name,
gboolean stingy_memory_use)
{
GimpBrush *brush;
g_return_val_if_fail (name != NULL, NULL);
brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0,
stingy_memory_use));
gimp_object_set_name (GIMP_OBJECT (brush), name);
......@@ -341,8 +343,9 @@ gimp_brush_get_standard (void)
if (! standard_brush)
{
standard_brush =
GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
standard_brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5,
0.0, 1.0,
FALSE));
gimp_object_set_name (GIMP_OBJECT (standard_brush), "Standard");
......@@ -354,7 +357,8 @@ gimp_brush_get_standard (void)
}
GimpData *
gimp_brush_load (const gchar *filename)
gimp_brush_load (const gchar *filename,
gboolean stingy_memory_use)
{
GimpBrush *brush;
gint fd;
......@@ -375,7 +379,7 @@ gimp_brush_load (const gchar *filename)
gimp_data_set_filename (GIMP_DATA (brush), filename);
/* Swap the brush to disk (if we're being stingy with memory) */
if (base_config->stingy_memory_use)
if (stingy_memory_use)
{
temp_buf_swap (brush->mask);
......
......@@ -321,13 +321,15 @@ gimp_brush_get_extension (GimpData *data)
}
GimpData *
gimp_brush_new (const gchar *name)
gimp_brush_new (const gchar *name,
gboolean stingy_memory_use)
{
GimpBrush *brush;
g_return_val_if_fail (name != NULL, NULL);
brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0,
stingy_memory_use));
gimp_object_set_name (GIMP_OBJECT (brush), name);
......@@ -341,8 +343,9 @@ gimp_brush_get_standard (void)
if (! standard_brush)
{
standard_brush =
GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5, 0.0, 1.0));
standard_brush = GIMP_BRUSH (gimp_brush_generated_new (5.0, 0.5,
0.0, 1.0,
FALSE));
gimp_object_set_name (GIMP_OBJECT (standard_brush), "Standard");
......@@ -354,7 +357,8 @@ gimp_brush_get_standard (void)
}
GimpData *
gimp_brush_load (const gchar *filename)
gimp_brush_load (const gchar *filename,
gboolean stingy_memory_use)
{
GimpBrush *brush;
gint fd;
......@@ -375,7 +379,7 @@ gimp_brush_load (const gchar *filename)
gimp_data_set_filename (GIMP_DATA (brush), filename);
/* Swap the brush to disk (if we're being stingy with memory) */
if (base_config->stingy_memory_use)
if (stingy_memory_use)
{
temp_buf_swap (brush->mask);
......
......@@ -68,9 +68,11 @@ struct _GimpBrushClass
GType gimp_brush_get_type (void) G_GNUC_CONST;
GimpData * gimp_brush_new (const gchar *name);
GimpData * gimp_brush_new (const gchar *name,
gboolean stingy_memory_use);
GimpData * gimp_brush_get_standard (void);
GimpData * gimp_brush_load (const gchar *filename);
GimpData * gimp_brush_load (const gchar *filename,
gboolean stingy_memory_use);
GimpBrush * gimp_brush_load_brush (gint fd,
const gchar *filename);
......
......@@ -47,10 +47,11 @@
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use);
static GimpBrushClass *parent_class = NULL;
......@@ -174,7 +175,8 @@ gimp_brush_generated_get_extension (GimpData *data)
}
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -183,7 +185,8 @@ gimp_brush_generated_duplicate (GimpData *data)
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
brush->aspect_ratio,
stingy_memory_use);
}
static double
......@@ -203,6 +206,11 @@ gauss (gdouble f)
return (2.0 * f*f);
}
#ifdef __GNUC__
#warning FIXME: extern GimpBaseConfig *base_config;
#endif
extern GimpBaseConfig *base_config;
static void
gimp_brush_generated_dirty (GimpData *data)
{
......@@ -330,10 +338,11 @@ gimp_brush_generated_dirty (GimpData *data)
}
GimpData *
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio)
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -353,11 +362,15 @@ gimp_brush_generated_new (gfloat radius,
/* render brush mask */
gimp_data_dirty (GIMP_DATA (brush));
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
return GIMP_DATA (brush);
}
GimpData *
gimp_brush_generated_load (const gchar *filename)
gimp_brush_generated_load (const gchar *filename,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
FILE *fp;
......@@ -416,7 +429,7 @@ gimp_brush_generated_load (const gchar *filename)
GIMP_DATA (brush)->dirty = FALSE;
if (base_config->stingy_memory_use)
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
return GIMP_DATA (brush);
......
......@@ -47,10 +47,11 @@
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use);
static GimpBrushClass *parent_class = NULL;
......@@ -174,7 +175,8 @@ gimp_brush_generated_get_extension (GimpData *data)
}
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -183,7 +185,8 @@ gimp_brush_generated_duplicate (GimpData *data)
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
brush->aspect_ratio,
stingy_memory_use);
}
static double
......@@ -203,6 +206,11 @@ gauss (gdouble f)
return (2.0 * f*f);
}
#ifdef __GNUC__
#warning FIXME: extern GimpBaseConfig *base_config;
#endif
extern GimpBaseConfig *base_config;
static void
gimp_brush_generated_dirty (GimpData *data)
{
......@@ -330,10 +338,11 @@ gimp_brush_generated_dirty (GimpData *data)
}
GimpData *
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio)
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -353,11 +362,15 @@ gimp_brush_generated_new (gfloat radius,
/* render brush mask */
gimp_data_dirty (GIMP_DATA (brush));
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
return GIMP_DATA (brush);
}
GimpData *
gimp_brush_generated_load (const gchar *filename)
gimp_brush_generated_load (const gchar *filename,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
FILE *fp;
......@@ -416,7 +429,7 @@ gimp_brush_generated_load (const gchar *filename)
GIMP_DATA (brush)->dirty = FALSE;
if (base_config->stingy_memory_use)
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
return GIMP_DATA (brush);
......
......@@ -47,10 +47,11 @@
static void gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass);
static void gimp_brush_generated_init (GimpBrushGenerated *brush);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
static gboolean gimp_brush_generated_save (GimpData *data);
static void gimp_brush_generated_dirty (GimpData *data);
static gchar * gimp_brush_generated_get_extension (GimpData *data);
static GimpData * gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use);
static GimpBrushClass *parent_class = NULL;
......@@ -174,7 +175,8 @@ gimp_brush_generated_get_extension (GimpData *data)
}
static GimpData *
gimp_brush_generated_duplicate (GimpData *data)
gimp_brush_generated_duplicate (GimpData *data,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -183,7 +185,8 @@ gimp_brush_generated_duplicate (GimpData *data)
return gimp_brush_generated_new (brush->radius,
brush->hardness,
brush->angle,
brush->aspect_ratio);
brush->aspect_ratio,
stingy_memory_use);
}
static double
......@@ -203,6 +206,11 @@ gauss (gdouble f)
return (2.0 * f*f);
}
#ifdef __GNUC__
#warning FIXME: extern GimpBaseConfig *base_config;
#endif
extern GimpBaseConfig *base_config;
static void
gimp_brush_generated_dirty (GimpData *data)
{
......@@ -330,10 +338,11 @@ gimp_brush_generated_dirty (GimpData *data)
}
GimpData *
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio)
gimp_brush_generated_new (gfloat radius,
gfloat hardness,
gfloat angle,
gfloat aspect_ratio,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
......@@ -353,11 +362,15 @@ gimp_brush_generated_new (gfloat radius,
/* render brush mask */
gimp_data_dirty (GIMP_DATA (brush));
if (stingy_memory_use)
temp_buf_swap (GIMP_BRUSH (brush)->mask);
return GIMP_DATA (brush);
}
GimpData *
gimp_brush_generated_load (const gchar *filename)
gimp_brush_generated_load (const gchar *filename,
gboolean stingy_memory_use)
{
GimpBrushGenerated *brush;
FILE *fp;
......@@ -416,7 +429,7 @@ gimp_brush_generated_load (const gchar *filename)
GIMP_DATA (brush)->dirty = FALSE;