mirror of https://github.com/GNOME/gimp.git
fixed a memleak.
2000-02-24 Michael Natterer <mitch@gimp.org> * app/datafiles.c: fixed a memleak. * app/gimpbrushlist.c * app/gradient.c * app/palette.c: use the gimp_path_* functions, cleanups. * app/gimpbrushpipe.c: call the "destroy" function of the parent class, not of the object class. Fixes a huge memleak on each "Refresh". * app/gimpbrushpipeP.h * app/gimplist.c * app/gimpbrush.c: did some cleanups while searching the brush memleak. * libgimp/gimpenv.c: gimp_path_get_user_writable_dir(): return a copy of the string. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c: g_free() the string returned by gimp_path_get_user_writable_dir().
This commit is contained in:
parent
a9df0647fc
commit
868888fe21
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
2000-02-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/datafiles.c: fixed a memleak.
|
||||
|
||||
* app/gimpbrushlist.c
|
||||
* app/gradient.c
|
||||
* app/palette.c: use the gimp_path_* functions, cleanups.
|
||||
|
||||
* app/gimpbrushpipe.c: call the "destroy" function of the parent
|
||||
class, not of the object class. Fixes a huge memleak on each
|
||||
"Refresh".
|
||||
|
||||
* app/gimpbrushpipeP.h
|
||||
* app/gimplist.c
|
||||
* app/gimpbrush.c: did some cleanups while searching the brush
|
||||
memleak.
|
||||
|
||||
* libgimp/gimpenv.c: gimp_path_get_user_writable_dir(): return a
|
||||
copy of the string.
|
||||
|
||||
* plug-ins/FractalExplorer/Dialogs.c
|
||||
* plug-ins/gfig/gfig.c
|
||||
* plug-ins/gflare/gflare.c: g_free() the string returned by
|
||||
gimp_path_get_user_writable_dir().
|
||||
|
||||
Thu Feb 24 02:20:15 CET 2000 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gimprc.c: gimp_parasite_attach() creates a copy of
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpsignal.h"
|
||||
|
@ -28,30 +28,32 @@
|
|||
#include "config.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
DIRTY,
|
||||
RENAME,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy(GtkObject *object)
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrush* brush=GIMP_BRUSH(object);
|
||||
if (brush->filename)
|
||||
g_free(brush->filename);
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free(brush->mask);
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
GimpBrush *brush = GIMP_BRUSH (object);
|
||||
|
||||
if (brush->filename)
|
||||
g_free (brush->filename);
|
||||
if (brush->name)
|
||||
g_free (brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -81,16 +83,16 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_init(GimpBrush *brush)
|
||||
gimp_brush_init (GimpBrush *brush)
|
||||
{
|
||||
brush->filename = NULL;
|
||||
brush->name = NULL;
|
||||
brush->spacing = 20;
|
||||
brush->mask = NULL;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,9 +100,11 @@ GtkType
|
|||
gimp_brush_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
if(!type)
|
||||
|
||||
if (!type)
|
||||
{
|
||||
static const GtkTypeInfo info = {
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrush",
|
||||
sizeof (GimpBrush),
|
||||
sizeof (GimpBrushClass),
|
||||
|
@ -116,10 +120,12 @@ gimp_brush_get_type (void)
|
|||
}
|
||||
|
||||
GimpBrush *
|
||||
gimp_brush_new (char *filename)
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush=GIMP_BRUSH(gtk_type_new(gimp_brush_get_type ()));
|
||||
gimp_brush_load(brush, filename);
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
|
@ -138,31 +144,35 @@ gimp_brush_want_null_motion (PaintCore *paint_core)
|
|||
TempBuf *
|
||||
gimp_brush_get_mask (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->name;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_set_name (GimpBrush *brush,
|
||||
char *name)
|
||||
gchar *name)
|
||||
{
|
||||
g_return_if_fail(GIMP_IS_BRUSH(brush));
|
||||
if (strcmp(brush->name, name) == 0)
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
||||
if (strcmp (brush->name, name) == 0)
|
||||
return;
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
brush->name = g_strdup(name);
|
||||
gtk_signal_emit(GTK_OBJECT(brush), gimp_brush_signals[RENAME]);
|
||||
g_free (brush->name);
|
||||
brush->name = g_strdup (name);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (brush), gimp_brush_signals[RENAME]);
|
||||
}
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_get_spacing (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (brush != NULL, 0);
|
||||
|
@ -173,7 +183,7 @@ gimp_brush_get_spacing (GimpBrush *brush)
|
|||
|
||||
void
|
||||
gimp_brush_set_spacing (GimpBrush *brush,
|
||||
int spacing)
|
||||
gint spacing)
|
||||
{
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
@ -183,7 +193,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
|
|||
|
||||
void
|
||||
gimp_brush_load (GimpBrush *brush,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
FILE * fp;
|
||||
|
||||
|
@ -207,16 +217,16 @@ gimp_brush_load (GimpBrush *brush,
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
int bn_size;
|
||||
unsigned char buf [sz_BrushHeader];
|
||||
gint bn_size;
|
||||
guchar buf [sz_BrushHeader];
|
||||
BrushHeader header;
|
||||
unsigned int * hp;
|
||||
int i;
|
||||
guint *hp;
|
||||
gint i;
|
||||
|
||||
/* Read in the header size */
|
||||
if ((fread (buf, 1, sz_BrushHeader, fp)) < sz_BrushHeader)
|
||||
|
@ -227,7 +237,7 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
hp = (unsigned int *) &header;
|
||||
hp = (guint *) &header;
|
||||
for (i = 0; i < (sz_BrushHeader / 4); i++)
|
||||
hp [i] = (buf [i * 4] << 24) + (buf [i * 4 + 1] << 16) +
|
||||
(buf [i * 4 + 2] << 8) + (buf [i * 4 + 3]);
|
||||
|
@ -242,7 +252,6 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (header.version == 1)
|
||||
{
|
||||
|
@ -252,48 +261,47 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
/* spacing is not defined in version 1 */
|
||||
header.spacing = 25;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the brush name */
|
||||
if ((bn_size = (header.header_size - sz_BrushHeader)))
|
||||
{
|
||||
brush->name = (char *) g_malloc (sizeof (char) * bn_size);
|
||||
brush->name = g_new (gchar, bn_size);
|
||||
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
brush->name = g_strdup (_("Unnamed"));
|
||||
|
||||
switch(header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
switch (header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpsignal.h"
|
||||
|
@ -28,30 +28,32 @@
|
|||
#include "config.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
DIRTY,
|
||||
RENAME,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy(GtkObject *object)
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrush* brush=GIMP_BRUSH(object);
|
||||
if (brush->filename)
|
||||
g_free(brush->filename);
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free(brush->mask);
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
GimpBrush *brush = GIMP_BRUSH (object);
|
||||
|
||||
if (brush->filename)
|
||||
g_free (brush->filename);
|
||||
if (brush->name)
|
||||
g_free (brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -81,16 +83,16 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_init(GimpBrush *brush)
|
||||
gimp_brush_init (GimpBrush *brush)
|
||||
{
|
||||
brush->filename = NULL;
|
||||
brush->name = NULL;
|
||||
brush->spacing = 20;
|
||||
brush->mask = NULL;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,9 +100,11 @@ GtkType
|
|||
gimp_brush_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
if(!type)
|
||||
|
||||
if (!type)
|
||||
{
|
||||
static const GtkTypeInfo info = {
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrush",
|
||||
sizeof (GimpBrush),
|
||||
sizeof (GimpBrushClass),
|
||||
|
@ -116,10 +120,12 @@ gimp_brush_get_type (void)
|
|||
}
|
||||
|
||||
GimpBrush *
|
||||
gimp_brush_new (char *filename)
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush=GIMP_BRUSH(gtk_type_new(gimp_brush_get_type ()));
|
||||
gimp_brush_load(brush, filename);
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
|
@ -138,31 +144,35 @@ gimp_brush_want_null_motion (PaintCore *paint_core)
|
|||
TempBuf *
|
||||
gimp_brush_get_mask (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->name;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_set_name (GimpBrush *brush,
|
||||
char *name)
|
||||
gchar *name)
|
||||
{
|
||||
g_return_if_fail(GIMP_IS_BRUSH(brush));
|
||||
if (strcmp(brush->name, name) == 0)
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
||||
if (strcmp (brush->name, name) == 0)
|
||||
return;
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
brush->name = g_strdup(name);
|
||||
gtk_signal_emit(GTK_OBJECT(brush), gimp_brush_signals[RENAME]);
|
||||
g_free (brush->name);
|
||||
brush->name = g_strdup (name);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (brush), gimp_brush_signals[RENAME]);
|
||||
}
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_get_spacing (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (brush != NULL, 0);
|
||||
|
@ -173,7 +183,7 @@ gimp_brush_get_spacing (GimpBrush *brush)
|
|||
|
||||
void
|
||||
gimp_brush_set_spacing (GimpBrush *brush,
|
||||
int spacing)
|
||||
gint spacing)
|
||||
{
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
@ -183,7 +193,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
|
|||
|
||||
void
|
||||
gimp_brush_load (GimpBrush *brush,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
FILE * fp;
|
||||
|
||||
|
@ -207,16 +217,16 @@ gimp_brush_load (GimpBrush *brush,
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
int bn_size;
|
||||
unsigned char buf [sz_BrushHeader];
|
||||
gint bn_size;
|
||||
guchar buf [sz_BrushHeader];
|
||||
BrushHeader header;
|
||||
unsigned int * hp;
|
||||
int i;
|
||||
guint *hp;
|
||||
gint i;
|
||||
|
||||
/* Read in the header size */
|
||||
if ((fread (buf, 1, sz_BrushHeader, fp)) < sz_BrushHeader)
|
||||
|
@ -227,7 +237,7 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
hp = (unsigned int *) &header;
|
||||
hp = (guint *) &header;
|
||||
for (i = 0; i < (sz_BrushHeader / 4); i++)
|
||||
hp [i] = (buf [i * 4] << 24) + (buf [i * 4 + 1] << 16) +
|
||||
(buf [i * 4 + 2] << 8) + (buf [i * 4 + 3]);
|
||||
|
@ -242,7 +252,6 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (header.version == 1)
|
||||
{
|
||||
|
@ -252,48 +261,47 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
/* spacing is not defined in version 1 */
|
||||
header.spacing = 25;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the brush name */
|
||||
if ((bn_size = (header.header_size - sz_BrushHeader)))
|
||||
{
|
||||
brush->name = (char *) g_malloc (sizeof (char) * bn_size);
|
||||
brush->name = g_new (gchar, bn_size);
|
||||
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
brush->name = g_strdup (_("Unnamed"));
|
||||
|
||||
switch(header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
switch (header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
static GimpBrushClass* gimp_brush_class;
|
||||
static GtkObjectClass* gimp_object_class;
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_destroy (GtkObject *object)
|
||||
|
@ -53,10 +53,11 @@ gimp_brush_pixmap_destroy (GtkObject *object)
|
|||
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
|
||||
|
||||
pixmap = GIMP_BRUSH_PIXMAP (object);
|
||||
|
||||
|
||||
temp_buf_free (pixmap->pixmap_mask);
|
||||
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,8 +71,8 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
|
|||
|
||||
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
|
||||
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
|
||||
}
|
||||
|
||||
|
@ -193,10 +194,10 @@ gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_destroy(GtkObject *object)
|
||||
gimp_brush_pipe_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
|
||||
|
@ -207,68 +208,74 @@ gimp_brush_pipe_destroy(GtkObject *object)
|
|||
g_free (pipe->stride);
|
||||
|
||||
for (i = 1; i < pipe->nbrushes; i++)
|
||||
gimp_object_destroy (pipe->brushes[i]);
|
||||
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
|
||||
|
||||
g_free (pipe->brushes);
|
||||
g_free (pipe->select);
|
||||
g_free (pipe->index);
|
||||
|
||||
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
gimp_brush_pixmap_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_pipe_init (GimpBrushPipe *pipe)
|
||||
{
|
||||
pipe->dimension = 0;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_brush_pipe_get_type (void)
|
||||
{
|
||||
static GtkType type=0;
|
||||
if (!type){
|
||||
GtkTypeInfo info={
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL};
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pipe_load (char *filename)
|
||||
gimp_brush_pipe_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
gchar *name;
|
||||
int i;
|
||||
int num_of_brushes;
|
||||
int totalcells;
|
||||
gint i;
|
||||
gint num_of_brushes;
|
||||
gint totalcells;
|
||||
gchar *paramstring;
|
||||
|
||||
if ((fp = fopen (filename, "rb")) == NULL)
|
||||
|
@ -294,7 +301,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
num_of_brushes = strtol(buf, ¶mstring, 10);
|
||||
num_of_brushes = strtol (buf, ¶mstring, 10);
|
||||
if (num_of_brushes < 1)
|
||||
{
|
||||
g_message (_("Brush pipes should have at least one brush."));
|
||||
|
@ -303,7 +310,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (*paramstring && isspace(*paramstring))
|
||||
while (*paramstring && isspace (*paramstring))
|
||||
paramstring++;
|
||||
|
||||
if (*paramstring)
|
||||
|
@ -311,9 +318,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
pixpipeparams_init (¶ms);
|
||||
pixpipeparams_parse (paramstring, ¶ms);
|
||||
pipe->dimension = params.dim;
|
||||
pipe->rank = g_new (int, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (int, pipe->dimension);
|
||||
pipe->rank = g_new (gint, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (gint, pipe->dimension);
|
||||
/* placement is not used at all ?? */
|
||||
if (params.free_placement_string)
|
||||
g_free (params.placement);
|
||||
|
@ -344,18 +351,18 @@ gimp_brush_pipe_load (char *filename)
|
|||
else
|
||||
{
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
}
|
||||
|
||||
totalcells = 1; /* Not all necessarily present, maybe */
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
totalcells *= pipe->rank[i];
|
||||
pipe->stride = g_new (int, pipe->dimension);
|
||||
pipe->stride = g_new (gint, pipe->dimension);
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
|
@ -365,10 +372,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
}
|
||||
g_assert (pipe->stride[pipe->dimension-1] == 1);
|
||||
|
||||
pattern = (GPattern*) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes =
|
||||
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
pipe->brushes = g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
|
||||
/* First pixmap brush in the list is the pipe itself */
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
|
@ -385,7 +391,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
|
||||
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[pipe->nbrushes]->pipe = pipe;
|
||||
|
||||
/* load the brush */
|
||||
|
@ -416,11 +422,12 @@ gimp_brush_pipe_load (char *filename)
|
|||
fclose (fp);
|
||||
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pixmap_load (char *filename)
|
||||
gimp_brush_pixmap_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
|
@ -433,19 +440,19 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
|
||||
pattern = (GPattern *) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
|
||||
pipe->brushes = g_new (GimpBrushPixmap *, 1);
|
||||
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
pipe->current = pipe->brushes[0];
|
||||
pipe->current = pipe->brushes[0];
|
||||
|
||||
pipe->brushes[0]->pipe = pipe;
|
||||
|
||||
|
@ -460,7 +467,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[0]->pixmap_mask = pattern->mask;
|
||||
|
||||
pipe->nbrushes = 1;
|
||||
|
@ -469,6 +476,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
g_free (pattern->name);
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
static GimpBrushClass* gimp_brush_class;
|
||||
static GtkObjectClass* gimp_object_class;
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_destroy (GtkObject *object)
|
||||
|
@ -53,10 +53,11 @@ gimp_brush_pixmap_destroy (GtkObject *object)
|
|||
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
|
||||
|
||||
pixmap = GIMP_BRUSH_PIXMAP (object);
|
||||
|
||||
|
||||
temp_buf_free (pixmap->pixmap_mask);
|
||||
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,8 +71,8 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
|
|||
|
||||
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
|
||||
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
|
||||
}
|
||||
|
||||
|
@ -193,10 +194,10 @@ gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_destroy(GtkObject *object)
|
||||
gimp_brush_pipe_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
|
||||
|
@ -207,68 +208,74 @@ gimp_brush_pipe_destroy(GtkObject *object)
|
|||
g_free (pipe->stride);
|
||||
|
||||
for (i = 1; i < pipe->nbrushes; i++)
|
||||
gimp_object_destroy (pipe->brushes[i]);
|
||||
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
|
||||
|
||||
g_free (pipe->brushes);
|
||||
g_free (pipe->select);
|
||||
g_free (pipe->index);
|
||||
|
||||
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
gimp_brush_pixmap_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_pipe_init (GimpBrushPipe *pipe)
|
||||
{
|
||||
pipe->dimension = 0;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_brush_pipe_get_type (void)
|
||||
{
|
||||
static GtkType type=0;
|
||||
if (!type){
|
||||
GtkTypeInfo info={
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL};
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pipe_load (char *filename)
|
||||
gimp_brush_pipe_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
gchar *name;
|
||||
int i;
|
||||
int num_of_brushes;
|
||||
int totalcells;
|
||||
gint i;
|
||||
gint num_of_brushes;
|
||||
gint totalcells;
|
||||
gchar *paramstring;
|
||||
|
||||
if ((fp = fopen (filename, "rb")) == NULL)
|
||||
|
@ -294,7 +301,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
num_of_brushes = strtol(buf, ¶mstring, 10);
|
||||
num_of_brushes = strtol (buf, ¶mstring, 10);
|
||||
if (num_of_brushes < 1)
|
||||
{
|
||||
g_message (_("Brush pipes should have at least one brush."));
|
||||
|
@ -303,7 +310,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (*paramstring && isspace(*paramstring))
|
||||
while (*paramstring && isspace (*paramstring))
|
||||
paramstring++;
|
||||
|
||||
if (*paramstring)
|
||||
|
@ -311,9 +318,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
pixpipeparams_init (¶ms);
|
||||
pixpipeparams_parse (paramstring, ¶ms);
|
||||
pipe->dimension = params.dim;
|
||||
pipe->rank = g_new (int, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (int, pipe->dimension);
|
||||
pipe->rank = g_new (gint, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (gint, pipe->dimension);
|
||||
/* placement is not used at all ?? */
|
||||
if (params.free_placement_string)
|
||||
g_free (params.placement);
|
||||
|
@ -344,18 +351,18 @@ gimp_brush_pipe_load (char *filename)
|
|||
else
|
||||
{
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
}
|
||||
|
||||
totalcells = 1; /* Not all necessarily present, maybe */
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
totalcells *= pipe->rank[i];
|
||||
pipe->stride = g_new (int, pipe->dimension);
|
||||
pipe->stride = g_new (gint, pipe->dimension);
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
|
@ -365,10 +372,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
}
|
||||
g_assert (pipe->stride[pipe->dimension-1] == 1);
|
||||
|
||||
pattern = (GPattern*) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes =
|
||||
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
pipe->brushes = g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
|
||||
/* First pixmap brush in the list is the pipe itself */
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
|
@ -385,7 +391,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
|
||||
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[pipe->nbrushes]->pipe = pipe;
|
||||
|
||||
/* load the brush */
|
||||
|
@ -416,11 +422,12 @@ gimp_brush_pipe_load (char *filename)
|
|||
fclose (fp);
|
||||
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pixmap_load (char *filename)
|
||||
gimp_brush_pixmap_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
|
@ -433,19 +440,19 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
|
||||
pattern = (GPattern *) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
|
||||
pipe->brushes = g_new (GimpBrushPixmap *, 1);
|
||||
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
pipe->current = pipe->brushes[0];
|
||||
pipe->current = pipe->brushes[0];
|
||||
|
||||
pipe->brushes[0]->pipe = pipe;
|
||||
|
||||
|
@ -460,7 +467,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[0]->pixmap_mask = pattern->mask;
|
||||
|
||||
pipe->nbrushes = 1;
|
||||
|
@ -469,6 +476,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
g_free (pattern->name);
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ datafiles_read_directories (gchar *path_str,
|
|||
}
|
||||
|
||||
gimp_path_free (path);
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
time_t
|
||||
|
|
|
@ -177,7 +177,7 @@ gimp_list_remove (GimpList *list,
|
|||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
else
|
||||
gtk_object_unref (GTK_OBJECT(val));
|
||||
gtk_object_unref (GTK_OBJECT (val));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,7 @@ datafiles_read_directories (gchar *path_str,
|
|||
}
|
||||
|
||||
gimp_path_free (path);
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
time_t
|
||||
|
|
158
app/gimpbrush.c
158
app/gimpbrush.c
|
@ -15,10 +15,10 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "gimpsignal.h"
|
||||
|
@ -28,30 +28,32 @@
|
|||
#include "config.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
DIRTY,
|
||||
RENAME,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GimpBrush *gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush * gimp_brush_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static guint gimp_brush_signals[LAST_SIGNAL];
|
||||
static GimpObjectClass* parent_class;
|
||||
|
||||
static void
|
||||
gimp_brush_destroy(GtkObject *object)
|
||||
gimp_brush_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrush* brush=GIMP_BRUSH(object);
|
||||
if (brush->filename)
|
||||
g_free(brush->filename);
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free(brush->mask);
|
||||
GTK_OBJECT_CLASS(parent_class)->destroy (object);
|
||||
GimpBrush *brush = GIMP_BRUSH (object);
|
||||
|
||||
if (brush->filename)
|
||||
g_free (brush->filename);
|
||||
if (brush->name)
|
||||
g_free (brush->name);
|
||||
if (brush->mask)
|
||||
temp_buf_free (brush->mask);
|
||||
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -81,16 +83,16 @@ gimp_brush_class_init (GimpBrushClass *klass)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_brush_init(GimpBrush *brush)
|
||||
gimp_brush_init (GimpBrush *brush)
|
||||
{
|
||||
brush->filename = NULL;
|
||||
brush->name = NULL;
|
||||
brush->spacing = 20;
|
||||
brush->mask = NULL;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
brush->x_axis.x = 15.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = 15.0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,9 +100,11 @@ GtkType
|
|||
gimp_brush_get_type (void)
|
||||
{
|
||||
static GtkType type = 0;
|
||||
if(!type)
|
||||
|
||||
if (!type)
|
||||
{
|
||||
static const GtkTypeInfo info = {
|
||||
static const GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrush",
|
||||
sizeof (GimpBrush),
|
||||
sizeof (GimpBrushClass),
|
||||
|
@ -116,10 +120,12 @@ gimp_brush_get_type (void)
|
|||
}
|
||||
|
||||
GimpBrush *
|
||||
gimp_brush_new (char *filename)
|
||||
gimp_brush_new (gchar *filename)
|
||||
{
|
||||
GimpBrush *brush=GIMP_BRUSH(gtk_type_new(gimp_brush_get_type ()));
|
||||
gimp_brush_load(brush, filename);
|
||||
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
|
||||
|
||||
gimp_brush_load (brush, filename);
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
|
@ -138,31 +144,35 @@ gimp_brush_want_null_motion (PaintCore *paint_core)
|
|||
TempBuf *
|
||||
gimp_brush_get_mask (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->mask;
|
||||
}
|
||||
|
||||
char *
|
||||
gimp_brush_get_name (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
|
||||
|
||||
return brush->name;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_set_name (GimpBrush *brush,
|
||||
char *name)
|
||||
gchar *name)
|
||||
{
|
||||
g_return_if_fail(GIMP_IS_BRUSH(brush));
|
||||
if (strcmp(brush->name, name) == 0)
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
||||
if (strcmp (brush->name, name) == 0)
|
||||
return;
|
||||
if (brush->name)
|
||||
g_free(brush->name);
|
||||
brush->name = g_strdup(name);
|
||||
gtk_signal_emit(GTK_OBJECT(brush), gimp_brush_signals[RENAME]);
|
||||
g_free (brush->name);
|
||||
brush->name = g_strdup (name);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (brush), gimp_brush_signals[RENAME]);
|
||||
}
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_get_spacing (GimpBrush *brush)
|
||||
{
|
||||
g_return_val_if_fail (brush != NULL, 0);
|
||||
|
@ -173,7 +183,7 @@ gimp_brush_get_spacing (GimpBrush *brush)
|
|||
|
||||
void
|
||||
gimp_brush_set_spacing (GimpBrush *brush,
|
||||
int spacing)
|
||||
gint spacing)
|
||||
{
|
||||
g_return_if_fail (brush != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH (brush));
|
||||
|
@ -183,7 +193,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
|
|||
|
||||
void
|
||||
gimp_brush_load (GimpBrush *brush,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
FILE * fp;
|
||||
|
||||
|
@ -207,16 +217,16 @@ gimp_brush_load (GimpBrush *brush,
|
|||
}
|
||||
|
||||
|
||||
int
|
||||
gint
|
||||
gimp_brush_load_brush (GimpBrush *brush,
|
||||
FILE *fp,
|
||||
char *filename)
|
||||
gchar *filename)
|
||||
{
|
||||
int bn_size;
|
||||
unsigned char buf [sz_BrushHeader];
|
||||
gint bn_size;
|
||||
guchar buf [sz_BrushHeader];
|
||||
BrushHeader header;
|
||||
unsigned int * hp;
|
||||
int i;
|
||||
guint *hp;
|
||||
gint i;
|
||||
|
||||
/* Read in the header size */
|
||||
if ((fread (buf, 1, sz_BrushHeader, fp)) < sz_BrushHeader)
|
||||
|
@ -227,7 +237,7 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
}
|
||||
|
||||
/* rearrange the bytes in each unsigned int */
|
||||
hp = (unsigned int *) &header;
|
||||
hp = (guint *) &header;
|
||||
for (i = 0; i < (sz_BrushHeader / 4); i++)
|
||||
hp [i] = (buf [i * 4] << 24) + (buf [i * 4 + 1] << 16) +
|
||||
(buf [i * 4 + 2] << 8) + (buf [i * 4 + 3]);
|
||||
|
@ -242,7 +252,6 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (header.version == 1)
|
||||
{
|
||||
|
@ -252,48 +261,47 @@ gimp_brush_load_brush (GimpBrush *brush,
|
|||
/* spacing is not defined in version 1 */
|
||||
header.spacing = 25;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the brush name */
|
||||
if ((bn_size = (header.header_size - sz_BrushHeader)))
|
||||
{
|
||||
brush->name = (char *) g_malloc (sizeof (char) * bn_size);
|
||||
brush->name = g_new (gchar, bn_size);
|
||||
if ((fread (brush->name, 1, bn_size, fp)) < bn_size)
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
g_message (_("Error in GIMP brush file...aborting."));
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
brush->name = g_strdup (_("Unnamed"));
|
||||
|
||||
switch(header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
switch (header.version)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
/* Get a new brush mask */
|
||||
brush->mask = temp_buf_new (header.width, header.height, header.bytes,
|
||||
0, 0, NULL);
|
||||
brush->spacing = header.spacing;
|
||||
/* set up spacing axis */
|
||||
brush->x_axis.x = header.width / 2.0;
|
||||
brush->x_axis.y = 0.0;
|
||||
brush->y_axis.x = 0.0;
|
||||
brush->y_axis.y = header.height / 2.0;
|
||||
/* Read the brush mask data */
|
||||
if ((fread (temp_buf_data (brush->mask), 1, header.width * header.height,
|
||||
fp)) < header.width * header.height)
|
||||
g_message (_("GIMP brush file appears to be truncated."));
|
||||
break;
|
||||
default:
|
||||
g_message (_("Unknown brush format version #%d in \"%s\"\n"),
|
||||
header.version, filename);
|
||||
fclose (fp);
|
||||
gimp_object_destroy (brush);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@
|
|||
#include "gimpbrushlistP.h"
|
||||
#include "general.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
/* global variables */
|
||||
GimpBrushList *brush_list = NULL;
|
||||
|
||||
/* local variables */
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
|
||||
/* local function prototypes */
|
||||
static void brushes_brush_load (gchar *filename);
|
||||
|
@ -73,7 +73,8 @@ static void
|
|||
gimp_brush_list_remove_func (GimpList *list,
|
||||
gpointer val)
|
||||
{
|
||||
list->list=g_slist_remove (list->list, val);
|
||||
list->list = g_slist_remove (list->list, val);
|
||||
|
||||
GIMP_BRUSH_LIST (list)->num_brushes--;
|
||||
}
|
||||
|
||||
|
@ -83,8 +84,9 @@ gimp_brush_list_class_init (GimpBrushListClass *klass)
|
|||
GimpListClass *gimp_list_class;
|
||||
|
||||
gimp_list_class = GIMP_LIST_CLASS(klass);
|
||||
gimp_list_class->add = gimp_brush_list_add_func;
|
||||
gimp_list_class->add = gimp_brush_list_add_func;
|
||||
gimp_list_class->remove = gimp_brush_list_remove_func;
|
||||
|
||||
parent_class = gtk_type_class (gimp_list_get_type ());
|
||||
}
|
||||
|
||||
|
@ -145,12 +147,8 @@ brushes_init (gint no_data)
|
|||
{
|
||||
brush_select_freeze_all ();
|
||||
|
||||
datafiles_read_directories (brush_path,
|
||||
(GimpDataFileLoaderFunc) brushes_brush_load,
|
||||
0);
|
||||
datafiles_read_directories (brush_vbr_path,
|
||||
(GimpDataFileLoaderFunc) brushes_brush_load,
|
||||
0);
|
||||
datafiles_read_directories (brush_path, brushes_brush_load, 0);
|
||||
datafiles_read_directories (brush_vbr_path, brushes_brush_load, 0);
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
|
@ -161,6 +159,8 @@ brushes_init (gint no_data)
|
|||
GimpBrush *
|
||||
brushes_get_standard_brush (void)
|
||||
{
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
|
||||
if (! standard_brush)
|
||||
{
|
||||
standard_brush =
|
||||
|
@ -228,84 +228,71 @@ brush_compare_func (gconstpointer first,
|
|||
void
|
||||
brushes_free (void)
|
||||
{
|
||||
if (brush_list)
|
||||
GList *vbr_path;
|
||||
gchar *vbr_dir;
|
||||
|
||||
if (!brush_list)
|
||||
return;
|
||||
|
||||
vbr_path = gimp_path_parse (brush_vbr_path, 16, TRUE, NULL);
|
||||
vbr_dir = gimp_path_get_user_writable_dir (vbr_path);
|
||||
gimp_path_free (vbr_path);
|
||||
|
||||
brush_select_freeze_all ();
|
||||
|
||||
while (GIMP_LIST (brush_list)->list)
|
||||
{
|
||||
brush_select_freeze_all ();
|
||||
GimpBrush *brush = GIMP_BRUSH (GIMP_LIST (brush_list)->list->data);
|
||||
|
||||
while (GIMP_LIST (brush_list)->list)
|
||||
if (GIMP_IS_BRUSH_GENERATED (brush) && vbr_dir)
|
||||
{
|
||||
GimpBrush * b = GIMP_BRUSH (GIMP_LIST (brush_list)->list->data);
|
||||
if (GIMP_IS_BRUSH_GENERATED (b))
|
||||
gchar *filename = g_strdup (brush->filename);
|
||||
|
||||
if (!filename)
|
||||
{
|
||||
gchar *filename = g_strdup (b->filename);
|
||||
if (!filename)
|
||||
{
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
FILE *tmp_fp;
|
||||
gint unum = 0;
|
||||
FILE *tmp_fp;
|
||||
gint unum = 0;
|
||||
|
||||
if (brush_vbr_path)
|
||||
{
|
||||
/* 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, G_SEARCHPATH_SEPARATOR_S);
|
||||
filename = g_strconcat (vbr_dir,
|
||||
brush->name, ".vbr",
|
||||
NULL);
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
if (home != NULL)
|
||||
path = g_strconcat (home, token + 1, NULL);
|
||||
else
|
||||
path = g_strdup (""); /* Better than nothing */
|
||||
else
|
||||
path = g_strdup (token);
|
||||
|
||||
filename = g_strconcat (path, G_DIR_SEPARATOR_S,
|
||||
b->name, ".vbr", NULL);
|
||||
while ((tmp_fp = fopen (filename, "r")))
|
||||
{ /* make sure we don't overwrite an existing brush */
|
||||
fclose (tmp_fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s%s_%d.vbr", path,
|
||||
G_DIR_SEPARATOR_S,
|
||||
b->name, unum);
|
||||
unum++;
|
||||
}
|
||||
g_free (path);
|
||||
}
|
||||
g_free (local_path);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* make sure we don't overwrite an existing brush */
|
||||
while ((tmp_fp = fopen (filename, "r")))
|
||||
{
|
||||
if (strcmp (&filename[strlen (filename) - 4], ".vbr"))
|
||||
{
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* okay we are ready to try to save the generated file */
|
||||
if (filename)
|
||||
{
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (b), filename);
|
||||
fclose (tmp_fp);
|
||||
g_free (filename);
|
||||
filename = g_strdup_printf ("%s%s_%d.vbr",
|
||||
vbr_dir,
|
||||
brush->name,
|
||||
unum);
|
||||
unum++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (&filename[strlen (filename) - 4], ".vbr"))
|
||||
{
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_brush_list_remove (brush_list, b);
|
||||
/* okay we are ready to try to save the generated file */
|
||||
if (filename)
|
||||
{
|
||||
gimp_brush_generated_save (GIMP_BRUSH_GENERATED (brush),
|
||||
filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
brush_select_thaw_all ();
|
||||
gimp_brush_list_remove (brush_list, brush);
|
||||
}
|
||||
|
||||
g_free (vbr_dir);
|
||||
|
||||
brush_select_thaw_all ();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -421,7 +408,7 @@ gimp_brush_list_add (GimpBrushList *brush_list,
|
|||
{
|
||||
gimp_brush_list_uniquefy_brush_name (brush_list, brush);
|
||||
gimp_list_add (GIMP_LIST (brush_list), brush);
|
||||
gtk_object_sink (GTK_OBJECT (brush));
|
||||
gtk_object_unref (GTK_OBJECT (brush));
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "rename",
|
||||
GTK_SIGNAL_FUNC (brush_renamed),
|
||||
brush_list);
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
#include "libgimp/gimpmath.h"
|
||||
#include "libgimp/parasiteio.h"
|
||||
|
||||
static GimpBrushClass* gimp_brush_class;
|
||||
static GtkObjectClass* gimp_object_class;
|
||||
static GimpBrushClass *gimp_brush_class;
|
||||
static GimpBrushPixmapClass *gimp_brush_pixmap_class;
|
||||
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
static GimpBrush *gimp_brush_pixmap_select_brush (PaintCore *paint_core);
|
||||
static gboolean gimp_brush_pixmap_want_null_motion (PaintCore *paint_core);
|
||||
|
||||
static void
|
||||
gimp_brush_pixmap_destroy (GtkObject *object)
|
||||
|
@ -53,10 +53,11 @@ gimp_brush_pixmap_destroy (GtkObject *object)
|
|||
g_return_if_fail (GIMP_IS_BRUSH_PIXMAP (object));
|
||||
|
||||
pixmap = GIMP_BRUSH_PIXMAP (object);
|
||||
|
||||
|
||||
temp_buf_free (pixmap->pixmap_mask);
|
||||
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,8 +71,8 @@ gimp_brush_pixmap_class_init (GimpBrushPixmapClass *klass)
|
|||
|
||||
gimp_brush_class = gtk_type_class (gimp_brush_get_type ());
|
||||
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
object_class->destroy = gimp_brush_pixmap_destroy;
|
||||
brush_class->select_brush = gimp_brush_pixmap_select_brush;
|
||||
brush_class->want_null_motion = gimp_brush_pixmap_want_null_motion;
|
||||
}
|
||||
|
||||
|
@ -193,10 +194,10 @@ gimp_brush_pixmap_want_null_motion (PaintCore *paint_core)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_destroy(GtkObject *object)
|
||||
gimp_brush_pipe_destroy (GtkObject *object)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
int i;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GIMP_IS_BRUSH_PIPE (object));
|
||||
|
@ -207,68 +208,74 @@ gimp_brush_pipe_destroy(GtkObject *object)
|
|||
g_free (pipe->stride);
|
||||
|
||||
for (i = 1; i < pipe->nbrushes; i++)
|
||||
gimp_object_destroy (pipe->brushes[i]);
|
||||
gtk_object_unref (GTK_OBJECT (pipe->brushes[i]));
|
||||
|
||||
g_free (pipe->brushes);
|
||||
g_free (pipe->select);
|
||||
g_free (pipe->index);
|
||||
|
||||
if (GTK_OBJECT_CLASS (gimp_object_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_object_class)->destroy) (object);
|
||||
if (GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (gimp_brush_pixmap_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
gimp_object_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
gimp_brush_pixmap_class = gtk_type_class (GIMP_TYPE_BRUSH_PIXMAP);
|
||||
object_class->destroy = gimp_brush_pipe_destroy;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_brush_pipe_init (GimpBrushPipe *pipe)
|
||||
{
|
||||
pipe->dimension = 0;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
pipe->rank = NULL;
|
||||
pipe->nbrushes = 0;
|
||||
pipe->select = NULL;
|
||||
pipe->index = NULL;
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_brush_pipe_get_type (void)
|
||||
{
|
||||
static GtkType type=0;
|
||||
if (!type){
|
||||
GtkTypeInfo info={
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL};
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
static GtkType type = 0;
|
||||
|
||||
if (!type)
|
||||
{
|
||||
GtkTypeInfo info =
|
||||
{
|
||||
"GimpBrushPipe",
|
||||
sizeof (GimpBrushPipe),
|
||||
sizeof (GimpBrushPipeClass),
|
||||
(GtkClassInitFunc) gimp_brush_pipe_class_init,
|
||||
(GtkObjectInitFunc) gimp_brush_pipe_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL
|
||||
};
|
||||
|
||||
type = gtk_type_unique (GIMP_TYPE_BRUSH_PIXMAP, &info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pipe_load (char *filename)
|
||||
gimp_brush_pipe_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
GPattern *pattern;
|
||||
PixPipeParams params;
|
||||
FILE *fp;
|
||||
gchar buf[1024];
|
||||
gchar *name;
|
||||
int i;
|
||||
int num_of_brushes;
|
||||
int totalcells;
|
||||
gint i;
|
||||
gint num_of_brushes;
|
||||
gint totalcells;
|
||||
gchar *paramstring;
|
||||
|
||||
if ((fp = fopen (filename, "rb")) == NULL)
|
||||
|
@ -294,7 +301,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
num_of_brushes = strtol(buf, ¶mstring, 10);
|
||||
num_of_brushes = strtol (buf, ¶mstring, 10);
|
||||
if (num_of_brushes < 1)
|
||||
{
|
||||
g_message (_("Brush pipes should have at least one brush."));
|
||||
|
@ -303,7 +310,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (*paramstring && isspace(*paramstring))
|
||||
while (*paramstring && isspace (*paramstring))
|
||||
paramstring++;
|
||||
|
||||
if (*paramstring)
|
||||
|
@ -311,9 +318,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
pixpipeparams_init (¶ms);
|
||||
pixpipeparams_parse (paramstring, ¶ms);
|
||||
pipe->dimension = params.dim;
|
||||
pipe->rank = g_new (int, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (int, pipe->dimension);
|
||||
pipe->rank = g_new (gint, pipe->dimension);
|
||||
pipe->select = g_new (PipeSelectModes, pipe->dimension);
|
||||
pipe->index = g_new (gint, pipe->dimension);
|
||||
/* placement is not used at all ?? */
|
||||
if (params.free_placement_string)
|
||||
g_free (params.placement);
|
||||
|
@ -344,18 +351,18 @@ gimp_brush_pipe_load (char *filename)
|
|||
else
|
||||
{
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = num_of_brushes;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
}
|
||||
|
||||
totalcells = 1; /* Not all necessarily present, maybe */
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
totalcells *= pipe->rank[i];
|
||||
pipe->stride = g_new (int, pipe->dimension);
|
||||
pipe->stride = g_new (gint, pipe->dimension);
|
||||
for (i = 0; i < pipe->dimension; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
|
@ -365,10 +372,9 @@ gimp_brush_pipe_load (char *filename)
|
|||
}
|
||||
g_assert (pipe->stride[pipe->dimension-1] == 1);
|
||||
|
||||
pattern = (GPattern*) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes =
|
||||
(GimpBrushPixmap **) g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
pipe->brushes = g_new0 (GimpBrushPixmap *, num_of_brushes);
|
||||
|
||||
/* First pixmap brush in the list is the pipe itself */
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
|
@ -385,7 +391,7 @@ gimp_brush_pipe_load (char *filename)
|
|||
g_free (GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name);
|
||||
GIMP_BRUSH (pipe->brushes[pipe->nbrushes])->name = NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[pipe->nbrushes]->pipe = pipe;
|
||||
|
||||
/* load the brush */
|
||||
|
@ -416,11 +422,12 @@ gimp_brush_pipe_load (char *filename)
|
|||
fclose (fp);
|
||||
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
GimpBrushPipe *
|
||||
gimp_brush_pixmap_load (char *filename)
|
||||
gimp_brush_pixmap_load (gchar *filename)
|
||||
{
|
||||
GimpBrushPipe *pipe;
|
||||
GPattern *pattern;
|
||||
|
@ -433,19 +440,19 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
/* A (single) pixmap brush is a pixmap pipe brush with just one pixmap */
|
||||
pipe->dimension = 1;
|
||||
pipe->rank = g_new (int, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->rank = g_new (gint, 1);
|
||||
pipe->rank[0] = 1;
|
||||
pipe->select = g_new (PipeSelectModes, 1);
|
||||
pipe->select[0] = PIPE_SELECT_INCREMENTAL;
|
||||
pipe->index = g_new (int, 1);
|
||||
pipe->index[0] = 0;
|
||||
pipe->index = g_new (gint, 1);
|
||||
pipe->index[0] = 0;
|
||||
|
||||
pattern = (GPattern *) g_malloc0 (sizeof (GPattern));
|
||||
pattern = g_new0 (GPattern, 1);
|
||||
|
||||
pipe->brushes = (GimpBrushPixmap **) g_new (GimpBrushPixmap *, 1);
|
||||
pipe->brushes = g_new (GimpBrushPixmap *, 1);
|
||||
|
||||
pipe->brushes[0] = GIMP_BRUSH_PIXMAP (pipe);
|
||||
pipe->current = pipe->brushes[0];
|
||||
pipe->current = pipe->brushes[0];
|
||||
|
||||
pipe->brushes[0]->pipe = pipe;
|
||||
|
||||
|
@ -460,7 +467,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
gimp_object_destroy (pipe);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pipe->brushes[0]->pixmap_mask = pattern->mask;
|
||||
|
||||
pipe->nbrushes = 1;
|
||||
|
@ -469,6 +476,7 @@ gimp_brush_pixmap_load (char *filename)
|
|||
|
||||
g_free (pattern->name);
|
||||
g_free (pattern);
|
||||
|
||||
return pipe;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,24 +39,25 @@ typedef enum
|
|||
|
||||
struct _GimpBrushPixmap
|
||||
{
|
||||
GimpBrush gbrush;
|
||||
TempBuf *pixmap_mask;
|
||||
GimpBrush gbrush;
|
||||
TempBuf *pixmap_mask;
|
||||
GimpBrushPipe *pipe;
|
||||
};
|
||||
|
||||
struct _GimpBrushPipe
|
||||
{
|
||||
GimpBrushPixmap pixmap; /* Also itself a pixmap brush */
|
||||
GimpBrushPixmap *current; /* Currently selected brush */
|
||||
int dimension;
|
||||
int *rank; /* Size in each dimension */
|
||||
int *stride; /* Aux for indexing */
|
||||
int nbrushes; /* Might be less than the product of the
|
||||
GimpBrushPixmap pixmap; /* Also itself a pixmap brush */
|
||||
|
||||
GimpBrushPixmap *current; /* Currently selected brush */
|
||||
gint dimension;
|
||||
gint *rank; /* Size in each dimension */
|
||||
gint *stride; /* Aux for indexing */
|
||||
gint nbrushes; /* Might be less than the product of the
|
||||
* ranks in some odd special case
|
||||
*/
|
||||
GimpBrushPixmap **brushes;
|
||||
PipeSelectModes *select; /* One mode per dimension */
|
||||
int *index; /* Current index for incremental dimensions */
|
||||
PipeSelectModes *select; /* One mode per dimension */
|
||||
gint *index; /* Current index for incremental dimensions */
|
||||
};
|
||||
|
||||
typedef struct _GimpBrushPixmapClass
|
||||
|
|
|
@ -177,7 +177,7 @@ gimp_list_remove (GimpList *list,
|
|||
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
||||
list);
|
||||
else
|
||||
gtk_object_unref (GTK_OBJECT(val));
|
||||
gtk_object_unref (GTK_OBJECT (val));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradient_select.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
@ -116,10 +117,13 @@
|
|||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
||||
#define GRAD_UPDATE_GRADIENT 1
|
||||
#define GRAD_UPDATE_PREVIEW 2
|
||||
#define GRAD_UPDATE_CONTROL 4
|
||||
#define GRAD_RESET_CONTROL 8
|
||||
enum
|
||||
{
|
||||
GRAD_UPDATE_GRADIENT = 1 << 0,
|
||||
GRAD_UPDATE_PREVIEW = 1 << 1,
|
||||
GRAD_UPDATE_CONTROL = 1 << 2,
|
||||
GRAD_RESET_CONTROL = 1 << 3
|
||||
};
|
||||
|
||||
/* Gradient editor type */
|
||||
|
||||
|
@ -6166,11 +6170,8 @@ static gchar *
|
|||
build_user_filename (gchar *name,
|
||||
gchar *path_str)
|
||||
{
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *grad_path;
|
||||
gchar *grad_dir;
|
||||
gchar *filename;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
@ -6178,34 +6179,16 @@ build_user_filename (gchar *name,
|
|||
if (!path_str)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
/* Get the first path specified in the list */
|
||||
grad_path = gimp_path_parse (path_str, 16, TRUE, NULL);
|
||||
grad_dir = gimp_path_get_user_writable_dir (grad_path);
|
||||
gimp_path_free (grad_path);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
filename = NULL;
|
||||
if (!grad_dir)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (!home)
|
||||
return NULL;
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
filename = g_strdup_printf ("%s%s", grad_dir, name);
|
||||
|
||||
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
g_free (grad_dir);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradient_select.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
@ -116,10 +117,13 @@
|
|||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
||||
#define GRAD_UPDATE_GRADIENT 1
|
||||
#define GRAD_UPDATE_PREVIEW 2
|
||||
#define GRAD_UPDATE_CONTROL 4
|
||||
#define GRAD_RESET_CONTROL 8
|
||||
enum
|
||||
{
|
||||
GRAD_UPDATE_GRADIENT = 1 << 0,
|
||||
GRAD_UPDATE_PREVIEW = 1 << 1,
|
||||
GRAD_UPDATE_CONTROL = 1 << 2,
|
||||
GRAD_RESET_CONTROL = 1 << 3
|
||||
};
|
||||
|
||||
/* Gradient editor type */
|
||||
|
||||
|
@ -6166,11 +6170,8 @@ static gchar *
|
|||
build_user_filename (gchar *name,
|
||||
gchar *path_str)
|
||||
{
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *grad_path;
|
||||
gchar *grad_dir;
|
||||
gchar *filename;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
@ -6178,34 +6179,16 @@ build_user_filename (gchar *name,
|
|||
if (!path_str)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
/* Get the first path specified in the list */
|
||||
grad_path = gimp_path_parse (path_str, 16, TRUE, NULL);
|
||||
grad_dir = gimp_path_get_user_writable_dir (grad_path);
|
||||
gimp_path_free (grad_path);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
filename = NULL;
|
||||
if (!grad_dir)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (!home)
|
||||
return NULL;
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
filename = g_strdup_printf ("%s%s", grad_dir, name);
|
||||
|
||||
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
g_free (grad_dir);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradient_select.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
@ -116,10 +117,13 @@
|
|||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
||||
#define GRAD_UPDATE_GRADIENT 1
|
||||
#define GRAD_UPDATE_PREVIEW 2
|
||||
#define GRAD_UPDATE_CONTROL 4
|
||||
#define GRAD_RESET_CONTROL 8
|
||||
enum
|
||||
{
|
||||
GRAD_UPDATE_GRADIENT = 1 << 0,
|
||||
GRAD_UPDATE_PREVIEW = 1 << 1,
|
||||
GRAD_UPDATE_CONTROL = 1 << 2,
|
||||
GRAD_RESET_CONTROL = 1 << 3
|
||||
};
|
||||
|
||||
/* Gradient editor type */
|
||||
|
||||
|
@ -6166,11 +6170,8 @@ static gchar *
|
|||
build_user_filename (gchar *name,
|
||||
gchar *path_str)
|
||||
{
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *grad_path;
|
||||
gchar *grad_dir;
|
||||
gchar *filename;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
@ -6178,34 +6179,16 @@ build_user_filename (gchar *name,
|
|||
if (!path_str)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
/* Get the first path specified in the list */
|
||||
grad_path = gimp_path_parse (path_str, 16, TRUE, NULL);
|
||||
grad_dir = gimp_path_get_user_writable_dir (grad_path);
|
||||
gimp_path_free (grad_path);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
filename = NULL;
|
||||
if (!grad_dir)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (!home)
|
||||
return NULL;
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
filename = g_strdup_printf ("%s%s", grad_dir, name);
|
||||
|
||||
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
g_free (grad_dir);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "color_area.h"
|
||||
#include "color_notebook.h"
|
||||
#include "datafiles.h"
|
||||
#include "general.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -47,6 +46,8 @@
|
|||
#include "palette_select.h"
|
||||
#include "dialog_handler.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps/zoom_in.xpm"
|
||||
|
@ -282,59 +283,37 @@ static PaletteEntries *
|
|||
palette_entries_new (gchar *palette_name)
|
||||
{
|
||||
PaletteEntries *entries = NULL;
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *pal_path;
|
||||
gchar *pal_dir;
|
||||
|
||||
if (palette_name)
|
||||
if (!palette_name || !palette_path)
|
||||
return NULL;
|
||||
|
||||
pal_path = gimp_path_parse (palette_path, 16, TRUE, NULL);
|
||||
pal_dir = gimp_path_get_user_writable_dir (pal_path);
|
||||
gimp_path_free (pal_path);
|
||||
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
|
||||
if (pal_dir)
|
||||
{
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
if (palette_path)
|
||||
{
|
||||
/* Get the first path specified in the palette path list */
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (palette_path);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (home)
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
else
|
||||
/* Just ignore the ~ if no HOME ??? */
|
||||
path = g_strdup (token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
|
||||
entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, palette_name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
}
|
||||
else
|
||||
entries->filename = NULL;
|
||||
|
||||
entries->name = palette_name; /* don't need to copy because this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
entries->filename = g_strdup_printf ("%s%s", pal_dir, palette_name);
|
||||
g_free (pal_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries->filename = NULL;
|
||||
}
|
||||
|
||||
entries->name = palette_name; /* this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "color_area.h"
|
||||
#include "color_notebook.h"
|
||||
#include "datafiles.h"
|
||||
#include "general.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -47,6 +46,8 @@
|
|||
#include "palette_select.h"
|
||||
#include "dialog_handler.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps/zoom_in.xpm"
|
||||
|
@ -282,59 +283,37 @@ static PaletteEntries *
|
|||
palette_entries_new (gchar *palette_name)
|
||||
{
|
||||
PaletteEntries *entries = NULL;
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *pal_path;
|
||||
gchar *pal_dir;
|
||||
|
||||
if (palette_name)
|
||||
if (!palette_name || !palette_path)
|
||||
return NULL;
|
||||
|
||||
pal_path = gimp_path_parse (palette_path, 16, TRUE, NULL);
|
||||
pal_dir = gimp_path_get_user_writable_dir (pal_path);
|
||||
gimp_path_free (pal_path);
|
||||
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
|
||||
if (pal_dir)
|
||||
{
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
if (palette_path)
|
||||
{
|
||||
/* Get the first path specified in the palette path list */
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (palette_path);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (home)
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
else
|
||||
/* Just ignore the ~ if no HOME ??? */
|
||||
path = g_strdup (token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
|
||||
entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, palette_name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
}
|
||||
else
|
||||
entries->filename = NULL;
|
||||
|
||||
entries->name = palette_name; /* don't need to copy because this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
entries->filename = g_strdup_printf ("%s%s", pal_dir, palette_name);
|
||||
g_free (pal_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries->filename = NULL;
|
||||
}
|
||||
|
||||
entries->name = palette_name; /* this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "gradient_header.h"
|
||||
#include "gradient_select.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimplimits.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
@ -116,10 +117,13 @@
|
|||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK)
|
||||
|
||||
#define GRAD_UPDATE_GRADIENT 1
|
||||
#define GRAD_UPDATE_PREVIEW 2
|
||||
#define GRAD_UPDATE_CONTROL 4
|
||||
#define GRAD_RESET_CONTROL 8
|
||||
enum
|
||||
{
|
||||
GRAD_UPDATE_GRADIENT = 1 << 0,
|
||||
GRAD_UPDATE_PREVIEW = 1 << 1,
|
||||
GRAD_UPDATE_CONTROL = 1 << 2,
|
||||
GRAD_RESET_CONTROL = 1 << 3
|
||||
};
|
||||
|
||||
/* Gradient editor type */
|
||||
|
||||
|
@ -6166,11 +6170,8 @@ static gchar *
|
|||
build_user_filename (gchar *name,
|
||||
gchar *path_str)
|
||||
{
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *grad_path;
|
||||
gchar *grad_dir;
|
||||
gchar *filename;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
@ -6178,34 +6179,16 @@ build_user_filename (gchar *name,
|
|||
if (!path_str)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
/* Get the first path specified in the list */
|
||||
grad_path = gimp_path_parse (path_str, 16, TRUE, NULL);
|
||||
grad_dir = gimp_path_get_user_writable_dir (grad_path);
|
||||
gimp_path_free (grad_path);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (path_str);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
filename = NULL;
|
||||
if (!grad_dir)
|
||||
return NULL; /* Perhaps this is not a good idea */
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (!home)
|
||||
return NULL;
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
filename = g_strdup_printf ("%s%s", grad_dir, name);
|
||||
|
||||
filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
g_free (grad_dir);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "color_area.h"
|
||||
#include "color_notebook.h"
|
||||
#include "datafiles.h"
|
||||
#include "general.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdnd.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -47,6 +46,8 @@
|
|||
#include "palette_select.h"
|
||||
#include "dialog_handler.h"
|
||||
|
||||
#include "libgimp/gimpenv.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps/zoom_in.xpm"
|
||||
|
@ -282,59 +283,37 @@ static PaletteEntries *
|
|||
palette_entries_new (gchar *palette_name)
|
||||
{
|
||||
PaletteEntries *entries = NULL;
|
||||
gchar *home;
|
||||
gchar *local_path;
|
||||
gchar *first_token;
|
||||
gchar *token;
|
||||
gchar *path;
|
||||
GList *pal_path;
|
||||
gchar *pal_dir;
|
||||
|
||||
if (palette_name)
|
||||
if (!palette_name || !palette_path)
|
||||
return NULL;
|
||||
|
||||
pal_path = gimp_path_parse (palette_path, 16, TRUE, NULL);
|
||||
pal_dir = gimp_path_get_user_writable_dir (pal_path);
|
||||
gimp_path_free (pal_path);
|
||||
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
|
||||
if (pal_dir)
|
||||
{
|
||||
entries = g_new (PaletteEntries, 1);
|
||||
if (palette_path)
|
||||
{
|
||||
/* Get the first path specified in the palette path list */
|
||||
home = g_get_home_dir ();
|
||||
local_path = g_strdup (palette_path);
|
||||
first_token = local_path;
|
||||
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
||||
|
||||
if (token)
|
||||
{
|
||||
if (*token == '~')
|
||||
{
|
||||
if (home)
|
||||
path = g_strdup_printf ("%s%s", home, token + 1);
|
||||
else
|
||||
/* Just ignore the ~ if no HOME ??? */
|
||||
path = g_strdup (token + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_strdup (token);
|
||||
}
|
||||
|
||||
entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
||||
path, palette_name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
g_free (local_path);
|
||||
}
|
||||
else
|
||||
entries->filename = NULL;
|
||||
|
||||
entries->name = palette_name; /* don't need to copy because this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
entries->filename = g_strdup_printf ("%s%s", pal_dir, palette_name);
|
||||
g_free (pal_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
entries->filename = NULL;
|
||||
}
|
||||
|
||||
entries->name = palette_name; /* this memory is ours */
|
||||
entries->colors = NULL;
|
||||
entries->n_colors = 0;
|
||||
entries->changed = TRUE;
|
||||
entries->pixmap = NULL;
|
||||
|
||||
palette_entries_list_insert (entries);
|
||||
|
||||
palette_save_palettes ();
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
|
|
@ -321,11 +321,11 @@ gimp_path_parse (gchar *path,
|
|||
}
|
||||
|
||||
if (!err)
|
||||
list = g_list_prepend (list, dir->str);
|
||||
list = g_list_prepend (list, g_strdup (dir->str));
|
||||
else if (check_failed)
|
||||
fail_list = g_list_prepend (fail_list, dir->str);
|
||||
fail_list = g_list_prepend (fail_list, g_strdup (dir->str));
|
||||
|
||||
g_string_free (dir, FALSE);
|
||||
g_string_free (dir, TRUE);
|
||||
}
|
||||
|
||||
g_strfreev (patharray);
|
||||
|
@ -442,7 +442,7 @@ gimp_path_get_user_writable_dir (GList *path)
|
|||
(euid != filestat.st_uid) &&
|
||||
(egid != filestat.st_gid))))
|
||||
{
|
||||
return (gchar *) list->data;
|
||||
return g_strdup ((gchar *) list->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ datafiles_read_directories (gchar *path_str,
|
|||
}
|
||||
|
||||
gimp_path_free (path);
|
||||
g_free (local_path);
|
||||
}
|
||||
|
||||
time_t
|
||||
|
|
|
@ -321,11 +321,11 @@ gimp_path_parse (gchar *path,
|
|||
}
|
||||
|
||||
if (!err)
|
||||
list = g_list_prepend (list, dir->str);
|
||||
list = g_list_prepend (list, g_strdup (dir->str));
|
||||
else if (check_failed)
|
||||
fail_list = g_list_prepend (fail_list, dir->str);
|
||||
fail_list = g_list_prepend (fail_list, g_strdup (dir->str));
|
||||
|
||||
g_string_free (dir, FALSE);
|
||||
g_string_free (dir, TRUE);
|
||||
}
|
||||
|
||||
g_strfreev (patharray);
|
||||
|
@ -442,7 +442,7 @@ gimp_path_get_user_writable_dir (GList *path)
|
|||
(euid != filestat.st_uid) &&
|
||||
(egid != filestat.st_gid))))
|
||||
{
|
||||
return (gchar *) list->data;
|
||||
return g_strdup ((gchar *) list->data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1739,9 +1739,11 @@ create_file_selection (void)
|
|||
dir = gimp_path_get_user_writable_dir (fractalexplorer_path_list);
|
||||
|
||||
if (!dir)
|
||||
dir = gimp_directory ();
|
||||
dir = g_strdup (gimp_directory ());
|
||||
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), dir);
|
||||
|
||||
g_free (dir);
|
||||
}
|
||||
else
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window),"/tmp");
|
||||
|
|
|
@ -1605,9 +1605,11 @@ create_file_selection (GFigObj *obj,
|
|||
dir = gimp_path_get_user_writable_dir (gfig_path_list);
|
||||
|
||||
if (!dir)
|
||||
dir = gimp_directory ();
|
||||
dir = g_strdup (gimp_directory ());
|
||||
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), dir);
|
||||
|
||||
g_free (dir);
|
||||
}
|
||||
else
|
||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (window), "/tmp");
|
||||
|
|
|
@ -1530,7 +1530,12 @@ gflare_save (GFlare *gflare)
|
|||
|
||||
path = gimp_path_get_user_writable_dir (gflare_path_list);
|
||||
|
||||
if (!path)
|
||||
path = g_strdup (gimp_directory ());
|
||||
|
||||
gflare->filename = g_strdup_printf ("%s%s", path, gflare->name);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
fp = fopen (gflare->filename, "w");
|
||||
|
|
Loading…
Reference in New Issue