Commit 0b5f5bf7 authored by Michael Natterer's avatar Michael Natterer 😴

plug-ins: port gfig to GimpPlugIn

parent 037421de
Pipeline #104525 passed with stages
in 18 minutes and 2 seconds
......@@ -57,23 +57,43 @@
#define GFIG_HEADER "GFIG Version 0.2\n"
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
typedef struct _Gfig Gfig;
typedef struct _GfigClass GfigClass;
struct _Gfig
{
GimpPlugIn parent_instance;
};
const GimpPlugInInfo PLUG_IN_INFO =
struct _GfigClass
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
GimpPlugInClass parent_class;
};
#define GFIG_TYPE (gfig_get_type ())
#define GFIG (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GFIG_TYPE, Gfig))
GType gfig_get_type (void) G_GNUC_CONST;
static GList * gfig_query_procedures (GimpPlugIn *plug_in);
static GimpProcedure * gfig_create_procedure (GimpPlugIn *plug_in,
const gchar *name);
static GimpValueArray * gfig_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data);
static gint load_options (GFigObj *gfig,
FILE *fp);
G_DEFINE_TYPE (Gfig, gfig, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (GFIG_TYPE)
gint line_no;
gint obj_show_single = -1; /* -1 all >= 0 object number */
......@@ -86,8 +106,6 @@ GfigObject *tmp_line; /* Needed when drawing lines */
gboolean need_to_scale;
static gint load_options (GFigObj *gfig,
FILE *fp);
/* globals */
GfigObjectClass dobj_class[10];
......@@ -104,72 +122,111 @@ gint preview_width, preview_height;
gdouble scale_x_factor, scale_y_factor;
GdkPixbuf *back_pixbuf = NULL;
MAIN ()
static void
query (void)
gfig_class_init (GfigClass *klass)
{
static const GimpParamDef args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
{ GIMP_PDB_INT32, "dummy", "dummy" }
};
gimp_install_procedure (PLUG_IN_PROC,
N_("Create geometric shapes"),
"Draw Vector Graphics and paint them onto your images. "
"Gfig allows you to draw many types of objects "
"including Lines, Circles, Ellipses, Curves, Polygons, "
"pointed stars, Bezier curves, and Spirals. "
"Objects can be painted using Brushes or other tools"
"or filled using colors or patterns. "
"Gfig objects can also be used to create selections. ",
"Andy Thomas",
"Andy Thomas",
"1997",
N_("_Gfig..."),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Render");
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
plug_in_class->query_procedures = gfig_query_procedures;
plug_in_class->create_procedure = gfig_create_procedure;
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
gfig_init (Gfig *gfig)
{
}
static GList *
gfig_query_procedures (GimpPlugIn *plug_in)
{
return g_list_append (NULL, g_strdup (PLUG_IN_PROC));
}
static GimpProcedure *
gfig_create_procedure (GimpPlugIn *plug_in,
const gchar *name)
{
GimpProcedure *procedure = NULL;
if (! strcmp (name, PLUG_IN_PROC))
{
procedure = gimp_procedure_new (plug_in, name, GIMP_PLUGIN,
gfig_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB*, GRAY*");
gimp_procedure_set_menu_label (procedure, N_("_Gfig..."));
gimp_procedure_add_menu_path (procedure, "<Image>/Filters/Render");
gimp_procedure_set_documentation (procedure,
N_("Create geometric shapes"),
"Draw Vector Graphics and paint them "
"onto your images. Gfig allows you "
"to draw many types of objects "
"including Lines, Circles, Ellipses, "
"Curves, Polygons, pointed stars, "
"Bezier curves, and Spirals. "
"Objects can be painted using "
"Brushes or other tools or filled "
"using colors or patterns. "
"Gfig objects can also be used to "
"create selections.",
name);
gimp_procedure_set_attribution (procedure,
"Andy Thomas",
"Andy Thomas",
"1997");
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("run-mode",
"Run mode",
"The run mode",
GIMP_TYPE_RUN_MODE,
GIMP_RUN_NONINTERACTIVE,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"Image",
"The input image",
FALSE,
G_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"Drawable",
"The input drawable",
FALSE,
G_PARAM_READWRITE));
}
return procedure;
}
static GimpValueArray *
gfig_run (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
static GimpParam values[1];
gint32 drawable_id;
GimpRunMode run_mode;
gint32 image_id;
gint32 drawable_id;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint pwidth, pheight;
INIT_I18N ();
gfig_context = g_new0 (GFigContext, 1);
gfig_context->show_background = TRUE;
gfig_context->selected_obj = NULL;
drawable_id = param[2].data.d_drawable;
gfig_context->show_background = TRUE;
gfig_context->selected_obj = NULL;
run_mode = param[0].data.d_int32;
run_mode = g_value_get_enum (gimp_value_array_index (args, 0));
image_id = gimp_value_get_image_id (gimp_value_array_index (args, 1));
drawable_id = gimp_value_get_drawable_id (gimp_value_array_index (args, 2));
gfig_context->image_id = param[1].data.d_image;
gfig_context->image_id = image_id;
gfig_context->drawable_id = drawable_id;
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
gimp_image_undo_group_start (gfig_context->image_id);
gimp_context_push ();
......@@ -184,7 +241,8 @@ run (const gchar *name,
gimp_context_pop ();
gimp_image_undo_group_end (gfig_context->image_id);
return;
return gimp_procedure_new_return_values (procedure, status, NULL);
}
/* Calculate preview size */
......@@ -200,7 +258,6 @@ run (const gchar *name,
pwidth = sel_width * pheight / sel_height;
}
preview_width = MAX (pwidth, 2); /* Min size is 2 */
preview_height = MAX (pheight, 2);
......@@ -216,12 +273,12 @@ run (const gchar *name,
{
case GIMP_RUN_INTERACTIVE:
case GIMP_RUN_WITH_LAST_VALS:
/*gimp_get_data (PLUG_IN_PROC, &selvals);*/
if (! gfig_dialog ())
{
gimp_image_undo_group_end (gfig_context->image_id);
return;
return gimp_procedure_new_return_values (procedure, GIMP_PDB_CANCEL,
NULL);
}
break;
......@@ -239,17 +296,8 @@ run (const gchar *name,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
else
#if 0
if (run_mode == GIMP_RUN_INTERACTIVE)
gimp_set_data (PLUG_IN_PROC, &selvals, sizeof (SelectItVals));
else
#endif /* 0 */
{
status = GIMP_PDB_EXECUTION_ERROR;
}
values[0].data.d_status = status;
return gimp_procedure_new_return_values (procedure, status, NULL);
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment