1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
1999-02-21 07:20:54 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1999-04-23 17:39:51 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_DIRENT_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <dirent.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
1998-07-20 06:32:35 +08:00
|
|
|
#include <math.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
1998-07-09 13:31:06 +08:00
|
|
|
#include "gimpbrushgenerated.h"
|
1999-08-23 14:06:12 +08:00
|
|
|
#include "gimpbrushpipe.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "brush_header.h"
|
|
|
|
#include "brush_select.h"
|
|
|
|
#include "colormaps.h"
|
|
|
|
#include "datafiles.h"
|
1998-06-06 11:49:01 +08:00
|
|
|
#include "devices.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "errors.h"
|
|
|
|
#include "gimprc.h"
|
1998-07-09 13:31:06 +08:00
|
|
|
#include "gimpsignal.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "menus.h"
|
1998-07-09 13:31:06 +08:00
|
|
|
#include "paint_core.h"
|
1999-04-22 22:34:00 +08:00
|
|
|
#include "paint_options.h"
|
1998-07-12 19:40:43 +08:00
|
|
|
#include "gimplist.h"
|
|
|
|
#include "gimpbrush.h"
|
|
|
|
#include "gimplistP.h"
|
|
|
|
#include "gimpbrushlistP.h"
|
1999-01-11 07:20:33 +08:00
|
|
|
#include "dialog_handler.h"
|
1999-08-30 18:51:01 +08:00
|
|
|
#include "general.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* global variables */
|
1998-07-12 19:40:43 +08:00
|
|
|
GimpBrush *active_brush = NULL;
|
|
|
|
GimpBrushList *brush_list = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-22 22:34:00 +08:00
|
|
|
BrushSelectP brush_select_dialog = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* static variables */
|
|
|
|
static int have_default_brush = 0;
|
|
|
|
|
|
|
|
/* static function prototypes */
|
1998-07-09 13:31:06 +08:00
|
|
|
static void create_default_brush (void);
|
1998-07-13 18:04:42 +08:00
|
|
|
static gint brush_compare_func (gconstpointer, gconstpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-16 19:44:56 +08:00
|
|
|
static void brush_load (char *filename);
|
1998-07-09 13:31:06 +08:00
|
|
|
|
|
|
|
/* class functions */
|
|
|
|
static GimpObjectClass* parent_class;
|
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_list_add_func(GimpList* list, gpointer val)
|
|
|
|
{
|
|
|
|
list->list=g_slist_insert_sorted (list->list, val, brush_compare_func);
|
|
|
|
GIMP_BRUSH_LIST(list)->num_brushes++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-07-24 16:56:18 +08:00
|
|
|
gimp_brush_list_remove_func(GimpList* list, gpointer val)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
|
|
|
list->list=g_slist_remove(list->list, val);
|
|
|
|
GIMP_BRUSH_LIST(list)->num_brushes--;
|
|
|
|
}
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_list_class_init (GimpBrushListClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-07-12 19:40:43 +08:00
|
|
|
GimpListClass *gimp_list_class;
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
gimp_list_class = GIMP_LIST_CLASS(klass);
|
|
|
|
gimp_list_class->add = gimp_brush_list_add_func;
|
1998-07-24 16:56:18 +08:00
|
|
|
gimp_list_class->remove = gimp_brush_list_remove_func;
|
1998-07-12 19:40:43 +08:00
|
|
|
parent_class = gtk_type_class (gimp_list_get_type ());
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
void
|
|
|
|
gimp_brush_list_init(GimpBrushList *list)
|
|
|
|
{
|
|
|
|
list->num_brushes = 0;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
GtkType gimp_brush_list_get_type(void)
|
|
|
|
{
|
1999-08-17 08:59:07 +08:00
|
|
|
static GtkType type=0;
|
1998-07-09 13:31:06 +08:00
|
|
|
if(!type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo info={
|
|
|
|
"GimpBrushList",
|
|
|
|
sizeof(GimpBrushList),
|
|
|
|
sizeof(GimpBrushListClass),
|
|
|
|
(GtkClassInitFunc)gimp_brush_list_class_init,
|
|
|
|
(GtkObjectInitFunc)gimp_brush_list_init,
|
1999-08-17 08:59:07 +08:00
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */NULL,
|
|
|
|
(GtkClassInitFunc) NULL};
|
1998-07-12 19:40:43 +08:00
|
|
|
type=gtk_type_unique(gimp_list_get_type(), &info);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
GimpBrushList *
|
|
|
|
gimp_brush_list_new ()
|
|
|
|
{
|
|
|
|
GimpBrushList *list=GIMP_BRUSH_LIST(gtk_type_new(gimp_brush_list_get_type()));
|
1998-07-12 19:40:43 +08:00
|
|
|
GIMP_LIST(list)->type = GIMP_TYPE_BRUSH;
|
|
|
|
GIMP_LIST(list)->weak = 0;
|
1998-07-09 13:31:06 +08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
/* function declarations */
|
|
|
|
void
|
|
|
|
brushes_init (int no_data)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (brush_list)
|
|
|
|
brushes_free();
|
1998-07-24 16:56:18 +08:00
|
|
|
else
|
|
|
|
brush_list = gimp_brush_list_new();
|
1998-07-09 13:31:06 +08:00
|
|
|
|
1998-07-10 16:59:55 +08:00
|
|
|
if (brush_path == NULL || (no_data))
|
1998-07-09 13:31:06 +08:00
|
|
|
create_default_brush ();
|
1998-07-10 16:59:55 +08:00
|
|
|
else
|
1998-07-16 19:44:56 +08:00
|
|
|
datafiles_read_directories (brush_path,(datafile_loader_t)brush_load, 0);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-16 19:44:56 +08:00
|
|
|
static void
|
|
|
|
brush_load(char *filename)
|
|
|
|
{
|
|
|
|
if (strcmp(&filename[strlen(filename) - 4], ".gbr") == 0)
|
1999-08-09 14:30:31 +08:00
|
|
|
{
|
|
|
|
GimpBrush *brush;
|
|
|
|
brush = gimp_brush_new(filename);
|
|
|
|
if (brush != NULL)
|
|
|
|
gimp_brush_list_add(brush_list, brush);
|
|
|
|
else
|
|
|
|
g_message("Warning: failed to load brush \"%s\"", filename);
|
|
|
|
}
|
1998-07-16 19:44:56 +08:00
|
|
|
else if (strcmp(&filename[strlen(filename) - 4], ".vbr") == 0)
|
1999-08-09 14:30:31 +08:00
|
|
|
{
|
|
|
|
GimpBrushGenerated *brush;
|
|
|
|
brush = gimp_brush_generated_load(filename);
|
|
|
|
if (brush != NULL)
|
|
|
|
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
|
|
|
|
else
|
|
|
|
g_message("Warning: failed to load brush \"%s\"", filename);
|
|
|
|
}
|
|
|
|
else if (strcmp(&filename[strlen(filename) - 4], ".gpb") == 0)
|
|
|
|
{
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
GimpBrushPipe *brush;
|
1999-08-09 14:30:31 +08:00
|
|
|
brush = gimp_brush_pixmap_load(filename);
|
|
|
|
if (brush != NULL)
|
|
|
|
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
|
|
|
|
else
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
g_message("Warning: failed to load pixmap brush \"%s\"", filename);
|
1999-08-09 14:30:31 +08:00
|
|
|
}
|
1999-08-17 08:59:07 +08:00
|
|
|
else if (strcmp(&filename[strlen(filename) - 4], ".gih") == 0)
|
|
|
|
{
|
1999-08-23 14:06:12 +08:00
|
|
|
GimpBrushPipe *brush;
|
|
|
|
brush = gimp_brush_pipe_load(filename);
|
1999-08-17 08:59:07 +08:00
|
|
|
if (brush != NULL)
|
|
|
|
gimp_brush_list_add(brush_list, GIMP_BRUSH(brush));
|
|
|
|
else
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
g_message("Warning: failed to load pixmap pipe \"%s\"", filename);
|
1999-08-17 08:59:07 +08:00
|
|
|
}
|
1998-07-16 19:44:56 +08:00
|
|
|
}
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
static gint
|
1998-06-11 01:20:56 +08:00
|
|
|
brush_compare_func (gconstpointer first, gconstpointer second)
|
1998-01-29 16:03:27 +08:00
|
|
|
{
|
1998-07-12 19:40:43 +08:00
|
|
|
return strcmp (((const GimpBrush *)first)->name,
|
|
|
|
((const GimpBrush *)second)->name);
|
1998-01-29 16:03:27 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
void
|
|
|
|
brushes_free ()
|
|
|
|
{
|
1998-07-24 16:56:18 +08:00
|
|
|
if (brush_list)
|
|
|
|
{
|
|
|
|
while (GIMP_LIST(brush_list)->list)
|
1999-08-30 18:51:01 +08:00
|
|
|
{
|
|
|
|
GimpBrush * b = GIMP_BRUSH (GIMP_LIST(brush_list)->list->data);
|
1999-08-31 04:42:34 +08:00
|
|
|
if (GIMP_IS_BRUSH_GENERATED (b))
|
1999-08-30 18:51:01 +08:00
|
|
|
{
|
1999-08-31 04:42:34 +08:00
|
|
|
char * filename = g_strdup (b->filename);
|
1999-08-30 18:51:01 +08:00
|
|
|
if (!filename)
|
|
|
|
{
|
|
|
|
char *home;
|
|
|
|
char *local_path;
|
|
|
|
char *first_token;
|
|
|
|
char *token;
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
if (brush_vbr_path)
|
|
|
|
{
|
1999-08-31 04:42:34 +08:00
|
|
|
/* Get the first path specified in the
|
|
|
|
* brush-vbr-path gimprc variable.
|
|
|
|
*/
|
|
|
|
home = g_get_home_dir ();
|
1999-08-30 18:51:01 +08:00
|
|
|
local_path = g_strdup (brush_vbr_path);
|
|
|
|
first_token = local_path;
|
1999-08-31 04:42:34 +08:00
|
|
|
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
1999-08-30 18:51:01 +08:00
|
|
|
|
|
|
|
if (token)
|
|
|
|
{
|
|
|
|
if (*token == '~')
|
1999-08-31 04:42:34 +08:00
|
|
|
if (home != NULL)
|
|
|
|
path = g_strconcat (home, token + 1, NULL);
|
|
|
|
else
|
|
|
|
path = g_strdup (""); /* Better than nothing */
|
1999-08-30 18:51:01 +08:00
|
|
|
else
|
1999-08-31 04:42:34 +08:00
|
|
|
path = g_strdup (token);
|
1999-08-30 18:51:01 +08:00
|
|
|
|
1999-08-31 04:42:34 +08:00
|
|
|
filename = g_strconcat (path, G_DIR_SEPARATOR_S, b->name, ".vbr", NULL);
|
1999-08-30 18:51:01 +08:00
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
g_free (local_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strcmp(&filename[strlen(filename) - 4], ".vbr"))
|
1999-08-31 04:42:34 +08:00
|
|
|
{
|
|
|
|
g_free (filename);
|
|
|
|
filename = NULL;
|
|
|
|
}
|
1999-08-30 18:51:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* okay we are ready to try to save the generated file*/
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
gimp_brush_generated_save ( GIMP_BRUSH_GENERATED(b), filename);
|
1999-08-31 04:42:34 +08:00
|
|
|
g_free (filename);
|
1999-08-30 18:51:01 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_brush_list_remove(brush_list, b);
|
|
|
|
}
|
1998-01-29 16:03:27 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
have_default_brush = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
brush_select_dialog_free ()
|
|
|
|
{
|
|
|
|
if (brush_select_dialog)
|
|
|
|
{
|
|
|
|
brush_select_free (brush_select_dialog);
|
|
|
|
brush_select_dialog = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
GimpBrush *
|
1997-11-25 06:05:25 +08:00
|
|
|
get_active_brush ()
|
|
|
|
{
|
|
|
|
if (have_default_brush)
|
|
|
|
{
|
|
|
|
have_default_brush = 0;
|
|
|
|
if (!active_brush)
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gimp_fatal_error (_("get_active_brush(): Specified default brush not found!"));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else if (! active_brush && brush_list)
|
1998-07-12 19:40:43 +08:00
|
|
|
/* need a gimp_list_get_first() type function */
|
1998-07-24 16:56:18 +08:00
|
|
|
select_brush((GimpBrush *) GIMP_LIST(brush_list)->list->data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return active_brush;
|
|
|
|
}
|
|
|
|
|
1998-09-07 04:05:06 +08:00
|
|
|
#if 0
|
1998-01-29 16:03:27 +08:00
|
|
|
static GSList *
|
1998-07-12 19:40:43 +08:00
|
|
|
insert_brush_in_list (GSList *list, GimpBrush * brush)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-29 16:03:27 +08:00
|
|
|
return g_slist_insert_sorted (list, brush, brush_compare_func);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-09-07 04:05:06 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
create_default_brush ()
|
|
|
|
{
|
1998-07-09 13:31:06 +08:00
|
|
|
GimpBrushGenerated *brush;
|
|
|
|
|
|
|
|
brush = gimp_brush_generated_new(5.0, .5, 0.0, 1.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Swap the brush to disk (if we're being stingy with memory) */
|
|
|
|
if (stingy_memory_use)
|
1998-07-09 13:31:06 +08:00
|
|
|
temp_buf_swap (GIMP_BRUSH(brush)->mask);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Make this the default, active brush */
|
1998-07-24 16:56:18 +08:00
|
|
|
select_brush(GIMP_BRUSH(brush));
|
1997-11-25 06:05:25 +08:00
|
|
|
have_default_brush = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
int
|
|
|
|
gimp_brush_list_get_brush_index (GimpBrushList *brush_list,
|
|
|
|
GimpBrush *brush)
|
|
|
|
{
|
|
|
|
/* fix me: make a gimp_list function that does this? */
|
1998-07-24 16:56:18 +08:00
|
|
|
return g_slist_index (GIMP_LIST(brush_list)->list, brush);
|
1998-07-20 22:05:33 +08:00
|
|
|
}
|
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
GimpBrush *
|
1998-07-20 22:05:33 +08:00
|
|
|
gimp_brush_list_get_brush_by_index (GimpBrushList *brush_list, int index)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *list;
|
1998-07-12 19:40:43 +08:00
|
|
|
GimpBrush * brush = NULL;
|
|
|
|
/* fix me: make a gimp_list function that does this? */
|
|
|
|
list = g_slist_nth (GIMP_LIST(brush_list)->list, index);
|
1998-01-29 16:03:27 +08:00
|
|
|
if (list)
|
1998-07-12 19:40:43 +08:00
|
|
|
brush = (GimpBrush *) list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
return brush;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-07-20 06:32:35 +08:00
|
|
|
static void
|
|
|
|
gimp_brush_list_uniquefy_brush_name(GimpBrushList *brush_list,
|
|
|
|
GimpBrush *brush)
|
|
|
|
{
|
1998-07-20 22:05:33 +08:00
|
|
|
GSList *list, *listb;
|
1998-07-20 06:32:35 +08:00
|
|
|
GimpBrush *brushb;
|
|
|
|
int number = 1;
|
|
|
|
char *newname;
|
|
|
|
char *oldname;
|
|
|
|
char *ext;
|
|
|
|
g_return_if_fail(GIMP_IS_BRUSH_LIST(brush_list));
|
|
|
|
g_return_if_fail(GIMP_IS_BRUSH(brush));
|
|
|
|
list = GIMP_LIST(brush_list)->list;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
brushb = GIMP_BRUSH(list->data);
|
|
|
|
if (brush != brushb &&
|
|
|
|
strcmp(gimp_brush_get_name(brush), gimp_brush_get_name(brushb)) == 0)
|
|
|
|
{ /* names conflict */
|
|
|
|
oldname = gimp_brush_get_name(brush);
|
|
|
|
newname = g_malloc(strlen(oldname)+10); /* if this aint enough
|
|
|
|
yer screwed */
|
|
|
|
strcpy (newname, oldname);
|
|
|
|
if ((ext = strrchr(newname, '#')))
|
|
|
|
{
|
|
|
|
number = atoi(ext+1);
|
|
|
|
if (&ext[(int)(log10(number) + 1)] != &newname[strlen(newname) - 1])
|
|
|
|
{
|
|
|
|
number = 1;
|
|
|
|
ext = &newname[strlen(newname)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
number = 1;
|
|
|
|
ext = &newname[strlen(newname)];
|
|
|
|
}
|
|
|
|
sprintf(ext, "#%d", number+1);
|
1998-07-20 22:05:33 +08:00
|
|
|
listb = GIMP_LIST(brush_list)->list;
|
|
|
|
while (listb) /* make sure the new name is unique */
|
|
|
|
{
|
|
|
|
brushb = GIMP_BRUSH(listb->data);
|
|
|
|
if (brush != brushb && strcmp(newname,
|
|
|
|
gimp_brush_get_name(brushb)) == 0)
|
|
|
|
{
|
|
|
|
number++;
|
|
|
|
sprintf(ext, "#%d", number+1);
|
|
|
|
listb = GIMP_LIST(brush_list)->list;
|
|
|
|
}
|
|
|
|
listb = listb->next;
|
|
|
|
}
|
1998-07-20 06:32:35 +08:00
|
|
|
gimp_brush_set_name(brush, newname);
|
|
|
|
g_free(newname);
|
1998-07-20 22:05:33 +08:00
|
|
|
if (gimp_list_have(GIMP_LIST(brush_list), brush))
|
|
|
|
{ /* ought to have a better way than this to resort the brush */
|
|
|
|
gtk_object_ref(GTK_OBJECT(brush));
|
|
|
|
gimp_brush_list_remove(brush_list, brush);
|
|
|
|
gimp_brush_list_add(brush_list, brush);
|
|
|
|
gtk_object_unref(GTK_OBJECT(brush));
|
|
|
|
}
|
1998-07-20 06:32:35 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void brush_renamed(GimpBrush *brush, GimpBrushList *brush_list)
|
|
|
|
{
|
|
|
|
gimp_brush_list_uniquefy_brush_name(brush_list, brush);
|
|
|
|
}
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
void
|
1998-07-12 19:40:43 +08:00
|
|
|
gimp_brush_list_add (GimpBrushList *brush_list, GimpBrush * brush)
|
1998-07-09 13:31:06 +08:00
|
|
|
{
|
1998-07-20 22:05:33 +08:00
|
|
|
gimp_brush_list_uniquefy_brush_name(brush_list, brush);
|
1998-07-12 19:40:43 +08:00
|
|
|
gimp_list_add(GIMP_LIST(brush_list), brush);
|
1998-07-13 18:04:42 +08:00
|
|
|
gtk_object_sink(GTK_OBJECT(brush));
|
1998-07-20 06:32:35 +08:00
|
|
|
gtk_signal_connect(GTK_OBJECT(brush), "rename",
|
|
|
|
(GtkSignalFunc)brush_renamed, brush_list);
|
1998-07-09 13:31:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
void
|
1998-07-12 19:40:43 +08:00
|
|
|
gimp_brush_list_remove (GimpBrushList *brush_list, GimpBrush * brush)
|
|
|
|
{
|
1998-07-20 06:32:35 +08:00
|
|
|
gtk_signal_disconnect_by_data(GTK_OBJECT(brush), brush_list);
|
1998-07-12 19:40:43 +08:00
|
|
|
gimp_list_remove(GIMP_LIST(brush_list), brush);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gimp_brush_list_length (GimpBrushList *brush_list)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail(GIMP_IS_BRUSH_LIST(brush_list), 0);
|
|
|
|
return (brush_list->num_brushes);
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpBrush *
|
|
|
|
gimp_brush_list_get_brush(GimpBrushList *blist, char *name)
|
|
|
|
{
|
|
|
|
GimpBrush *brushp;
|
|
|
|
GSList *list;
|
|
|
|
if (blist == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
list = GIMP_LIST(brush_list)->list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
brushp = (GimpBrush *) list->data;
|
|
|
|
|
|
|
|
if (!strcmp (brushp->name, name))
|
|
|
|
{
|
|
|
|
return brushp;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
select_brush (GimpBrush * brush)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* Make sure the active brush is swapped before we get a new one... */
|
1998-07-25 18:20:07 +08:00
|
|
|
if (stingy_memory_use && active_brush && active_brush->mask)
|
1997-11-25 06:05:25 +08:00
|
|
|
temp_buf_swap (active_brush->mask);
|
|
|
|
|
1998-07-24 16:56:18 +08:00
|
|
|
if (active_brush)
|
|
|
|
gtk_object_unref(GTK_OBJECT(active_brush));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Set the active brush */
|
|
|
|
active_brush = brush;
|
1998-07-24 16:56:18 +08:00
|
|
|
|
|
|
|
gtk_object_ref(GTK_OBJECT(active_brush));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Make sure the active brush is unswapped... */
|
|
|
|
if (stingy_memory_use)
|
|
|
|
temp_buf_unswap (brush->mask);
|
|
|
|
|
|
|
|
/* Keep up appearances in the brush dialog */
|
|
|
|
if (brush_select_dialog)
|
1998-07-20 22:05:33 +08:00
|
|
|
brush_select_select (brush_select_dialog,
|
|
|
|
gimp_brush_list_get_brush_index(brush_list, brush));
|
1998-06-06 11:49:01 +08:00
|
|
|
|
|
|
|
device_status_update (current_device);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
gave parasite undo a MISC_UNDO class for now so it compiles
* app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now
so it compiles
* app/tools_cmds.c: fix crop invoker to give correct args to
crop_image
* app/color_cmds.c: s/GRAY/GRAY_LUT/g;
* app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs,
brush_select_dialog, s/active_dialogs/brush_active_dialogs/
* app/gimage_cmds.[ch]
* app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate
function from gimage_cmds to channel_ops, export offset and duplicate
* app/gimpbrushlist.[ch]: removed PDB procs
* app/gradient.[ch]: removed PDB procs,
* app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients,
grad_active_dialogs, gradient_select_dialog
* app/gradient_select.c: removed PDB procs,
s/active_dialogs/grad_active_dialogs/
* app/patterns.[ch]: removed PDB procs
* app/pattern_select.[ch]: removed PDB procs,
s/active_dialogs/pattern_active_dialogs/
* app/procedural_db.c: removed PDB procs and supporting functions
* app/procedrual_db.h: fiddled with enums
* app/channel_cmds.[ch]
* app/drawable_cmds.[ch]
* app/parasite_cmds.[ch]: pdbgenned now, removed header files
* app/gimpparasite.c: minor cleanup
* app/internal_procs.c: use pdbgen stuff
* app/tools_cmds.c
* app/text_tool_cmds.c: updated from pdbgen
* app/brushes_cmds.c
* app/brush_select_cmds.c
* app/gradient_cmds.c
* app/gradient_select_cmds.c
* app/patterns_cmds.c
* app/pattern_select_cmds.c
* app/procedural_db_cmds.c: new pdbgen files
* app/Makefile.am: file shuffle (see above)
-Yosh
1999-04-24 04:54:02 +08:00
|
|
|
create_brush_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
if (!brush_select_dialog)
|
|
|
|
{
|
|
|
|
/* Create the dialog... */
|
1998-09-19 08:40:27 +08:00
|
|
|
brush_select_dialog = brush_select_new (NULL,NULL,0.0,0,0);
|
1999-01-11 07:20:33 +08:00
|
|
|
|
|
|
|
/* register this one only */
|
|
|
|
dialog_register(brush_select_dialog->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Popup the dialog */
|
|
|
|
if (!GTK_WIDGET_VISIBLE (brush_select_dialog->shell))
|
|
|
|
gtk_widget_show (brush_select_dialog->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise(brush_select_dialog->shell->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|