mirror of https://github.com/GNOME/gimp.git
Save the name on a line of its own as it can contain spaces. Print spaces
1999-08-30 Tor Lillqvist <tml@iki.fi> * app/gimpbrushgenerated.c (gimp_brush_generated_save): Save the name on a line of its own as it can contain spaces. Print spaces between the floating-point values. (gimp_brush_generated_load) Corrspondingly, read the name from a line of its own. * app/gimpbrushlist.c (brushes_free): Portability fixes. Use g_strconcat. Free allocated strings.
This commit is contained in:
parent
04cfec7586
commit
c2ef7d787a
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
1999-08-30 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* app/gimpbrushgenerated.c (gimp_brush_generated_save): Save the
|
||||
name on a line of its own (as it can contain spaces). Print spaces
|
||||
between the floating-point values. (gimp_brush_generated_load)
|
||||
Corrspondingly, read the name from a line of its own.
|
||||
|
||||
* app/gimpbrushlist.c (brushes_free): Portability fixes. Use
|
||||
g_strconcat. Free allocated strings.
|
||||
|
||||
Mon Aug 30 22:15:29 MEST 1999 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/devices.c: use the new [gimp|pattern]_preview_widgets.
|
||||
|
|
|
@ -118,10 +118,11 @@ gimp_brush_generated_load (const char *file_name)
|
|||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
fscanf(fp, "%8s", string);
|
||||
g_return_val_if_fail(strcmp(string, "GIMP-VBR") == 0, NULL);
|
||||
fgets(string, 255, fp);
|
||||
g_return_val_if_fail(strncmp(string, "GIMP-VBR", 8) == 0, NULL);
|
||||
/* make sure we are reading a compatible version */
|
||||
fscanf(fp, "%f", &version);
|
||||
fgets (string, 255, fp);
|
||||
sscanf(string, "%f", &version);
|
||||
g_return_val_if_fail(version < 2.0, NULL);
|
||||
|
||||
/* create new brush */
|
||||
|
@ -130,7 +131,9 @@ gimp_brush_generated_load (const char *file_name)
|
|||
gimp_brush_generated_freeze(brush);
|
||||
|
||||
/* read name */
|
||||
fscanf(fp, "%255s", string);
|
||||
fgets(string, 255, fp);
|
||||
if (string[strlen(string)-1] == '\n')
|
||||
string[strlen(string)-1] = 0;
|
||||
GIMP_BRUSH(brush)->name = g_strdup (string);
|
||||
/* read brush spacing */
|
||||
fscanf(fp, "%f", &fl);
|
||||
|
@ -162,7 +165,6 @@ void
|
|||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const char *file_name)
|
||||
{
|
||||
/* WARNING: untested function */
|
||||
FILE *fp;
|
||||
if ((fp = fopen(file_name, "wb")) == NULL)
|
||||
{
|
||||
|
@ -174,15 +176,15 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
/* write version */
|
||||
fprintf(fp, "1.0\n");
|
||||
/* write name */
|
||||
fprintf(fp, "%s", GIMP_BRUSH(brush)->name);
|
||||
fprintf(fp, "%.255s\n", GIMP_BRUSH(brush)->name);
|
||||
/* write brush spacing */
|
||||
fprintf(fp, "%f", (float)GIMP_BRUSH(brush)->spacing);
|
||||
fprintf(fp, "%f ", (float)GIMP_BRUSH(brush)->spacing);
|
||||
/* write brush radius */
|
||||
fprintf(fp, "%f", brush->radius);
|
||||
fprintf(fp, "%f ", brush->radius);
|
||||
/* write brush hardness */
|
||||
fprintf(fp, "%f", brush->hardness);
|
||||
fprintf(fp, "%f ", brush->hardness);
|
||||
/* write brush aspect_ratio */
|
||||
fprintf(fp, "%f", brush->aspect_ratio);
|
||||
fprintf(fp, "%f ", brush->aspect_ratio);
|
||||
/* write brush angle */
|
||||
fprintf(fp, "%f", brush->angle);
|
||||
|
||||
|
|
|
@ -118,10 +118,11 @@ gimp_brush_generated_load (const char *file_name)
|
|||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
fscanf(fp, "%8s", string);
|
||||
g_return_val_if_fail(strcmp(string, "GIMP-VBR") == 0, NULL);
|
||||
fgets(string, 255, fp);
|
||||
g_return_val_if_fail(strncmp(string, "GIMP-VBR", 8) == 0, NULL);
|
||||
/* make sure we are reading a compatible version */
|
||||
fscanf(fp, "%f", &version);
|
||||
fgets (string, 255, fp);
|
||||
sscanf(string, "%f", &version);
|
||||
g_return_val_if_fail(version < 2.0, NULL);
|
||||
|
||||
/* create new brush */
|
||||
|
@ -130,7 +131,9 @@ gimp_brush_generated_load (const char *file_name)
|
|||
gimp_brush_generated_freeze(brush);
|
||||
|
||||
/* read name */
|
||||
fscanf(fp, "%255s", string);
|
||||
fgets(string, 255, fp);
|
||||
if (string[strlen(string)-1] == '\n')
|
||||
string[strlen(string)-1] = 0;
|
||||
GIMP_BRUSH(brush)->name = g_strdup (string);
|
||||
/* read brush spacing */
|
||||
fscanf(fp, "%f", &fl);
|
||||
|
@ -162,7 +165,6 @@ void
|
|||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const char *file_name)
|
||||
{
|
||||
/* WARNING: untested function */
|
||||
FILE *fp;
|
||||
if ((fp = fopen(file_name, "wb")) == NULL)
|
||||
{
|
||||
|
@ -174,15 +176,15 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
/* write version */
|
||||
fprintf(fp, "1.0\n");
|
||||
/* write name */
|
||||
fprintf(fp, "%s", GIMP_BRUSH(brush)->name);
|
||||
fprintf(fp, "%.255s\n", GIMP_BRUSH(brush)->name);
|
||||
/* write brush spacing */
|
||||
fprintf(fp, "%f", (float)GIMP_BRUSH(brush)->spacing);
|
||||
fprintf(fp, "%f ", (float)GIMP_BRUSH(brush)->spacing);
|
||||
/* write brush radius */
|
||||
fprintf(fp, "%f", brush->radius);
|
||||
fprintf(fp, "%f ", brush->radius);
|
||||
/* write brush hardness */
|
||||
fprintf(fp, "%f", brush->hardness);
|
||||
fprintf(fp, "%f ", brush->hardness);
|
||||
/* write brush aspect_ratio */
|
||||
fprintf(fp, "%f", brush->aspect_ratio);
|
||||
fprintf(fp, "%f ", brush->aspect_ratio);
|
||||
/* write brush angle */
|
||||
fprintf(fp, "%f", brush->angle);
|
||||
|
||||
|
|
|
@ -118,10 +118,11 @@ gimp_brush_generated_load (const char *file_name)
|
|||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
fscanf(fp, "%8s", string);
|
||||
g_return_val_if_fail(strcmp(string, "GIMP-VBR") == 0, NULL);
|
||||
fgets(string, 255, fp);
|
||||
g_return_val_if_fail(strncmp(string, "GIMP-VBR", 8) == 0, NULL);
|
||||
/* make sure we are reading a compatible version */
|
||||
fscanf(fp, "%f", &version);
|
||||
fgets (string, 255, fp);
|
||||
sscanf(string, "%f", &version);
|
||||
g_return_val_if_fail(version < 2.0, NULL);
|
||||
|
||||
/* create new brush */
|
||||
|
@ -130,7 +131,9 @@ gimp_brush_generated_load (const char *file_name)
|
|||
gimp_brush_generated_freeze(brush);
|
||||
|
||||
/* read name */
|
||||
fscanf(fp, "%255s", string);
|
||||
fgets(string, 255, fp);
|
||||
if (string[strlen(string)-1] == '\n')
|
||||
string[strlen(string)-1] = 0;
|
||||
GIMP_BRUSH(brush)->name = g_strdup (string);
|
||||
/* read brush spacing */
|
||||
fscanf(fp, "%f", &fl);
|
||||
|
@ -162,7 +165,6 @@ void
|
|||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const char *file_name)
|
||||
{
|
||||
/* WARNING: untested function */
|
||||
FILE *fp;
|
||||
if ((fp = fopen(file_name, "wb")) == NULL)
|
||||
{
|
||||
|
@ -174,15 +176,15 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
/* write version */
|
||||
fprintf(fp, "1.0\n");
|
||||
/* write name */
|
||||
fprintf(fp, "%s", GIMP_BRUSH(brush)->name);
|
||||
fprintf(fp, "%.255s\n", GIMP_BRUSH(brush)->name);
|
||||
/* write brush spacing */
|
||||
fprintf(fp, "%f", (float)GIMP_BRUSH(brush)->spacing);
|
||||
fprintf(fp, "%f ", (float)GIMP_BRUSH(brush)->spacing);
|
||||
/* write brush radius */
|
||||
fprintf(fp, "%f", brush->radius);
|
||||
fprintf(fp, "%f ", brush->radius);
|
||||
/* write brush hardness */
|
||||
fprintf(fp, "%f", brush->hardness);
|
||||
fprintf(fp, "%f ", brush->hardness);
|
||||
/* write brush aspect_ratio */
|
||||
fprintf(fp, "%f", brush->aspect_ratio);
|
||||
fprintf(fp, "%f ", brush->aspect_ratio);
|
||||
/* write brush angle */
|
||||
fprintf(fp, "%f", brush->angle);
|
||||
|
||||
|
|
|
@ -118,10 +118,11 @@ gimp_brush_generated_load (const char *file_name)
|
|||
return NULL;
|
||||
|
||||
/* make sure the file we are reading is the right type */
|
||||
fscanf(fp, "%8s", string);
|
||||
g_return_val_if_fail(strcmp(string, "GIMP-VBR") == 0, NULL);
|
||||
fgets(string, 255, fp);
|
||||
g_return_val_if_fail(strncmp(string, "GIMP-VBR", 8) == 0, NULL);
|
||||
/* make sure we are reading a compatible version */
|
||||
fscanf(fp, "%f", &version);
|
||||
fgets (string, 255, fp);
|
||||
sscanf(string, "%f", &version);
|
||||
g_return_val_if_fail(version < 2.0, NULL);
|
||||
|
||||
/* create new brush */
|
||||
|
@ -130,7 +131,9 @@ gimp_brush_generated_load (const char *file_name)
|
|||
gimp_brush_generated_freeze(brush);
|
||||
|
||||
/* read name */
|
||||
fscanf(fp, "%255s", string);
|
||||
fgets(string, 255, fp);
|
||||
if (string[strlen(string)-1] == '\n')
|
||||
string[strlen(string)-1] = 0;
|
||||
GIMP_BRUSH(brush)->name = g_strdup (string);
|
||||
/* read brush spacing */
|
||||
fscanf(fp, "%f", &fl);
|
||||
|
@ -162,7 +165,6 @@ void
|
|||
gimp_brush_generated_save (GimpBrushGenerated *brush,
|
||||
const char *file_name)
|
||||
{
|
||||
/* WARNING: untested function */
|
||||
FILE *fp;
|
||||
if ((fp = fopen(file_name, "wb")) == NULL)
|
||||
{
|
||||
|
@ -174,15 +176,15 @@ gimp_brush_generated_save (GimpBrushGenerated *brush,
|
|||
/* write version */
|
||||
fprintf(fp, "1.0\n");
|
||||
/* write name */
|
||||
fprintf(fp, "%s", GIMP_BRUSH(brush)->name);
|
||||
fprintf(fp, "%.255s\n", GIMP_BRUSH(brush)->name);
|
||||
/* write brush spacing */
|
||||
fprintf(fp, "%f", (float)GIMP_BRUSH(brush)->spacing);
|
||||
fprintf(fp, "%f ", (float)GIMP_BRUSH(brush)->spacing);
|
||||
/* write brush radius */
|
||||
fprintf(fp, "%f", brush->radius);
|
||||
fprintf(fp, "%f ", brush->radius);
|
||||
/* write brush hardness */
|
||||
fprintf(fp, "%f", brush->hardness);
|
||||
fprintf(fp, "%f ", brush->hardness);
|
||||
/* write brush aspect_ratio */
|
||||
fprintf(fp, "%f", brush->aspect_ratio);
|
||||
fprintf(fp, "%f ", brush->aspect_ratio);
|
||||
/* write brush angle */
|
||||
fprintf(fp, "%f", brush->angle);
|
||||
|
||||
|
|
|
@ -202,15 +202,14 @@ brush_compare_func (gconstpointer first, gconstpointer second)
|
|||
void
|
||||
brushes_free ()
|
||||
{
|
||||
printf("freeing brushes\n");
|
||||
if (brush_list)
|
||||
{
|
||||
while (GIMP_LIST(brush_list)->list)
|
||||
{
|
||||
GimpBrush * b = GIMP_BRUSH (GIMP_LIST(brush_list)->list->data);
|
||||
char * filename = b->filename;
|
||||
if (GIMP_IS_BRUSH_GENERATED (b))
|
||||
if (GIMP_IS_BRUSH_GENERATED (b))
|
||||
{
|
||||
char * filename = g_strdup (b->filename);
|
||||
if (!filename)
|
||||
{
|
||||
char *home;
|
||||
|
@ -221,47 +220,44 @@ brushes_free ()
|
|||
|
||||
if (brush_vbr_path)
|
||||
{
|
||||
printf("posibly saving %s\n", b->name);
|
||||
/* Get the first path specified in the brush vbr path variable */
|
||||
home = getenv("HOME");
|
||||
/* Get the first path specified in the
|
||||
* brush-vbr-path gimprc variable.
|
||||
*/
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (brush_vbr_path);
|
||||
first_token = local_path;
|
||||
token = xstrsep(&first_token, ":");
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
path = g_malloc(strlen(home) + strlen(token) + 1);
|
||||
sprintf(path, "%s%s", home, token + 1);
|
||||
}
|
||||
if (home != NULL)
|
||||
path = g_strconcat (home, token + 1, NULL);
|
||||
else
|
||||
path = g_strdup (""); /* Better than nothing */
|
||||
else
|
||||
{
|
||||
path = g_malloc(strlen(token) + 1);
|
||||
strcpy(path, token);
|
||||
}
|
||||
path = g_strdup (token);
|
||||
|
||||
filename = g_malloc (strlen (path) + strlen (b->name) + 2 + 4);
|
||||
sprintf (filename, "%s/%s.vbr", path, b->name);
|
||||
|
||||
filename = g_strconcat (path, G_DIR_SEPARATOR_S, b->name, ".vbr", NULL);
|
||||
g_free (path);
|
||||
}
|
||||
g_free (local_path);
|
||||
}
|
||||
else
|
||||
filename = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(&filename[strlen(filename) - 4], ".vbr"))
|
||||
filename = NULL;
|
||||
{
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* okay we are ready to try to save the generated file*/
|
||||
if (filename)
|
||||
{
|
||||
printf("saving %s\n", filename);
|
||||
gimp_brush_generated_save ( GIMP_BRUSH_GENERATED(b), filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue