mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
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
This commit is contained in:
parent
020a39a9a5
commit
b8c19394dc
70 changed files with 5974 additions and 8485 deletions
57
ChangeLog
57
ChangeLog
|
@ -1,3 +1,60 @@
|
|||
Thu Apr 22 22:14:02 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* 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)
|
||||
|
||||
Fri Apr 23 17:11:42 1999 ape@lrdpf.spacetec.no (Asbjorn Pettersen)
|
||||
|
||||
* app/temp_buf.c:
|
||||
|
|
|
@ -56,6 +56,8 @@ gimp_SOURCES = \
|
|||
brush_header.h \
|
||||
brush_select.c \
|
||||
brush_select.h \
|
||||
brush_select_cmds.c \
|
||||
brushes_cmds.c \
|
||||
bucket_fill.c \
|
||||
bucket_fill.h \
|
||||
buildmenu.c \
|
||||
|
@ -66,11 +68,11 @@ gimp_SOURCES = \
|
|||
channel.h \
|
||||
channel_pvt.h \
|
||||
channel_cmds.c \
|
||||
channel_cmds.h \
|
||||
channels_dialog.c \
|
||||
channels_dialog.h \
|
||||
channel_ops.c \
|
||||
channel_ops.h \
|
||||
channel_ops_cmds.c \
|
||||
clone.c \
|
||||
clone.h \
|
||||
color_area.c \
|
||||
|
@ -126,7 +128,6 @@ gimp_SOURCES = \
|
|||
drawable.h \
|
||||
drawable_pvt.h \
|
||||
drawable_cmds.c \
|
||||
drawable_cmds.h \
|
||||
edit_cmds.c \
|
||||
edit_selection.c \
|
||||
edit_selection.h \
|
||||
|
@ -206,7 +207,9 @@ gimp_SOURCES = \
|
|||
gradient.c \
|
||||
gradient_header.h \
|
||||
gradient_select.c \
|
||||
gradient_select_cmds.c \
|
||||
gradient.h \
|
||||
gradient_cmds.c \
|
||||
gximage.c \
|
||||
gximage.h \
|
||||
histogramwidget.c \
|
||||
|
@ -277,7 +280,6 @@ gimp_SOURCES = \
|
|||
paintbrush.c \
|
||||
paintbrush.h \
|
||||
parasite_cmds.c \
|
||||
parasite_cmds.h \
|
||||
parasitelist.c \
|
||||
parasitelist.h \
|
||||
parasitelistF.h \
|
||||
|
@ -289,8 +291,10 @@ gimp_SOURCES = \
|
|||
pattern_header.h \
|
||||
pattern_select.c \
|
||||
pattern_select.h \
|
||||
pattern_select_cmds.c \
|
||||
patterns.c \
|
||||
patterns.h \
|
||||
patterns_cmds.c \
|
||||
pencil.c \
|
||||
pencil.h \
|
||||
perspective_tool.c \
|
||||
|
@ -309,6 +313,7 @@ gimp_SOURCES = \
|
|||
preferences_dialog.h \
|
||||
procedural_db.c \
|
||||
procedural_db.h \
|
||||
procedural_db_cmds.c \
|
||||
rect_select.c \
|
||||
rect_select.h \
|
||||
rect_selectP.h \
|
||||
|
|
|
@ -90,14 +90,8 @@ static void spacing_scale_update (GtkAdjustment *, gpointer);
|
|||
|
||||
/* local variables */
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
GSList *brush_active_dialogs = NULL;
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
@ -491,7 +485,7 @@ brush_select_free (BrushSelectP bsp)
|
|||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,bsp);
|
||||
brush_active_dialogs = g_slist_remove(brush_active_dialogs,bsp);
|
||||
|
||||
g_free (bsp);
|
||||
}
|
||||
|
@ -1296,14 +1290,14 @@ paint_options_toggle_callback (GtkWidget *widget,
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
brushes_check_dialogs ()
|
||||
brushes_check_dialogs (void)
|
||||
{
|
||||
GSList *list;
|
||||
BrushSelectP bsp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = brush_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -1315,314 +1309,10 @@ brushes_check_dialogs ()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove (active_dialogs,bsp);
|
||||
brush_active_dialogs = g_slist_remove (brush_active_dialogs,bsp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter brush_active_dialogs list*/
|
||||
brush_select_close_callback (NULL, bsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
brushes_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_brush;
|
||||
gdouble initial_opacity = 1.0;
|
||||
gint initial_spacing = 20;
|
||||
gint initial_mode = 0;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_brush = (char *) args[2].value.pdb_pointer;
|
||||
|
||||
/* If null just use the active brush */
|
||||
if (initial_brush && strlen (initial_brush))
|
||||
{
|
||||
initial_opacity = args[3].value.pdb_float;
|
||||
initial_spacing = args[4].value.pdb_int;
|
||||
initial_mode = args[5].value.pdb_int;
|
||||
}
|
||||
|
||||
/* Check the proc exists */
|
||||
if (!success || (prec = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_popup_proc, success);
|
||||
}
|
||||
|
||||
/*create_brush_dialog();*/
|
||||
if (initial_brush && strlen (initial_brush))
|
||||
newdialog = brush_select_new (title,
|
||||
initial_brush,
|
||||
initial_opacity,
|
||||
initial_spacing,
|
||||
initial_mode);
|
||||
else
|
||||
newdialog = brush_select_new(title,NULL,0.0,0,0);
|
||||
|
||||
/* Add to list of proc to run when brush changes */
|
||||
/* change_callbacks = g_list_append(change_callbacks,g_strdup(name));*/
|
||||
newdialog->callback_name = g_strdup (name);
|
||||
|
||||
/* Add to active brush dialogs list */
|
||||
active_dialogs = g_slist_append (active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&brushes_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"brush_callback",
|
||||
"the callback PDB proc to call when brush selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial brush",
|
||||
"The name of the brush to set as the first selected",
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"initial opacity",
|
||||
"The initial opacity of the brush",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial paint mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_popup_proc =
|
||||
{
|
||||
"gimp_brushes_popup",
|
||||
"Invokes the Gimp brush selection",
|
||||
"This procedure popups the brush selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof (brushes_popup_in_args) / sizeof (brushes_popup_in_args[0]),
|
||||
brushes_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_popup_invoker } },
|
||||
};
|
||||
|
||||
static BrushSelectP
|
||||
brush_get_brushselect (gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
BrushSelectP bsp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
bsp = (BrushSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (strcmp (name, bsp->callback_name) == 0)
|
||||
{
|
||||
return bsp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
brush_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP bsp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_close_popup_proc, success);
|
||||
}
|
||||
|
||||
bsp = brush_get_brushselect (name);
|
||||
|
||||
if(bsp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,bsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (bsp->shell))
|
||||
gtk_widget_hide (bsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if (bsp != brush_select_dialog)
|
||||
{
|
||||
gtk_widget_destroy (bsp->shell);
|
||||
brush_select_free (bsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brush_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback_PDB_entry_name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_close_popup_proc =
|
||||
{
|
||||
"gimp_brushes_close_popup",
|
||||
"Popdown the Gimp brush selection",
|
||||
"This procedure closes an opened brush selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof (brush_close_popup_in_args) / sizeof (brush_close_popup_in_args[0]),
|
||||
brush_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brush_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brush_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * brush_name;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP bsp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
brush_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup (pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_set_popup_proc, success);
|
||||
}
|
||||
|
||||
bsp = brush_get_brushselect (pdbname);
|
||||
|
||||
|
||||
if(bsp)
|
||||
{
|
||||
GimpBrushP active = gimp_brush_list_get_brush (brush_list,brush_name);
|
||||
|
||||
if(active)
|
||||
{
|
||||
/* Must alter the wigdets on screen as well */
|
||||
|
||||
bsp->brush = active;
|
||||
brush_select_select (bsp, gimp_brush_list_get_brush_index (brush_list, active));
|
||||
|
||||
bsp->opacity_value = args[2].value.pdb_float;
|
||||
bsp->spacing_value = args[3].value.pdb_int;
|
||||
if(args[4].value.pdb_int >= 0 && args[4].value.pdb_int <= VALUE_MODE)
|
||||
bsp->paint_mode = args[4].value.pdb_int;
|
||||
|
||||
bsp->spacing_data->value = bsp->spacing_value;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data), "value_changed");
|
||||
|
||||
bsp->opacity_data->value = bsp->opacity_value * 100.0;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->opacity_data), "value_changed");
|
||||
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(bsp->option_menu),bsp->paint_mode);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_set_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brush_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback_PDB_entry_name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"brushname",
|
||||
"The name of the brush to set as selected",
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The initial opacity of the brush",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial paint mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_popup_proc =
|
||||
{
|
||||
"gimp_brushes_set_popup",
|
||||
"Sets the current brush selection in a popup",
|
||||
"Sets the current brush selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(brush_set_popup_in_args) / sizeof(brush_set_popup_in_args[0]),
|
||||
brush_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brush_set_popup_invoker } },
|
||||
};
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gimpbrush.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef struct _BrushSelect _BrushSelect, *BrushSelectP;
|
||||
|
||||
|
@ -94,10 +93,10 @@ void brushes_check_dialogs (void);
|
|||
void brush_select_show_paint_options (BrushSelectP bsp,
|
||||
gboolean show);
|
||||
|
||||
/* PDB entry */
|
||||
extern ProcRecord brushes_popup_proc;
|
||||
extern ProcRecord brushes_close_popup_proc;
|
||||
extern ProcRecord brushes_set_popup_proc;
|
||||
extern ProcRecord brushes_get_brush_data_proc;
|
||||
/* List of active dialogs */
|
||||
extern GSList *brush_active_dialogs;
|
||||
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
|
||||
#endif /* __BRUSH_SELECT_H__ */
|
||||
|
|
334
app/brush_select_cmds.c
Normal file
334
app/brush_select_cmds.c
Normal file
|
@ -0,0 +1,334 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "brush_select.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "paint_funcs.h"
|
||||
|
||||
static ProcRecord brushes_popup_proc;
|
||||
static ProcRecord brushes_close_popup_proc;
|
||||
static ProcRecord brushes_set_popup_proc;
|
||||
|
||||
void
|
||||
register_brush_select_procs (void)
|
||||
{
|
||||
procedural_db_register (&brushes_popup_proc);
|
||||
procedural_db_register (&brushes_close_popup_proc);
|
||||
procedural_db_register (&brushes_set_popup_proc);
|
||||
}
|
||||
|
||||
static BrushSelectP
|
||||
brush_get_brushselect (gchar *name)
|
||||
{
|
||||
GSList *list = brush_active_dialogs;
|
||||
BrushSelectP bsp;
|
||||
|
||||
while (list)
|
||||
{
|
||||
bsp = (BrushSelectP) list->data;
|
||||
|
||||
if (!strcmp (name, bsp->callback_name))
|
||||
return bsp;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
brushes_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
gchar *title;
|
||||
gchar *brush;
|
||||
gdouble opacity;
|
||||
gint32 spacing;
|
||||
gint32 paint_mode;
|
||||
ProcRecord *prec;
|
||||
BrushSelectP newdialog;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
title = (gchar *) args[1].value.pdb_pointer;
|
||||
if (title == NULL)
|
||||
success = FALSE;
|
||||
|
||||
brush = (gchar *) args[2].value.pdb_pointer;
|
||||
|
||||
opacity = args[3].value.pdb_float;
|
||||
|
||||
spacing = args[4].value.pdb_int;
|
||||
|
||||
paint_mode = args[5].value.pdb_int;
|
||||
if (paint_mode < NORMAL_MODE || paint_mode > DIVIDE_MODE)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)))
|
||||
{
|
||||
if (brush && strlen (brush))
|
||||
newdialog = brush_select_new (title, brush, opacity, spacing,
|
||||
paint_mode);
|
||||
else
|
||||
newdialog = brush_select_new (title, NULL, 0.0, 0, 0);
|
||||
|
||||
/* Add to list of proc to run when brush changes */
|
||||
/* change_callbacks = g_list_append (change_callbacks, g_strdup (name)); */
|
||||
newdialog->callback_name = g_strdup (name);
|
||||
|
||||
/* Add to active brush dialogs list */
|
||||
brush_active_dialogs = g_slist_append (brush_active_dialogs, newdialog);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"brush_callback",
|
||||
"The callback PDB proc to call when brush selection is made"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"popup_title",
|
||||
"Title to give the brush popup window"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"initial_brush",
|
||||
"The name of the brush to set as the first selected"
|
||||
},
|
||||
{
|
||||
PDB_FLOAT,
|
||||
"opacity",
|
||||
"The initial opacity of the brush"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"paint_mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5), DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_popup_proc =
|
||||
{
|
||||
"gimp_brushes_popup",
|
||||
"Invokes the Gimp brush selection.",
|
||||
"This procedure popups the brush selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
6,
|
||||
brushes_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
ProcRecord *prec;
|
||||
BrushSelectP bsp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
brush_active_dialogs = g_slist_remove (brush_active_dialogs, bsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (bsp->shell))
|
||||
gtk_widget_hide (bsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if (bsp != brush_select_dialog)
|
||||
{
|
||||
gtk_widget_destroy (bsp->shell);
|
||||
brush_select_free (bsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_close_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_close_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"brush_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_close_popup_proc =
|
||||
{
|
||||
"gimp_brushes_close_popup",
|
||||
"Popdown the Gimp brush selection.",
|
||||
"This procedure closes an opened brush selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_close_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_close_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
gchar *brush_name;
|
||||
gdouble opacity;
|
||||
gint32 spacing;
|
||||
gint32 paint_mode;
|
||||
ProcRecord *prec;
|
||||
BrushSelectP bsp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
brush_name = (gchar *) args[1].value.pdb_pointer;
|
||||
if (brush_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
opacity = args[2].value.pdb_float;
|
||||
|
||||
spacing = args[3].value.pdb_int;
|
||||
|
||||
paint_mode = args[4].value.pdb_int;
|
||||
if (paint_mode < NORMAL_MODE || paint_mode > DIVIDE_MODE)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(bsp = brush_get_brushselect (name)))
|
||||
{
|
||||
GimpBrushP active = gimp_brush_list_get_brush (brush_list, brush_name);
|
||||
|
||||
if (active)
|
||||
{
|
||||
/* Must alter the wigdets on screen as well */
|
||||
|
||||
bsp->brush = active;
|
||||
brush_select_select (bsp, gimp_brush_list_get_brush_index (brush_list, active));
|
||||
|
||||
bsp->opacity_value = opacity;
|
||||
bsp->spacing_value = spacing;
|
||||
bsp->paint_mode = paint_mode;
|
||||
|
||||
bsp->spacing_data->value = bsp->spacing_value;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data),
|
||||
"value_changed");
|
||||
|
||||
bsp->opacity_data->value = bsp->opacity_value * 100.0;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->opacity_data),
|
||||
"value_changed");
|
||||
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (bsp->option_menu), bsp->paint_mode);
|
||||
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_set_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_set_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"brush_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"brush_name",
|
||||
"The name of the brush to set as selected"
|
||||
},
|
||||
{
|
||||
PDB_FLOAT,
|
||||
"opacity",
|
||||
"The initial opacity of the brush"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"paint_mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5), DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_set_popup_proc =
|
||||
{
|
||||
"gimp_brushes_set_popup",
|
||||
"Sets the current brush selection in a popup.",
|
||||
"Sets the current brush selection in a popup.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
5,
|
||||
brushes_set_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_set_popup_invoker } }
|
||||
};
|
621
app/brushes_cmds.c
Normal file
621
app/brushes_cmds.c
Normal file
|
@ -0,0 +1,621 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlistP.h"
|
||||
#include "gimplist.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "paint_options.h"
|
||||
|
||||
static ProcRecord brushes_refresh_proc;
|
||||
static ProcRecord brushes_get_brush_proc;
|
||||
static ProcRecord brushes_set_brush_proc;
|
||||
static ProcRecord brushes_get_opacity_proc;
|
||||
static ProcRecord brushes_set_opacity_proc;
|
||||
static ProcRecord brushes_get_spacing_proc;
|
||||
static ProcRecord brushes_set_spacing_proc;
|
||||
static ProcRecord brushes_get_paint_mode_proc;
|
||||
static ProcRecord brushes_set_paint_mode_proc;
|
||||
static ProcRecord brushes_list_proc;
|
||||
static ProcRecord brushes_get_brush_data_proc;
|
||||
|
||||
void
|
||||
register_brushes_procs (void)
|
||||
{
|
||||
procedural_db_register (&brushes_refresh_proc);
|
||||
procedural_db_register (&brushes_get_brush_proc);
|
||||
procedural_db_register (&brushes_set_brush_proc);
|
||||
procedural_db_register (&brushes_get_opacity_proc);
|
||||
procedural_db_register (&brushes_set_opacity_proc);
|
||||
procedural_db_register (&brushes_get_spacing_proc);
|
||||
procedural_db_register (&brushes_set_spacing_proc);
|
||||
procedural_db_register (&brushes_get_paint_mode_proc);
|
||||
procedural_db_register (&brushes_set_paint_mode_proc);
|
||||
procedural_db_register (&brushes_list_proc);
|
||||
procedural_db_register (&brushes_get_brush_data_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
brushes_refresh_invoker (Argument *args)
|
||||
{
|
||||
/* FIXME: I've hardcoded success to be 1, because brushes_init() is a
|
||||
* void function right now. It'd be nice if it returned a value at
|
||||
* some future date, so we could tell if things blew up when reparsing
|
||||
* the list (for whatever reason).
|
||||
* - Seth "Yes, this is a kludge" Burgess
|
||||
* <sjburges@gimp.org>
|
||||
*/
|
||||
|
||||
brushes_init (FALSE);
|
||||
|
||||
return procedural_db_return_args (&brushes_refresh_proc, TRUE);
|
||||
}
|
||||
|
||||
static ProcRecord brushes_refresh_proc =
|
||||
{
|
||||
"gimp_brushes_refresh",
|
||||
"Refresh current brushes.",
|
||||
"This procedure retrieves all brushes currently in the user's brush path and updates the brush dialog accordingly.",
|
||||
"Seth Burgess",
|
||||
"Seth Burgess",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_refresh_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_get_brush_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GimpBrush *brushp;
|
||||
|
||||
success = (brushp = get_active_brush ()) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_brush_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (brushp->name);
|
||||
return_args[2].value.pdb_int = brushp->mask->width;
|
||||
return_args[3].value.pdb_int = brushp->mask->height;
|
||||
return_args[4].value.pdb_int = brushp->spacing;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_get_brush_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The brush name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The brush width"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"height",
|
||||
"The brush height"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The brush spacing: 0 <= spacing <= 1000"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_get_brush_proc =
|
||||
{
|
||||
"gimp_brushes_get_brush",
|
||||
"Retrieve information about the currently active brush mask.",
|
||||
"This procedure retrieves information about the currently active brush mask. This includes the brush name, the width and height, and the brush spacing paramter. All paint operations and stroke operations use this mask to control the application of paint to the image.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
4,
|
||||
brushes_get_brush_outargs,
|
||||
{ { brushes_get_brush_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_set_brush_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
GimpBrush *brushp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
brushp = gimp_brush_list_get_brush (brush_list, name);
|
||||
if (brushp)
|
||||
select_brush (brushp);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_set_brush_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_set_brush_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The brush name"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_set_brush_proc =
|
||||
{
|
||||
"gimp_brushes_set_brush",
|
||||
"Set the specified brush as the active brush.",
|
||||
"This procedure allows the active brush mask to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed brushes. If there is no matching brush found, this procedure will return an error. Otherwise, the specified brush becomes active and will be used in all subsequent paint operations.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_set_brush_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_set_brush_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_get_opacity_invoker (Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_opacity_proc, TRUE);
|
||||
return_args[1].value.pdb_float = paint_options_get_opacity () * 100.0;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_get_opacity_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_FLOAT,
|
||||
"opacity",
|
||||
"The brush opacity: 0 <= opacity <= 100"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_get_opacity_proc =
|
||||
{
|
||||
"gimp_brushes_get_opacity",
|
||||
"Get the brush opacity.",
|
||||
"This procedure returns the opacity setting for brushes. This value is set globally and will remain the same even if the brush mask is changed. The return value is a floating point number between 0 and 100.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
brushes_get_opacity_outargs,
|
||||
{ { brushes_get_opacity_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_set_opacity_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gdouble opacity;
|
||||
|
||||
opacity = args[0].value.pdb_float;
|
||||
if (opacity < 0.0 || opacity > 100.0)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
paint_options_set_opacity (opacity / 100.0);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_opacity_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_set_opacity_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_FLOAT,
|
||||
"opacity",
|
||||
"The brush opacity: 0 <= opacity <= 100"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_set_opacity_proc =
|
||||
{
|
||||
"gimp_brushes_set_opacity",
|
||||
"Set the brush opacity.",
|
||||
"This procedure modifies the opacity setting for brushes. This value is set globally and will remain the same even if the brush mask is changed. The value should be a floating point number between 0 and 100.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_set_opacity_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_set_opacity_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_get_spacing_invoker (Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_spacing_proc, TRUE);
|
||||
return_args[1].value.pdb_int = gimp_brush_get_spacing (get_active_brush ());
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_get_spacing_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The brush spacing: 0 <= spacing <= 1000"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_get_spacing_proc =
|
||||
{
|
||||
"gimp_brushes_get_spacing",
|
||||
"Get the brush spacing.",
|
||||
"This procedure returns the spacing setting for brushes. This value is set per brush and will change if a different brush is selected. The return value is an integer between 0 and 1000 which represents percentage of the maximum of the width and height of the mask.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
brushes_get_spacing_outargs,
|
||||
{ { brushes_get_spacing_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_set_spacing_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gint32 spacing;
|
||||
|
||||
spacing = args[0].value.pdb_int;
|
||||
if (spacing < 0 || spacing > 1000)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_brush_set_spacing (get_active_brush(), spacing);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_spacing_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_set_spacing_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The brush spacing: 0 <= spacing <= 1000"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_set_spacing_proc =
|
||||
{
|
||||
"gimp_brushes_set_spacing",
|
||||
"Set the brush spacing.",
|
||||
"This procedure modifies the spacing setting for the current brush. This value is set on a per-brush basis and will change if a different brush mask is selected. The value should be a integer between 0 and 1000.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_set_spacing_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_set_spacing_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_get_paint_mode_invoker (Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_paint_mode_proc, TRUE);
|
||||
return_args[1].value.pdb_int = paint_options_get_paint_mode ();
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_get_paint_mode_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"paint_mode",
|
||||
"The paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5), DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_get_paint_mode_proc =
|
||||
{
|
||||
"gimp_brushes_get_paint_mode",
|
||||
"Get the brush paint mode.",
|
||||
"This procedure returns the paint-mode setting for brushes. This value is set globally and will not change if a different brush is selected. The return value is an integer which corresponds to the values listed in the argument description.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
brushes_get_paint_mode_outargs,
|
||||
{ { brushes_get_paint_mode_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_set_paint_mode_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gint32 paint_mode;
|
||||
|
||||
paint_mode = args[0].value.pdb_int;
|
||||
if (paint_mode < NORMAL_MODE || paint_mode > DIVIDE_MODE)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
paint_options_set_paint_mode (paint_mode);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_paint_mode_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg brushes_set_paint_mode_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"paint_mode",
|
||||
"The paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5), DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_set_paint_mode_proc =
|
||||
{
|
||||
"gimp_brushes_set_paint_mode",
|
||||
"Set the brush paint mode.",
|
||||
"This procedure modifies the paint_mode setting for the current brush. This value is set globally and will not change if a different brush mask is selected.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_set_paint_mode_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { brushes_set_paint_mode_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_list_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar **brushes;
|
||||
GSList *list = NULL;
|
||||
int i = 0;
|
||||
|
||||
brushes = g_new (char *, brush_list->num_brushes);
|
||||
|
||||
success = (list = GIMP_LIST (brush_list)->list) != NULL;
|
||||
|
||||
while (list)
|
||||
{
|
||||
brushes[i++] = g_strdup (((GimpBrush *) list->data)->name);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = brush_list->num_brushes;
|
||||
return_args[2].value.pdb_pointer = brushes;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_list_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_brushes",
|
||||
"The number of brushes in the brush list"
|
||||
},
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"brush_list",
|
||||
"The list of brush names"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_list_proc =
|
||||
{
|
||||
"gimp_brushes_list",
|
||||
"Retrieve a complete listing of the available brushes.",
|
||||
"This procedure returns a complete listing of available GIMP brushes. Each name returned can be used as input to the 'gimp_brushes_set_brush'.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
2,
|
||||
brushes_list_outargs,
|
||||
{ { brushes_list_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brushes_get_brush_data_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *name;
|
||||
gint32 length = 0;
|
||||
gint8 *mask_data = NULL;
|
||||
GimpBrushP brushp = NULL;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list = GIMP_LIST (brush_list)->list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
brushp = (GimpBrushP) list->data;
|
||||
|
||||
if (!strcmp (brushp->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
success = (brushp = get_active_brush ()) != NULL;
|
||||
|
||||
if (success)
|
||||
{
|
||||
length = brushp->mask->height * brushp->mask->width;
|
||||
mask_data = g_new (gint8, length);
|
||||
g_memmove (mask_data, temp_buf_data (brushp->mask), length);
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_brush_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (brushp->name);
|
||||
return_args[2].value.pdb_float = 1.0;
|
||||
return_args[3].value.pdb_int = brushp->spacing;
|
||||
return_args[4].value.pdb_int = 0;
|
||||
return_args[5].value.pdb_int = brushp->mask->width;
|
||||
return_args[6].value.pdb_int = brushp->mask->height;
|
||||
return_args[7].value.pdb_int = length;
|
||||
return_args[8].value.pdb_pointer = mask_data;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg brushes_get_brush_data_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"the brush name (\"\" means current active pattern)"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg brushes_get_brush_data_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The brush name"
|
||||
},
|
||||
{
|
||||
PDB_FLOAT,
|
||||
"opacity",
|
||||
"The brush opacity: 0 <= opacity <= 100"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"spacing",
|
||||
"The brush spacing: 0 <= spacing <= 1000"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"paint_mode",
|
||||
"The paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5), DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The brush width"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"height",
|
||||
"The brush height"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"length",
|
||||
"Length of brush mask data"
|
||||
},
|
||||
{
|
||||
PDB_INT8ARRAY,
|
||||
"mask_data",
|
||||
"The brush mask data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord brushes_get_brush_data_proc =
|
||||
{
|
||||
"gimp_brushes_get_brush_data",
|
||||
"Retrieve information about the currently active brush (including data).",
|
||||
"This procedure retrieves information about the currently active brush. This includes the brush name, and the brush extents (width and height). It also returns the brush data.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
brushes_get_brush_data_inargs,
|
||||
8,
|
||||
brushes_get_brush_data_outargs,
|
||||
{ { brushes_get_brush_data_invoker } }
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -1,38 +0,0 @@
|
|||
/* 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __CHANNEL_CMDS_H__
|
||||
#define __CHANNEL_CMDS_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
extern ProcRecord channel_new_proc;
|
||||
extern ProcRecord channel_copy_proc;
|
||||
extern ProcRecord channel_delete_proc;
|
||||
extern ProcRecord channel_get_name_proc;
|
||||
extern ProcRecord channel_set_name_proc;
|
||||
extern ProcRecord channel_get_visible_proc;
|
||||
extern ProcRecord channel_set_visible_proc;
|
||||
extern ProcRecord channel_get_show_masked_proc;
|
||||
extern ProcRecord channel_set_show_masked_proc;
|
||||
extern ProcRecord channel_get_opacity_proc;
|
||||
extern ProcRecord channel_set_opacity_proc;
|
||||
extern ProcRecord channel_get_color_proc;
|
||||
extern ProcRecord channel_set_color_proc;
|
||||
extern ProcRecord channel_get_tattoo_proc;
|
||||
|
||||
#endif /* __CHANNEL_CMDS_H__ */
|
|
@ -21,6 +21,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "channel_ops.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "floating_sel.h"
|
||||
#include "general.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "channel_pvt.h"
|
||||
#include "layer_pvt.h"
|
||||
|
||||
#define ENTRY_WIDTH 60
|
||||
|
||||
|
@ -49,13 +51,6 @@ typedef struct
|
|||
} OffsetDialog;
|
||||
|
||||
/* Local procedures */
|
||||
static void offset (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
int offset_x,
|
||||
int offset_y);
|
||||
|
||||
static void offset_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void offset_cancel_callback (GtkWidget *widget,
|
||||
|
@ -72,8 +67,6 @@ static void offset_wraparound_update (GtkWidget *widget,
|
|||
static void offset_halfheight_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static Argument * channel_ops_offset_invoker (Argument *args);
|
||||
|
||||
|
||||
void
|
||||
channel_ops_offset (GimpImage* gimage)
|
||||
|
@ -212,8 +205,8 @@ channel_ops_offset (GimpImage* gimage)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
offset (GImage *gimage,
|
||||
void
|
||||
offset (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
|
@ -548,103 +541,177 @@ offset_halfheight_update (GtkWidget *widget,
|
|||
gtk_entry_set_text (GTK_ENTRY (off_d->off_y_entry), buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/* The offset procedure definition */
|
||||
ProcArg channel_ops_offset_args[] =
|
||||
GimpImage *
|
||||
duplicate (GimpImage *gimage)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable to offset"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: { OFFSET_BACKGROUND (0), OFFSET_TRANSPARENT (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
channel_ops_offset_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_offset_invoker } },
|
||||
};
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int wrap_around;
|
||||
int fill_type;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
if (success)
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
wrap_around = (args[1].value.pdb_int) ? TRUE : FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offset_x = args[3].value.pdb_int;
|
||||
offset_y = args[4].value.pdb_int;
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
if (success)
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
void
|
||||
channel_ops_duplicate (GimpImage *gimage)
|
||||
{
|
||||
gdisplay_new (duplicate (gimage), 0x0101);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
|
||||
typedef enum {
|
||||
OFFSET_BACKGROUND,
|
||||
|
@ -27,9 +28,10 @@ typedef enum {
|
|||
} ChannelOffsetType;
|
||||
|
||||
/* channel_ops functions */
|
||||
void channel_ops_offset (GimpImage*);
|
||||
void channel_ops_offset (GimpImage *);
|
||||
void channel_ops_duplicate (GimpImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord channel_ops_offset_proc;
|
||||
void offset (GimpImage *, GimpDrawable *, gboolean, int, int, int);
|
||||
GimpImage * duplicate (GimpImage *);
|
||||
|
||||
#endif /* __CHANNEL_OPS_H__ */
|
||||
|
|
171
app/channel_ops_cmds.c
Normal file
171
app/channel_ops_cmds.c
Normal file
|
@ -0,0 +1,171 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "channel_ops.h"
|
||||
#include "drawable.h"
|
||||
#include "gimage.h"
|
||||
|
||||
static ProcRecord channel_ops_offset_proc;
|
||||
static ProcRecord channel_ops_duplicate_proc;
|
||||
|
||||
void
|
||||
register_channel_ops_procs (void)
|
||||
{
|
||||
procedural_db_register (&channel_ops_offset_proc);
|
||||
procedural_db_register (&channel_ops_duplicate_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
gboolean wrap_around;
|
||||
gint32 fill_type;
|
||||
gint32 offset_x;
|
||||
gint32 offset_y;
|
||||
GimpImage *gimage;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
|
||||
wrap_around = args[1].value.pdb_int ? TRUE : FALSE;
|
||||
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
|
||||
offset_x = args[3].value.pdb_int;
|
||||
|
||||
offset_y = args[4].value.pdb_int;
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimage = drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg channel_ops_offset_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable to offset"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: OFFSET_BACKGROUND (0) or OFFSET_TRANSPARENT (1)"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
5,
|
||||
channel_ops_offset_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { channel_ops_offset_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
channel_ops_duplicate_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GimpImage *gimage;
|
||||
GimpImage *new_gimage = NULL;
|
||||
|
||||
gimage = pdb_id_to_image (args[0].value.pdb_int);
|
||||
if (gimage == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = (new_gimage = duplicate (gimage)) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&channel_ops_duplicate_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = pdb_image_to_id (new_gimage);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg channel_ops_duplicate_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_IMAGE,
|
||||
"image",
|
||||
"The image"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg channel_ops_duplicate_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_IMAGE,
|
||||
"new_image",
|
||||
"The new, duplicated image"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord channel_ops_duplicate_proc =
|
||||
{
|
||||
"gimp_channel_ops_duplicate",
|
||||
"Duplicate the specified image",
|
||||
"This procedure duplicates the specified image, copying all layers, channels, and image information.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
channel_ops_duplicate_inargs,
|
||||
1,
|
||||
channel_ops_duplicate_outargs,
|
||||
{ { channel_ops_duplicate_invoker } }
|
||||
};
|
|
@ -208,7 +208,7 @@ levels_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -562,7 +562,7 @@ curves_spline_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) || (num_points & 1) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -681,7 +681,7 @@ curves_explicit_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) || (num_bytes != 256) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -922,7 +922,7 @@ histogram_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "app_procs.h"
|
||||
#include "parasitelist.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -101,9 +102,8 @@ static void save_func(char *key, Parasite *p, FILE *fp)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_parasiterc_save()
|
||||
gimp_parasiterc_save(void)
|
||||
{
|
||||
int i;
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "channel_ops.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "floating_sel.h"
|
||||
#include "general.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "channel_pvt.h"
|
||||
#include "layer_pvt.h"
|
||||
|
||||
#define ENTRY_WIDTH 60
|
||||
|
||||
|
@ -49,13 +51,6 @@ typedef struct
|
|||
} OffsetDialog;
|
||||
|
||||
/* Local procedures */
|
||||
static void offset (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
int offset_x,
|
||||
int offset_y);
|
||||
|
||||
static void offset_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void offset_cancel_callback (GtkWidget *widget,
|
||||
|
@ -72,8 +67,6 @@ static void offset_wraparound_update (GtkWidget *widget,
|
|||
static void offset_halfheight_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static Argument * channel_ops_offset_invoker (Argument *args);
|
||||
|
||||
|
||||
void
|
||||
channel_ops_offset (GimpImage* gimage)
|
||||
|
@ -212,8 +205,8 @@ channel_ops_offset (GimpImage* gimage)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
offset (GImage *gimage,
|
||||
void
|
||||
offset (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
|
@ -548,103 +541,177 @@ offset_halfheight_update (GtkWidget *widget,
|
|||
gtk_entry_set_text (GTK_ENTRY (off_d->off_y_entry), buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/* The offset procedure definition */
|
||||
ProcArg channel_ops_offset_args[] =
|
||||
GimpImage *
|
||||
duplicate (GimpImage *gimage)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable to offset"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: { OFFSET_BACKGROUND (0), OFFSET_TRANSPARENT (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
channel_ops_offset_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_offset_invoker } },
|
||||
};
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int wrap_around;
|
||||
int fill_type;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
if (success)
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
wrap_around = (args[1].value.pdb_int) ? TRUE : FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offset_x = args[3].value.pdb_int;
|
||||
offset_y = args[4].value.pdb_int;
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
if (success)
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
void
|
||||
channel_ops_duplicate (GimpImage *gimage)
|
||||
{
|
||||
gdisplay_new (duplicate (gimage), 0x0101);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
|
||||
typedef enum {
|
||||
OFFSET_BACKGROUND,
|
||||
|
@ -27,9 +28,10 @@ typedef enum {
|
|||
} ChannelOffsetType;
|
||||
|
||||
/* channel_ops functions */
|
||||
void channel_ops_offset (GimpImage*);
|
||||
void channel_ops_offset (GimpImage *);
|
||||
void channel_ops_duplicate (GimpImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord channel_ops_offset_proc;
|
||||
void offset (GimpImage *, GimpDrawable *, gboolean, int, int, int);
|
||||
GimpImage * duplicate (GimpImage *);
|
||||
|
||||
#endif /* __CHANNEL_OPS_H__ */
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "parasitelist.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -448,7 +449,7 @@ gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite)
|
|||
parasite differs from the current one and we arn't undoable */
|
||||
if (parasite_is_undoable(parasite))
|
||||
{
|
||||
undo_push_group_start(drawable->gimage); /* do a group in case we have
|
||||
undo_push_group_start(drawable->gimage, MISC_UNDO); /* do a group in case we have
|
||||
attach_parrent set */
|
||||
undo_push_drawable_parasite (drawable->gimage, drawable, parasite);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "channel_ops.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "floating_sel.h"
|
||||
#include "general.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "channel_pvt.h"
|
||||
#include "layer_pvt.h"
|
||||
|
||||
#define ENTRY_WIDTH 60
|
||||
|
||||
|
@ -49,13 +51,6 @@ typedef struct
|
|||
} OffsetDialog;
|
||||
|
||||
/* Local procedures */
|
||||
static void offset (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
int offset_x,
|
||||
int offset_y);
|
||||
|
||||
static void offset_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void offset_cancel_callback (GtkWidget *widget,
|
||||
|
@ -72,8 +67,6 @@ static void offset_wraparound_update (GtkWidget *widget,
|
|||
static void offset_halfheight_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static Argument * channel_ops_offset_invoker (Argument *args);
|
||||
|
||||
|
||||
void
|
||||
channel_ops_offset (GimpImage* gimage)
|
||||
|
@ -212,8 +205,8 @@ channel_ops_offset (GimpImage* gimage)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
offset (GImage *gimage,
|
||||
void
|
||||
offset (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
|
@ -548,103 +541,177 @@ offset_halfheight_update (GtkWidget *widget,
|
|||
gtk_entry_set_text (GTK_ENTRY (off_d->off_y_entry), buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/* The offset procedure definition */
|
||||
ProcArg channel_ops_offset_args[] =
|
||||
GimpImage *
|
||||
duplicate (GimpImage *gimage)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable to offset"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: { OFFSET_BACKGROUND (0), OFFSET_TRANSPARENT (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
channel_ops_offset_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_offset_invoker } },
|
||||
};
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int wrap_around;
|
||||
int fill_type;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
if (success)
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
wrap_around = (args[1].value.pdb_int) ? TRUE : FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offset_x = args[3].value.pdb_int;
|
||||
offset_y = args[4].value.pdb_int;
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
if (success)
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
void
|
||||
channel_ops_duplicate (GimpImage *gimage)
|
||||
{
|
||||
gdisplay_new (duplicate (gimage), 0x0101);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
|
||||
typedef enum {
|
||||
OFFSET_BACKGROUND,
|
||||
|
@ -27,9 +28,10 @@ typedef enum {
|
|||
} ChannelOffsetType;
|
||||
|
||||
/* channel_ops functions */
|
||||
void channel_ops_offset (GimpImage*);
|
||||
void channel_ops_offset (GimpImage *);
|
||||
void channel_ops_duplicate (GimpImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord channel_ops_offset_proc;
|
||||
void offset (GimpImage *, GimpDrawable *, gboolean, int, int, int);
|
||||
GimpImage * duplicate (GimpImage *);
|
||||
|
||||
#endif /* __CHANNEL_OPS_H__ */
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "layer.h"
|
||||
#include "paint_core.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "parasitelist.h"
|
||||
#include "tools.h"
|
||||
#include "transform_core.h"
|
||||
#include "undo.h"
|
||||
|
@ -2253,7 +2254,6 @@ undo_pop_parasite (GImage *gimage,
|
|||
{
|
||||
ParasiteUndo *data;
|
||||
Parasite *tmp;
|
||||
int tmp_ref;
|
||||
|
||||
data = data_ptr;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "app_procs.h"
|
||||
#include "parasitelist.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -101,9 +102,8 @@ static void save_func(char *key, Parasite *p, FILE *fp)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_parasiterc_save()
|
||||
gimp_parasiterc_save(void)
|
||||
{
|
||||
int i;
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
|
||||
|
|
1659
app/drawable_cmds.c
1659
app/drawable_cmds.c
File diff suppressed because it is too large
Load diff
|
@ -1,49 +0,0 @@
|
|||
/* 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __DRAWABLE_CMDS_H__
|
||||
#define __DRAWABLE_CMDS_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
extern ProcRecord drawable_merge_shadow_proc;
|
||||
extern ProcRecord drawable_fill_proc;
|
||||
extern ProcRecord drawable_update_proc;
|
||||
extern ProcRecord drawable_mask_bounds_proc;
|
||||
extern ProcRecord drawable_gimage_proc;
|
||||
extern ProcRecord drawable_type_proc;
|
||||
extern ProcRecord drawable_has_alpha_proc;
|
||||
extern ProcRecord drawable_type_with_alpha_proc;
|
||||
extern ProcRecord drawable_color_proc;
|
||||
extern ProcRecord drawable_gray_proc;
|
||||
extern ProcRecord drawable_indexed_proc;
|
||||
extern ProcRecord drawable_bytes_proc;
|
||||
extern ProcRecord drawable_width_proc;
|
||||
extern ProcRecord drawable_height_proc;
|
||||
extern ProcRecord drawable_offsets_proc;
|
||||
extern ProcRecord drawable_layer_proc;
|
||||
extern ProcRecord drawable_layer_mask_proc;
|
||||
extern ProcRecord drawable_channel_proc;
|
||||
extern ProcRecord drawable_set_pixel_proc;
|
||||
extern ProcRecord drawable_get_pixel_proc;
|
||||
extern ProcRecord gimp_drawable_find_parasite_proc;
|
||||
extern ProcRecord gimp_drawable_parasite_list_proc;
|
||||
extern ProcRecord gimp_drawable_attach_parasite_proc;
|
||||
extern ProcRecord gimp_drawable_detach_parasite_proc;
|
||||
extern ProcRecord drawable_set_image_proc;
|
||||
|
||||
#endif /* __DRAWABLE_CMDS_H__ */
|
|
@ -56,9 +56,6 @@ static Argument *gimp_image_detach_parasite_invoker (Argument *);
|
|||
static Argument *gimp_image_get_layer_by_tattoo_invoker (Argument *);
|
||||
static Argument *gimp_image_get_channel_by_tattoo_invoker (Argument *);
|
||||
|
||||
static GImage * duplicate (GImage *gimage);
|
||||
|
||||
static Argument * channel_ops_duplicate_invoker (Argument *args);
|
||||
/************************/
|
||||
/* GIMAGE_LIST_IMAGES */
|
||||
|
||||
|
@ -3848,258 +3845,6 @@ ProcRecord gimage_floating_sel_attached_to_proc =
|
|||
};
|
||||
|
||||
|
||||
static GImage *
|
||||
duplicate (GImage *gimage)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
GImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
/* The duplicate procedure definition */
|
||||
ProcArg channel_ops_duplicate_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg channel_ops_duplicate_out_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"new_image",
|
||||
"the new, duplicated image"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_duplicate_proc =
|
||||
{
|
||||
"gimp_channel_ops_duplicate",
|
||||
"Duplicate the specified image",
|
||||
"This procedure duplicates the specified image, copying all layers, channels, and image information.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
channel_ops_duplicate_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
channel_ops_duplicate_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_duplicate_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_duplicate_invoker (Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage, *new_gimage;
|
||||
|
||||
new_gimage = NULL;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
if (success)
|
||||
success = ((new_gimage = duplicate ((void *) gimage)) != NULL);
|
||||
|
||||
return_args = procedural_db_return_args (&channel_ops_duplicate_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = pdb_image_to_id(new_gimage);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
channel_ops_duplicate (void *gimage_ptr)
|
||||
{
|
||||
GImage *gimage;
|
||||
GImage *new_gimage;
|
||||
|
||||
gimage = (GImage *) gimage_ptr;
|
||||
new_gimage = duplicate (gimage);
|
||||
|
||||
gdisplay_new (new_gimage, 0x0101);
|
||||
}
|
||||
|
||||
|
||||
/* GUIDES STUFF */
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
|
||||
void channel_ops_duplicate (void *);
|
||||
|
||||
extern ProcRecord gimage_list_images_proc;
|
||||
extern ProcRecord gimage_new_proc;
|
||||
extern ProcRecord gimage_resize_proc;
|
||||
|
@ -73,7 +71,6 @@ extern ProcRecord gimage_disable_undo_proc;
|
|||
extern ProcRecord gimage_clean_all_proc;
|
||||
extern ProcRecord gimage_floating_sel_proc;
|
||||
extern ProcRecord gimage_floating_sel_attached_to_proc;
|
||||
extern ProcRecord channel_ops_duplicate_proc;
|
||||
|
||||
extern ProcRecord gimp_image_add_hguide_proc;
|
||||
extern ProcRecord gimp_image_add_vguide_proc;
|
||||
|
|
|
@ -62,8 +62,6 @@ BrushSelectP brush_select_dialog = NULL;
|
|||
|
||||
|
||||
/* static variables */
|
||||
static int success;
|
||||
static Argument *return_args;
|
||||
static int have_default_brush = 0;
|
||||
|
||||
/* static function prototypes */
|
||||
|
@ -418,7 +416,7 @@ select_brush (GimpBrush * brush)
|
|||
|
||||
|
||||
void
|
||||
create_brush_dialog ()
|
||||
create_brush_dialog (void)
|
||||
{
|
||||
if (!brush_select_dialog)
|
||||
{
|
||||
|
@ -438,651 +436,3 @@ create_brush_dialog ()
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************/
|
||||
/* BRUSHES_GET_BRUSH */
|
||||
|
||||
static Argument *
|
||||
brushes_get_brush_invoker (Argument *args)
|
||||
{
|
||||
GimpBrush * brushp;
|
||||
|
||||
success = (brushp = get_active_brush ()) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_brush_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (brushp->name);
|
||||
return_args[2].value.pdb_int = brushp->mask->width;
|
||||
return_args[3].value.pdb_int = brushp->mask->height;
|
||||
return_args[4].value.pdb_int = brushp->spacing;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
brushes_refresh_brush_invoker (Argument *args)
|
||||
{
|
||||
|
||||
/* FIXME: I've hardcoded success to be 1, because brushes_init() is a
|
||||
* void function right now. It'd be nice if it returned a value at
|
||||
* some future date, so we could tell if things blew up when reparsing
|
||||
* the list (for whatever reason).
|
||||
* - Seth "Yes, this is a kludge" Burgess
|
||||
* <sjburges@ou.edu>
|
||||
*/
|
||||
|
||||
success = TRUE ;
|
||||
brushes_init(FALSE);
|
||||
return procedural_db_return_args (&brushes_refresh_brush_proc, success);
|
||||
}
|
||||
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_get_brush_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the brush name"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the brush width"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"height",
|
||||
"the brush height"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"the brush spacing: (% of MAX [width, height])"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_get_brush_proc =
|
||||
{
|
||||
"gimp_brushes_get_brush",
|
||||
"Retrieve information about the currently active brush mask",
|
||||
"This procedure retrieves information about the currently active brush mask. This includes the brush name, the width and height, and the brush spacing paramter. All paint operations and stroke operations use this mask to control the application of paint to the image.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
4,
|
||||
brushes_get_brush_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_get_brush_invoker } },
|
||||
};
|
||||
|
||||
/* =========================================================== */
|
||||
/* REFRESH BRUSHES */
|
||||
/* =========================================================== */
|
||||
|
||||
ProcRecord brushes_refresh_brush_proc =
|
||||
{
|
||||
"gimp_brushes_refresh",
|
||||
"Refresh current brushes",
|
||||
"This procedure retrieves all brushes currently in the user's brush path "
|
||||
"and updates the brush dialog accordingly.",
|
||||
"Seth Burgess<sjburges@ou.edu>",
|
||||
"Seth Burgess",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_refresh_brush_invoker } },
|
||||
};
|
||||
|
||||
/****************************/
|
||||
/* PDB Interface To Brushes */
|
||||
/****************************/
|
||||
|
||||
/*************************/
|
||||
/* BRUSHES_GET_OPACITY */
|
||||
|
||||
static Argument *
|
||||
brushes_get_opacity_invoker (Argument *args)
|
||||
{
|
||||
return_args = procedural_db_return_args (&brushes_get_opacity_proc, TRUE);
|
||||
return_args[1].value.pdb_float = paint_options_get_opacity () * 100.0;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_get_opacity_out_args[] =
|
||||
{
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the brush opacity: 0 <= opacity <= 100"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_get_opacity_proc =
|
||||
{
|
||||
"gimp_brushes_get_opacity",
|
||||
"Get the brush opacity",
|
||||
"This procedure returns the opacity setting for brushes. This value is set globally and will remain the same even if the brush mask is changed. The return value is a floating point number between 0 and 100.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
brushes_get_opacity_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_get_opacity_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/*************************/
|
||||
/* BRUSHES_SET_OPACITY */
|
||||
|
||||
static Argument *
|
||||
brushes_set_opacity_invoker (Argument *args)
|
||||
{
|
||||
double opacity;
|
||||
|
||||
opacity = args[0].value.pdb_float;
|
||||
success = (opacity >= 0.0 && opacity <= 100.0);
|
||||
|
||||
if (success)
|
||||
paint_options_set_opacity (opacity / 100.0);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_opacity_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_set_opacity_args[] =
|
||||
{
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the brush opacity: 0 <= opacity <= 100"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_opacity_proc =
|
||||
{
|
||||
"gimp_brushes_set_opacity",
|
||||
"Set the brush opacity",
|
||||
"This procedure modifies the opacity setting for brushes. This value is set globally and will remain the same even if the brush mask is changed. The value should be a floating point number between 0 and 100.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
brushes_set_opacity_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_set_opacity_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/*************************/
|
||||
/* BRUSHES_GET_SPACING */
|
||||
|
||||
static Argument *
|
||||
brushes_get_spacing_invoker (Argument *args)
|
||||
{
|
||||
return_args = procedural_db_return_args (&brushes_get_spacing_proc, TRUE);
|
||||
return_args[1].value.pdb_int = gimp_brush_get_spacing (get_active_brush ());
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_get_spacing_out_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"the brush spacing: 0 <= spacing <= 1000"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_get_spacing_proc =
|
||||
{
|
||||
"gimp_brushes_get_spacing",
|
||||
"Get the brush spacing",
|
||||
"This procedure returns the spacing setting for brushes. This value is set per brush and will change if a different brush is selected. The return value is an integer between 0 and 1000 which represents percentage of the maximum of the width and height of the mask.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
brushes_get_spacing_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_get_spacing_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/*************************/
|
||||
/* BRUSHES_SET_SPACING */
|
||||
|
||||
static Argument *
|
||||
brushes_set_spacing_invoker (Argument *args)
|
||||
{
|
||||
int spacing;
|
||||
|
||||
spacing = args[0].value.pdb_int;
|
||||
success = (spacing >= 0 && spacing <= 1000);
|
||||
|
||||
if (success)
|
||||
gimp_brush_set_spacing (get_active_brush (), spacing);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_spacing_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_set_spacing_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"the brush spacing: 0 <= spacing <= 1000"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_spacing_proc =
|
||||
{
|
||||
"gimp_brushes_set_spacing",
|
||||
"Set the brush spacing",
|
||||
"This procedure modifies the spacing setting for the current brush. This value is set on a per-brush basis and will change if a different brush mask is selected. The value should be a integer between 0 and 1000.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
brushes_set_spacing_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_set_spacing_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/****************************/
|
||||
/* BRUSHES_GET_PAINT_MODE */
|
||||
|
||||
static Argument *
|
||||
brushes_get_paint_mode_invoker (Argument *args)
|
||||
{
|
||||
return_args = procedural_db_return_args (&brushes_get_paint_mode_proc, TRUE);
|
||||
return_args[1].value.pdb_int = paint_options_get_paint_mode ();
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_get_paint_mode_out_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_get_paint_mode_proc =
|
||||
{
|
||||
"gimp_brushes_get_paint_mode",
|
||||
"Get the brush paint_mode",
|
||||
"This procedure returns the paint-mode setting for brushes. This value is set globally and will not change if a different brush is selected. The return value is an integer between 0 and 13 which corresponds to the values listed in the argument description.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
brushes_get_paint_mode_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_get_paint_mode_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/****************************/
|
||||
/* BRUSHES_SET_PAINT_MODE */
|
||||
|
||||
static Argument *
|
||||
brushes_set_paint_mode_invoker (Argument *args)
|
||||
{
|
||||
int paint_mode;
|
||||
|
||||
paint_mode = args[0].value.pdb_int;
|
||||
success = (paint_mode >= NORMAL_MODE && paint_mode <= VALUE_MODE);
|
||||
|
||||
if (success)
|
||||
paint_options_set_paint_mode (paint_mode);
|
||||
|
||||
return procedural_db_return_args (&brushes_set_paint_mode_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_set_paint_mode_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_paint_mode_proc =
|
||||
{
|
||||
"gimp_brushes_set_paint_mode",
|
||||
"Set the brush paint_mode",
|
||||
"This procedure modifies the paint_mode setting for the current brush. This value is set globally and will not change if a different brush mask is selected.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
brushes_set_paint_mode_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_set_paint_mode_invoker } },
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***********************/
|
||||
/* BRUSHES_SET_BRUSH */
|
||||
|
||||
|
||||
static Argument *
|
||||
brushes_set_brush_invoker (Argument *args)
|
||||
{
|
||||
GimpBrush * brushp;
|
||||
char *name;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
if (success)
|
||||
{
|
||||
brushp = gimp_brush_list_get_brush(brush_list, name);
|
||||
if (brushp)
|
||||
select_brush(brushp);
|
||||
else
|
||||
success = 0;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_set_brush_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_set_brush_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the brush name"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_brush_proc =
|
||||
{
|
||||
"gimp_brushes_set_brush",
|
||||
"Set the specified brush as the active brush",
|
||||
"This procedure allows the active brush mask to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed brushes. If there is no matching brush found, this procedure will return an error. Otherwise, the specified brush becomes active and will be used in all subsequent paint operations.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
brushes_set_brush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_set_brush_invoker } },
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/******************/
|
||||
/* BRUSHES_LIST */
|
||||
|
||||
static Argument *
|
||||
brushes_list_invoker (Argument *args)
|
||||
{
|
||||
GimpBrush * brushp;
|
||||
GSList *list;
|
||||
char **brushes;
|
||||
int i;
|
||||
|
||||
brushes = (char **) g_malloc (sizeof (char *) * brush_list->num_brushes);
|
||||
|
||||
success = (list = GIMP_LIST(brush_list)->list) != NULL;
|
||||
i = 0;
|
||||
|
||||
while (list)
|
||||
{
|
||||
brushp = (GimpBrush *) list->data;
|
||||
|
||||
brushes[i++] = g_strdup (brushp->name);
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = brush_list->num_brushes;
|
||||
return_args[2].value.pdb_pointer = brushes;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_list_out_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"num_brushes",
|
||||
"the number of brushes in the brush list"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"brush_list",
|
||||
"the list of brush names"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord brushes_list_proc =
|
||||
{
|
||||
"gimp_brushes_list",
|
||||
"Retrieve a complete listing of the available brushes",
|
||||
"This procedure returns a complete listing of available GIMP brushes. Each name returned can be used as input to the 'gimp_brushes_set_brush'",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
2,
|
||||
brushes_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_list_invoker } },
|
||||
};
|
||||
|
||||
/*******************************/
|
||||
/* BRUSHES_GET_BRUSH_DATA */
|
||||
|
||||
static Argument *
|
||||
brushes_get_brush_data_invoker (Argument *args)
|
||||
{
|
||||
GimpBrushP brushp = NULL;
|
||||
GSList *list;
|
||||
char *name;
|
||||
static Argument *return_args;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
if (!success)
|
||||
{
|
||||
/* No name use active pattern */
|
||||
success = (brushp = get_active_brush ()) != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = GIMP_LIST(brush_list)->list;
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
brushp = (GimpBrushP) list->data;
|
||||
|
||||
if (!strcmp (brushp->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&brushes_get_brush_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (brushp->name);
|
||||
return_args[2].value.pdb_float = 1.0; /*opacity_value;*/
|
||||
return_args[3].value.pdb_int = brushp->spacing;
|
||||
return_args[4].value.pdb_int = 0; /* paint_mode; */
|
||||
return_args[5].value.pdb_int = brushp->mask->width;
|
||||
return_args[6].value.pdb_int = brushp->mask->height;
|
||||
return_args[7].value.pdb_int = brushp->mask->height*brushp->mask->width;
|
||||
return_args[8].value.pdb_pointer = g_malloc(return_args[7].value.pdb_int);
|
||||
g_memmove(return_args[8].value.pdb_pointer,
|
||||
temp_buf_data (brushp->mask),
|
||||
return_args[7].value.pdb_int);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
|
||||
ProcArg brushes_get_brush_data_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the brush name (\"\" means current active pattern) "
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg brushes_get_brush_data_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the brush name"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the brush opacity"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"the brush spacing"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the brush paint mode"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the brush width"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"height",
|
||||
"the brush height"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"length",
|
||||
"length of brush mask data"},
|
||||
{ PDB_INT8ARRAY,
|
||||
"mask_data",
|
||||
"the brush mask data"},
|
||||
};
|
||||
|
||||
ProcRecord brushes_get_brush_data_proc =
|
||||
{
|
||||
"gimp_brushes_get_brush_data",
|
||||
"Retrieve information about the currently active brush (including data)",
|
||||
"This procedure retrieves information about the currently active brush. This includes the brush name, and the brush extents (width and height). It also returns the brush data",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(brushes_get_brush_data_in_args) / sizeof(brushes_get_brush_data_in_args[0]),
|
||||
brushes_get_brush_data_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
sizeof(brushes_get_brush_data_out_args) / sizeof(brushes_get_brush_data_out_args[0]),
|
||||
brushes_get_brush_data_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_get_brush_data_invoker } },
|
||||
};
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define __GIMPBRUSHELIST_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "procedural_db.h"
|
||||
#include "temp_buf.h"
|
||||
#include "gimpbrush.h"
|
||||
#include "gimpbrushlistF.h"
|
||||
|
@ -55,16 +54,4 @@ GimpBrushP get_active_brush (void);
|
|||
/* TODO: {re}move this function */
|
||||
void create_brush_dialog (void);
|
||||
|
||||
/* Brush procedures */
|
||||
extern ProcRecord brushes_get_opacity_proc;
|
||||
extern ProcRecord brushes_set_opacity_proc;
|
||||
extern ProcRecord brushes_get_spacing_proc;
|
||||
extern ProcRecord brushes_set_spacing_proc;
|
||||
extern ProcRecord brushes_get_paint_mode_proc;
|
||||
extern ProcRecord brushes_set_paint_mode_proc;
|
||||
extern ProcRecord brushes_get_brush_proc;
|
||||
extern ProcRecord brushes_set_brush_proc;
|
||||
extern ProcRecord brushes_list_proc;
|
||||
extern ProcRecord brushes_refresh_brush_proc;
|
||||
|
||||
#endif /* __GIMPBRUSHELIST_H__ */
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "channel_ops.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "floating_sel.h"
|
||||
#include "general.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "channel_pvt.h"
|
||||
#include "layer_pvt.h"
|
||||
|
||||
#define ENTRY_WIDTH 60
|
||||
|
||||
|
@ -49,13 +51,6 @@ typedef struct
|
|||
} OffsetDialog;
|
||||
|
||||
/* Local procedures */
|
||||
static void offset (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
int offset_x,
|
||||
int offset_y);
|
||||
|
||||
static void offset_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void offset_cancel_callback (GtkWidget *widget,
|
||||
|
@ -72,8 +67,6 @@ static void offset_wraparound_update (GtkWidget *widget,
|
|||
static void offset_halfheight_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static Argument * channel_ops_offset_invoker (Argument *args);
|
||||
|
||||
|
||||
void
|
||||
channel_ops_offset (GimpImage* gimage)
|
||||
|
@ -212,8 +205,8 @@ channel_ops_offset (GimpImage* gimage)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
offset (GImage *gimage,
|
||||
void
|
||||
offset (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
|
@ -548,103 +541,177 @@ offset_halfheight_update (GtkWidget *widget,
|
|||
gtk_entry_set_text (GTK_ENTRY (off_d->off_y_entry), buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/* The offset procedure definition */
|
||||
ProcArg channel_ops_offset_args[] =
|
||||
GimpImage *
|
||||
duplicate (GimpImage *gimage)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable to offset"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: { OFFSET_BACKGROUND (0), OFFSET_TRANSPARENT (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
channel_ops_offset_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_offset_invoker } },
|
||||
};
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int wrap_around;
|
||||
int fill_type;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
if (success)
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
wrap_around = (args[1].value.pdb_int) ? TRUE : FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offset_x = args[3].value.pdb_int;
|
||||
offset_y = args[4].value.pdb_int;
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
if (success)
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
void
|
||||
channel_ops_duplicate (GimpImage *gimage)
|
||||
{
|
||||
gdisplay_new (duplicate (gimage), 0x0101);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
|
||||
typedef enum {
|
||||
OFFSET_BACKGROUND,
|
||||
|
@ -27,9 +28,10 @@ typedef enum {
|
|||
} ChannelOffsetType;
|
||||
|
||||
/* channel_ops functions */
|
||||
void channel_ops_offset (GimpImage*);
|
||||
void channel_ops_offset (GimpImage *);
|
||||
void channel_ops_duplicate (GimpImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord channel_ops_offset_proc;
|
||||
void offset (GimpImage *, GimpDrawable *, gboolean, int, int, int);
|
||||
GimpImage * duplicate (GimpImage *);
|
||||
|
||||
#endif /* __CHANNEL_OPS_H__ */
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "parasitelist.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -448,7 +449,7 @@ gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite)
|
|||
parasite differs from the current one and we arn't undoable */
|
||||
if (parasite_is_undoable(parasite))
|
||||
{
|
||||
undo_push_group_start(drawable->gimage); /* do a group in case we have
|
||||
undo_push_group_start(drawable->gimage, MISC_UNDO); /* do a group in case we have
|
||||
attach_parrent set */
|
||||
undo_push_drawable_parasite (drawable->gimage, drawable, parasite);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "channel_ops.h"
|
||||
#include "cursorutil.h"
|
||||
#include "drawable.h"
|
||||
#include "floating_sel.h"
|
||||
#include "general.h"
|
||||
|
@ -31,6 +32,7 @@
|
|||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "channel_pvt.h"
|
||||
#include "layer_pvt.h"
|
||||
|
||||
#define ENTRY_WIDTH 60
|
||||
|
||||
|
@ -49,13 +51,6 @@ typedef struct
|
|||
} OffsetDialog;
|
||||
|
||||
/* Local procedures */
|
||||
static void offset (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
int offset_x,
|
||||
int offset_y);
|
||||
|
||||
static void offset_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void offset_cancel_callback (GtkWidget *widget,
|
||||
|
@ -72,8 +67,6 @@ static void offset_wraparound_update (GtkWidget *widget,
|
|||
static void offset_halfheight_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static Argument * channel_ops_offset_invoker (Argument *args);
|
||||
|
||||
|
||||
void
|
||||
channel_ops_offset (GimpImage* gimage)
|
||||
|
@ -212,8 +205,8 @@ channel_ops_offset (GimpImage* gimage)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
offset (GImage *gimage,
|
||||
void
|
||||
offset (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int wrap_around,
|
||||
int fill_type,
|
||||
|
@ -548,103 +541,177 @@ offset_halfheight_update (GtkWidget *widget,
|
|||
gtk_entry_set_text (GTK_ENTRY (off_d->off_y_entry), buffer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/*
|
||||
* Procedure database functions and data structures
|
||||
*/
|
||||
|
||||
/* The offset procedure definition */
|
||||
ProcArg channel_ops_offset_args[] =
|
||||
GimpImage *
|
||||
duplicate (GimpImage *gimage)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable to offset"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"wrap_around",
|
||||
"wrap image around or fill vacated regions"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_type",
|
||||
"fill vacated regions of drawable with background or transparent: { OFFSET_BACKGROUND (0), OFFSET_TRANSPARENT (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_x",
|
||||
"offset by this amount in X direction"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offset_y",
|
||||
"offset by this amount in Y direction"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord channel_ops_offset_proc =
|
||||
{
|
||||
"gimp_channel_ops_offset",
|
||||
"Offset the drawable by the specified amounts in the X and Y directions",
|
||||
"This procedure offsets the specified drawable by the amounts specified by 'offset_x' and 'offset_y'. If 'wrap_around' is set to TRUE, then portions of the drawable which are offset out of bounds are wrapped around. Alternatively, the undefined regions of the drawable can be filled with transparency or the background color, as specified by the 'fill_type' parameter.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
channel_ops_offset_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { channel_ops_offset_invoker } },
|
||||
};
|
||||
PixelRegion srcPR, destPR;
|
||||
GimpImage *new_gimage;
|
||||
Layer *layer, *new_layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel, *new_channel;
|
||||
GSList *list;
|
||||
GList *glist;
|
||||
Guide *guide = NULL;
|
||||
Layer *active_layer = NULL;
|
||||
Channel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
GimpDrawable *floating_sel_drawable = NULL;
|
||||
int count;
|
||||
|
||||
|
||||
static Argument *
|
||||
channel_ops_offset_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
int int_value;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int wrap_around;
|
||||
int fill_type;
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
gimp_add_busy_cursors_until_idle();
|
||||
|
||||
if (success)
|
||||
/* Create a new image */
|
||||
new_gimage = gimage_new (gimage->width, gimage->height, gimage->base_type);
|
||||
gimage_disable_undo (new_gimage);
|
||||
|
||||
/* Copy-on-write the projection tilemanager so we don't have
|
||||
to reproject the new gimage - since if we do the duplicate
|
||||
operation correctly, the projection for the new gimage is
|
||||
identical to that of the source. */
|
||||
new_gimage->construct_flag = gimage->construct_flag;
|
||||
new_gimage->proj_type = gimage->proj_type;
|
||||
new_gimage->proj_bytes = gimage->proj_bytes;
|
||||
new_gimage->proj_level = gimage->proj_level;
|
||||
pixel_region_init (&srcPR, gimp_image_projection (gimage), 0, 0,
|
||||
gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, gimp_image_projection (new_gimage), 0, 0,
|
||||
new_gimage->width, new_gimage->height, TRUE);
|
||||
/* We don't want to copy a half-redrawn projection, so force
|
||||
a flush. */
|
||||
gdisplays_finish_draw();
|
||||
copy_region(&srcPR, &destPR);
|
||||
|
||||
/* Copy floating layer */
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
if (floating_layer)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
wrap_around = (args[1].value.pdb_int) ? TRUE : FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
fill_type = args[2].value.pdb_int;
|
||||
if (fill_type < OFFSET_BACKGROUND || fill_type > OFFSET_TRANSPARENT)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offset_x = args[3].value.pdb_int;
|
||||
offset_y = args[4].value.pdb_int;
|
||||
floating_sel_relax (floating_layer, FALSE);
|
||||
|
||||
floating_sel_drawable = floating_layer->fs.drawable;
|
||||
floating_layer = NULL;
|
||||
}
|
||||
|
||||
if (success)
|
||||
offset (gimage, drawable, wrap_around, fill_type, offset_x, offset_y);
|
||||
/* Copy the layers */
|
||||
list = gimage->layers;
|
||||
count = 0;
|
||||
layer = NULL;
|
||||
while (list)
|
||||
{
|
||||
layer = (Layer *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
return procedural_db_return_args (&channel_ops_offset_proc, success);
|
||||
new_layer = layer_copy (layer, FALSE);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_layer), new_gimage);
|
||||
|
||||
/* Make sure the copied layer doesn't say: "<old layer> copy" */
|
||||
layer_set_name(GIMP_LAYER(new_layer),
|
||||
layer_get_name(GIMP_LAYER(layer)));
|
||||
|
||||
/* Make sure if the layer has a layer mask, it's name isn't screwed up */
|
||||
if (new_layer->mask)
|
||||
{
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_layer->mask),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(layer->mask)));
|
||||
}
|
||||
|
||||
if (gimage->active_layer == layer)
|
||||
active_layer = new_layer;
|
||||
|
||||
if (gimage->floating_sel == layer)
|
||||
floating_layer = new_layer;
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
|
||||
|
||||
/* Add the layer */
|
||||
if (floating_layer != new_layer)
|
||||
gimage_add_layer (new_gimage, new_layer, count++);
|
||||
}
|
||||
|
||||
/* Copy the channels */
|
||||
list = gimage->channels;
|
||||
count = 0;
|
||||
while (list)
|
||||
{
|
||||
channel = (Channel *) list->data;
|
||||
list = g_slist_next (list);
|
||||
|
||||
new_channel = channel_copy (channel);
|
||||
|
||||
gimp_drawable_set_gimage(GIMP_DRAWABLE(new_channel), new_gimage);
|
||||
|
||||
/* Make sure the copied channel doesn't say: "<old channel> copy" */
|
||||
gimp_drawable_set_name(GIMP_DRAWABLE(new_channel),
|
||||
gimp_drawable_get_name(GIMP_DRAWABLE(channel)));
|
||||
|
||||
if (gimage->active_channel == channel)
|
||||
active_channel = (new_channel);
|
||||
|
||||
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
|
||||
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
|
||||
|
||||
/* Add the channel */
|
||||
gimage_add_channel (new_gimage, new_channel, count++);
|
||||
}
|
||||
|
||||
/* Copy the selection mask */
|
||||
pixel_region_init (&srcPR, drawable_data (GIMP_DRAWABLE(gimage->selection_mask)), 0, 0, gimage->width, gimage->height, FALSE);
|
||||
pixel_region_init (&destPR, drawable_data (GIMP_DRAWABLE(new_gimage->selection_mask)), 0, 0, gimage->width, gimage->height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
new_gimage->selection_mask->bounds_known = FALSE;
|
||||
new_gimage->selection_mask->boundary_known = FALSE;
|
||||
|
||||
/* Set active layer, active channel */
|
||||
new_gimage->active_layer = active_layer;
|
||||
new_gimage->active_channel = active_channel;
|
||||
if (floating_layer)
|
||||
floating_sel_attach (floating_layer, new_floating_sel_drawable);
|
||||
|
||||
/* Copy the colormap if necessary */
|
||||
if (new_gimage->base_type == INDEXED)
|
||||
memcpy (new_gimage->cmap, gimage->cmap, gimage->num_cols * 3);
|
||||
new_gimage->num_cols = gimage->num_cols;
|
||||
|
||||
/* copy state of all color channels */
|
||||
for (count = 0; count < MAX_CHANNELS; count++)
|
||||
{
|
||||
new_gimage->visible[count] = gimage->visible[count];
|
||||
new_gimage->active[count] = gimage->active[count];
|
||||
}
|
||||
|
||||
/* Copy any Guides */
|
||||
glist = gimage->guides;
|
||||
while (glist)
|
||||
{
|
||||
Guide* new_guide;
|
||||
|
||||
guide = (Guide*) glist->data;
|
||||
glist = g_list_next (glist);
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case HORIZONTAL_GUIDE:
|
||||
new_guide = gimp_image_add_hguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
case VERTICAL_GUIDE:
|
||||
new_guide = gimp_image_add_vguide(new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
break;
|
||||
default:
|
||||
g_error("Unknown guide orientation.\n");
|
||||
}
|
||||
}
|
||||
|
||||
gimage_enable_undo (new_gimage);
|
||||
|
||||
return new_gimage;
|
||||
}
|
||||
|
||||
void
|
||||
channel_ops_duplicate (GimpImage *gimage)
|
||||
{
|
||||
gdisplay_new (duplicate (gimage), 0x0101);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
|
||||
typedef enum {
|
||||
OFFSET_BACKGROUND,
|
||||
|
@ -27,9 +28,10 @@ typedef enum {
|
|||
} ChannelOffsetType;
|
||||
|
||||
/* channel_ops functions */
|
||||
void channel_ops_offset (GimpImage*);
|
||||
void channel_ops_offset (GimpImage *);
|
||||
void channel_ops_duplicate (GimpImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord channel_ops_offset_proc;
|
||||
void offset (GimpImage *, GimpDrawable *, gboolean, int, int, int);
|
||||
GimpImage * duplicate (GimpImage *);
|
||||
|
||||
#endif /* __CHANNEL_OPS_H__ */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "app_procs.h"
|
||||
#include "parasitelist.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -101,9 +102,8 @@ static void save_func(char *key, Parasite *p, FILE *fp)
|
|||
}
|
||||
|
||||
void
|
||||
gimp_parasiterc_save()
|
||||
gimp_parasiterc_save(void)
|
||||
{
|
||||
int i;
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
|
||||
|
|
392
app/gradient.c
392
app/gradient.c
|
@ -381,19 +381,11 @@ static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
|||
|
||||
static char *build_user_filename(char *name, char *path_str);
|
||||
|
||||
/* Procedural database functions */
|
||||
|
||||
static Argument *gradients_get_list_invoker(Argument *args);
|
||||
static Argument *gradients_get_active_invoker(Argument *args);
|
||||
static Argument *gradients_set_active_invoker(Argument *args);
|
||||
static Argument *gradients_sample_uniform_invoker(Argument *args);
|
||||
static Argument *gradients_sample_custom_invoker(Argument *args);
|
||||
|
||||
|
||||
/***** Local variables *****/
|
||||
|
||||
GdkColor black;
|
||||
static int num_gradients = 0;
|
||||
int num_gradients = 0;
|
||||
gradient_t *curr_gradient = NULL; /* The active gradient */
|
||||
GSList *gradients_list = NULL; /* The list of gradients */
|
||||
gradient_t *grad_default_gradient = NULL;
|
||||
|
@ -5999,175 +5991,6 @@ build_user_filename(char *name, char *path_str)
|
|||
} /* build_user_filename */
|
||||
|
||||
|
||||
/***** Procedural database declarations and functions *****/
|
||||
|
||||
/***** gradients_get_list *****/
|
||||
|
||||
ProcArg gradients_get_list_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_gradients",
|
||||
"The number of loaded gradients"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"gradient_names",
|
||||
"The list of gradient names"
|
||||
}
|
||||
}; /* gradients_get_list_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_list_proc = {
|
||||
"gimp_gradients_get_list",
|
||||
"Retrieve the list of loaded gradients",
|
||||
"This procedure returns a list of the gradients that are currently loaded "
|
||||
"in the gradient editor. You can later use the gimp_gradients_set_active "
|
||||
"function to set the active gradient.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_list_out_args) / sizeof(gradients_get_list_out_args[0]),
|
||||
gradients_get_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_list_invoker } }
|
||||
}; /* gradients_get_list_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_get_list_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gradient_t *grad;
|
||||
GSList *list;
|
||||
char **gradients;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
gradients = g_malloc(sizeof(char *) * num_gradients);
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
success = (list != NULL);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
gradients[i++] = g_strdup(grad->name);
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_list_proc, success);
|
||||
|
||||
if (success) {
|
||||
return_args[1].value.pdb_int = num_gradients;
|
||||
return_args[2].value.pdb_pointer = gradients;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_list_invoker */
|
||||
|
||||
|
||||
/***** gradients_get_active *****/
|
||||
|
||||
ProcArg gradients_get_active_out_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the active gradient"
|
||||
}
|
||||
}; /* gradients_get_active_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_active_proc = {
|
||||
"gimp_gradients_get_active",
|
||||
"Retrieve the name of the active gradient",
|
||||
"This procedure returns the name of the active gradient in hte gradient editor.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_active_out_args) / sizeof(gradients_get_active_out_args[0]),
|
||||
gradients_get_active_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_active_invoker } }
|
||||
}; /* gradients_get_active_proc */
|
||||
|
||||
|
||||
Argument *
|
||||
gradients_get_active_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success;
|
||||
|
||||
success = (curr_gradient != NULL);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_active_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup(curr_gradient->name);
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_set_active *****/
|
||||
|
||||
ProcArg gradients_set_active_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the gradient to set"
|
||||
}
|
||||
}; /* gradients_set_active_args */
|
||||
|
||||
|
||||
ProcRecord gradients_set_active_proc = {
|
||||
"gimp_gradients_set_active",
|
||||
"Sets the specified gradient as the active gradient",
|
||||
"This procedure lets you set the specified gradient as the active "
|
||||
"or \"current\" one. The name is simply a string which corresponds "
|
||||
"to one of the loaded gradients in the gradient editor. If no "
|
||||
"matching gradient is found, this procedure will return an error. "
|
||||
"Otherwise, the specified gradient will become active and will be used "
|
||||
"for subsequent custom gradient operations.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_set_active_args) / sizeof(gradients_set_active_args[0]),
|
||||
gradients_set_active_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_set_active_invoker } }
|
||||
}; /* gradients_set_active_proc */
|
||||
|
||||
gint
|
||||
grad_set_grad_to_name(gchar *name)
|
||||
{
|
||||
|
@ -6208,216 +6031,3 @@ grad_set_grad_to_name(gchar *name)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_set_active_invoker(Argument *args)
|
||||
{
|
||||
char *name;
|
||||
int success;
|
||||
|
||||
name = args[0].value.pdb_pointer;
|
||||
|
||||
success = (name != NULL);
|
||||
|
||||
if (success) {
|
||||
/* See if we have a gradient with the specified name */
|
||||
success = grad_set_grad_to_name(name);
|
||||
} /* if */
|
||||
|
||||
return procedural_db_return_args(&gradients_set_active_proc, success);
|
||||
} /* gradients_set_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_uniform *****/
|
||||
|
||||
ProcArg gradients_sample_uniform_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
}
|
||||
}; /* gradients_sample_uniform_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_uniform_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_uniform_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_uniform_proc = {
|
||||
"gimp_gradients_sample_uniform",
|
||||
"Sample the active gradient in uniform parts",
|
||||
"This procedure samples the active gradient from the gradient editor in the "
|
||||
"specified number of uniform parts. It returns a list of floating-point values "
|
||||
"which correspond to the RGBA values for each sample. The minimum number of "
|
||||
"samples to take is 2, in which case the returned colors will correspond to the "
|
||||
"{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples "
|
||||
"is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_args) / sizeof(gradients_sample_uniform_args[0]),
|
||||
gradients_sample_uniform_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_out_args) / sizeof(gradients_sample_uniform_out_args[0]),
|
||||
gradients_sample_uniform_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_uniform_invoker } }
|
||||
}; /* gradients_sample_uniform_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_uniform_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i >= 2);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_uniform_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_uniform_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_custom *****/
|
||||
|
||||
ProcArg gradients_sample_custom_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"positions",
|
||||
"The list of positions to sample along the gradient"
|
||||
}
|
||||
}; /* gradients_sample_custom_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_custom_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_custom_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_custom_proc = {
|
||||
"gimp_gradients_sample_custom",
|
||||
"Sample the active gradient in custom positions",
|
||||
"This procedure samples the active gradient from the gradient editor in "
|
||||
"the specified number of points. The procedure will sample the gradient "
|
||||
"in the specified positions from the list. The left endpoint of the "
|
||||
"gradient corresponds to position 0.0, and the right endpoint corresponds "
|
||||
"to 1.0. The procedure returns a list of floating-point values which "
|
||||
"correspond to the RGBA values for each sample.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_args) / sizeof(gradients_sample_custom_args[0]),
|
||||
gradients_sample_custom_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_out_args) / sizeof(gradients_sample_custom_out_args[0]),
|
||||
gradients_sample_custom_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_custom_invoker } }
|
||||
}; /* gradients_sample_custom_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_custom_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
gdouble *pos;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i > 0);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_custom_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = args[1].value.pdb_pointer;
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(*pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos++;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_custom_invoker */
|
||||
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#ifndef _GRADIENT_H_
|
||||
#define _GRADIENT_H_
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
void gradients_init(int no_data);
|
||||
void gradients_free(void);
|
||||
|
||||
|
@ -38,17 +32,4 @@ void grad_create_gradient_editor(void);
|
|||
void grad_free_gradient_editor(void);
|
||||
void gradients_check_dialogs(void);
|
||||
|
||||
|
||||
/***** Procedural database exports *****/
|
||||
|
||||
extern ProcRecord gradients_get_list_proc;
|
||||
extern ProcRecord gradients_get_active_proc;
|
||||
extern ProcRecord gradients_set_active_proc;
|
||||
extern ProcRecord gradients_sample_uniform_proc;
|
||||
extern ProcRecord gradients_sample_custom_proc;
|
||||
extern ProcRecord gradients_close_popup_proc;
|
||||
extern ProcRecord gradients_set_popup_proc;
|
||||
extern ProcRecord gradients_popup_proc;
|
||||
extern ProcRecord gradients_get_gradient_data_proc;
|
||||
|
||||
#endif
|
||||
|
|
364
app/gradient_cmds.c
Normal file
364
app/gradient_cmds.c
Normal file
|
@ -0,0 +1,364 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
||||
static ProcRecord gradients_get_list_proc;
|
||||
static ProcRecord gradients_get_active_proc;
|
||||
static ProcRecord gradients_set_active_proc;
|
||||
static ProcRecord gradients_sample_uniform_proc;
|
||||
static ProcRecord gradients_sample_custom_proc;
|
||||
|
||||
void
|
||||
register_gradient_procs (void)
|
||||
{
|
||||
procedural_db_register (&gradients_get_list_proc);
|
||||
procedural_db_register (&gradients_get_active_proc);
|
||||
procedural_db_register (&gradients_set_active_proc);
|
||||
procedural_db_register (&gradients_sample_uniform_proc);
|
||||
procedural_db_register (&gradients_sample_custom_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
gradients_get_list_invoker (Argument *args)
|
||||
{
|
||||
gboolean success;
|
||||
Argument *return_args;
|
||||
gchar **gradients;
|
||||
gradient_t *grad;
|
||||
GSList *list;
|
||||
int i = 0;
|
||||
|
||||
gradients = g_new (gchar *, num_gradients);
|
||||
|
||||
success = (list = gradients_list) != NULL;
|
||||
|
||||
while (list)
|
||||
{
|
||||
grad = list->data;
|
||||
gradients[i++] = g_strdup (grad->name);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_get_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = num_gradients;
|
||||
return_args[2].value.pdb_pointer = gradients;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gradients_get_list_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_gradients",
|
||||
"The number of loaded gradients"
|
||||
},
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"gradient_names",
|
||||
"The list of gradient names"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_get_list_proc =
|
||||
{
|
||||
"gimp_gradients_get_list",
|
||||
"Retrieve the list of loaded gradients.",
|
||||
"This procedure returns a list of the gradients that are currently loaded in the gradient editor. You can later use the gimp_gradients_set_active function to set the active gradient.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
2,
|
||||
gradients_get_list_outargs,
|
||||
{ { gradients_get_list_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_get_active_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
|
||||
success = curr_gradient != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_get_active_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (curr_gradient->name);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gradients_get_active_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the active gradient"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_get_active_proc =
|
||||
{
|
||||
"gimp_gradients_get_active",
|
||||
"Retrieve the name of the active gradient.",
|
||||
"This procedure returns the name of the active gradient in the gradient editor.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
gradients_get_active_outargs,
|
||||
{ { gradients_get_active_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_set_active_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = grad_set_grad_to_name (name);
|
||||
|
||||
return procedural_db_return_args (&gradients_set_active_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gradients_set_active_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the gradient to set"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_set_active_proc =
|
||||
{
|
||||
"gimp_gradients_set_active",
|
||||
"Sets the specified gradient as the active gradient.",
|
||||
"This procedure lets you set the specified gradient as the active or \"current\" one. The name is simply a string which corresponds to one of the loaded gradients in the gradient editor. If no matching gradient is found, this procedure will return an error. Otherwise, the specified gradient will become active and will be used for subsequent custom gradient operations.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
gradients_set_active_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gradients_set_active_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_sample_uniform_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gint32 i;
|
||||
gint32 array_length = 0;
|
||||
gdouble *color_samples = NULL;
|
||||
gdouble pos, delta;
|
||||
gdouble r, g, b, a;
|
||||
gdouble *pv;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
if (i < 2)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
array_length = i * 4;
|
||||
|
||||
pv = color_samples = g_new (gdouble, array_length);
|
||||
|
||||
while (i--)
|
||||
{
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_sample_uniform_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = array_length;
|
||||
return_args[2].value.pdb_pointer = color_samples;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gradients_sample_uniform_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg gradients_sample_uniform_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{
|
||||
PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_sample_uniform_proc =
|
||||
{
|
||||
"gimp_gradients_sample_uniform",
|
||||
"Sample the active gradient in uniform parts.",
|
||||
"This procedure samples the active gradient from the gradient editor in the specified number of uniform parts. It returns a list of floating-point values which correspond to the RGBA values for each sample. The minimum number of samples to take is 2, in which case the returned colors will correspond to the { 0.0, 1.0 } positions in the gradient. For example, if the number of samples is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
gradients_sample_uniform_inargs,
|
||||
2,
|
||||
gradients_sample_uniform_outargs,
|
||||
{ { gradients_sample_uniform_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_sample_custom_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gint32 i;
|
||||
gdouble *pos;
|
||||
gint32 array_length = 0;
|
||||
gdouble *color_samples = NULL;
|
||||
gdouble r, g, b, a;
|
||||
gdouble *pv;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
if (i <= 0)
|
||||
success = FALSE;
|
||||
|
||||
pos = (gdouble *) args[1].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
{
|
||||
array_length = i * 4;
|
||||
|
||||
pv = color_samples = g_new (gdouble, array_length);
|
||||
|
||||
while (i--)
|
||||
{
|
||||
grad_get_color_at(*pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_sample_custom_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = array_length;
|
||||
return_args[2].value.pdb_pointer = color_samples;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gradients_sample_custom_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
},
|
||||
{
|
||||
PDB_FLOATARRAY,
|
||||
"positions",
|
||||
"The list of positions to sample along the gradient"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg gradients_sample_custom_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{
|
||||
PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_sample_custom_proc =
|
||||
{
|
||||
"gimp_gradients_sample_custom",
|
||||
"Sample the active gradient in custom positions.",
|
||||
"This procedure samples the active gradient from the gradient editor in the specified number of points. The procedure will sample the gradient in the specified positions from the list. The left endpoint of the gradient corresponds to position 0.0, and the right endpoint corresponds to 1.0. The procedure returns a list of floating-point values which correspond to the RGBA values for each sample.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
gradients_sample_custom_inargs,
|
||||
2,
|
||||
gradients_sample_custom_outargs,
|
||||
{ { gradients_sample_custom_invoker } }
|
||||
};
|
|
@ -381,19 +381,11 @@ static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
|||
|
||||
static char *build_user_filename(char *name, char *path_str);
|
||||
|
||||
/* Procedural database functions */
|
||||
|
||||
static Argument *gradients_get_list_invoker(Argument *args);
|
||||
static Argument *gradients_get_active_invoker(Argument *args);
|
||||
static Argument *gradients_set_active_invoker(Argument *args);
|
||||
static Argument *gradients_sample_uniform_invoker(Argument *args);
|
||||
static Argument *gradients_sample_custom_invoker(Argument *args);
|
||||
|
||||
|
||||
/***** Local variables *****/
|
||||
|
||||
GdkColor black;
|
||||
static int num_gradients = 0;
|
||||
int num_gradients = 0;
|
||||
gradient_t *curr_gradient = NULL; /* The active gradient */
|
||||
GSList *gradients_list = NULL; /* The list of gradients */
|
||||
gradient_t *grad_default_gradient = NULL;
|
||||
|
@ -5999,175 +5991,6 @@ build_user_filename(char *name, char *path_str)
|
|||
} /* build_user_filename */
|
||||
|
||||
|
||||
/***** Procedural database declarations and functions *****/
|
||||
|
||||
/***** gradients_get_list *****/
|
||||
|
||||
ProcArg gradients_get_list_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_gradients",
|
||||
"The number of loaded gradients"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"gradient_names",
|
||||
"The list of gradient names"
|
||||
}
|
||||
}; /* gradients_get_list_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_list_proc = {
|
||||
"gimp_gradients_get_list",
|
||||
"Retrieve the list of loaded gradients",
|
||||
"This procedure returns a list of the gradients that are currently loaded "
|
||||
"in the gradient editor. You can later use the gimp_gradients_set_active "
|
||||
"function to set the active gradient.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_list_out_args) / sizeof(gradients_get_list_out_args[0]),
|
||||
gradients_get_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_list_invoker } }
|
||||
}; /* gradients_get_list_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_get_list_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gradient_t *grad;
|
||||
GSList *list;
|
||||
char **gradients;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
gradients = g_malloc(sizeof(char *) * num_gradients);
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
success = (list != NULL);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
gradients[i++] = g_strdup(grad->name);
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_list_proc, success);
|
||||
|
||||
if (success) {
|
||||
return_args[1].value.pdb_int = num_gradients;
|
||||
return_args[2].value.pdb_pointer = gradients;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_list_invoker */
|
||||
|
||||
|
||||
/***** gradients_get_active *****/
|
||||
|
||||
ProcArg gradients_get_active_out_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the active gradient"
|
||||
}
|
||||
}; /* gradients_get_active_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_active_proc = {
|
||||
"gimp_gradients_get_active",
|
||||
"Retrieve the name of the active gradient",
|
||||
"This procedure returns the name of the active gradient in hte gradient editor.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_active_out_args) / sizeof(gradients_get_active_out_args[0]),
|
||||
gradients_get_active_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_active_invoker } }
|
||||
}; /* gradients_get_active_proc */
|
||||
|
||||
|
||||
Argument *
|
||||
gradients_get_active_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success;
|
||||
|
||||
success = (curr_gradient != NULL);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_active_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup(curr_gradient->name);
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_set_active *****/
|
||||
|
||||
ProcArg gradients_set_active_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the gradient to set"
|
||||
}
|
||||
}; /* gradients_set_active_args */
|
||||
|
||||
|
||||
ProcRecord gradients_set_active_proc = {
|
||||
"gimp_gradients_set_active",
|
||||
"Sets the specified gradient as the active gradient",
|
||||
"This procedure lets you set the specified gradient as the active "
|
||||
"or \"current\" one. The name is simply a string which corresponds "
|
||||
"to one of the loaded gradients in the gradient editor. If no "
|
||||
"matching gradient is found, this procedure will return an error. "
|
||||
"Otherwise, the specified gradient will become active and will be used "
|
||||
"for subsequent custom gradient operations.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_set_active_args) / sizeof(gradients_set_active_args[0]),
|
||||
gradients_set_active_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_set_active_invoker } }
|
||||
}; /* gradients_set_active_proc */
|
||||
|
||||
gint
|
||||
grad_set_grad_to_name(gchar *name)
|
||||
{
|
||||
|
@ -6208,216 +6031,3 @@ grad_set_grad_to_name(gchar *name)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_set_active_invoker(Argument *args)
|
||||
{
|
||||
char *name;
|
||||
int success;
|
||||
|
||||
name = args[0].value.pdb_pointer;
|
||||
|
||||
success = (name != NULL);
|
||||
|
||||
if (success) {
|
||||
/* See if we have a gradient with the specified name */
|
||||
success = grad_set_grad_to_name(name);
|
||||
} /* if */
|
||||
|
||||
return procedural_db_return_args(&gradients_set_active_proc, success);
|
||||
} /* gradients_set_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_uniform *****/
|
||||
|
||||
ProcArg gradients_sample_uniform_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
}
|
||||
}; /* gradients_sample_uniform_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_uniform_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_uniform_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_uniform_proc = {
|
||||
"gimp_gradients_sample_uniform",
|
||||
"Sample the active gradient in uniform parts",
|
||||
"This procedure samples the active gradient from the gradient editor in the "
|
||||
"specified number of uniform parts. It returns a list of floating-point values "
|
||||
"which correspond to the RGBA values for each sample. The minimum number of "
|
||||
"samples to take is 2, in which case the returned colors will correspond to the "
|
||||
"{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples "
|
||||
"is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_args) / sizeof(gradients_sample_uniform_args[0]),
|
||||
gradients_sample_uniform_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_out_args) / sizeof(gradients_sample_uniform_out_args[0]),
|
||||
gradients_sample_uniform_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_uniform_invoker } }
|
||||
}; /* gradients_sample_uniform_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_uniform_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i >= 2);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_uniform_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_uniform_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_custom *****/
|
||||
|
||||
ProcArg gradients_sample_custom_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"positions",
|
||||
"The list of positions to sample along the gradient"
|
||||
}
|
||||
}; /* gradients_sample_custom_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_custom_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_custom_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_custom_proc = {
|
||||
"gimp_gradients_sample_custom",
|
||||
"Sample the active gradient in custom positions",
|
||||
"This procedure samples the active gradient from the gradient editor in "
|
||||
"the specified number of points. The procedure will sample the gradient "
|
||||
"in the specified positions from the list. The left endpoint of the "
|
||||
"gradient corresponds to position 0.0, and the right endpoint corresponds "
|
||||
"to 1.0. The procedure returns a list of floating-point values which "
|
||||
"correspond to the RGBA values for each sample.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_args) / sizeof(gradients_sample_custom_args[0]),
|
||||
gradients_sample_custom_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_out_args) / sizeof(gradients_sample_custom_out_args[0]),
|
||||
gradients_sample_custom_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_custom_invoker } }
|
||||
}; /* gradients_sample_custom_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_custom_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
gdouble *pos;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i > 0);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_custom_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = args[1].value.pdb_pointer;
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(*pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos++;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_custom_invoker */
|
||||
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#ifndef _GRADIENT_H_
|
||||
#define _GRADIENT_H_
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
void gradients_init(int no_data);
|
||||
void gradients_free(void);
|
||||
|
||||
|
@ -38,17 +32,4 @@ void grad_create_gradient_editor(void);
|
|||
void grad_free_gradient_editor(void);
|
||||
void gradients_check_dialogs(void);
|
||||
|
||||
|
||||
/***** Procedural database exports *****/
|
||||
|
||||
extern ProcRecord gradients_get_list_proc;
|
||||
extern ProcRecord gradients_get_active_proc;
|
||||
extern ProcRecord gradients_set_active_proc;
|
||||
extern ProcRecord gradients_sample_uniform_proc;
|
||||
extern ProcRecord gradients_sample_custom_proc;
|
||||
extern ProcRecord gradients_close_popup_proc;
|
||||
extern ProcRecord gradients_set_popup_proc;
|
||||
extern ProcRecord gradients_popup_proc;
|
||||
extern ProcRecord gradients_get_gradient_data_proc;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef __GRADIENT_HEADER_H__
|
||||
#define __GRADIENT_HEADER_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define GRAD_LIST_WIDTH 300
|
||||
#define GRAD_LIST_HEIGHT 80
|
||||
|
||||
|
@ -230,5 +232,28 @@ extern gradient_t *curr_gradient; /* The active gradient */
|
|||
extern GSList *gradients_list; /* The list of gradients */
|
||||
extern gradient_t *grad_default_gradient;
|
||||
extern gradient_editor_t *g_editor; /* The gradient editor */
|
||||
extern int num_gradients;
|
||||
|
||||
#define G_SAMPLE 40
|
||||
|
||||
typedef struct _GradSelect _GradSelect, *GradSelectP;
|
||||
|
||||
struct _GradSelect {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *clist;
|
||||
gchar *callback_name;
|
||||
gradient_t *grad;
|
||||
gint sample_size;
|
||||
GdkColor black;
|
||||
GdkGC *gc;
|
||||
};
|
||||
|
||||
GradSelectP gsel_new_selection(gchar * title, gchar * initial_gradient);
|
||||
void grad_select_free (GradSelectP gsp);
|
||||
|
||||
extern GSList *grad_active_dialogs; /* List of active dialogs */
|
||||
extern GradSelectP gradient_select_dialog; /* The main selection dialog */
|
||||
|
||||
#endif /* __GRADIENT_HEADER_H__ */
|
||||
|
|
|
@ -61,26 +61,8 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define G_SAMPLE 40
|
||||
|
||||
typedef struct _GradSelect _GradSelect, *GradSelectP;
|
||||
|
||||
struct _GradSelect {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *clist;
|
||||
gchar *callback_name;
|
||||
gradient_t *grad;
|
||||
gint sample_size;
|
||||
GdkColor black;
|
||||
GdkGC *gc;
|
||||
};
|
||||
|
||||
static GSList *active_dialogs = NULL; /* List of active dialogs */
|
||||
GSList *grad_active_dialogs = NULL; /* List of active dialogs */
|
||||
GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */
|
||||
static int success;
|
||||
static Argument *return_args;
|
||||
|
||||
static void grad_select_close_callback (GtkWidget *, gpointer);
|
||||
static void grad_select_edit_callback (GtkWidget *, gpointer);
|
||||
|
@ -104,7 +86,7 @@ grad_free_gradient_editor(void)
|
|||
void
|
||||
grad_sel_rename_all(gint n, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -123,7 +105,7 @@ grad_sel_rename_all(gint n, gradient_t *grad)
|
|||
void
|
||||
grad_sel_new_all(gint pos, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -146,7 +128,7 @@ grad_sel_new_all(gint pos, gradient_t *grad)
|
|||
void
|
||||
grad_sel_copy_all(gint pos, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -169,7 +151,7 @@ grad_sel_copy_all(gint pos, gradient_t *grad)
|
|||
void
|
||||
grad_sel_delete_all(gint n)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -188,7 +170,7 @@ grad_sel_delete_all(gint n)
|
|||
void
|
||||
grad_sel_free_all()
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -211,7 +193,7 @@ grad_sel_free_all()
|
|||
void
|
||||
grad_sel_refill_all()
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
int select_pos = -1;
|
||||
|
||||
|
@ -244,7 +226,7 @@ void
|
|||
sel_update_dialogs(gint row, gradient_t *grad)
|
||||
{
|
||||
/* Go around each updating the names and hopefully the previews */
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -312,7 +294,7 @@ grad_select_free (GradSelectP gsp)
|
|||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp);
|
||||
|
||||
g_free (gsp);
|
||||
}
|
||||
|
@ -321,14 +303,14 @@ grad_select_free (GradSelectP gsp)
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
gradients_check_dialogs()
|
||||
gradients_check_dialogs(void)
|
||||
{
|
||||
GSList *list;
|
||||
GradSelectP gsp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = grad_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -340,9 +322,9 @@ gradients_check_dialogs()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter grad_active_dialogs list*/
|
||||
grad_select_close_callback(NULL,gsp);
|
||||
}
|
||||
}
|
||||
|
@ -590,408 +572,3 @@ grad_create_gradient_editor(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_gradient;
|
||||
ProcRecord *prec = NULL;
|
||||
gint sample_sz;
|
||||
GradSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_gradient = (char *) args[2].value.pdb_pointer;
|
||||
sample_sz = args[3].value.pdb_int;
|
||||
|
||||
if(sample_sz < 0 || sample_sz > 10000)
|
||||
sample_sz = G_SAMPLE;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_popup_proc, success);
|
||||
}
|
||||
|
||||
if(initial_gradient && strlen(initial_gradient))
|
||||
newdialog = gsel_new_selection(title,
|
||||
initial_gradient);
|
||||
else
|
||||
newdialog = gsel_new_selection(title,NULL);
|
||||
|
||||
/* Add to list of proc to run when pattern changes */
|
||||
newdialog->callback_name = g_strdup(name);
|
||||
newdialog->sample_size = sample_sz;
|
||||
|
||||
/* Add to active gradient dialogs list */
|
||||
active_dialogs = g_slist_append(active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&gradients_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"gradients_callback",
|
||||
"the callback PDB proc to call when gradient selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the gradient popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial gradient",
|
||||
"The name of the pattern to set as the first selected",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample size",
|
||||
"size of the sample to return when the gradient is changed (< 10000)",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_popup_proc =
|
||||
{
|
||||
"gimp_gradients_popup",
|
||||
"Invokes the Gimp gradients selection",
|
||||
"This procedure popups the gradients selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_popup_in_args) / sizeof(gradients_popup_in_args[0]),
|
||||
gradients_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_popup_invoker } },
|
||||
};
|
||||
|
||||
static GradSelectP
|
||||
gradients_get_gradientselect(gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
GradSelectP gsp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
gsp = (GradSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if(strcmp(name,gsp->callback_name) == 0)
|
||||
{
|
||||
return gsp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
gradients_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
GradSelectP gsp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
gsp = gradients_get_gradientselect(name);
|
||||
|
||||
if(gsp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (gsp->shell))
|
||||
gtk_widget_hide (gsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if(gsp != gradient_select_dialog)
|
||||
{
|
||||
/* Send data back */
|
||||
gtk_widget_destroy(gsp->shell);
|
||||
grad_select_free(gsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_close_popup_proc =
|
||||
{
|
||||
"gimp_gradients_close_popup",
|
||||
"Popdown the Gimp gradient selection",
|
||||
"This procedure closes an opened gradient selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_close_popup_in_args) / sizeof(gradients_close_popup_in_args[0]),
|
||||
gradients_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * gradient_name;
|
||||
ProcRecord *prec = NULL;
|
||||
GradSelectP gsp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
gradient_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_set_popup_proc, success);
|
||||
}
|
||||
|
||||
gsp = gradients_get_gradientselect(pdbname);
|
||||
|
||||
if(gsp)
|
||||
{
|
||||
/* Can alter active_dialogs list*/
|
||||
GSList *tmp;
|
||||
gradient_t *active = NULL;
|
||||
int pos = 0;
|
||||
|
||||
tmp = gradients_list;
|
||||
|
||||
while (tmp) {
|
||||
active = tmp->data;
|
||||
|
||||
if (strcmp(gradient_name, active->name) == 0)
|
||||
break; /* We found the one we want */
|
||||
|
||||
pos++;
|
||||
tmp = g_slist_next(tmp);
|
||||
} /* while */
|
||||
|
||||
if(active)
|
||||
{
|
||||
gtk_clist_select_row(GTK_CLIST(gsp->clist),pos,-1);
|
||||
gtk_clist_moveto(GTK_CLIST(gsp->clist),pos,0,0.0,0.0);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"gradient name to set",
|
||||
"The name of the gradient to set as selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_set_popup_proc =
|
||||
{
|
||||
"gimp_gradients_set_popup",
|
||||
"Sets the current gradient selection in a popup",
|
||||
"Sets the current gradient selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_set_popup_in_args) / sizeof(gradients_set_popup_in_args[0]),
|
||||
gradients_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_set_popup_invoker } },
|
||||
};
|
||||
|
||||
/*********************************/
|
||||
/* GRADIENTS_GET_GRADIENT_DATA */
|
||||
|
||||
static Argument *
|
||||
gradients_get_gradient_data_invoker (Argument *args)
|
||||
{
|
||||
gradient_t * grad = NULL;
|
||||
GSList *list;
|
||||
char *name;
|
||||
gint sample_sz;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
sample_sz = args[1].value.pdb_int;
|
||||
|
||||
if(sample_sz < 0 || sample_sz > 10000)
|
||||
sample_sz = G_SAMPLE;
|
||||
|
||||
if (!success)
|
||||
{
|
||||
/* No name use active pattern */
|
||||
success = (grad = curr_gradient) != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
|
||||
if (strcmp(grad->name, name) == 0)
|
||||
{
|
||||
success = TRUE;
|
||||
break; /* We found it! */
|
||||
}
|
||||
|
||||
/* Select that gradient in the listbox */
|
||||
/* Only if gradient editor has been created */
|
||||
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i = sample_sz;
|
||||
gradient_t *oldgrad = curr_gradient;
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
curr_gradient = grad;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
curr_gradient = oldgrad;
|
||||
|
||||
return_args[1].value.pdb_pointer = g_strdup (grad->name);
|
||||
return_args[2].value.pdb_int = sample_sz*4;
|
||||
return_args[3].value.pdb_pointer = values;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
|
||||
ProcArg gradients_get_gradient_data_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the gradient name (\"\" means current active gradient) "
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample size",
|
||||
"size of the sample to return when the gradient is changed (< 10000)"
|
||||
},
|
||||
};
|
||||
|
||||
ProcArg gradients_get_gradient_data_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the gradient name"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the gradient sample width (r,g,b,a) "
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"grad data",
|
||||
"the gradient sample data"},
|
||||
};
|
||||
|
||||
ProcRecord gradients_get_gradient_data_proc =
|
||||
{
|
||||
"gimp_gradients_get_gradient_data",
|
||||
"Retrieve information about the specified gradient (including data)",
|
||||
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_get_gradient_data_in_args) / sizeof(gradients_get_gradient_data_in_args[0]),
|
||||
gradients_get_gradient_data_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
sizeof(gradients_get_gradient_data_out_args) / sizeof(gradients_get_gradient_data_out_args[0]),
|
||||
gradients_get_gradient_data_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_get_gradient_data_invoker } },
|
||||
};
|
||||
|
|
424
app/gradient_select_cmds.c
Normal file
424
app/gradient_select_cmds.c
Normal file
|
@ -0,0 +1,424 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "gradient.h"
|
||||
#include "gradient_header.h"
|
||||
|
||||
static ProcRecord gradients_popup_proc;
|
||||
static ProcRecord gradients_close_popup_proc;
|
||||
static ProcRecord gradients_set_popup_proc;
|
||||
static ProcRecord gradients_get_gradient_data_proc;
|
||||
|
||||
void
|
||||
register_gradient_select_procs (void)
|
||||
{
|
||||
procedural_db_register (&gradients_popup_proc);
|
||||
procedural_db_register (&gradients_close_popup_proc);
|
||||
procedural_db_register (&gradients_set_popup_proc);
|
||||
procedural_db_register (&gradients_get_gradient_data_proc);
|
||||
}
|
||||
|
||||
static GradSelectP
|
||||
gradients_get_gradientselect(gchar *name)
|
||||
{
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while (list)
|
||||
{
|
||||
gsp = (GradSelectP) list->data;
|
||||
|
||||
if (!strcmp (name, gsp->callback_name))
|
||||
return gsp;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
gradients_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
gchar *title;
|
||||
gchar *initial_gradient;
|
||||
gint32 sample_size;
|
||||
ProcRecord *prec;
|
||||
GradSelectP newdialog;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
title = (gchar *) args[1].value.pdb_pointer;
|
||||
if (title == NULL)
|
||||
success = FALSE;
|
||||
|
||||
initial_gradient = (gchar *) args[2].value.pdb_pointer;
|
||||
|
||||
sample_size = args[3].value.pdb_int;
|
||||
if (sample_size <= 0 || sample_size > 10000)
|
||||
sample_size = G_SAMPLE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)))
|
||||
{
|
||||
if (initial_gradient && strlen (initial_gradient))
|
||||
newdialog = gsel_new_selection (title, initial_gradient);
|
||||
else
|
||||
newdialog = gsel_new_selection (title, NULL);
|
||||
|
||||
newdialog->callback_name = g_strdup (name);
|
||||
newdialog->sample_size = sample_size;
|
||||
|
||||
/* Add to active gradient dialogs list */
|
||||
grad_active_dialogs = g_slist_append (grad_active_dialogs, newdialog);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gradients_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"gradients_callback",
|
||||
"The callback PDB proc to call when gradient selection is made"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"popup_title",
|
||||
"Title to give the gradient popup window"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"initial_gradient",
|
||||
"The name of the pattern to set as the first selected"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"sample_size",
|
||||
"Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_popup_proc =
|
||||
{
|
||||
"gimp_gradients_popup",
|
||||
"Invokes the Gimp gradients selection.",
|
||||
"This procedure popups the gradients selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
4,
|
||||
gradients_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gradients_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
ProcRecord *prec;
|
||||
GradSelectP gsp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(gsp = gradients_get_gradientselect (name)))
|
||||
{
|
||||
grad_active_dialogs = g_slist_remove (grad_active_dialogs, gsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (gsp->shell))
|
||||
gtk_widget_hide (gsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if (gsp != gradient_select_dialog)
|
||||
{
|
||||
/* Send data back */
|
||||
gtk_widget_destroy (gsp->shell);
|
||||
grad_select_free (gsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gradients_close_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"gradients_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_close_popup_proc =
|
||||
{
|
||||
"gimp_gradients_close_popup",
|
||||
"Popdown the Gimp gradient selection.",
|
||||
"This procedure closes an opened gradient selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
gradients_close_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gradients_close_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *pdbname;
|
||||
gchar *gradient_name;
|
||||
ProcRecord *prec;
|
||||
GradSelectP gsp;
|
||||
|
||||
pdbname = (gchar *) args[0].value.pdb_pointer;
|
||||
if (pdbname == NULL)
|
||||
success = FALSE;
|
||||
|
||||
gradient_name = (gchar *) args[1].value.pdb_pointer;
|
||||
if (gradient_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (pdbname)) &&
|
||||
(gsp = gradients_get_gradientselect (pdbname)))
|
||||
{
|
||||
GSList *tmp;
|
||||
gradient_t *active = NULL;
|
||||
int pos = 0;
|
||||
|
||||
tmp = gradients_list;
|
||||
|
||||
while (tmp)
|
||||
{
|
||||
active = tmp->data;
|
||||
|
||||
if (!strcmp (gradient_name, active->name))
|
||||
break; /* We found the one we want */
|
||||
|
||||
pos++;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
if (active)
|
||||
{
|
||||
gtk_clist_select_row (GTK_CLIST (gsp->clist), pos, -1);
|
||||
gtk_clist_moveto (GTK_CLIST (gsp->clist), pos, 0, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_set_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gradients_set_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"gradients_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"gradient_name",
|
||||
"The name of the gradient to set as selected"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_set_popup_proc =
|
||||
{
|
||||
"gimp_gradients_set_popup",
|
||||
"Sets the current gradient selection in a popup.",
|
||||
"Sets the current gradient selection in a popup.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
gradients_set_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gradients_set_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_get_gradient_data_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *name;
|
||||
gint32 sample_size;
|
||||
gdouble *values = NULL;
|
||||
gradient_t *oldgrad, *grad = NULL;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
sample_size = args[1].value.pdb_int;
|
||||
if (sample_size <= 0 || sample_size > 10000)
|
||||
sample_size = G_SAMPLE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list = gradients_list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
grad = list->data;
|
||||
|
||||
if (!strcmp (grad->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break; /* We found it! */
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
success = (grad = curr_gradient) != NULL;
|
||||
|
||||
if (success)
|
||||
{
|
||||
gdouble *values, *pv;
|
||||
gdouble pos, delta;
|
||||
gdouble r, g, b, a;
|
||||
int i = sample_size;
|
||||
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
pv = values = g_new (gdouble, i * 4);
|
||||
|
||||
oldgrad = curr_gradient;
|
||||
curr_gradient = grad;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
grad_get_color_at (pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
}
|
||||
|
||||
curr_gradient = oldgrad;
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (grad->name);
|
||||
return_args[2].value.pdb_int = sample_size * 4;
|
||||
return_args[3].value.pdb_pointer = values;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gradients_get_gradient_data_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The gradient name (\"\" means current active gradient)"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"sample_size",
|
||||
"Size of the sample to return when the gradient is changed (0 < sample_size <= 10000)"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg gradients_get_gradient_data_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The gradient name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The gradient sample width (r,g,b,a)"
|
||||
},
|
||||
{
|
||||
PDB_FLOATARRAY,
|
||||
"grad_data",
|
||||
"The gradient sample data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gradients_get_gradient_data_proc =
|
||||
{
|
||||
"gimp_gradients_get_gradient_data",
|
||||
"Retrieve information about the specified gradient (including data).",
|
||||
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
gradients_get_gradient_data_inargs,
|
||||
3,
|
||||
gradients_get_gradient_data_outargs,
|
||||
{ { gradients_get_gradient_data_invoker } }
|
||||
};
|
|
@ -90,14 +90,8 @@ static void spacing_scale_update (GtkAdjustment *, gpointer);
|
|||
|
||||
/* local variables */
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
GSList *brush_active_dialogs = NULL;
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
@ -491,7 +485,7 @@ brush_select_free (BrushSelectP bsp)
|
|||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,bsp);
|
||||
brush_active_dialogs = g_slist_remove(brush_active_dialogs,bsp);
|
||||
|
||||
g_free (bsp);
|
||||
}
|
||||
|
@ -1296,14 +1290,14 @@ paint_options_toggle_callback (GtkWidget *widget,
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
brushes_check_dialogs ()
|
||||
brushes_check_dialogs (void)
|
||||
{
|
||||
GSList *list;
|
||||
BrushSelectP bsp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = brush_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -1315,314 +1309,10 @@ brushes_check_dialogs ()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove (active_dialogs,bsp);
|
||||
brush_active_dialogs = g_slist_remove (brush_active_dialogs,bsp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter brush_active_dialogs list*/
|
||||
brush_select_close_callback (NULL, bsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
brushes_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_brush;
|
||||
gdouble initial_opacity = 1.0;
|
||||
gint initial_spacing = 20;
|
||||
gint initial_mode = 0;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_brush = (char *) args[2].value.pdb_pointer;
|
||||
|
||||
/* If null just use the active brush */
|
||||
if (initial_brush && strlen (initial_brush))
|
||||
{
|
||||
initial_opacity = args[3].value.pdb_float;
|
||||
initial_spacing = args[4].value.pdb_int;
|
||||
initial_mode = args[5].value.pdb_int;
|
||||
}
|
||||
|
||||
/* Check the proc exists */
|
||||
if (!success || (prec = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_popup_proc, success);
|
||||
}
|
||||
|
||||
/*create_brush_dialog();*/
|
||||
if (initial_brush && strlen (initial_brush))
|
||||
newdialog = brush_select_new (title,
|
||||
initial_brush,
|
||||
initial_opacity,
|
||||
initial_spacing,
|
||||
initial_mode);
|
||||
else
|
||||
newdialog = brush_select_new(title,NULL,0.0,0,0);
|
||||
|
||||
/* Add to list of proc to run when brush changes */
|
||||
/* change_callbacks = g_list_append(change_callbacks,g_strdup(name));*/
|
||||
newdialog->callback_name = g_strdup (name);
|
||||
|
||||
/* Add to active brush dialogs list */
|
||||
active_dialogs = g_slist_append (active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&brushes_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brushes_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"brush_callback",
|
||||
"the callback PDB proc to call when brush selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial brush",
|
||||
"The name of the brush to set as the first selected",
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"initial opacity",
|
||||
"The initial opacity of the brush",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial paint mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_popup_proc =
|
||||
{
|
||||
"gimp_brushes_popup",
|
||||
"Invokes the Gimp brush selection",
|
||||
"This procedure popups the brush selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof (brushes_popup_in_args) / sizeof (brushes_popup_in_args[0]),
|
||||
brushes_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brushes_popup_invoker } },
|
||||
};
|
||||
|
||||
static BrushSelectP
|
||||
brush_get_brushselect (gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
BrushSelectP bsp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
bsp = (BrushSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (strcmp (name, bsp->callback_name) == 0)
|
||||
{
|
||||
return bsp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
brush_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP bsp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup (name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_close_popup_proc, success);
|
||||
}
|
||||
|
||||
bsp = brush_get_brushselect (name);
|
||||
|
||||
if(bsp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,bsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (bsp->shell))
|
||||
gtk_widget_hide (bsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if (bsp != brush_select_dialog)
|
||||
{
|
||||
gtk_widget_destroy (bsp->shell);
|
||||
brush_select_free (bsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brush_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback_PDB_entry_name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_close_popup_proc =
|
||||
{
|
||||
"gimp_brushes_close_popup",
|
||||
"Popdown the Gimp brush selection",
|
||||
"This procedure closes an opened brush selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof (brush_close_popup_in_args) / sizeof (brush_close_popup_in_args[0]),
|
||||
brush_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brush_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
brush_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * brush_name;
|
||||
ProcRecord *prec = NULL;
|
||||
BrushSelectP bsp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
brush_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup (pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&brushes_set_popup_proc, success);
|
||||
}
|
||||
|
||||
bsp = brush_get_brushselect (pdbname);
|
||||
|
||||
|
||||
if(bsp)
|
||||
{
|
||||
GimpBrushP active = gimp_brush_list_get_brush (brush_list,brush_name);
|
||||
|
||||
if(active)
|
||||
{
|
||||
/* Must alter the wigdets on screen as well */
|
||||
|
||||
bsp->brush = active;
|
||||
brush_select_select (bsp, gimp_brush_list_get_brush_index (brush_list, active));
|
||||
|
||||
bsp->opacity_value = args[2].value.pdb_float;
|
||||
bsp->spacing_value = args[3].value.pdb_int;
|
||||
if(args[4].value.pdb_int >= 0 && args[4].value.pdb_int <= VALUE_MODE)
|
||||
bsp->paint_mode = args[4].value.pdb_int;
|
||||
|
||||
bsp->spacing_data->value = bsp->spacing_value;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->spacing_data), "value_changed");
|
||||
|
||||
bsp->opacity_data->value = bsp->opacity_value * 100.0;
|
||||
gtk_signal_emit_by_name (GTK_OBJECT (bsp->opacity_data), "value_changed");
|
||||
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(bsp->option_menu),bsp->paint_mode);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&brushes_set_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg brush_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback_PDB_entry_name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"brushname",
|
||||
"The name of the brush to set as selected",
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The initial opacity of the brush",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"spacing",
|
||||
"The initial spacing of the brush (if < 0 then use brush default spacing)",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"initial paint mode",
|
||||
"The initial paint mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord brushes_set_popup_proc =
|
||||
{
|
||||
"gimp_brushes_set_popup",
|
||||
"Sets the current brush selection in a popup",
|
||||
"Sets the current brush selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(brush_set_popup_in_args) / sizeof(brush_set_popup_in_args[0]),
|
||||
brush_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { brush_set_popup_invoker } },
|
||||
};
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gimpbrush.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef struct _BrushSelect _BrushSelect, *BrushSelectP;
|
||||
|
||||
|
@ -94,10 +93,10 @@ void brushes_check_dialogs (void);
|
|||
void brush_select_show_paint_options (BrushSelectP bsp,
|
||||
gboolean show);
|
||||
|
||||
/* PDB entry */
|
||||
extern ProcRecord brushes_popup_proc;
|
||||
extern ProcRecord brushes_close_popup_proc;
|
||||
extern ProcRecord brushes_set_popup_proc;
|
||||
extern ProcRecord brushes_get_brush_data_proc;
|
||||
/* List of active dialogs */
|
||||
extern GSList *brush_active_dialogs;
|
||||
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
|
||||
#endif /* __BRUSH_SELECT_H__ */
|
||||
|
|
|
@ -381,19 +381,11 @@ static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
|||
|
||||
static char *build_user_filename(char *name, char *path_str);
|
||||
|
||||
/* Procedural database functions */
|
||||
|
||||
static Argument *gradients_get_list_invoker(Argument *args);
|
||||
static Argument *gradients_get_active_invoker(Argument *args);
|
||||
static Argument *gradients_set_active_invoker(Argument *args);
|
||||
static Argument *gradients_sample_uniform_invoker(Argument *args);
|
||||
static Argument *gradients_sample_custom_invoker(Argument *args);
|
||||
|
||||
|
||||
/***** Local variables *****/
|
||||
|
||||
GdkColor black;
|
||||
static int num_gradients = 0;
|
||||
int num_gradients = 0;
|
||||
gradient_t *curr_gradient = NULL; /* The active gradient */
|
||||
GSList *gradients_list = NULL; /* The list of gradients */
|
||||
gradient_t *grad_default_gradient = NULL;
|
||||
|
@ -5999,175 +5991,6 @@ build_user_filename(char *name, char *path_str)
|
|||
} /* build_user_filename */
|
||||
|
||||
|
||||
/***** Procedural database declarations and functions *****/
|
||||
|
||||
/***** gradients_get_list *****/
|
||||
|
||||
ProcArg gradients_get_list_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_gradients",
|
||||
"The number of loaded gradients"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"gradient_names",
|
||||
"The list of gradient names"
|
||||
}
|
||||
}; /* gradients_get_list_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_list_proc = {
|
||||
"gimp_gradients_get_list",
|
||||
"Retrieve the list of loaded gradients",
|
||||
"This procedure returns a list of the gradients that are currently loaded "
|
||||
"in the gradient editor. You can later use the gimp_gradients_set_active "
|
||||
"function to set the active gradient.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_list_out_args) / sizeof(gradients_get_list_out_args[0]),
|
||||
gradients_get_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_list_invoker } }
|
||||
}; /* gradients_get_list_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_get_list_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gradient_t *grad;
|
||||
GSList *list;
|
||||
char **gradients;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
gradients = g_malloc(sizeof(char *) * num_gradients);
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
success = (list != NULL);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
gradients[i++] = g_strdup(grad->name);
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_list_proc, success);
|
||||
|
||||
if (success) {
|
||||
return_args[1].value.pdb_int = num_gradients;
|
||||
return_args[2].value.pdb_pointer = gradients;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_list_invoker */
|
||||
|
||||
|
||||
/***** gradients_get_active *****/
|
||||
|
||||
ProcArg gradients_get_active_out_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the active gradient"
|
||||
}
|
||||
}; /* gradients_get_active_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_active_proc = {
|
||||
"gimp_gradients_get_active",
|
||||
"Retrieve the name of the active gradient",
|
||||
"This procedure returns the name of the active gradient in hte gradient editor.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_active_out_args) / sizeof(gradients_get_active_out_args[0]),
|
||||
gradients_get_active_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_active_invoker } }
|
||||
}; /* gradients_get_active_proc */
|
||||
|
||||
|
||||
Argument *
|
||||
gradients_get_active_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success;
|
||||
|
||||
success = (curr_gradient != NULL);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_active_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup(curr_gradient->name);
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_set_active *****/
|
||||
|
||||
ProcArg gradients_set_active_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the gradient to set"
|
||||
}
|
||||
}; /* gradients_set_active_args */
|
||||
|
||||
|
||||
ProcRecord gradients_set_active_proc = {
|
||||
"gimp_gradients_set_active",
|
||||
"Sets the specified gradient as the active gradient",
|
||||
"This procedure lets you set the specified gradient as the active "
|
||||
"or \"current\" one. The name is simply a string which corresponds "
|
||||
"to one of the loaded gradients in the gradient editor. If no "
|
||||
"matching gradient is found, this procedure will return an error. "
|
||||
"Otherwise, the specified gradient will become active and will be used "
|
||||
"for subsequent custom gradient operations.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_set_active_args) / sizeof(gradients_set_active_args[0]),
|
||||
gradients_set_active_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_set_active_invoker } }
|
||||
}; /* gradients_set_active_proc */
|
||||
|
||||
gint
|
||||
grad_set_grad_to_name(gchar *name)
|
||||
{
|
||||
|
@ -6208,216 +6031,3 @@ grad_set_grad_to_name(gchar *name)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_set_active_invoker(Argument *args)
|
||||
{
|
||||
char *name;
|
||||
int success;
|
||||
|
||||
name = args[0].value.pdb_pointer;
|
||||
|
||||
success = (name != NULL);
|
||||
|
||||
if (success) {
|
||||
/* See if we have a gradient with the specified name */
|
||||
success = grad_set_grad_to_name(name);
|
||||
} /* if */
|
||||
|
||||
return procedural_db_return_args(&gradients_set_active_proc, success);
|
||||
} /* gradients_set_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_uniform *****/
|
||||
|
||||
ProcArg gradients_sample_uniform_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
}
|
||||
}; /* gradients_sample_uniform_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_uniform_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_uniform_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_uniform_proc = {
|
||||
"gimp_gradients_sample_uniform",
|
||||
"Sample the active gradient in uniform parts",
|
||||
"This procedure samples the active gradient from the gradient editor in the "
|
||||
"specified number of uniform parts. It returns a list of floating-point values "
|
||||
"which correspond to the RGBA values for each sample. The minimum number of "
|
||||
"samples to take is 2, in which case the returned colors will correspond to the "
|
||||
"{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples "
|
||||
"is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_args) / sizeof(gradients_sample_uniform_args[0]),
|
||||
gradients_sample_uniform_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_out_args) / sizeof(gradients_sample_uniform_out_args[0]),
|
||||
gradients_sample_uniform_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_uniform_invoker } }
|
||||
}; /* gradients_sample_uniform_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_uniform_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i >= 2);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_uniform_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_uniform_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_custom *****/
|
||||
|
||||
ProcArg gradients_sample_custom_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"positions",
|
||||
"The list of positions to sample along the gradient"
|
||||
}
|
||||
}; /* gradients_sample_custom_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_custom_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_custom_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_custom_proc = {
|
||||
"gimp_gradients_sample_custom",
|
||||
"Sample the active gradient in custom positions",
|
||||
"This procedure samples the active gradient from the gradient editor in "
|
||||
"the specified number of points. The procedure will sample the gradient "
|
||||
"in the specified positions from the list. The left endpoint of the "
|
||||
"gradient corresponds to position 0.0, and the right endpoint corresponds "
|
||||
"to 1.0. The procedure returns a list of floating-point values which "
|
||||
"correspond to the RGBA values for each sample.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_args) / sizeof(gradients_sample_custom_args[0]),
|
||||
gradients_sample_custom_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_out_args) / sizeof(gradients_sample_custom_out_args[0]),
|
||||
gradients_sample_custom_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_custom_invoker } }
|
||||
}; /* gradients_sample_custom_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_custom_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
gdouble *pos;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i > 0);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_custom_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = args[1].value.pdb_pointer;
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(*pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos++;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_custom_invoker */
|
||||
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#ifndef _GRADIENT_H_
|
||||
#define _GRADIENT_H_
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
void gradients_init(int no_data);
|
||||
void gradients_free(void);
|
||||
|
||||
|
@ -38,17 +32,4 @@ void grad_create_gradient_editor(void);
|
|||
void grad_free_gradient_editor(void);
|
||||
void gradients_check_dialogs(void);
|
||||
|
||||
|
||||
/***** Procedural database exports *****/
|
||||
|
||||
extern ProcRecord gradients_get_list_proc;
|
||||
extern ProcRecord gradients_get_active_proc;
|
||||
extern ProcRecord gradients_set_active_proc;
|
||||
extern ProcRecord gradients_sample_uniform_proc;
|
||||
extern ProcRecord gradients_sample_custom_proc;
|
||||
extern ProcRecord gradients_close_popup_proc;
|
||||
extern ProcRecord gradients_set_popup_proc;
|
||||
extern ProcRecord gradients_popup_proc;
|
||||
extern ProcRecord gradients_get_gradient_data_proc;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -61,26 +61,8 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define G_SAMPLE 40
|
||||
|
||||
typedef struct _GradSelect _GradSelect, *GradSelectP;
|
||||
|
||||
struct _GradSelect {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *clist;
|
||||
gchar *callback_name;
|
||||
gradient_t *grad;
|
||||
gint sample_size;
|
||||
GdkColor black;
|
||||
GdkGC *gc;
|
||||
};
|
||||
|
||||
static GSList *active_dialogs = NULL; /* List of active dialogs */
|
||||
GSList *grad_active_dialogs = NULL; /* List of active dialogs */
|
||||
GradSelectP gradient_select_dialog = NULL; /* The main selection dialog */
|
||||
static int success;
|
||||
static Argument *return_args;
|
||||
|
||||
static void grad_select_close_callback (GtkWidget *, gpointer);
|
||||
static void grad_select_edit_callback (GtkWidget *, gpointer);
|
||||
|
@ -104,7 +86,7 @@ grad_free_gradient_editor(void)
|
|||
void
|
||||
grad_sel_rename_all(gint n, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -123,7 +105,7 @@ grad_sel_rename_all(gint n, gradient_t *grad)
|
|||
void
|
||||
grad_sel_new_all(gint pos, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -146,7 +128,7 @@ grad_sel_new_all(gint pos, gradient_t *grad)
|
|||
void
|
||||
grad_sel_copy_all(gint pos, gradient_t *grad)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -169,7 +151,7 @@ grad_sel_copy_all(gint pos, gradient_t *grad)
|
|||
void
|
||||
grad_sel_delete_all(gint n)
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -188,7 +170,7 @@ grad_sel_delete_all(gint n)
|
|||
void
|
||||
grad_sel_free_all()
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -211,7 +193,7 @@ grad_sel_free_all()
|
|||
void
|
||||
grad_sel_refill_all()
|
||||
{
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
int select_pos = -1;
|
||||
|
||||
|
@ -244,7 +226,7 @@ void
|
|||
sel_update_dialogs(gint row, gradient_t *grad)
|
||||
{
|
||||
/* Go around each updating the names and hopefully the previews */
|
||||
GSList *list = active_dialogs;
|
||||
GSList *list = grad_active_dialogs;
|
||||
GradSelectP gsp;
|
||||
|
||||
while(list)
|
||||
|
@ -312,7 +294,7 @@ grad_select_free (GradSelectP gsp)
|
|||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp);
|
||||
|
||||
g_free (gsp);
|
||||
}
|
||||
|
@ -321,14 +303,14 @@ grad_select_free (GradSelectP gsp)
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
gradients_check_dialogs()
|
||||
gradients_check_dialogs(void)
|
||||
{
|
||||
GSList *list;
|
||||
GradSelectP gsp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = grad_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -340,9 +322,9 @@ gradients_check_dialogs()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
grad_active_dialogs = g_slist_remove(grad_active_dialogs,gsp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter grad_active_dialogs list*/
|
||||
grad_select_close_callback(NULL,gsp);
|
||||
}
|
||||
}
|
||||
|
@ -590,408 +572,3 @@ grad_create_gradient_editor(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_gradient;
|
||||
ProcRecord *prec = NULL;
|
||||
gint sample_sz;
|
||||
GradSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_gradient = (char *) args[2].value.pdb_pointer;
|
||||
sample_sz = args[3].value.pdb_int;
|
||||
|
||||
if(sample_sz < 0 || sample_sz > 10000)
|
||||
sample_sz = G_SAMPLE;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_popup_proc, success);
|
||||
}
|
||||
|
||||
if(initial_gradient && strlen(initial_gradient))
|
||||
newdialog = gsel_new_selection(title,
|
||||
initial_gradient);
|
||||
else
|
||||
newdialog = gsel_new_selection(title,NULL);
|
||||
|
||||
/* Add to list of proc to run when pattern changes */
|
||||
newdialog->callback_name = g_strdup(name);
|
||||
newdialog->sample_size = sample_sz;
|
||||
|
||||
/* Add to active gradient dialogs list */
|
||||
active_dialogs = g_slist_append(active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&gradients_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"gradients_callback",
|
||||
"the callback PDB proc to call when gradient selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the gradient popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial gradient",
|
||||
"The name of the pattern to set as the first selected",
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample size",
|
||||
"size of the sample to return when the gradient is changed (< 10000)",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_popup_proc =
|
||||
{
|
||||
"gimp_gradients_popup",
|
||||
"Invokes the Gimp gradients selection",
|
||||
"This procedure popups the gradients selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_popup_in_args) / sizeof(gradients_popup_in_args[0]),
|
||||
gradients_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_popup_invoker } },
|
||||
};
|
||||
|
||||
static GradSelectP
|
||||
gradients_get_gradientselect(gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
GradSelectP gsp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
gsp = (GradSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if(strcmp(name,gsp->callback_name) == 0)
|
||||
{
|
||||
return gsp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
gradients_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
GradSelectP gsp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
gsp = gradients_get_gradientselect(name);
|
||||
|
||||
if(gsp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,gsp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (gsp->shell))
|
||||
gtk_widget_hide (gsp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if(gsp != gradient_select_dialog)
|
||||
{
|
||||
/* Send data back */
|
||||
gtk_widget_destroy(gsp->shell);
|
||||
grad_select_free(gsp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_close_popup_proc =
|
||||
{
|
||||
"gimp_gradients_close_popup",
|
||||
"Popdown the Gimp gradient selection",
|
||||
"This procedure closes an opened gradient selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_close_popup_in_args) / sizeof(gradients_close_popup_in_args[0]),
|
||||
gradients_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gradients_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * gradient_name;
|
||||
ProcRecord *prec = NULL;
|
||||
GradSelectP gsp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
gradient_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&gradients_set_popup_proc, success);
|
||||
}
|
||||
|
||||
gsp = gradients_get_gradientselect(pdbname);
|
||||
|
||||
if(gsp)
|
||||
{
|
||||
/* Can alter active_dialogs list*/
|
||||
GSList *tmp;
|
||||
gradient_t *active = NULL;
|
||||
int pos = 0;
|
||||
|
||||
tmp = gradients_list;
|
||||
|
||||
while (tmp) {
|
||||
active = tmp->data;
|
||||
|
||||
if (strcmp(gradient_name, active->name) == 0)
|
||||
break; /* We found the one we want */
|
||||
|
||||
pos++;
|
||||
tmp = g_slist_next(tmp);
|
||||
} /* while */
|
||||
|
||||
if(active)
|
||||
{
|
||||
gtk_clist_select_row(GTK_CLIST(gsp->clist),pos,-1);
|
||||
gtk_clist_moveto(GTK_CLIST(gsp->clist),pos,0,0.0,0.0);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gradients_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg gradients_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"gradient name to set",
|
||||
"The name of the gradient to set as selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord gradients_set_popup_proc =
|
||||
{
|
||||
"gimp_gradients_set_popup",
|
||||
"Sets the current gradient selection in a popup",
|
||||
"Sets the current gradient selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_set_popup_in_args) / sizeof(gradients_set_popup_in_args[0]),
|
||||
gradients_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_set_popup_invoker } },
|
||||
};
|
||||
|
||||
/*********************************/
|
||||
/* GRADIENTS_GET_GRADIENT_DATA */
|
||||
|
||||
static Argument *
|
||||
gradients_get_gradient_data_invoker (Argument *args)
|
||||
{
|
||||
gradient_t * grad = NULL;
|
||||
GSList *list;
|
||||
char *name;
|
||||
gint sample_sz;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
sample_sz = args[1].value.pdb_int;
|
||||
|
||||
if(sample_sz < 0 || sample_sz > 10000)
|
||||
sample_sz = G_SAMPLE;
|
||||
|
||||
if (!success)
|
||||
{
|
||||
/* No name use active pattern */
|
||||
success = (grad = curr_gradient) != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
|
||||
if (strcmp(grad->name, name) == 0)
|
||||
{
|
||||
success = TRUE;
|
||||
break; /* We found it! */
|
||||
}
|
||||
|
||||
/* Select that gradient in the listbox */
|
||||
/* Only if gradient editor has been created */
|
||||
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&gradients_get_gradient_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i = sample_sz;
|
||||
gradient_t *oldgrad = curr_gradient;
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
curr_gradient = grad;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
curr_gradient = oldgrad;
|
||||
|
||||
return_args[1].value.pdb_pointer = g_strdup (grad->name);
|
||||
return_args[2].value.pdb_int = sample_sz*4;
|
||||
return_args[3].value.pdb_pointer = values;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
|
||||
ProcArg gradients_get_gradient_data_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the gradient name (\"\" means current active gradient) "
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample size",
|
||||
"size of the sample to return when the gradient is changed (< 10000)"
|
||||
},
|
||||
};
|
||||
|
||||
ProcArg gradients_get_gradient_data_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the gradient name"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the gradient sample width (r,g,b,a) "
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"grad data",
|
||||
"the gradient sample data"},
|
||||
};
|
||||
|
||||
ProcRecord gradients_get_gradient_data_proc =
|
||||
{
|
||||
"gimp_gradients_get_gradient_data",
|
||||
"Retrieve information about the specified gradient (including data)",
|
||||
"This procedure retrieves information about the gradient. This includes the gradient name, and the sample data for the gradient.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(gradients_get_gradient_data_in_args) / sizeof(gradients_get_gradient_data_in_args[0]),
|
||||
gradients_get_gradient_data_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
sizeof(gradients_get_gradient_data_out_args) / sizeof(gradients_get_gradient_data_out_args[0]),
|
||||
gradients_get_gradient_data_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gradients_get_gradient_data_invoker } },
|
||||
};
|
||||
|
|
|
@ -71,14 +71,8 @@ gint NUM_PATTERN_COLUMNS = 6;
|
|||
gint NUM_PATTERN_ROWS = 5;
|
||||
gint STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main pattern dialog */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
GSList *pattern_active_dialogs = NULL;
|
||||
|
||||
|
||||
/* If title == NULL then it is the main pattern dialog */
|
||||
|
@ -293,7 +287,7 @@ pattern_select_free (PatternSelectP psp)
|
|||
g_free(psp->callback_name);
|
||||
|
||||
/* remove from active list */
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp);
|
||||
|
||||
g_free (psp);
|
||||
}
|
||||
|
@ -845,14 +839,14 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
patterns_check_dialogs()
|
||||
patterns_check_dialogs(void)
|
||||
{
|
||||
GSList *list;
|
||||
PatternSelectP psp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = pattern_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -864,259 +858,10 @@ patterns_check_dialogs()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter pattern_active_dialogs list*/
|
||||
pattern_select_close_callback(NULL,psp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
patterns_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_pattern;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_pattern = (char *) args[2].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_popup_proc, success);
|
||||
}
|
||||
|
||||
if(initial_pattern && strlen(initial_pattern))
|
||||
newdialog = pattern_select_new(title,
|
||||
initial_pattern);
|
||||
else
|
||||
newdialog = pattern_select_new(title,NULL);
|
||||
|
||||
/* Add to list of proc to run when pattern changes */
|
||||
newdialog->callback_name = g_strdup(name);
|
||||
|
||||
/* Add to active pattern dialogs list */
|
||||
active_dialogs = g_slist_append(active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&patterns_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"pattern_callback",
|
||||
"the callback PDB proc to call when pattern selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the pattern popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial pattern",
|
||||
"The name of the pattern to set as the first selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_popup_proc =
|
||||
{
|
||||
"gimp_patterns_popup",
|
||||
"Invokes the Gimp pattern selection",
|
||||
"This procedure popups the pattern selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_popup_in_args) / sizeof(patterns_popup_in_args[0]),
|
||||
patterns_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_popup_invoker } },
|
||||
};
|
||||
|
||||
static PatternSelectP
|
||||
patterns_get_patternselect(gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
PatternSelectP psp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
psp = (PatternSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if(strcmp(name,psp->callback_name) == 0)
|
||||
{
|
||||
return psp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
patterns_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP psp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
psp = patterns_get_patternselect(name);
|
||||
|
||||
if(psp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (psp->shell))
|
||||
gtk_widget_hide (psp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if(psp != pattern_select_dialog)
|
||||
{
|
||||
/* Send data back */
|
||||
gtk_widget_destroy(psp->shell);
|
||||
pattern_select_free(psp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_close_popup_proc =
|
||||
{
|
||||
"gimp_patterns_close_popup",
|
||||
"Popdown the Gimp pattern selection",
|
||||
"This procedure closes an opened pattern selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_close_popup_in_args) / sizeof(patterns_close_popup_in_args[0]),
|
||||
patterns_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * pattern_name;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP psp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
pattern_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_set_popup_proc, success);
|
||||
}
|
||||
|
||||
psp = patterns_get_patternselect(pdbname);
|
||||
|
||||
if(psp)
|
||||
{
|
||||
/* Can alter active_dialogs list*/
|
||||
GPatternP active = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
if(active)
|
||||
{
|
||||
psp->pattern = active;
|
||||
pattern_select_select (psp, active->index);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"pattern name to set",
|
||||
"The name of the pattern to set as selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_set_popup_proc =
|
||||
{
|
||||
"gimp_patterns_set_popup",
|
||||
"Sets the current pattern selection in a popup",
|
||||
"Sets the current pattern selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_set_popup_in_args) / sizeof(patterns_set_popup_in_args[0]),
|
||||
patterns_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_set_popup_invoker } },
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef __PATTERN_SELECT_H__
|
||||
#define __PATTERN_SELECT_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "patterns.h"
|
||||
|
||||
typedef struct _PatternSelect _PatternSelect, *PatternSelectP;
|
||||
|
@ -59,10 +60,7 @@ void pattern_select_select (PatternSelectP, int);
|
|||
void pattern_select_free (PatternSelectP);
|
||||
void patterns_check_dialogs(void);
|
||||
|
||||
/* PDB entry */
|
||||
extern ProcRecord patterns_popup_proc;
|
||||
extern ProcRecord patterns_close_popup_proc;
|
||||
extern ProcRecord patterns_set_popup_proc;
|
||||
|
||||
extern GSList *pattern_active_dialogs; /* List of active dialogs */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
|
||||
#endif /* __PATTERN_SELECT_H__ */
|
||||
|
|
|
@ -20,21 +20,10 @@
|
|||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "brush_select.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "channel_cmds.h"
|
||||
#include "channel_ops.h"
|
||||
#include "drawable_cmds.h"
|
||||
#include "equalize.h"
|
||||
#include "gimage_cmds.h"
|
||||
#include "gimage_mask_cmds.h"
|
||||
#include "gimprc.h"
|
||||
#include "gradient.h"
|
||||
#include "layer_cmds.h"
|
||||
#include "internal_procs.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "parasite_cmds.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -52,9 +41,20 @@ void register_color_procs (void);
|
|||
void register_misc_procs (void);
|
||||
void register_tools_procs (void);
|
||||
void register_gimprc_procs (void);
|
||||
void register_channel_procs (void);
|
||||
void register_channel_ops_procs (void);
|
||||
void register_gradient_procs (void);
|
||||
void register_gradient_select_procs (void);
|
||||
void register_brushes_procs (void);
|
||||
void register_brush_select_procs (void);
|
||||
void register_patterns_procs (void);
|
||||
void register_pattern_select_procs (void);
|
||||
void register_parasite_procs (void);
|
||||
void register_drawable_procs (void);
|
||||
void register_procedural_db_procs (void);
|
||||
|
||||
void
|
||||
internal_procs_init ()
|
||||
internal_procs_init (void)
|
||||
{
|
||||
gfloat pcount = 0;
|
||||
/* grep -c procedural_db_register internal_procs.c */
|
||||
|
@ -213,50 +213,15 @@ internal_procs_init ()
|
|||
pcount/total_pcount);
|
||||
|
||||
/* Channel procedures */
|
||||
procedural_db_register (&channel_new_proc); pcount++;
|
||||
procedural_db_register (&channel_copy_proc); pcount++;
|
||||
procedural_db_register (&channel_delete_proc); pcount++;
|
||||
procedural_db_register (&channel_get_name_proc); pcount++;
|
||||
procedural_db_register (&channel_set_name_proc); pcount++;
|
||||
procedural_db_register (&channel_get_visible_proc); pcount++;
|
||||
procedural_db_register (&channel_set_visible_proc); pcount++;
|
||||
procedural_db_register (&channel_get_show_masked_proc); pcount++;
|
||||
procedural_db_register (&channel_set_show_masked_proc); pcount++;
|
||||
procedural_db_register (&channel_get_opacity_proc); pcount++;
|
||||
procedural_db_register (&channel_set_opacity_proc); pcount++;
|
||||
procedural_db_register (&channel_get_color_proc); pcount++;
|
||||
procedural_db_register (&channel_set_color_proc); pcount++;
|
||||
procedural_db_register (&channel_get_tattoo_proc); pcount++;
|
||||
register_channel_procs ();
|
||||
pcount += 14;
|
||||
|
||||
app_init_update_status(NULL, _("Drawable procedures"),
|
||||
pcount/total_pcount);
|
||||
|
||||
/* Drawable procedures */
|
||||
procedural_db_register (&drawable_merge_shadow_proc); pcount++;
|
||||
procedural_db_register (&drawable_fill_proc); pcount++;
|
||||
procedural_db_register (&drawable_update_proc); pcount++;
|
||||
procedural_db_register (&drawable_mask_bounds_proc); pcount++;
|
||||
procedural_db_register (&drawable_gimage_proc); pcount++;
|
||||
procedural_db_register (&drawable_type_proc); pcount++;
|
||||
procedural_db_register (&drawable_has_alpha_proc); pcount++;
|
||||
procedural_db_register (&drawable_type_with_alpha_proc); pcount++;
|
||||
procedural_db_register (&drawable_color_proc); pcount++;
|
||||
procedural_db_register (&drawable_gray_proc); pcount++;
|
||||
procedural_db_register (&drawable_indexed_proc); pcount++;
|
||||
procedural_db_register (&drawable_bytes_proc); pcount++;
|
||||
procedural_db_register (&drawable_width_proc); pcount++;
|
||||
procedural_db_register (&drawable_height_proc); pcount++;
|
||||
procedural_db_register (&drawable_offsets_proc); pcount++;
|
||||
procedural_db_register (&drawable_layer_proc); pcount++;
|
||||
procedural_db_register (&drawable_layer_mask_proc); pcount++;
|
||||
procedural_db_register (&drawable_channel_proc); pcount++;
|
||||
procedural_db_register (&drawable_set_pixel_proc); pcount++;
|
||||
procedural_db_register (&drawable_get_pixel_proc); pcount++;
|
||||
procedural_db_register (&gimp_drawable_find_parasite_proc); pcount++;
|
||||
procedural_db_register (&gimp_drawable_parasite_list_proc); pcount++;
|
||||
procedural_db_register (&gimp_drawable_attach_parasite_proc); pcount++;
|
||||
procedural_db_register (&gimp_drawable_detach_parasite_proc); pcount++;
|
||||
procedural_db_register (&drawable_set_image_proc); pcount++;
|
||||
register_drawable_procs ();
|
||||
pcount += 25;
|
||||
|
||||
app_init_update_status(NULL, _("Floating selections"),
|
||||
pcount/total_pcount);
|
||||
|
@ -283,37 +248,16 @@ internal_procs_init ()
|
|||
pcount/total_pcount);
|
||||
|
||||
/* Interface procs */
|
||||
procedural_db_register (&brushes_get_brush_proc); pcount++;
|
||||
procedural_db_register (&brushes_refresh_brush_proc); pcount++;
|
||||
procedural_db_register (&brushes_set_brush_proc); pcount++;
|
||||
procedural_db_register (&brushes_get_opacity_proc); pcount++;
|
||||
procedural_db_register (&brushes_set_opacity_proc); pcount++;
|
||||
procedural_db_register (&brushes_get_spacing_proc); pcount++;
|
||||
procedural_db_register (&brushes_set_spacing_proc); pcount++;
|
||||
procedural_db_register (&brushes_get_paint_mode_proc); pcount++;
|
||||
procedural_db_register (&brushes_set_paint_mode_proc); pcount++;
|
||||
procedural_db_register (&brushes_list_proc); pcount++;
|
||||
procedural_db_register (&brushes_popup_proc); pcount++;
|
||||
procedural_db_register (&brushes_close_popup_proc); pcount++;
|
||||
procedural_db_register (&brushes_set_popup_proc); pcount++;
|
||||
procedural_db_register (&brushes_get_brush_data_proc); pcount++;
|
||||
procedural_db_register (&patterns_get_pattern_proc); pcount++;
|
||||
procedural_db_register (&patterns_set_pattern_proc); pcount++;
|
||||
procedural_db_register (&patterns_list_proc); pcount++;
|
||||
procedural_db_register (&patterns_get_pattern_data_proc); pcount++;
|
||||
procedural_db_register (&patterns_popup_proc); pcount++;
|
||||
procedural_db_register (&patterns_close_popup_proc); pcount++;
|
||||
procedural_db_register (&patterns_set_popup_proc); pcount++;
|
||||
register_brushes_procs ();
|
||||
register_brush_select_procs ();
|
||||
register_patterns_procs ();
|
||||
register_pattern_select_procs ();
|
||||
pcount += 20;
|
||||
|
||||
procedural_db_register (&gradients_get_list_proc); pcount++;
|
||||
procedural_db_register (&gradients_get_active_proc); pcount++;
|
||||
procedural_db_register (&gradients_set_active_proc); pcount++;
|
||||
procedural_db_register (&gradients_sample_uniform_proc); pcount++;
|
||||
procedural_db_register (&gradients_sample_custom_proc); pcount++;
|
||||
procedural_db_register (&gradients_popup_proc); pcount++;
|
||||
procedural_db_register (&gradients_close_popup_proc); pcount++;
|
||||
procedural_db_register (&gradients_set_popup_proc); pcount++;
|
||||
procedural_db_register (&gradients_get_gradient_data_proc); pcount++;
|
||||
|
||||
register_gradient_procs ();
|
||||
register_gradient_select_procs ();
|
||||
pcount += 9;
|
||||
|
||||
app_init_update_status(NULL, _("Image procedures"),
|
||||
pcount/total_pcount);
|
||||
|
@ -328,8 +272,8 @@ internal_procs_init ()
|
|||
pcount/total_pcount);
|
||||
|
||||
/* Channel Ops procedures */
|
||||
procedural_db_register (&channel_ops_duplicate_proc); pcount++;
|
||||
procedural_db_register (&channel_ops_offset_proc); pcount++;
|
||||
register_channel_ops_procs ();
|
||||
pcount += 2;
|
||||
|
||||
app_init_update_status(NULL, _("gimprc ops"),
|
||||
pcount/total_pcount);
|
||||
|
@ -340,11 +284,8 @@ internal_procs_init ()
|
|||
app_init_update_status(NULL, _("parasites"),
|
||||
pcount/total_pcount);
|
||||
/* parasite procedures */
|
||||
procedural_db_register (¶site_new_proc); pcount++;
|
||||
procedural_db_register (&gimp_parasite_list_proc); pcount++;
|
||||
procedural_db_register (&gimp_find_parasite_proc); pcount++;
|
||||
procedural_db_register (&gimp_attach_parasite_proc); pcount++;
|
||||
procedural_db_register (&gimp_detach_parasite_proc); pcount++;
|
||||
register_parasite_procs ();
|
||||
pcount += 5;
|
||||
|
||||
/* paths procedures */
|
||||
register_paths_procs ();
|
||||
|
@ -358,14 +299,8 @@ internal_procs_init ()
|
|||
pcount += 11;
|
||||
|
||||
/* Procedural Database */
|
||||
procedural_db_register (&procedural_db_dump_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_query_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_proc_info_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_proc_arg_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_proc_val_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_get_data_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_set_data_proc); pcount++;
|
||||
procedural_db_register (&procedural_db_get_data_size_proc); pcount++;
|
||||
register_procedural_db_procs ();
|
||||
pcount += 8;
|
||||
|
||||
register_misc_procs ();
|
||||
}
|
||||
|
|
|
@ -1,147 +1,180 @@
|
|||
/* parasite_cmds.c
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library 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 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 library is distributed in the hope that it will be useful,
|
||||
* 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
|
||||
* Library General Public License for more details.
|
||||
* 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 Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "libgimp/parasite.h"
|
||||
#include "parasitelist.h"
|
||||
#include "gimpparasite.h"
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "appenv.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* The Parasite procs prototypes */
|
||||
static Argument *parasite_new_invoker (Argument *);
|
||||
static Argument *gimp_find_parasite_invoker (Argument *);
|
||||
static Argument *gimp_attach_parasite_invoker (Argument *);
|
||||
static Argument *gimp_detach_parasite_invoker (Argument *);
|
||||
static Argument *gimp_parasite_list_invoker (Argument *);
|
||||
#include "drawable.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpparasite.h"
|
||||
#include "libgimp/parasite.h"
|
||||
|
||||
static Argument *parasite_new_invoker (Argument *args);
|
||||
static ProcRecord parasite_new_proc;
|
||||
static ProcRecord find_parasite_proc;
|
||||
static ProcRecord attach_parasite_proc;
|
||||
static ProcRecord detach_parasite_proc;
|
||||
static ProcRecord parasite_list_proc;
|
||||
static ProcRecord drawable_find_parasite_proc;
|
||||
static ProcRecord drawable_attach_parasite_proc;
|
||||
static ProcRecord drawable_detach_parasite_proc;
|
||||
static ProcRecord drawable_parasite_list_proc;
|
||||
|
||||
|
||||
/***** parasite_new ****/
|
||||
ProcArg parasite_new_args[] =
|
||||
void
|
||||
register_parasite_procs (void)
|
||||
{
|
||||
{ PDB_STRING,
|
||||
procedural_db_register (¶site_new_proc);
|
||||
procedural_db_register (&find_parasite_proc);
|
||||
procedural_db_register (&attach_parasite_proc);
|
||||
procedural_db_register (&detach_parasite_proc);
|
||||
procedural_db_register (¶site_list_proc);
|
||||
procedural_db_register (&drawable_find_parasite_proc);
|
||||
procedural_db_register (&drawable_attach_parasite_proc);
|
||||
procedural_db_register (&drawable_detach_parasite_proc);
|
||||
procedural_db_register (&drawable_parasite_list_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
parasite_new_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *name;
|
||||
gint32 flags;
|
||||
gint32 size;
|
||||
gchar *data;
|
||||
Parasite *parasite = NULL;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
|
||||
flags = args[1].value.pdb_int;
|
||||
|
||||
size = args[2].value.pdb_int;
|
||||
if (size < 0)
|
||||
success = FALSE;
|
||||
|
||||
data = (gchar *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (size > 0 && data == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
success = (parasite = parasite_new (name, flags, size, data)) != NULL;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (¶site_new_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = parasite;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg parasite_new_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the parasite to create"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
{
|
||||
PDB_INT32,
|
||||
"flags",
|
||||
"The flags ( 1 == persistance )"
|
||||
"The flags (1 == persistance)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
{
|
||||
PDB_INT32,
|
||||
"size",
|
||||
"The size of the data in bytes"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
{
|
||||
PDB_STRING,
|
||||
"data",
|
||||
"The data"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg parasite_new_out_args[] =
|
||||
static ProcArg parasite_new_outargs[] =
|
||||
{
|
||||
{ PDB_PARASITE,
|
||||
{
|
||||
PDB_PARASITE,
|
||||
"parasite",
|
||||
"the new parasite"
|
||||
},
|
||||
"The new parasite"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord parasite_new_proc =
|
||||
static ProcRecord parasite_new_proc =
|
||||
{
|
||||
"parasite_new",
|
||||
"creates a new parasite.",
|
||||
"creates a new parasite unatached to to any image or drawable",
|
||||
"gimp_parasite_new",
|
||||
"Creates a new parasite.",
|
||||
"Creates a new parasite unatached to to any image or drawable.",
|
||||
"Jay Cox",
|
||||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
parasite_new_args,
|
||||
|
||||
/* Output arguments */
|
||||
parasite_new_inargs,
|
||||
1,
|
||||
parasite_new_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { parasite_new_invoker } },
|
||||
parasite_new_outargs,
|
||||
{ { parasite_new_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
parasite_new_invoker (Argument *args)
|
||||
find_parasite_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
char *name;
|
||||
guint32 flags, size;
|
||||
void *data;
|
||||
gchar *name;
|
||||
Parasite *parasite = NULL;
|
||||
|
||||
/* name */
|
||||
if (success)
|
||||
{ name = (char *) args[0].value.pdb_pointer; }
|
||||
/* flags */
|
||||
if (success)
|
||||
{ flags = args[1].value.pdb_int; }
|
||||
/* size */
|
||||
if (success)
|
||||
{ size = args[2].value.pdb_int; }
|
||||
/* data */
|
||||
if (success)
|
||||
{
|
||||
data = args[3].value.pdb_pointer;
|
||||
if (size > 0 && data == 0)
|
||||
success = FALSE;
|
||||
}
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
|
||||
parasite = parasite_copy (gimp_find_parasite (name));
|
||||
success = parasite != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&find_parasite_proc, success);
|
||||
|
||||
return_args = procedural_db_return_args (¶site_new_proc,
|
||||
success);
|
||||
/* The real work */
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer =
|
||||
parasite_new (name, flags, size, data);
|
||||
}
|
||||
return_args[1].value.pdb_pointer = parasite;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
|
||||
/***** gimp_find_parasite *****/
|
||||
ProcArg gimp_find_parasite_args[] =
|
||||
static ProcArg find_parasite_inargs[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the parasite to find"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg gimp_find_parasite_out_args[] =
|
||||
static ProcArg find_parasite_outargs[] =
|
||||
{
|
||||
{ PDB_PARASITE,
|
||||
{
|
||||
PDB_PARASITE,
|
||||
"parasite",
|
||||
"the found parasite"
|
||||
},
|
||||
"The found parasite"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimp_find_parasite_proc =
|
||||
static ProcRecord find_parasite_proc =
|
||||
{
|
||||
"gimp_find_parasite",
|
||||
"Finds the named parasite.",
|
||||
|
@ -150,117 +183,80 @@ ProcRecord gimp_find_parasite_proc =
|
|||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
gimp_find_parasite_args,
|
||||
|
||||
/* Output arguments */
|
||||
find_parasite_inargs,
|
||||
1,
|
||||
gimp_find_parasite_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimp_find_parasite_invoker } },
|
||||
find_parasite_outargs,
|
||||
{ { find_parasite_invoker } }
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
gimp_find_parasite_invoker (Argument *args)
|
||||
attach_parasite_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
Argument *return_args;
|
||||
char *name = NULL;
|
||||
gboolean success = TRUE;
|
||||
Parasite *parasite;
|
||||
|
||||
parasite = (Parasite *) args[0].value.pdb_pointer;
|
||||
if (parasite == NULL)
|
||||
success = FALSE;
|
||||
|
||||
/* name */
|
||||
if (success)
|
||||
{
|
||||
name = (char *) args[0].value.pdb_pointer;
|
||||
}
|
||||
gimp_attach_parasite (parasite);
|
||||
|
||||
return_args = procedural_db_return_args (&gimp_find_parasite_proc,
|
||||
success);
|
||||
/* The real work */
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer =
|
||||
parasite_copy(gimp_find_parasite (name));
|
||||
}
|
||||
|
||||
return return_args;
|
||||
return procedural_db_return_args (&attach_parasite_proc, success);
|
||||
}
|
||||
|
||||
/*** gimp_attach_parasite ***/
|
||||
|
||||
ProcArg gimp_attach_parasite_args[] =
|
||||
static ProcArg attach_parasite_inargs[] =
|
||||
{
|
||||
{ PDB_PARASITE,
|
||||
{
|
||||
PDB_PARASITE,
|
||||
"parasite",
|
||||
"The parasite to attach to the gimp"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimp_attach_parasite_proc =
|
||||
static ProcRecord attach_parasite_proc =
|
||||
{
|
||||
"gimp_attach_parasite",
|
||||
"Add a parasite to the gimp",
|
||||
"Add a parasite to the gimp.",
|
||||
"This procedure attaches a parasite to the gimp. It has no return values.",
|
||||
"Jay Cox",
|
||||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
gimp_attach_parasite_args,
|
||||
|
||||
/* Output arguments */
|
||||
attach_parasite_inargs,
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimp_attach_parasite_invoker } },
|
||||
{ { attach_parasite_invoker } }
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
gimp_attach_parasite_invoker (Argument *args)
|
||||
detach_parasite_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
Parasite *parasite = NULL;
|
||||
Argument *return_args;
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
|
||||
|
||||
|
||||
if (success)
|
||||
{
|
||||
parasite = (Parasite *)args[0].value.pdb_pointer;
|
||||
if (parasite == NULL)
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_attach_parasite (parasite);
|
||||
}
|
||||
gimp_detach_parasite (name);
|
||||
|
||||
return_args = procedural_db_return_args (&gimp_attach_parasite_proc,
|
||||
success);
|
||||
|
||||
return return_args;
|
||||
return procedural_db_return_args (&detach_parasite_proc, success);
|
||||
}
|
||||
|
||||
|
||||
/*** gimp_detach_parasite ***/
|
||||
|
||||
ProcArg gimp_detach_parasite_args[] =
|
||||
static ProcArg detach_parasite_inargs[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the parasite to detach from the gimp"
|
||||
"The name of the parasite to detach from the gimp."
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimp_detach_parasite_proc =
|
||||
static ProcRecord detach_parasite_proc =
|
||||
{
|
||||
"gimp_detach_parasite",
|
||||
"Removes a parasite from the gimp.",
|
||||
|
@ -269,93 +265,292 @@ ProcRecord gimp_detach_parasite_proc =
|
|||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
gimp_detach_parasite_args,
|
||||
|
||||
/* Output arguments */
|
||||
detach_parasite_inargs,
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimp_detach_parasite_invoker } },
|
||||
{ { detach_parasite_invoker } }
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
gimp_detach_parasite_invoker (Argument *args)
|
||||
parasite_list_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
char *parasite = NULL;
|
||||
Argument *return_args;
|
||||
gint32 num_parasites;
|
||||
gchar **parasites;
|
||||
|
||||
if (success)
|
||||
{
|
||||
parasite = (char *)args[0].value.pdb_pointer;
|
||||
if (parasite == NULL)
|
||||
success = FALSE;
|
||||
}
|
||||
parasites = gimp_parasite_list (&num_parasites);
|
||||
|
||||
if (success)
|
||||
{
|
||||
gimp_detach_parasite (parasite);
|
||||
}
|
||||
return_args = procedural_db_return_args (¶site_list_proc, TRUE);
|
||||
|
||||
return_args = procedural_db_return_args (&gimp_detach_parasite_proc,
|
||||
success);
|
||||
return_args[1].value.pdb_int = num_parasites;
|
||||
return_args[2].value.pdb_pointer = parasites;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/***** gimp_parasite_list ****/
|
||||
ProcArg gimp_parasite_list_out_args[] =
|
||||
static ProcArg parasite_list_outargs[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_parasites",
|
||||
"the number of attached parasites"
|
||||
"The number of attached parasites"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"parasites",
|
||||
"the names of currently attached parasites"
|
||||
"The names of currently attached parasites"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimp_parasite_list_proc =
|
||||
static ProcRecord parasite_list_proc =
|
||||
{
|
||||
"gimp_parasite_list",
|
||||
"list all parasites",
|
||||
"List all parasites.",
|
||||
"Returns a list of all currently attached parasites.",
|
||||
"Marc Lehmann",
|
||||
"Marc Lehmann",
|
||||
"1999",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
2,
|
||||
gimp_parasite_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimp_parasite_list_invoker } },
|
||||
parasite_list_outargs,
|
||||
{ { parasite_list_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gimp_parasite_list_invoker (Argument *args)
|
||||
drawable_find_parasite_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GimpDrawable *drawable;
|
||||
gchar *name;
|
||||
Parasite *parasite = NULL;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
|
||||
name = (gchar *) args[1].value.pdb_pointer;
|
||||
|
||||
return_args = procedural_db_return_args (&gimp_parasite_list_proc,
|
||||
success);
|
||||
/* The real work */
|
||||
if (success)
|
||||
return_args[2].value.pdb_pointer = gimp_parasite_list (&return_args[1].value.pdb_int);
|
||||
{
|
||||
parasite = parasite_copy (gimp_drawable_find_parasite (drawable, name));
|
||||
success = parasite != NULL;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&drawable_find_parasite_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = parasite;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg drawable_find_parasite_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the parasite to find"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg drawable_find_parasite_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_PARASITE,
|
||||
"parasite",
|
||||
"The found parasite"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord drawable_find_parasite_proc =
|
||||
{
|
||||
"gimp_drawable_find_parasite",
|
||||
"Finds the named parasitein a drawable.",
|
||||
"Finds and returns the named parasite that was previously attached to a drawable.",
|
||||
"Jay Cox",
|
||||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
drawable_find_parasite_inargs,
|
||||
1,
|
||||
drawable_find_parasite_outargs,
|
||||
{ { drawable_find_parasite_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
drawable_attach_parasite_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
Parasite *parasite;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
|
||||
parasite = (Parasite *) args[1].value.pdb_pointer;
|
||||
if (parasite == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_attach_parasite (drawable, parasite);
|
||||
|
||||
return procedural_db_return_args (&drawable_attach_parasite_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg drawable_attach_parasite_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable"
|
||||
},
|
||||
{
|
||||
PDB_PARASITE,
|
||||
"parasite",
|
||||
"The parasite to attach to a drawable"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord drawable_attach_parasite_proc =
|
||||
{
|
||||
"gimp_drawable_attach_parasite",
|
||||
"Add a parasite to a drawable.",
|
||||
"This procedure attaches a parasite to a drawable. It has no return values.",
|
||||
"Jay Cox",
|
||||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
drawable_attach_parasite_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { drawable_attach_parasite_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
drawable_detach_parasite_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
gchar *name;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
|
||||
name = (gchar *) args[1].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
gimp_drawable_detach_parasite (drawable, name);
|
||||
|
||||
return procedural_db_return_args (&drawable_detach_parasite_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg drawable_detach_parasite_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The name of the parasite to detach from a drawable."
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord drawable_detach_parasite_proc =
|
||||
{
|
||||
"gimp_drawable_detach_parasite",
|
||||
"Removes a parasite from a drawable.",
|
||||
"This procedure detaches a parasite from a drawable. It has no return values.",
|
||||
"Jay Cox",
|
||||
"Jay Cox",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
drawable_detach_parasite_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { drawable_detach_parasite_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
drawable_parasite_list_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GimpDrawable *drawable;
|
||||
gint32 num_parasites;
|
||||
gchar **parasites = NULL;
|
||||
|
||||
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
parasites = gimp_drawable_parasite_list (drawable, &num_parasites);
|
||||
|
||||
return_args = procedural_db_return_args (&drawable_parasite_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = num_parasites;
|
||||
return_args[2].value.pdb_pointer = parasites;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg drawable_parasite_list_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg drawable_parasite_list_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_parasites",
|
||||
"The number of attached parasites"
|
||||
},
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"parasites",
|
||||
"The names of currently attached parasites"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord drawable_parasite_list_proc =
|
||||
{
|
||||
"gimp_drawable_parasite_list",
|
||||
"List all parasites.",
|
||||
"Returns a list of all currently attached parasites.",
|
||||
"Marc Lehmann",
|
||||
"Marc Lehmann",
|
||||
"1999",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
drawable_parasite_list_inargs,
|
||||
2,
|
||||
drawable_parasite_list_outargs,
|
||||
{ { drawable_parasite_list_invoker } }
|
||||
};
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* parasite_cmds.c
|
||||
* Copyright (C) 1998 Jay Cox <jaycox@earthlink.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PARASITE_CMDS_H__
|
||||
#define __PARASITE_CMDS_H__
|
||||
|
||||
extern ProcRecord parasite_new_proc;
|
||||
extern ProcRecord gimp_find_parasite_proc;
|
||||
extern ProcRecord gimp_attach_parasite_proc;
|
||||
extern ProcRecord gimp_detach_parasite_proc;
|
||||
extern ProcRecord gimp_parasite_list_proc;
|
||||
|
||||
#endif /* __PARASITE_CMDS_H__ */
|
|
@ -71,14 +71,8 @@ gint NUM_PATTERN_COLUMNS = 6;
|
|||
gint NUM_PATTERN_ROWS = 5;
|
||||
gint STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main pattern dialog */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
GSList *pattern_active_dialogs = NULL;
|
||||
|
||||
|
||||
/* If title == NULL then it is the main pattern dialog */
|
||||
|
@ -293,7 +287,7 @@ pattern_select_free (PatternSelectP psp)
|
|||
g_free(psp->callback_name);
|
||||
|
||||
/* remove from active list */
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp);
|
||||
|
||||
g_free (psp);
|
||||
}
|
||||
|
@ -845,14 +839,14 @@ pattern_select_scroll_update (GtkAdjustment *adjustment,
|
|||
/* Close active dialogs that no longer have PDB registered for them */
|
||||
|
||||
void
|
||||
patterns_check_dialogs()
|
||||
patterns_check_dialogs(void)
|
||||
{
|
||||
GSList *list;
|
||||
PatternSelectP psp;
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
|
||||
list = active_dialogs;
|
||||
list = pattern_active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
|
@ -864,259 +858,10 @@ patterns_check_dialogs()
|
|||
|
||||
if(!prec)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
pattern_active_dialogs = g_slist_remove(pattern_active_dialogs,psp);
|
||||
|
||||
/* Can alter active_dialogs list*/
|
||||
/* Can alter pattern_active_dialogs list*/
|
||||
pattern_select_close_callback(NULL,psp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************
|
||||
* PDB interfaces.
|
||||
*/
|
||||
|
||||
|
||||
static Argument *
|
||||
patterns_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
gchar * title;
|
||||
gchar * initial_pattern;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP newdialog;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
title = (char *) args[1].value.pdb_pointer;
|
||||
initial_pattern = (char *) args[2].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_popup_proc, success);
|
||||
}
|
||||
|
||||
if(initial_pattern && strlen(initial_pattern))
|
||||
newdialog = pattern_select_new(title,
|
||||
initial_pattern);
|
||||
else
|
||||
newdialog = pattern_select_new(title,NULL);
|
||||
|
||||
/* Add to list of proc to run when pattern changes */
|
||||
newdialog->callback_name = g_strdup(name);
|
||||
|
||||
/* Add to active pattern dialogs list */
|
||||
active_dialogs = g_slist_append(active_dialogs,newdialog);
|
||||
|
||||
return procedural_db_return_args (&patterns_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"pattern_callback",
|
||||
"the callback PDB proc to call when pattern selection is made"
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"popup title",
|
||||
"title to give the pattern popup window",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"initial pattern",
|
||||
"The name of the pattern to set as the first selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_popup_proc =
|
||||
{
|
||||
"gimp_patterns_popup",
|
||||
"Invokes the Gimp pattern selection",
|
||||
"This procedure popups the pattern selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_popup_in_args) / sizeof(patterns_popup_in_args[0]),
|
||||
patterns_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_popup_invoker } },
|
||||
};
|
||||
|
||||
static PatternSelectP
|
||||
patterns_get_patternselect(gchar *name)
|
||||
{
|
||||
GSList *list;
|
||||
PatternSelectP psp;
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
while (list)
|
||||
{
|
||||
psp = (PatternSelectP) list->data;
|
||||
list = list->next;
|
||||
|
||||
if(strcmp(name,psp->callback_name) == 0)
|
||||
{
|
||||
return psp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
patterns_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP psp;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(name)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
psp = patterns_get_patternselect(name);
|
||||
|
||||
if(psp)
|
||||
{
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (psp->shell))
|
||||
gtk_widget_hide (psp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if(psp != pattern_select_dialog)
|
||||
{
|
||||
/* Send data back */
|
||||
gtk_widget_destroy(psp->shell);
|
||||
pattern_select_free(psp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_close_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_close_popup_proc =
|
||||
{
|
||||
"gimp_patterns_close_popup",
|
||||
"Popdown the Gimp pattern selection",
|
||||
"This procedure closes an opened pattern selection dialog",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_close_popup_in_args) / sizeof(patterns_close_popup_in_args[0]),
|
||||
patterns_close_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_close_popup_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gchar * pdbname;
|
||||
gchar * pattern_name;
|
||||
ProcRecord *prec = NULL;
|
||||
PatternSelectP psp;
|
||||
|
||||
success = (pdbname = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
pattern_name = (char *) args[1].value.pdb_pointer;
|
||||
|
||||
/* Check the proc exists */
|
||||
if(!success || (prec = procedural_db_lookup(pdbname)) == NULL)
|
||||
{
|
||||
success = 0;
|
||||
return procedural_db_return_args (&patterns_set_popup_proc, success);
|
||||
}
|
||||
|
||||
psp = patterns_get_patternselect(pdbname);
|
||||
|
||||
if(psp)
|
||||
{
|
||||
/* Can alter active_dialogs list*/
|
||||
GPatternP active = pattern_list_get_pattern(pattern_list,pattern_name);
|
||||
if(active)
|
||||
{
|
||||
psp->pattern = active;
|
||||
pattern_select_select (psp, active->index);
|
||||
success = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_set_popup_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"callback PDB entry name",
|
||||
"The name of the callback registered for this popup",
|
||||
},
|
||||
{ PDB_STRING,
|
||||
"pattern name to set",
|
||||
"The name of the pattern to set as selected",
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord patterns_set_popup_proc =
|
||||
{
|
||||
"gimp_patterns_set_popup",
|
||||
"Sets the current pattern selection in a popup",
|
||||
"Sets the current pattern selection in a popup",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_set_popup_in_args) / sizeof(patterns_set_popup_in_args[0]),
|
||||
patterns_set_popup_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_set_popup_invoker } },
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef __PATTERN_SELECT_H__
|
||||
#define __PATTERN_SELECT_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "patterns.h"
|
||||
|
||||
typedef struct _PatternSelect _PatternSelect, *PatternSelectP;
|
||||
|
@ -59,10 +60,7 @@ void pattern_select_select (PatternSelectP, int);
|
|||
void pattern_select_free (PatternSelectP);
|
||||
void patterns_check_dialogs(void);
|
||||
|
||||
/* PDB entry */
|
||||
extern ProcRecord patterns_popup_proc;
|
||||
extern ProcRecord patterns_close_popup_proc;
|
||||
extern ProcRecord patterns_set_popup_proc;
|
||||
|
||||
extern GSList *pattern_active_dialogs; /* List of active dialogs */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
|
||||
#endif /* __PATTERN_SELECT_H__ */
|
||||
|
|
263
app/pattern_select_cmds.c
Normal file
263
app/pattern_select_cmds.c
Normal file
|
@ -0,0 +1,263 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "pattern_select.h"
|
||||
|
||||
static ProcRecord patterns_popup_proc;
|
||||
static ProcRecord patterns_close_popup_proc;
|
||||
static ProcRecord patterns_set_popup_proc;
|
||||
|
||||
void
|
||||
register_pattern_select_procs (void)
|
||||
{
|
||||
procedural_db_register (&patterns_popup_proc);
|
||||
procedural_db_register (&patterns_close_popup_proc);
|
||||
procedural_db_register (&patterns_set_popup_proc);
|
||||
}
|
||||
|
||||
static PatternSelectP
|
||||
pattern_get_patternselect (gchar *name)
|
||||
{
|
||||
GSList *list = pattern_active_dialogs;
|
||||
PatternSelectP psp;
|
||||
|
||||
while (list)
|
||||
{
|
||||
psp = (PatternSelectP) list->data;
|
||||
|
||||
if (!strcmp (name, psp->callback_name))
|
||||
return psp;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Argument *
|
||||
patterns_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
gchar *title;
|
||||
gchar *pattern;
|
||||
ProcRecord *prec;
|
||||
PatternSelectP newdialog;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
title = (gchar *) args[1].value.pdb_pointer;
|
||||
if (title == NULL)
|
||||
success = FALSE;
|
||||
|
||||
pattern = (gchar *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)))
|
||||
{
|
||||
if (pattern && strlen (pattern))
|
||||
newdialog = pattern_select_new (title, pattern);
|
||||
else
|
||||
newdialog = pattern_select_new (title, NULL);
|
||||
|
||||
/* Add to list of proc to run when pattern changes */
|
||||
newdialog->callback_name = g_strdup (name);
|
||||
|
||||
/* Add to active pattern dialogs list */
|
||||
pattern_active_dialogs = g_slist_append (pattern_active_dialogs, newdialog);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg patterns_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"pattern_callback",
|
||||
"The callback PDB proc to call when pattern selection is made"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"popup_title",
|
||||
"Title to give the pattern popup window"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"initial_pattern",
|
||||
"The name of the pattern to set as the first selected"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_popup_proc =
|
||||
{
|
||||
"gimp_patterns_popup",
|
||||
"Invokes the Gimp pattern selection.",
|
||||
"This procedure popups the pattern selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
3,
|
||||
patterns_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { patterns_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_close_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
ProcRecord *prec;
|
||||
PatternSelectP psp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(psp = pattern_get_patternselect (name)))
|
||||
{
|
||||
pattern_active_dialogs = g_slist_remove (pattern_active_dialogs, psp);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (psp->shell))
|
||||
gtk_widget_hide (psp->shell);
|
||||
|
||||
/* Free memory if poping down dialog which is not the main one */
|
||||
if (psp != pattern_select_dialog)
|
||||
{
|
||||
gtk_widget_destroy (psp->shell);
|
||||
pattern_select_free (psp);
|
||||
}
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_close_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg patterns_close_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"pattern_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_close_popup_proc =
|
||||
{
|
||||
"gimp_patterns_close_popup",
|
||||
"Popdown the Gimp pattern selection.",
|
||||
"This procedure closes an opened pattern selection dialog.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
patterns_close_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { patterns_close_popup_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_set_popup_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
gchar *pattern_name;
|
||||
ProcRecord *prec;
|
||||
PatternSelectP psp;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
pattern_name = (gchar *) args[1].value.pdb_pointer;
|
||||
if (pattern_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((prec = procedural_db_lookup (name)) &&
|
||||
(psp = pattern_get_patternselect (name)))
|
||||
{
|
||||
GPatternP active = pattern_list_get_pattern (pattern_list, pattern_name);
|
||||
|
||||
if (active)
|
||||
{
|
||||
/* Must alter the wigdets on screen as well */
|
||||
|
||||
psp->pattern = active;
|
||||
pattern_select_select (psp, active->index);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_set_popup_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg patterns_set_popup_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"pattern_callback",
|
||||
"The name of the callback registered for this popup"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"pattern_name",
|
||||
"The name of the pattern to set as selected"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_set_popup_proc =
|
||||
{
|
||||
"gimp_patterns_set_popup",
|
||||
"Sets the current pattern selection in a popup.",
|
||||
"Sets the current pattern selection in a popup.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
patterns_set_popup_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { patterns_set_popup_invoker } }
|
||||
};
|
316
app/patterns.c
316
app/patterns.c
|
@ -55,8 +55,6 @@ int num_patterns = 0;
|
|||
PatternSelectP pattern_select_dialog = NULL;
|
||||
|
||||
/* static variables */
|
||||
static int success;
|
||||
static Argument *return_args;
|
||||
static int have_default_pattern = 0;
|
||||
|
||||
/* static function prototypes */
|
||||
|
@ -310,7 +308,7 @@ select_pattern (pattern)
|
|||
|
||||
|
||||
void
|
||||
create_pattern_dialog ()
|
||||
create_pattern_dialog (void)
|
||||
{
|
||||
if (!pattern_select_dialog)
|
||||
{
|
||||
|
@ -344,315 +342,3 @@ free_pattern (pattern)
|
|||
|
||||
g_free (pattern);
|
||||
}
|
||||
|
||||
|
||||
/**************************/
|
||||
/* PATTERNS_GET_PATTERN */
|
||||
|
||||
static Argument *
|
||||
patterns_get_pattern_invoker (Argument *args)
|
||||
{
|
||||
GPatternP patternp;
|
||||
|
||||
success = (patternp = get_active_pattern ()) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_get_pattern_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (patternp->name);
|
||||
return_args[2].value.pdb_int = patternp->mask->width;
|
||||
return_args[3].value.pdb_int = patternp->mask->height;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_get_pattern_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the pattern name"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the pattern width"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"height",
|
||||
"the pattern height"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord patterns_get_pattern_proc =
|
||||
{
|
||||
"gimp_patterns_get_pattern",
|
||||
"Retrieve information about the currently active pattern",
|
||||
"This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). All clone and bucket-fill operations with patterns will use this pattern to control the application of paint to the image.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
3,
|
||||
patterns_get_pattern_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_get_pattern_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/*******************************/
|
||||
/* PATTERNS_GET_PATTERN_DATA */
|
||||
|
||||
static Argument *
|
||||
patterns_get_pattern_data_invoker (Argument *args)
|
||||
{
|
||||
GPatternP patternp = NULL;
|
||||
GSList *list;
|
||||
char *name;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
if (!success)
|
||||
{
|
||||
/* No name use active pattern */
|
||||
success = (patternp = get_active_pattern ()) != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
list = pattern_list;
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
if (!strcmp (patternp->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_get_pattern_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (patternp->name);
|
||||
return_args[2].value.pdb_int = patternp->mask->width;
|
||||
return_args[3].value.pdb_int = patternp->mask->height;
|
||||
return_args[4].value.pdb_int = patternp->mask->bytes;
|
||||
return_args[5].value.pdb_int = patternp->mask->height*patternp->mask->width*patternp->mask->bytes;
|
||||
return_args[6].value.pdb_pointer = g_malloc(return_args[5].value.pdb_int);
|
||||
g_memmove(return_args[6].value.pdb_pointer,
|
||||
temp_buf_data (patternp->mask),
|
||||
return_args[5].value.pdb_int);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
|
||||
ProcArg patterns_get_pattern_data_in_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the pattern name (\"\" means current active pattern) "
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg patterns_get_pattern_data_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the pattern name"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"width",
|
||||
"the pattern width"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"height",
|
||||
"the pattern height"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"mask bpp",
|
||||
"pattern bytes per pixel"},
|
||||
{ PDB_INT32,
|
||||
"mask len",
|
||||
"length of pattern mask data"},
|
||||
{ PDB_INT8ARRAY,
|
||||
"mask data",
|
||||
"the pattern mask data"},
|
||||
};
|
||||
|
||||
ProcRecord patterns_get_pattern_data_proc =
|
||||
{
|
||||
"gimp_patterns_get_pattern_data",
|
||||
"Retrieve information about the currently active pattern (including data)",
|
||||
"This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). It also returns the pattern data",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
sizeof(patterns_get_pattern_data_in_args) / sizeof(patterns_get_pattern_data_in_args[0]),
|
||||
patterns_get_pattern_data_in_args,
|
||||
|
||||
/* Output arguments */
|
||||
sizeof(patterns_get_pattern_data_out_args) / sizeof(patterns_get_pattern_data_out_args[0]),
|
||||
patterns_get_pattern_data_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_get_pattern_data_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/**************************/
|
||||
/* PATTERNS_SET_PATTERN */
|
||||
|
||||
static Argument *
|
||||
patterns_set_pattern_invoker (Argument *args)
|
||||
{
|
||||
GPatternP patternp;
|
||||
GSList *list;
|
||||
char *name;
|
||||
|
||||
success = (name = (char *) args[0].value.pdb_pointer) != NULL;
|
||||
|
||||
if (success)
|
||||
{
|
||||
list = pattern_list;
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
if (!strcmp (patternp->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
select_pattern (patternp);
|
||||
break;
|
||||
}
|
||||
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_set_pattern_proc, success);
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_set_pattern_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"the pattern name"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord patterns_set_pattern_proc =
|
||||
{
|
||||
"gimp_patterns_set_pattern",
|
||||
"Set the specified pattern as the active pattern",
|
||||
"This procedure allows the active pattern mask to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed patterns. If there is no matching pattern found, this procedure will return an error. Otherwise, the specified pattern becomes active and will be used in all subsequent paint operations.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
patterns_set_pattern_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_set_pattern_invoker } },
|
||||
};
|
||||
|
||||
|
||||
/*******************/
|
||||
/* PATTERNS_LIST */
|
||||
|
||||
static Argument *
|
||||
patterns_list_invoker (Argument *args)
|
||||
{
|
||||
GPatternP patternp;
|
||||
GSList *list;
|
||||
char **patterns;
|
||||
int i;
|
||||
|
||||
patterns = (char **) g_malloc (sizeof (char *) * num_patterns);
|
||||
|
||||
success = (list = pattern_list) != NULL;
|
||||
i = 0;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
patterns[i++] = g_strdup (patternp->name);
|
||||
list = g_slist_next (list);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = num_patterns;
|
||||
return_args[2].value.pdb_pointer = patterns;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg patterns_list_out_args[] =
|
||||
{
|
||||
{ PDB_INT32,
|
||||
"num_patterns",
|
||||
"the number of patterns in the pattern list"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"pattern_list",
|
||||
"the list of pattern names"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord patterns_list_proc =
|
||||
{
|
||||
"gimp_patterns_list",
|
||||
"Retrieve a complete listing of the available patterns",
|
||||
"This procedure returns a complete listing of available GIMP patterns. Each name returned can be used as input to the 'gimp_patterns_set_pattern'",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
2,
|
||||
patterns_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { patterns_list_invoker } },
|
||||
};
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include "temp_buf.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef struct _GPattern GPattern, * GPatternP;
|
||||
|
||||
|
@ -46,9 +45,4 @@ void create_pattern_dialog (void);
|
|||
extern GSList * pattern_list;
|
||||
extern int num_patterns;
|
||||
|
||||
/* Pattern procedures */
|
||||
extern ProcRecord patterns_get_pattern_proc;
|
||||
extern ProcRecord patterns_set_pattern_proc;
|
||||
extern ProcRecord patterns_list_proc;
|
||||
extern ProcRecord patterns_get_pattern_data_proc;
|
||||
#endif /* __PATTERNS_H__ */
|
||||
|
|
335
app/patterns_cmds.c
Normal file
335
app/patterns_cmds.c
Normal file
|
@ -0,0 +1,335 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "patterns.h"
|
||||
|
||||
static ProcRecord patterns_get_pattern_proc;
|
||||
static ProcRecord patterns_set_pattern_proc;
|
||||
static ProcRecord patterns_list_proc;
|
||||
static ProcRecord patterns_get_pattern_data_proc;
|
||||
|
||||
void
|
||||
register_patterns_procs (void)
|
||||
{
|
||||
procedural_db_register (&patterns_get_pattern_proc);
|
||||
procedural_db_register (&patterns_set_pattern_proc);
|
||||
procedural_db_register (&patterns_list_proc);
|
||||
procedural_db_register (&patterns_get_pattern_data_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
patterns_get_pattern_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GPatternP patternp;
|
||||
|
||||
success = (patternp = get_active_pattern ()) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_get_pattern_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (patternp->name);
|
||||
return_args[2].value.pdb_int = patternp->mask->width;
|
||||
return_args[3].value.pdb_int = patternp->mask->height;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg patterns_get_pattern_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The pattern name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The pattern width"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"height",
|
||||
"The pattern height"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_get_pattern_proc =
|
||||
{
|
||||
"gimp_patterns_get_pattern",
|
||||
"Retrieve information about the currently active pattern.",
|
||||
"This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). All clone and bucket-fill operations with patterns will use this pattern to control the application of paint to the image.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
3,
|
||||
patterns_get_pattern_outargs,
|
||||
{ { patterns_get_pattern_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_set_pattern_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
GPatternP patternp;
|
||||
GSList *list;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
list = pattern_list;
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
if (!strcmp (patternp->name, name))
|
||||
{
|
||||
select_pattern (patternp);
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&patterns_set_pattern_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg patterns_set_pattern_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The pattern name"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_set_pattern_proc =
|
||||
{
|
||||
"gimp_patterns_set_pattern",
|
||||
"Set the specified pattern as the active pattern.",
|
||||
"This procedure allows the active pattern mask to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed patterns. If there is no matching pattern found, this procedure will return an error. Otherwise, the specified pattern becomes active and will be used in all subsequent paint operations.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
patterns_set_pattern_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { patterns_set_pattern_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_list_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar **patterns;
|
||||
GSList *list = NULL;
|
||||
int i = 0;
|
||||
|
||||
patterns = g_new (char *, num_patterns);
|
||||
|
||||
success = (list = pattern_list) != NULL;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patterns[i++] = g_strdup (((GPatternP) list->data)->name);
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_list_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = num_patterns;
|
||||
return_args[2].value.pdb_pointer = patterns;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg patterns_list_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_patterns",
|
||||
"The number of patterns in the pattern list"
|
||||
},
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"pattern_list",
|
||||
"The list of pattern names"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_list_proc =
|
||||
{
|
||||
"gimp_patterns_list",
|
||||
"Retrieve a complete listing of the available patterns.",
|
||||
"This procedure returns a complete listing of available GIMP patterns. Each name returned can be used as input to the 'gimp_patterns_set_pattern'.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
2,
|
||||
patterns_list_outargs,
|
||||
{ { patterns_list_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
patterns_get_pattern_data_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *name;
|
||||
gint32 length = 0;
|
||||
gint8 *mask_data = NULL;
|
||||
GPatternP patternp = NULL;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (strlen (name))
|
||||
{
|
||||
GSList *list = pattern_list;
|
||||
|
||||
success = FALSE;
|
||||
|
||||
while (list)
|
||||
{
|
||||
patternp = (GPatternP) list->data;
|
||||
|
||||
if (!strcmp (patternp->name, name))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
success = (patternp = get_active_pattern ()) != NULL;
|
||||
|
||||
if (success)
|
||||
{
|
||||
length = patternp->mask->height * patternp->mask->width *
|
||||
patternp->mask->bytes;
|
||||
mask_data = g_new (gint8, length);
|
||||
g_memmove (mask_data, temp_buf_data (patternp->mask), length);
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&patterns_get_pattern_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (patternp->name);
|
||||
return_args[2].value.pdb_int = patternp->mask->width;
|
||||
return_args[3].value.pdb_int = patternp->mask->height;
|
||||
return_args[4].value.pdb_int = patternp->mask->bytes;
|
||||
return_args[5].value.pdb_int = length;
|
||||
return_args[6].value.pdb_pointer = mask_data;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg patterns_get_pattern_data_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"the pattern name (\"\" means current active pattern)"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg patterns_get_pattern_data_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The pattern name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"width",
|
||||
"The pattern width"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"height",
|
||||
"The pattern height"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"mask_bpp",
|
||||
"Pattern bytes per pixel"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"length",
|
||||
"Length of pattern mask data"
|
||||
},
|
||||
{
|
||||
PDB_INT8ARRAY,
|
||||
"mask_data",
|
||||
"The pattern mask data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord patterns_get_pattern_data_proc =
|
||||
{
|
||||
"gimp_patterns_get_pattern_data",
|
||||
"Retrieve information about the currently active pattern (including data).",
|
||||
"This procedure retrieves information about the currently active pattern. This includes the pattern name, and the pattern extents (width and height). It also returns the pattern data.",
|
||||
"Andy Thomas",
|
||||
"Andy Thomas",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
patterns_get_pattern_data_inargs,
|
||||
6,
|
||||
patterns_get_pattern_data_outargs,
|
||||
{ { patterns_get_pattern_data_invoker } }
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -47,11 +47,8 @@ typedef enum
|
|||
PDB_PATH,
|
||||
PDB_PARASITE,
|
||||
PDB_STATUS,
|
||||
PDB_END
|
||||
PDB_END /*< skip >*/
|
||||
} PDBArgType;
|
||||
/* NOTE: If you change the PDBArgType enum above, you _must_ change
|
||||
* the type_str array in procedural_db.c to match. */
|
||||
|
||||
|
||||
/* Error types */
|
||||
typedef enum
|
||||
|
@ -64,12 +61,12 @@ typedef enum
|
|||
|
||||
|
||||
/* Procedure types */
|
||||
typedef enum
|
||||
typedef enum /*< chop=PDB_ >*/
|
||||
{
|
||||
PDB_INTERNAL,
|
||||
PDB_PLUGIN,
|
||||
PDB_EXTENSION,
|
||||
PDB_TEMPORARY
|
||||
PDB_TEMPORARY /*< skip >*/
|
||||
} PDBProcType;
|
||||
|
||||
|
||||
|
@ -173,16 +170,6 @@ struct _ProcRecord
|
|||
} exec_method;
|
||||
};
|
||||
|
||||
/* External data */
|
||||
extern ProcRecord procedural_db_dump_proc;
|
||||
extern ProcRecord procedural_db_query_proc;
|
||||
extern ProcRecord procedural_db_proc_info_proc;
|
||||
extern ProcRecord procedural_db_proc_arg_proc;
|
||||
extern ProcRecord procedural_db_proc_val_proc;
|
||||
extern ProcRecord procedural_db_get_data_proc;
|
||||
extern ProcRecord procedural_db_set_data_proc;
|
||||
extern ProcRecord procedural_db_get_data_size_proc;
|
||||
|
||||
/* Functions */
|
||||
void procedural_db_init (void);
|
||||
void procedural_db_free (void);
|
||||
|
@ -198,14 +185,16 @@ Argument * procedural_db_return_args (ProcRecord *,
|
|||
int);
|
||||
void procedural_db_destroy_args (Argument *,
|
||||
int);
|
||||
void pdb_add_image(GimpImage* gimage);
|
||||
gint pdb_image_to_id(GimpImage* gimage);
|
||||
GimpImage* pdb_id_to_image(gint id);
|
||||
void pdb_remove_image(GimpImage* image);
|
||||
void pdb_add_image (GimpImage *gimage);
|
||||
gint pdb_image_to_id (GimpImage *gimage);
|
||||
GimpImage * pdb_id_to_image (gint id);
|
||||
void pdb_remove_image (GimpImage *image);
|
||||
|
||||
/* "type" should really be a PDBArgType, but we can cope with
|
||||
* out-of-range values. */
|
||||
const char *pdb_type_name (gint type);
|
||||
* out-of-range values.
|
||||
*/
|
||||
const char * pdb_type_name (gint type); /* really exists in _cmds.c file */
|
||||
|
||||
extern GHashTable *procedural_ht;
|
||||
|
||||
#endif /* __PROCEDURAL_DB_H__ */
|
||||
|
|
964
app/procedural_db_cmds.c
Normal file
964
app/procedural_db_cmds.c
Normal file
|
@ -0,0 +1,964 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "config.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "regex.h"
|
||||
|
||||
/* Query structure */
|
||||
typedef struct _PDBQuery PDBQuery;
|
||||
|
||||
struct _PDBQuery
|
||||
{
|
||||
regex_t name_regex;
|
||||
regex_t blurb_regex;
|
||||
regex_t help_regex;
|
||||
regex_t author_regex;
|
||||
regex_t copyright_regex;
|
||||
regex_t date_regex;
|
||||
regex_t proc_type_regex;
|
||||
|
||||
gchar **list_of_procs;
|
||||
int num_procs;
|
||||
};
|
||||
|
||||
typedef struct _PDBData PDBData;
|
||||
|
||||
struct _PDBData
|
||||
{
|
||||
gchar *identifier;
|
||||
gint bytes;
|
||||
gchar *data;
|
||||
};
|
||||
|
||||
static FILE *procedural_db_out = NULL;
|
||||
static GList *data_list = NULL;
|
||||
|
||||
static char *proc_type_str[] =
|
||||
{
|
||||
N_("Internal GIMP procedure"),
|
||||
N_("GIMP Plug-In"),
|
||||
N_("GIMP Extension"),
|
||||
N_("Temporary Procedure")
|
||||
};
|
||||
|
||||
static const char * const type_str[] =
|
||||
{
|
||||
"PDB_INT32",
|
||||
"PDB_INT16",
|
||||
"PDB_INT8",
|
||||
"PDB_FLOAT",
|
||||
"PDB_STRING",
|
||||
"PDB_INT32ARRAY",
|
||||
"PDB_INT16ARRAY",
|
||||
"PDB_INT8ARRAY",
|
||||
"PDB_FLOATARRAY",
|
||||
"PDB_STRINGARRAY",
|
||||
"PDB_COLOR",
|
||||
"PDB_REGION",
|
||||
"PDB_DISPLAY",
|
||||
"PDB_IMAGE",
|
||||
"PDB_LAYER",
|
||||
"PDB_CHANNEL",
|
||||
"PDB_DRAWABLE",
|
||||
"PDB_SELECTION",
|
||||
"PDB_BOUNDARY",
|
||||
"PDB_PATH",
|
||||
"PDB_PARASITE",
|
||||
"PDB_STATUS"
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_dump_proc;
|
||||
static ProcRecord procedural_db_query_proc;
|
||||
static ProcRecord procedural_db_proc_info_proc;
|
||||
static ProcRecord procedural_db_proc_arg_proc;
|
||||
static ProcRecord procedural_db_proc_val_proc;
|
||||
static ProcRecord procedural_db_get_data_proc;
|
||||
static ProcRecord procedural_db_get_data_size_proc;
|
||||
static ProcRecord procedural_db_set_data_proc;
|
||||
|
||||
void
|
||||
register_procedural_db_procs (void)
|
||||
{
|
||||
procedural_db_register (&procedural_db_dump_proc);
|
||||
procedural_db_register (&procedural_db_query_proc);
|
||||
procedural_db_register (&procedural_db_proc_info_proc);
|
||||
procedural_db_register (&procedural_db_proc_arg_proc);
|
||||
procedural_db_register (&procedural_db_proc_val_proc);
|
||||
procedural_db_register (&procedural_db_get_data_proc);
|
||||
procedural_db_register (&procedural_db_get_data_size_proc);
|
||||
procedural_db_register (&procedural_db_set_data_proc);
|
||||
}
|
||||
|
||||
static int
|
||||
match_strings (regex_t *preg,
|
||||
gchar *a)
|
||||
{
|
||||
return regexec (preg, a, 0, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
procedural_db_query_entry (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GList *list;
|
||||
ProcRecord *proc;
|
||||
PDBQuery *pdb_query;
|
||||
int new_length;
|
||||
|
||||
list = (GList *) value;
|
||||
proc = (ProcRecord *) list->data;
|
||||
pdb_query = (PDBQuery *) user_data;
|
||||
|
||||
if (!match_strings (&pdb_query->name_regex, proc->name) &&
|
||||
!match_strings (&pdb_query->blurb_regex, proc->blurb) &&
|
||||
!match_strings (&pdb_query->help_regex, proc->help) &&
|
||||
!match_strings (&pdb_query->author_regex, proc->author) &&
|
||||
!match_strings (&pdb_query->copyright_regex, proc->copyright) &&
|
||||
!match_strings (&pdb_query->date_regex, proc->date) &&
|
||||
!match_strings (&pdb_query->proc_type_regex,
|
||||
proc_type_str[(int) proc->proc_type]))
|
||||
{
|
||||
new_length = proc->name ? (strlen (proc->name) + 1) : 0;
|
||||
|
||||
if (new_length)
|
||||
{
|
||||
pdb_query->num_procs++;
|
||||
pdb_query->list_of_procs = g_realloc (pdb_query->list_of_procs,
|
||||
(sizeof (gchar **) * pdb_query->num_procs));
|
||||
pdb_query->list_of_procs[pdb_query->num_procs - 1] = g_strdup (proc->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
output_string (const char *string)
|
||||
{
|
||||
fprintf (procedural_db_out, "\"");
|
||||
while (*string)
|
||||
{
|
||||
switch (*string)
|
||||
{
|
||||
case '\\' : fprintf (procedural_db_out, "\\\\"); break;
|
||||
case '\"' : fprintf (procedural_db_out, "\\\""); break;
|
||||
case '{' : fprintf (procedural_db_out, "@{"); break;
|
||||
case '@' : fprintf (procedural_db_out, "@@"); break;
|
||||
case '}' : fprintf (procedural_db_out, "@}"); break;
|
||||
default:
|
||||
fprintf (procedural_db_out, "%c", *string);
|
||||
}
|
||||
string++;
|
||||
}
|
||||
fprintf (procedural_db_out, "\"\n");
|
||||
}
|
||||
|
||||
static void
|
||||
procedural_db_print_entry (gpointer key,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
int i;
|
||||
ProcRecord *procedure;
|
||||
GList *list = (GList *) value;
|
||||
int num = 0;
|
||||
GString *buf = g_string_new ("");
|
||||
|
||||
while (list)
|
||||
{
|
||||
num++;
|
||||
procedure = (ProcRecord*) list->data;
|
||||
list = list->next;
|
||||
|
||||
fprintf (procedural_db_out, "\n(register-procedure ");
|
||||
|
||||
if (list || num != 1)
|
||||
{
|
||||
g_string_sprintf (buf, "%s <%d>", procedure->name, num);
|
||||
output_string (buf->str);
|
||||
}
|
||||
else
|
||||
output_string (procedure->name);
|
||||
|
||||
output_string (procedure->blurb);
|
||||
output_string (procedure->help);
|
||||
output_string (procedure->author);
|
||||
output_string (procedure->copyright);
|
||||
output_string (procedure->date);
|
||||
output_string (proc_type_str[(int) procedure->proc_type]);
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
for (i = 0; i < procedure->num_args; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
|
||||
output_string (procedure->args[i].name );
|
||||
output_string (type_str[procedure->args[i].arg_type]);
|
||||
output_string (procedure->args[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
|
||||
fprintf (procedural_db_out, "( ");
|
||||
for (i = 0; i < procedure->num_values; i++)
|
||||
{
|
||||
fprintf (procedural_db_out, "( ");
|
||||
output_string (procedure->values[i].name );
|
||||
output_string (type_str[procedure->values[i].arg_type]);
|
||||
output_string (procedure->values[i].description);
|
||||
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
}
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
fprintf (procedural_db_out, " ) ");
|
||||
}
|
||||
|
||||
g_string_free (buf, TRUE);
|
||||
}
|
||||
|
||||
/* This really doesn't belong here, but it depends on your generated type_str
|
||||
* array.
|
||||
*/
|
||||
const char *
|
||||
pdb_type_name (gint type)
|
||||
{
|
||||
if (type >= 0 && type <= PDB_END)
|
||||
return type_str[type];
|
||||
else
|
||||
return g_strdup_printf ("(PDB type %d unknown)", type);
|
||||
/* Yeah, we leak the memory. But then you shouldn't try and
|
||||
* get the name of a PDB type that doesn't exist, should you.
|
||||
*/
|
||||
}
|
||||
|
||||
static Argument *
|
||||
procedural_db_dump_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *filename;
|
||||
|
||||
filename = (gchar *) args[0].value.pdb_pointer;
|
||||
if (filename == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if ((procedural_db_out = fopen (filename, "w")))
|
||||
{
|
||||
g_hash_table_foreach (procedural_ht, procedural_db_print_entry, NULL);
|
||||
fclose (procedural_db_out);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&procedural_db_dump_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_dump_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"filename",
|
||||
"The dump filename"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_dump_proc =
|
||||
{
|
||||
"gimp_procedural_db_dump",
|
||||
"Dumps the current contents of the procedural database",
|
||||
"This procedure dumps the contents of the procedural database to the specified file. The file will contain all of the information provided for each registered procedure. This file is in a format appropriate for use with the supplied \"pdb_self_doc.el\" Elisp script, which generates a texinfo document.",
|
||||
"Spencer Kimball & Josh MacDonald",
|
||||
"Spencer Kimball & Josh MacDonald & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
procedural_db_dump_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { procedural_db_dump_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_query_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *name;
|
||||
gchar *blurb;
|
||||
gchar *help;
|
||||
gchar *author;
|
||||
gchar *copyright;
|
||||
gchar *date;
|
||||
gchar *proc_type;
|
||||
PDBQuery pdb_query;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
blurb = (gchar *) args[1].value.pdb_pointer;
|
||||
if (blurb == NULL)
|
||||
success = FALSE;
|
||||
|
||||
help = (gchar *) args[2].value.pdb_pointer;
|
||||
if (help == NULL)
|
||||
success = FALSE;
|
||||
|
||||
author = (gchar *) args[3].value.pdb_pointer;
|
||||
if (author == NULL)
|
||||
success = FALSE;
|
||||
|
||||
copyright = (gchar *) args[4].value.pdb_pointer;
|
||||
if (copyright == NULL)
|
||||
success = FALSE;
|
||||
|
||||
date = (gchar *) args[5].value.pdb_pointer;
|
||||
if (date == NULL)
|
||||
success = FALSE;
|
||||
|
||||
proc_type = (gchar *) args[6].value.pdb_pointer;
|
||||
if (proc_type == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
regcomp (&pdb_query.name_regex, name, 0);
|
||||
regcomp (&pdb_query.blurb_regex, blurb, 0);
|
||||
regcomp (&pdb_query.help_regex, help, 0);
|
||||
regcomp (&pdb_query.author_regex, author, 0);
|
||||
regcomp (&pdb_query.copyright_regex, copyright, 0);
|
||||
regcomp (&pdb_query.date_regex, date, 0);
|
||||
regcomp (&pdb_query.proc_type_regex, proc_type, 0);
|
||||
|
||||
pdb_query.list_of_procs = NULL;
|
||||
pdb_query.num_procs = 0;
|
||||
|
||||
g_hash_table_foreach (procedural_ht, procedural_db_query_entry, &pdb_query);
|
||||
|
||||
free (pdb_query.name_regex.buffer);
|
||||
free (pdb_query.blurb_regex.buffer);
|
||||
free (pdb_query.help_regex.buffer);
|
||||
free (pdb_query.author_regex.buffer);
|
||||
free (pdb_query.copyright_regex.buffer);
|
||||
free (pdb_query.date_regex.buffer);
|
||||
free (pdb_query.proc_type_regex.buffer);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_query_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = pdb_query.num_procs;
|
||||
return_args[2].value.pdb_pointer = pdb_query.list_of_procs;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_query_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"name",
|
||||
"The regex for procedure name"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"blurb",
|
||||
"The regex for procedure blurb"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"help",
|
||||
"The regex for procedure help"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"author",
|
||||
"The regex for procedure author"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"copyright",
|
||||
"The regex for procedure copyright"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"date",
|
||||
"The regex for procedure date"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"proc_type",
|
||||
"The regex for procedure type: { 'Internal GIMP procedure', 'GIMP Plug-in', 'GIMP Extension' }"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_query_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_matches",
|
||||
"The number of matching procedures"
|
||||
},
|
||||
{
|
||||
PDB_STRINGARRAY,
|
||||
"procedure_names",
|
||||
"The list of procedure names"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_query_proc =
|
||||
{
|
||||
"gimp_procedural_db_query",
|
||||
"Queries the procedural database for its contents using regular expression matching.",
|
||||
"This procedure queries the contents of the procedural database. It is supplied with seven arguments matching procedures on { name, blurb, help, author, copyright, date, procedure type}. This is accomplished using regular expression matching. For instance, to find all procedures with \"jpeg\" listed in the blurb, all seven arguments can be supplied as \".*\", except for the second, which can be supplied as \".*jpeg.*\". There are two return arguments for this procedure. The first is the number of procedures matching the query. The second is a concatenated list of procedure names corresponding to those matching the query. If no matching entries are found, then the returned string is NULL and the number of entries is 0.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
7,
|
||||
procedural_db_query_inargs,
|
||||
2,
|
||||
procedural_db_query_outargs,
|
||||
{ { procedural_db_query_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_proc_info_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *proc_name;
|
||||
ProcRecord *proc = NULL;
|
||||
|
||||
proc_name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (proc_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = (proc = procedural_db_lookup (proc_name)) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_proc_info_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_pointer = g_strdup (proc->blurb);
|
||||
return_args[2].value.pdb_pointer = g_strdup (proc->help);
|
||||
return_args[3].value.pdb_pointer = g_strdup (proc->author);
|
||||
return_args[4].value.pdb_pointer = g_strdup (proc->copyright);
|
||||
return_args[5].value.pdb_pointer = g_strdup (proc->date);
|
||||
return_args[6].value.pdb_int = proc->proc_type;
|
||||
return_args[7].value.pdb_int = proc->num_args;
|
||||
return_args[8].value.pdb_int = proc->num_values;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_proc_info_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"procedure",
|
||||
"The procedure name"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_proc_info_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"blurb",
|
||||
"A short blurb"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"help",
|
||||
"Detailed procedure help"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"author",
|
||||
"Author(s) of the procedure"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"copyright",
|
||||
"The copyright"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"date",
|
||||
"Copyright date"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"proc_type",
|
||||
"The procedure type: { INTERNAL (0), PLUGIN (1), EXTENSION (2) }"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_args",
|
||||
"The number of input arguments"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"num_values",
|
||||
"The number of return values"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_proc_info_proc =
|
||||
{
|
||||
"gimp_procedural_db_proc_info",
|
||||
"Queries the procedural database for information on the specified procedure.",
|
||||
"This procedure returns information on the specified procedure. A short blurb, detailed help, author(s), copyright information, procedure type, number of input, and number of return values are returned. For specific information on each input argument and return value, use the 'gimp_procedural_db_query_proc_arg' and 'gimp_procedural_db_query_proc_val' procedures.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
procedural_db_proc_info_inargs,
|
||||
8,
|
||||
procedural_db_proc_info_outargs,
|
||||
{ { procedural_db_proc_info_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_proc_arg_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *proc_name;
|
||||
gint32 arg_num;
|
||||
ProcRecord *proc;
|
||||
ProcArg *arg = NULL;
|
||||
|
||||
proc_name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (proc_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
arg_num = args[1].value.pdb_int;
|
||||
|
||||
if (success)
|
||||
{
|
||||
proc = procedural_db_lookup (proc_name);
|
||||
if (proc && (arg_num >= 0 && arg_num < proc->num_args))
|
||||
arg = &proc->args[arg_num];
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_proc_arg_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = arg->arg_type;
|
||||
return_args[2].value.pdb_pointer = g_strdup (arg->name);
|
||||
return_args[3].value.pdb_pointer = g_strdup (arg->description);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_proc_arg_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"procedure",
|
||||
"The procedure name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"arg_num",
|
||||
"The argument number"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_proc_arg_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"arg_type",
|
||||
"The type of argument { PDB_INT32 (0), PDB_INT16 (1), PDB_INT8 (2), PDB_FLOAT (3), PDB_STRING (4), PDB_INT32ARRAY (5), PDB_INT16ARRAY (6), PDB_INT8ARRAY (7), PDB_FLOATARRAY (8), PDB_STRINGARRAY (9), PDB_COLOR (10), PDB_REGION (11), PDB_DISPLAY (12), PDB_IMAGE (13), PDB_LAYER (14), PDB_CHANNEL (15), PDB_DRAWABLE (16), PDB_SELECTION (17), PDB_BOUNDARY (18), PDB_PATH (19), PDB_PARASITE (20), PDB_STATUS (21) }"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"arg_name",
|
||||
"The name of the argument"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"arg_desc",
|
||||
"A description of the argument"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_proc_arg_proc =
|
||||
{
|
||||
"gimp_procedural_db_proc_arg",
|
||||
"Queries the procedural database for information on the specified procedure's argument.",
|
||||
"This procedure returns information on the specified procedure's argument. The argument type, name, and a description are retrieved.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
procedural_db_proc_arg_inargs,
|
||||
3,
|
||||
procedural_db_proc_arg_outargs,
|
||||
{ { procedural_db_proc_arg_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_proc_val_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *proc_name;
|
||||
gint32 val_num;
|
||||
ProcRecord *proc;
|
||||
ProcArg *val = NULL;
|
||||
|
||||
proc_name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (proc_name == NULL)
|
||||
success = FALSE;
|
||||
|
||||
val_num = args[1].value.pdb_int;
|
||||
|
||||
if (success)
|
||||
{
|
||||
proc = procedural_db_lookup (proc_name);
|
||||
if (proc && (val_num >= 0 && val_num < proc->num_values))
|
||||
val = &proc->values[val_num];
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_proc_val_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = val->arg_type;
|
||||
return_args[2].value.pdb_pointer = g_strdup (val->name);
|
||||
return_args[3].value.pdb_pointer = g_strdup (val->description);
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_proc_val_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"procedure",
|
||||
"The procedure name"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"val_num",
|
||||
"The return value number"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_proc_val_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"val_type",
|
||||
"The type of return value { PDB_INT32 (0), PDB_INT16 (1), PDB_INT8 (2), PDB_FLOAT (3), PDB_STRING (4), PDB_INT32ARRAY (5), PDB_INT16ARRAY (6), PDB_INT8ARRAY (7), PDB_FLOATARRAY (8), PDB_STRINGARRAY (9), PDB_COLOR (10), PDB_REGION (11), PDB_DISPLAY (12), PDB_IMAGE (13), PDB_LAYER (14), PDB_CHANNEL (15), PDB_DRAWABLE (16), PDB_SELECTION (17), PDB_BOUNDARY (18), PDB_PATH (19), PDB_PARASITE (20), PDB_STATUS (21) }"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"val_name",
|
||||
"The name of the return value"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"val_desc",
|
||||
"A description of the return value"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_proc_val_proc =
|
||||
{
|
||||
"gimp_procedural_db_proc_val",
|
||||
"Queries the procedural database for information on the specified procedure's return value.",
|
||||
"This procedure returns information on the specified procedure's return value. The return value type, name, and a description are retrieved.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
procedural_db_proc_val_inargs,
|
||||
3,
|
||||
procedural_db_proc_val_outargs,
|
||||
{ { procedural_db_proc_val_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_get_data_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *identifier;
|
||||
gint8 *data_copy = NULL;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
data_copy = g_new (char, data->bytes);
|
||||
memcpy (data_copy, data->data, data->bytes);
|
||||
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_get_data_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
return_args[1].value.pdb_int = data->bytes;
|
||||
return_args[2].value.pdb_pointer = data_copy;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_get_data_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"identifier",
|
||||
"The identifier associated with data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_get_data_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"bytes",
|
||||
"The number of bytes in the data"
|
||||
},
|
||||
{
|
||||
PDB_INT8ARRAY,
|
||||
"data",
|
||||
"A byte array containing data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_get_data_proc =
|
||||
{
|
||||
"gimp_procedural_db_get_data",
|
||||
"Returns data associated with the specified identifier.",
|
||||
"This procedure returns any data which may have been associated with the specified identifier. The data is a variable length array of bytes. If no data has been associated with the identifier, an error is returned.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
procedural_db_get_data_inargs,
|
||||
2,
|
||||
procedural_db_get_data_outargs,
|
||||
{ { procedural_db_get_data_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_get_data_size_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *identifier;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
success = FALSE;
|
||||
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
data = (PDBData *) list->data;
|
||||
list = list->next;
|
||||
|
||||
if (!strcmp (data->identifier, identifier))
|
||||
{
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&procedural_db_get_data_size_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = data->bytes;
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_get_data_size_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"identifier",
|
||||
"The identifier associated with data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg procedural_db_get_data_size_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_INT32,
|
||||
"bytes",
|
||||
"The number of bytes in the data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_get_data_size_proc =
|
||||
{
|
||||
"gimp_procedural_db_get_data_size",
|
||||
"Returns size of data associated with the specified identifier.",
|
||||
"This procedure returns the size of any data which may have been associated with the specified identifier. If no data has been associated with the identifier, an error is returned.",
|
||||
"Nick Lamb",
|
||||
"Nick Lamb",
|
||||
"1998",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
procedural_db_get_data_size_inargs,
|
||||
1,
|
||||
procedural_db_get_data_size_outargs,
|
||||
{ { procedural_db_get_data_size_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
procedural_db_set_data_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *identifier;
|
||||
gint32 bytes;
|
||||
gint8 *data_src;
|
||||
PDBData *data = NULL;
|
||||
GList *list;
|
||||
|
||||
identifier = (gchar *) args[0].value.pdb_pointer;
|
||||
if (identifier == NULL)
|
||||
success = FALSE;
|
||||
|
||||
bytes = args[1].value.pdb_int;
|
||||
if (bytes <= 0)
|
||||
success = FALSE;
|
||||
|
||||
data_src = (gint8 *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
{
|
||||
list = data_list;
|
||||
while (list)
|
||||
{
|
||||
if (!strcmp (((PDBData *) list->data)->identifier, identifier))
|
||||
data = (PDBData *) list->data;
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
/* If there isn't already data with the specified identifier, create one */
|
||||
if (data == NULL)
|
||||
{
|
||||
data = (PDBData *) g_new (PDBData, 1);
|
||||
data_list = g_list_append (data_list, data);
|
||||
}
|
||||
else
|
||||
g_free (data->data);
|
||||
|
||||
data->identifier = g_strdup (identifier);
|
||||
data->bytes = bytes;
|
||||
data->data = g_new (char, data->bytes);
|
||||
memcpy (data->data, (char *) data_src, data->bytes);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&procedural_db_set_data_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg procedural_db_set_data_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"identifier",
|
||||
"The identifier associated with data"
|
||||
},
|
||||
{
|
||||
PDB_INT32,
|
||||
"bytes",
|
||||
"The number of bytes in the data"
|
||||
},
|
||||
{
|
||||
PDB_INT8ARRAY,
|
||||
"data",
|
||||
"A byte array containing data"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord procedural_db_set_data_proc =
|
||||
{
|
||||
"gimp_procedural_db_set_data",
|
||||
"Associates the specified identifier with the supplied data.",
|
||||
"This procedure associates the supplied data with the provided identifier. The data may be subsequently retrieved by a call to 'procedural-db-get-data'.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
3,
|
||||
procedural_db_set_data_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { procedural_db_set_data_invoker } }
|
||||
};
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "drawable.h"
|
||||
#include "layer.h"
|
||||
#include "text_tool.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static ProcRecord text_fontname_proc;
|
||||
static ProcRecord text_get_extents_fontname_proc;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "blend.h"
|
||||
#include "bucket_fill.h"
|
||||
#include "by_color_select.h"
|
||||
#include "channel.h"
|
||||
#include "clone.h"
|
||||
#include "color_picker.h"
|
||||
#include "convolve.h"
|
||||
|
@ -34,6 +35,8 @@
|
|||
#include "flip_tool.h"
|
||||
#include "free_select.h"
|
||||
#include "fuzzy_select.h"
|
||||
#include "paint_core.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "paintbrush.h"
|
||||
#include "pencil.h"
|
||||
#include "perspective_tool.h"
|
||||
|
@ -893,7 +896,7 @@ crop_invoker (Argument *args)
|
|||
success = FALSE;
|
||||
else
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
FALSE, FALSE);
|
||||
FALSE, TRUE);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&crop_proc, success);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "layer.h"
|
||||
#include "paint_core.h"
|
||||
#include "paint_funcs.h"
|
||||
#include "parasitelist.h"
|
||||
#include "tools.h"
|
||||
#include "transform_core.h"
|
||||
#include "undo.h"
|
||||
|
@ -2253,7 +2254,6 @@ undo_pop_parasite (GImage *gimage,
|
|||
{
|
||||
ParasiteUndo *data;
|
||||
Parasite *tmp;
|
||||
int tmp_ref;
|
||||
|
||||
data = data_ptr;
|
||||
|
||||
|
|
|
@ -381,19 +381,11 @@ static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
|||
|
||||
static char *build_user_filename(char *name, char *path_str);
|
||||
|
||||
/* Procedural database functions */
|
||||
|
||||
static Argument *gradients_get_list_invoker(Argument *args);
|
||||
static Argument *gradients_get_active_invoker(Argument *args);
|
||||
static Argument *gradients_set_active_invoker(Argument *args);
|
||||
static Argument *gradients_sample_uniform_invoker(Argument *args);
|
||||
static Argument *gradients_sample_custom_invoker(Argument *args);
|
||||
|
||||
|
||||
/***** Local variables *****/
|
||||
|
||||
GdkColor black;
|
||||
static int num_gradients = 0;
|
||||
int num_gradients = 0;
|
||||
gradient_t *curr_gradient = NULL; /* The active gradient */
|
||||
GSList *gradients_list = NULL; /* The list of gradients */
|
||||
gradient_t *grad_default_gradient = NULL;
|
||||
|
@ -5999,175 +5991,6 @@ build_user_filename(char *name, char *path_str)
|
|||
} /* build_user_filename */
|
||||
|
||||
|
||||
/***** Procedural database declarations and functions *****/
|
||||
|
||||
/***** gradients_get_list *****/
|
||||
|
||||
ProcArg gradients_get_list_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_gradients",
|
||||
"The number of loaded gradients"
|
||||
},
|
||||
{ PDB_STRINGARRAY,
|
||||
"gradient_names",
|
||||
"The list of gradient names"
|
||||
}
|
||||
}; /* gradients_get_list_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_list_proc = {
|
||||
"gimp_gradients_get_list",
|
||||
"Retrieve the list of loaded gradients",
|
||||
"This procedure returns a list of the gradients that are currently loaded "
|
||||
"in the gradient editor. You can later use the gimp_gradients_set_active "
|
||||
"function to set the active gradient.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_list_out_args) / sizeof(gradients_get_list_out_args[0]),
|
||||
gradients_get_list_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_list_invoker } }
|
||||
}; /* gradients_get_list_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_get_list_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gradient_t *grad;
|
||||
GSList *list;
|
||||
char **gradients;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
gradients = g_malloc(sizeof(char *) * num_gradients);
|
||||
|
||||
list = gradients_list;
|
||||
|
||||
success = (list != NULL);
|
||||
|
||||
i = 0;
|
||||
|
||||
while (list) {
|
||||
grad = list->data;
|
||||
gradients[i++] = g_strdup(grad->name);
|
||||
list = g_slist_next(list);
|
||||
} /* while */
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_list_proc, success);
|
||||
|
||||
if (success) {
|
||||
return_args[1].value.pdb_int = num_gradients;
|
||||
return_args[2].value.pdb_pointer = gradients;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_list_invoker */
|
||||
|
||||
|
||||
/***** gradients_get_active *****/
|
||||
|
||||
ProcArg gradients_get_active_out_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the active gradient"
|
||||
}
|
||||
}; /* gradients_get_active_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_get_active_proc = {
|
||||
"gimp_gradients_get_active",
|
||||
"Retrieve the name of the active gradient",
|
||||
"This procedure returns the name of the active gradient in hte gradient editor.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_get_active_out_args) / sizeof(gradients_get_active_out_args[0]),
|
||||
gradients_get_active_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_get_active_invoker } }
|
||||
}; /* gradients_get_active_proc */
|
||||
|
||||
|
||||
Argument *
|
||||
gradients_get_active_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success;
|
||||
|
||||
success = (curr_gradient != NULL);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_get_active_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup(curr_gradient->name);
|
||||
|
||||
return return_args;
|
||||
} /* gradients_get_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_set_active *****/
|
||||
|
||||
ProcArg gradients_set_active_args[] = {
|
||||
{ PDB_STRING,
|
||||
"name",
|
||||
"The name of the gradient to set"
|
||||
}
|
||||
}; /* gradients_set_active_args */
|
||||
|
||||
|
||||
ProcRecord gradients_set_active_proc = {
|
||||
"gimp_gradients_set_active",
|
||||
"Sets the specified gradient as the active gradient",
|
||||
"This procedure lets you set the specified gradient as the active "
|
||||
"or \"current\" one. The name is simply a string which corresponds "
|
||||
"to one of the loaded gradients in the gradient editor. If no "
|
||||
"matching gradient is found, this procedure will return an error. "
|
||||
"Otherwise, the specified gradient will become active and will be used "
|
||||
"for subsequent custom gradient operations.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_set_active_args) / sizeof(gradients_set_active_args[0]),
|
||||
gradients_set_active_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_set_active_invoker } }
|
||||
}; /* gradients_set_active_proc */
|
||||
|
||||
gint
|
||||
grad_set_grad_to_name(gchar *name)
|
||||
{
|
||||
|
@ -6208,216 +6031,3 @@ grad_set_grad_to_name(gchar *name)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_set_active_invoker(Argument *args)
|
||||
{
|
||||
char *name;
|
||||
int success;
|
||||
|
||||
name = args[0].value.pdb_pointer;
|
||||
|
||||
success = (name != NULL);
|
||||
|
||||
if (success) {
|
||||
/* See if we have a gradient with the specified name */
|
||||
success = grad_set_grad_to_name(name);
|
||||
} /* if */
|
||||
|
||||
return procedural_db_return_args(&gradients_set_active_proc, success);
|
||||
} /* gradients_set_active_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_uniform *****/
|
||||
|
||||
ProcArg gradients_sample_uniform_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
}
|
||||
}; /* gradients_sample_uniform_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_uniform_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_uniform_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_uniform_proc = {
|
||||
"gimp_gradients_sample_uniform",
|
||||
"Sample the active gradient in uniform parts",
|
||||
"This procedure samples the active gradient from the gradient editor in the "
|
||||
"specified number of uniform parts. It returns a list of floating-point values "
|
||||
"which correspond to the RGBA values for each sample. The minimum number of "
|
||||
"samples to take is 2, in which case the returned colors will correspond to the "
|
||||
"{ 0.0, 1.0 } positions in the gradient. For example, if the number of samples "
|
||||
"is 3, the procedure will return the colors at positions { 0.0, 0.5, 1.0 }.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_args) / sizeof(gradients_sample_uniform_args[0]),
|
||||
gradients_sample_uniform_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_uniform_out_args) / sizeof(gradients_sample_uniform_out_args[0]),
|
||||
gradients_sample_uniform_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_uniform_invoker } }
|
||||
}; /* gradients_sample_uniform_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_uniform_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
double pos, delta;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i >= 2);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_uniform_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = 0.0;
|
||||
delta = 1.0 / (i - 1);
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos += delta;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_uniform_invoker */
|
||||
|
||||
|
||||
/***** gradients_sample_custom *****/
|
||||
|
||||
ProcArg gradients_sample_custom_args[] = {
|
||||
{ PDB_INT32,
|
||||
"num_samples",
|
||||
"The number of samples to take"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"positions",
|
||||
"The list of positions to sample along the gradient"
|
||||
}
|
||||
}; /* gradients_sample_custom_args */
|
||||
|
||||
|
||||
ProcArg gradients_sample_custom_out_args[] = {
|
||||
{ PDB_INT32,
|
||||
"array_length",
|
||||
"Length of the color_samples array (4 * num_samples)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"color_samples",
|
||||
"Color samples: { R1, G1, B1, A1, ..., Rn, Gn, Bn, An }"
|
||||
}
|
||||
}; /* gradients_sample_custom_out_args */
|
||||
|
||||
|
||||
ProcRecord gradients_sample_custom_proc = {
|
||||
"gimp_gradients_sample_custom",
|
||||
"Sample the active gradient in custom positions",
|
||||
"This procedure samples the active gradient from the gradient editor in "
|
||||
"the specified number of points. The procedure will sample the gradient "
|
||||
"in the specified positions from the list. The left endpoint of the "
|
||||
"gradient corresponds to position 0.0, and the right endpoint corresponds "
|
||||
"to 1.0. The procedure returns a list of floating-point values which "
|
||||
"correspond to the RGBA values for each sample.",
|
||||
"Federico Mena Quintero",
|
||||
"Federico Mena Quintero",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_args) / sizeof(gradients_sample_custom_args[0]),
|
||||
gradients_sample_custom_args,
|
||||
|
||||
/* Output arguments */
|
||||
|
||||
sizeof(gradients_sample_custom_out_args) / sizeof(gradients_sample_custom_out_args[0]),
|
||||
gradients_sample_custom_out_args,
|
||||
|
||||
/* Exec method */
|
||||
|
||||
{ { gradients_sample_custom_invoker } }
|
||||
}; /* gradients_sample_custom_proc */
|
||||
|
||||
|
||||
static Argument *
|
||||
gradients_sample_custom_invoker(Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
gdouble *values, *pv;
|
||||
gdouble *pos;
|
||||
double r, g, b, a;
|
||||
int i;
|
||||
int success;
|
||||
|
||||
i = args[0].value.pdb_int;
|
||||
|
||||
success = (i > 0);
|
||||
|
||||
return_args = procedural_db_return_args(&gradients_sample_custom_proc, success);
|
||||
|
||||
if (success) {
|
||||
pos = args[1].value.pdb_pointer;
|
||||
|
||||
values = g_malloc(i * 4 * sizeof(gdouble));
|
||||
pv = values;
|
||||
|
||||
return_args[1].value.pdb_int = i * 4;
|
||||
|
||||
while (i--) {
|
||||
grad_get_color_at(*pos, &r, &g, &b, &a);
|
||||
|
||||
*pv++ = r;
|
||||
*pv++ = g;
|
||||
*pv++ = b;
|
||||
*pv++ = a;
|
||||
|
||||
pos++;
|
||||
} /* while */
|
||||
|
||||
return_args[2].value.pdb_pointer = values;
|
||||
} /* if */
|
||||
|
||||
return return_args;
|
||||
} /* gradients_sample_custom_invoker */
|
||||
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
#ifndef _GRADIENT_H_
|
||||
#define _GRADIENT_H_
|
||||
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
void gradients_init(int no_data);
|
||||
void gradients_free(void);
|
||||
|
||||
|
@ -38,17 +32,4 @@ void grad_create_gradient_editor(void);
|
|||
void grad_free_gradient_editor(void);
|
||||
void gradients_check_dialogs(void);
|
||||
|
||||
|
||||
/***** Procedural database exports *****/
|
||||
|
||||
extern ProcRecord gradients_get_list_proc;
|
||||
extern ProcRecord gradients_get_active_proc;
|
||||
extern ProcRecord gradients_set_active_proc;
|
||||
extern ProcRecord gradients_sample_uniform_proc;
|
||||
extern ProcRecord gradients_sample_custom_proc;
|
||||
extern ProcRecord gradients_close_popup_proc;
|
||||
extern ProcRecord gradients_set_popup_proc;
|
||||
extern ProcRecord gradients_popup_proc;
|
||||
extern ProcRecord gradients_get_gradient_data_proc;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,7 +125,7 @@ HELP
|
|||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ HELP
|
|||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) || (num_points & 1) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -421,7 +421,7 @@ HELP
|
|||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) || (num_bytes != 256) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
@ -593,7 +593,7 @@ HELP
|
|||
code => <<'CODE'
|
||||
{
|
||||
if (gimp_drawable_indexed (drawable) ||
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY))
|
||||
(gimp_drawable_gray (drawable) && channel != GRAY_LUT))
|
||||
success = FALSE;
|
||||
else
|
||||
{
|
||||
|
|
|
@ -441,7 +441,7 @@ HELP
|
|||
success = FALSE;
|
||||
else
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
FALSE, FALSE);
|
||||
FALSE, TRUE);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
|
@ -441,7 +441,7 @@ HELP
|
|||
success = FALSE;
|
||||
else
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
FALSE, FALSE);
|
||||
FALSE, TRUE);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
|
@ -356,6 +356,7 @@ HELP
|
|||
|
||||
@inargs = ( &data_ident_arg, &data_arg );
|
||||
$inargs[1]->{alias} = 'data_src';
|
||||
delete @{$inargs[1]->{array}}{qw(alias no_declare)};
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'PDBData *data = NULL', 'GList *list' ],
|
||||
|
@ -380,6 +381,7 @@ HELP
|
|||
g_free (data->data);
|
||||
|
||||
data->identifier = g_strdup (identifier);
|
||||
data->bytes = bytes;
|
||||
data->data = g_new (char, data->bytes);
|
||||
memcpy (data->data, (char *) data_src, data->bytes);
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ HELP
|
|||
success = FALSE;
|
||||
else
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
FALSE, FALSE);
|
||||
FALSE, TRUE);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
|
@ -441,7 +441,7 @@ HELP
|
|||
success = FALSE;
|
||||
else
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
FALSE, FALSE);
|
||||
FALSE, TRUE);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue