Commit 5b076e99 authored by Michael Natterer's avatar Michael Natterer 😴

libgimp: remove legacy support from gimpbrush,pattern,..select.c

Their users have all been ported to GimpPlugIn.
parent 30c3fd4d
......@@ -43,23 +43,12 @@ typedef struct
/* local function prototypes */
static void gimp_brush_data_free (GimpBrushData *data);
static void gimp_brush_data_free (GimpBrushData *data);
static void gimp_temp_brush_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpValueArray *
gimp_temp_brush_run_func (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_brush_run_idle (GimpBrushData *brush_data);
/* private variables */
static GHashTable *gimp_brush_select_ht = NULL;
static GimpValueArray * gimp_temp_brush_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_brush_idle (GimpBrushData *data);
/* public functions */
......@@ -75,13 +64,11 @@ gimp_brush_select_new (const gchar *title,
GDestroyNotify data_destroy)
{
GimpPlugIn *plug_in = gimp_get_plug_in ();
GimpProcedure *procedure;
gchar *brush_callback;
GimpBrushData *brush_data;
if (plug_in)
brush_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
else
brush_callback = gimp_pdb_temp_name ();
brush_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
brush_data = g_slice_new0 (GimpBrushData);
......@@ -90,145 +77,85 @@ gimp_brush_select_new (const gchar *title,
brush_data->data = data;
brush_data->data_destroy = data_destroy;
if (plug_in)
{
GimpProcedure *procedure = gimp_procedure_new (plug_in,
brush_callback,
GIMP_TEMPORARY,
gimp_temp_brush_run_func,
brush_data,
(GDestroyNotify)
gimp_brush_data_free);
gimp_procedure_add_argument (procedure,
g_param_spec_string ("brush-name",
"Brush name",
"The brush name",
NULL,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("opacity",
"Opacity",
NULL,
0.0, 1.0, 1.0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spacing",
"Spacing",
NULL,
-1, 1000, 20,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("paint-mode",
"Paint mode",
NULL,
GIMP_TYPE_LAYER_MODE,
GIMP_LAYER_MODE_NORMAL,
procedure = gimp_procedure_new (plug_in,
brush_callback,
GIMP_TEMPORARY,
gimp_temp_brush_run,
brush_data,
(GDestroyNotify)
gimp_brush_data_free);
gimp_procedure_add_argument (procedure,
g_param_spec_string ("brush-name",
"Brush name",
"The brush name",
NULL,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("opacity",
"Opacity",
NULL,
0.0, 1.0, 1.0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("spacing",
"Spacing",
NULL,
-1, 1000, 20,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("paint-mode",
"Paint mode",
NULL,
GIMP_TYPE_LAYER_MODE,
GIMP_LAYER_MODE_NORMAL,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("mask-width",
"Brush width",
NULL,
0, 10000, 0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("mask-height",
"Brush height",
NULL,
0, 10000, 0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("mask-len",
"Mask length",
"Length of brush "
"mask data",
0, G_MAXINT, 0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("mask-width",
"Brush width",
NULL,
0, 10000, 0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("mask-height",
"Brush height",
NULL,
0, 10000, 0,
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8_array ("mask-data",
"Mask data",
"The brush mask "
"data",
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("closing",
"Closing",
"If the dialog was "
"cloaing",
FALSE,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("mask-len",
"Mask length",
"Length of brush "
"mask data",
0, G_MAXINT, 0,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8_array ("mask-data",
"Mask data",
"The brush mask "
"data",
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("closing",
"Closing",
"If the dialog was "
"cloaing",
FALSE,
G_PARAM_READWRITE));
gimp_plug_in_add_temp_procedure (plug_in, procedure);
g_object_unref (procedure);
}
else
{
static const GimpParamDef args[] =
{
{ GIMP_PDB_STRING, "str", "String" },
{ GIMP_PDB_FLOAT, "opacity", "Opacity" },
{ GIMP_PDB_INT32, "spacing", "Spacing" },
{ GIMP_PDB_INT32, "paint mode", "Paint mode" },
{ GIMP_PDB_INT32, "mask width", "Brush width" },
{ GIMP_PDB_INT32, "mask height" "Brush height" },
{ GIMP_PDB_INT32, "mask len", "Length of brush mask data" },
{ GIMP_PDB_INT8ARRAY, "mask data", "The brush mask data" },
{ GIMP_PDB_INT32, "dialog status", "If the dialog was closing "
"[0 = No, 1 = Yes]" }
};
gimp_install_temp_proc (brush_callback,
"Temporary brush popup callback procedure",
"",
"",
"",
"",
NULL,
"",
GIMP_TEMPORARY,
G_N_ELEMENTS (args), 0,
args, NULL,
gimp_temp_brush_run);
}
gimp_plug_in_add_temp_procedure (plug_in, procedure);
g_object_unref (procedure);
if (gimp_brushes_popup (brush_callback, title, brush_name,
opacity, spacing, paint_mode))
{
/* Allow callbacks to be watched */
if (plug_in)
{
gimp_plug_in_extension_enable (plug_in);
}
else
{
gimp_extension_enable ();
/* Now add to hash table so we can find it again */
if (! gimp_brush_select_ht)
{
gimp_brush_select_ht =
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) gimp_brush_data_free);
}
g_hash_table_insert (gimp_brush_select_ht,
g_strdup (brush_callback),
brush_data);
}
gimp_plug_in_extension_enable (plug_in);
return brush_callback;
}
if (plug_in)
{
gimp_plug_in_remove_temp_procedure (plug_in, brush_callback);
}
else
{
gimp_uninstall_temp_proc (brush_callback);
gimp_brush_data_free (brush_data);
}
gimp_plug_in_remove_temp_procedure (plug_in, brush_callback);
return NULL;
}
......@@ -240,28 +167,7 @@ gimp_brush_select_destroy (const gchar *brush_callback)
g_return_if_fail (brush_callback != NULL);
if (plug_in)
{
gimp_plug_in_remove_temp_procedure (plug_in, brush_callback);
}
else
{
GimpBrushData *brush_data;
g_return_if_fail (gimp_brush_select_ht != NULL);
brush_data = g_hash_table_lookup (gimp_brush_select_ht, brush_callback);
if (! brush_data)
{
g_warning ("Can't find internal brush data");
return;
}
g_hash_table_remove (gimp_brush_select_ht, brush_callback);
gimp_uninstall_temp_proc (brush_callback);
}
gimp_plug_in_remove_temp_procedure (plug_in, brush_callback);
}
......@@ -288,53 +194,10 @@ gimp_brush_data_free (GimpBrushData *data)
g_slice_free (GimpBrushData, data);
}
static void
gimp_temp_brush_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpBrushData *brush_data;
brush_data = g_hash_table_lookup (gimp_brush_select_ht, name);
if (! brush_data)
{
g_warning ("Can't find internal brush data");
}
else
{
g_free (brush_data->brush_name);
g_free (brush_data->brush_mask_data);
brush_data->brush_name = g_strdup (param[0].data.d_string);
brush_data->opacity = param[1].data.d_float;
brush_data->spacing = param[2].data.d_int32;
brush_data->paint_mode = param[3].data.d_int32;
brush_data->width = param[4].data.d_int32;
brush_data->height = param[5].data.d_int32;
brush_data->brush_mask_data = g_memdup (param[7].data.d_int8array,
param[6].data.d_int32);
brush_data->closing = param[8].data.d_int32;
if (! brush_data->idle_id)
brush_data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_brush_run_idle,
brush_data);
}
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
}
static GimpValueArray *
gimp_temp_brush_run_func (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
gimp_temp_brush_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
GimpBrushData *data = run_data;
......@@ -351,33 +214,32 @@ gimp_temp_brush_run_func (GimpProcedure *procedure,
data->closing = g_value_get_boolean (gimp_value_array_index (args, 8));
if (! data->idle_id)
data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_brush_run_idle,
data);
data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_brush_idle, data);
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
}
static gboolean
gimp_temp_brush_run_idle (GimpBrushData *brush_data)
gimp_temp_brush_idle (GimpBrushData *data)
{
brush_data->idle_id = 0;
if (brush_data->callback)
brush_data->callback (brush_data->brush_name,
brush_data->opacity,
brush_data->spacing,
brush_data->paint_mode,
brush_data->width,
brush_data->height,
brush_data->brush_mask_data,
brush_data->closing,
brush_data->data);
if (brush_data->closing)
data->idle_id = 0;
if (data->callback)
data->callback (data->brush_name,
data->opacity,
data->spacing,
data->paint_mode,
data->width,
data->height,
data->brush_mask_data,
data->closing,
data->data);
if (data->closing)
{
gchar *brush_callback = brush_data->brush_callback;
gchar *brush_callback = data->brush_callback;
brush_data->brush_callback = NULL;
data->brush_callback = NULL;
gimp_brush_select_destroy (brush_callback);
g_free (brush_callback);
}
......
......@@ -37,23 +37,12 @@ typedef struct
/* local function prototypes */
static void gimp_font_data_free (GimpFontData *data);
static void gimp_font_data_free (GimpFontData *data);
static void gimp_temp_font_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpValueArray *
gimp_temp_font_run_func (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_font_run_idle (GimpFontData *font_data);
/* private variables */
static GHashTable *gimp_font_select_ht = NULL;
static GimpValueArray * gimp_temp_font_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_font_idle (GimpFontData *data);
/* public functions */
......@@ -65,14 +54,12 @@ gimp_font_select_new (const gchar *title,
gpointer data,
GDestroyNotify data_destroy)
{
GimpPlugIn *plug_in = gimp_get_plug_in ();
gchar *font_callback;
GimpFontData *font_data;
GimpPlugIn *plug_in = gimp_get_plug_in ();
GimpProcedure *procedure;
gchar *font_callback;
GimpFontData *font_data;
if (plug_in)
font_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
else
font_callback = gimp_pdb_temp_name ();
font_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
font_data = g_slice_new0 (GimpFontData);
......@@ -81,93 +68,40 @@ gimp_font_select_new (const gchar *title,
font_data->data = data;
font_data->data_destroy = data_destroy;
if (plug_in)
{
GimpProcedure *procedure = gimp_procedure_new (plug_in,
font_callback,
GIMP_TEMPORARY,
gimp_temp_font_run_func,
font_data,
(GDestroyNotify)
gimp_font_data_free);
gimp_procedure_add_argument (procedure,
g_param_spec_string ("font-name",
"Font name",
"The font name",
NULL,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("closing",
"Closing",
"If the dialog was "
"closing",
FALSE,
G_PARAM_READWRITE));
gimp_plug_in_add_temp_procedure (plug_in, procedure);
g_object_unref (procedure);
}
else
{
static const GimpParamDef args[] =
{
{ GIMP_PDB_STRING, "str", "String" },
{ GIMP_PDB_INT32, "dialog status", "If the dialog was closing "
"[0 = No, 1 = Yes]" }
};
gimp_install_temp_proc (font_callback,
"Temporary font popup callback procedure",
"",
"",
"",
"",
NULL,
"",
GIMP_TEMPORARY,
G_N_ELEMENTS (args), 0,
args, NULL,
gimp_temp_font_run);
}
procedure = gimp_procedure_new (plug_in,
font_callback,
GIMP_TEMPORARY,
gimp_temp_font_run,
font_data,
(GDestroyNotify)
gimp_font_data_free);
gimp_procedure_add_argument (procedure,
g_param_spec_string ("font-name",
"Font name",
"The font name",
NULL,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("closing",
"Closing",
"If the dialog was "
"closing",
FALSE,
G_PARAM_READWRITE));
gimp_plug_in_add_temp_procedure (plug_in, procedure);
g_object_unref (procedure);
if (gimp_fonts_popup (font_callback, title, font_name))
{
/* Allow callbacks to be watched */
if (plug_in)
{
gimp_plug_in_extension_enable (plug_in);
}
else
{
gimp_extension_enable ();
/* Now add to hash table so we can find it again */
if (! gimp_font_select_ht)
{
gimp_font_select_ht =
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free,
(GDestroyNotify) gimp_font_data_free);
}
g_hash_table_insert (gimp_font_select_ht,
g_strdup (font_callback),
font_data);
}
gimp_plug_in_extension_enable (plug_in);
return font_callback;
}
if (plug_in)
{
gimp_plug_in_remove_temp_procedure (plug_in, font_callback);
}
else
{
gimp_uninstall_temp_proc (font_callback);
gimp_font_data_free (font_data);
}
gimp_plug_in_remove_temp_procedure (plug_in, font_callback);
return NULL;
}
......@@ -179,28 +113,7 @@ gimp_font_select_destroy (const gchar *font_callback)
g_return_if_fail (font_callback != NULL);
if (plug_in)
{
gimp_plug_in_remove_temp_procedure (plug_in, font_callback);
}
else
{
GimpFontData *font_data;
g_return_if_fail (gimp_font_select_ht != NULL);
font_data = g_hash_table_lookup (gimp_font_select_ht, font_callback);
if (! font_data)
{
g_warning ("Can't find internal font data");
return;
}
gimp_uninstall_temp_proc (font_callback);
g_hash_table_remove (gimp_font_select_ht, font_callback);
}
gimp_plug_in_remove_temp_procedure (plug_in, font_callback);
}
......@@ -226,45 +139,10 @@ gimp_font_data_free (GimpFontData *data)
g_slice_free (GimpFontData, data);
}
static void
gimp_temp_font_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpFontData *font_data;
font_data = g_hash_table_lookup (gimp_font_select_ht, name);
if (! font_data)
{
g_warning ("Can't find internal font data");
}
else
{
g_free (font_data->font_name);
font_data->font_name = g_strdup (param[0].data.d_string);
font_data->closing = param[1].data.d_int32;
if (! font_data->idle_id)
font_data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_font_run_idle,
font_data);
}
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_SUCCESS;
}
static GimpValueArray *
gimp_temp_font_run_func (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
gimp_temp_font_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
GimpFontData *data = run_data;
......@@ -274,27 +152,27 @@ gimp_temp_font_run_func (GimpProcedure *procedure,
data->closing = g_value_get_boolean (gimp_value_array_index (args, 1));
if (! data->idle_id)
data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_font_run_idle,
data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_font_idle,
data);
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
}
static gboolean
gimp_temp_font_run_idle (GimpFontData *font_data)
gimp_temp_font_idle (GimpFontData *data)
{
font_data->idle_id = 0;
data->idle_id = 0;
if (font_data->callback)
font_data->callback (font_data->font_name,
font_data->closing,
font_data->data);
if (data->callback)
data->callback (data->font_name,
data->closing,
data->data);
if (font_data->closing)
if (data->closing)
{
gchar *font_callback = font_data->font_callback;
gchar *font_callback = data->font_callback;
font_data->font_callback = NULL;
data->font_callback = NULL;
gimp_font_select_destroy (font_callback);
g_free (font_callback);
}
......
......@@ -39,23 +39,12 @@ typedef struct
/* local function prototypes */
static void gimp_gradient_data_free (GimpGradientData *data);
static void gimp_gradient_data_free (GimpGradientData *data);
static void gimp_temp_gradient_run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static GimpValueArray *
gimp_temp_gradient_run_func (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_gradient_run_idle (GimpGradientData *gradient_data);
/* private variables */
static GHashTable *gimp_gradient_select_ht = NULL;
static GimpValueArray * gimp_temp_gradient_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gboolean gimp_temp_gradient_idle (GimpGradientData *data);
/* public functions */
......@@ -69,13 +58,11 @@ gimp_gradient_select_new (const gchar *title,
GDestroyNotify data_destroy)
{
GimpPlugIn *plug_in = gimp_get_plug_in ();
GimpProcedure *procedure;
gchar *gradient_callback;
GimpGradientData *gradient_data;
if (plug_in)
gradient_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
else
gradient_callback = gimp_pdb_temp_name ();
gradient_callback = gimp_pdb_temp_procedure_name (gimp_get_pdb ());
gradient_data = g_slice_new0 (GimpGradientData);
......@@ -84,109 +71,53 @@ gimp_gradient_select_new (const gchar *title,
gradient_data->data = data;
gradient_data->data_destroy = data_destroy;
if (plug_in)
{
GimpProcedure *procedure = gimp_procedure_new (plug_in,
gradient_callback,
GIMP_TEMPORARY,
gimp_temp_gradient_run_func,
gradient_data,
(GDestroyNotify)
gimp_gradient_data_free);
gimp_procedure_add_argument (procedure,
g_param_spec_string ("gradient-name",
"Gradient name",
"The gradient name",
NULL,