plug-ins: Port gimpressionist to gimp_image_procedure_new2 ().

A few minor code style issues were also fixed.
Note that there's only one procedure parameter (Preset name), 
but it's not retained between runs.
I want to ask about this before making a full conversion to
GimpProcedureDialog widgets.
This commit is contained in:
Alx Sa 2023-08-20 18:57:05 +00:00 committed by Jehan
parent 7e25a6a1e4
commit 8be4592e38
5 changed files with 43 additions and 67 deletions

View File

@ -186,9 +186,9 @@ brushdmenuselect (GtkWidget *widget,
for (row = 0, y = y1; y < y2; row++, y++)
{
guchar *tmprow = p->col + row * rowstride;
guchar *tmprow_ptr;
gint x2 = x1 + w;
guchar *tmprow = p->col + row * rowstride;
gint x2 = x1 + w;
gegl_buffer_get (src_buffer, GEGL_RECTANGLE (x1, y, w, 1), 1.0,
format, src_row,

View File

@ -64,7 +64,7 @@ static GimpValueArray * gimpressionist_run (GimpProcedure *p
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
const GimpValueArray *args,
GimpProcedureConfig *config,
gpointer run_data);
static void gimpressionist_main (void);
@ -110,9 +110,9 @@ gimpressionist_create_procedure (GimpPlugIn *plug_in,
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = gimp_image_procedure_new (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN,
gimpressionist_run, NULL, NULL);
procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN,
gimpressionist_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB*, GRAY*");
gimp_procedure_set_sensitivity_mask (procedure,
@ -124,8 +124,8 @@ gimpressionist_create_procedure (GimpPlugIn *plug_in,
gimp_procedure_set_documentation (procedure,
_("Performs various artistic "
"operations"),
"Performs various artistic operations "
"on an image",
_("Performs various artistic operations "
"on an image"),
name);
gimp_procedure_set_attribution (procedure,
"Vidar Madsen <vidar@prosalg.no>",
@ -133,8 +133,8 @@ gimpressionist_create_procedure (GimpPlugIn *plug_in,
PLUG_IN_VERSION);
GIMP_PROC_ARG_STRING (procedure, "preset",
"Preset",
"Preset Name",
_("Preset"),
_("Preset Name"),
NULL,
G_PARAM_READWRITE);
}
@ -163,10 +163,10 @@ gimpressionist_run (GimpProcedure *procedure,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
const GimpValueArray *args,
GimpProcedureConfig *config,
gpointer run_data)
{
const gchar *preset_name;
gchar *preset_name;
gegl_init (NULL, NULL);
@ -210,7 +210,7 @@ gimpressionist_run (GimpProcedure *procedure,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_PROC, &pcvals);
if (! create_gimpressionist ())
if (! create_gimpressionist (procedure, config))
{
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL,
@ -219,7 +219,9 @@ gimpressionist_run (GimpProcedure *procedure,
break;
case GIMP_RUN_NONINTERACTIVE:
preset_name = GIMP_VALUES_GET_STRING (args, 0);
g_object_get (config,
"preset", &preset_name,
NULL);
if (select_preset (preset_name))
{
@ -273,7 +275,7 @@ gimpressionist_run (GimpProcedure *procedure,
orientation_map_free_resources ();
size_map_free_resources ();
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
}
static const Babl *

View File

@ -107,57 +107,28 @@ create_one_column_list (GtkWidget *parent,
return view;
}
static void
dialog_response (GtkWidget *widget,
gint response_id,
gpointer data)
{
switch (response_id)
{
case GTK_RESPONSE_OK:
store_values ();
pcvals.run = TRUE;
gtk_widget_destroy (widget);
break;
default:
gtk_widget_destroy (widget);
break;
}
}
static GtkWidget *
create_dialog (void)
static gboolean
create_dialog (GimpProcedure *procedure,
GimpProcedureConfig *config)
{
GtkWidget *notebook;
GtkWidget *hbox;
GtkWidget *preview_box;
gboolean run;
gimp_ui_init (PLUG_IN_BINARY);
dialog = gimp_dialog_new (_("GIMPressionist"), PLUG_IN_ROLE,
NULL, 0,
gimp_standard_help_func, PLUG_IN_PROC,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_OK"), GTK_RESPONSE_OK,
NULL);
dialog = gimp_procedure_dialog_new (procedure,
GIMP_PROCEDURE_CONFIG (config),
_("GIMPressionist"));
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_window_set_transient (GTK_WINDOW (dialog));
g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response),
NULL);
g_signal_connect (dialog, "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
@ -189,19 +160,22 @@ create_dialog (void)
* */
restore_values ();
gtk_widget_show (dialog);
run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
if (run)
store_values ();
return dialog;
gtk_widget_destroy (dialog);
return run;
}
gint
create_gimpressionist (void)
create_gimpressionist (GimpProcedure *procedure,
GimpProcedureConfig *config)
{
pcvals.run = FALSE;
create_dialog ();
gtk_main ();
pcvals.run = create_dialog (procedure, config);
return pcvals.run;
}

View File

@ -159,8 +159,9 @@ double getsiz_proto (double x, double y, int n, smvector_t *vec,
double smstrexp, int voronoi);
void set_colorbrushes (const gchar *fn);
int create_gimpressionist (void);
void set_colorbrushes (const gchar *fn);
int create_gimpressionist (GimpProcedure *procedure,
GimpProcedureConfig *config);
double dist (double x, double y, double dx, double dy);

View File

@ -25,10 +25,9 @@ enum SELECT_PRESET_RETURN_VALUES
SELECT_PRESET_LOAD_FAILED = -2,
};
void create_presetpage (GtkNotebook *);
int select_preset (const gchar *preset);
void preset_free (void);
void preset_save_button_set_sensitive (gboolean s);
void create_presetpage (GtkNotebook *notebook);
int select_preset (const gchar *preset);
void preset_free (void);
void preset_save_button_set_sensitive (gboolean s);
#endif