[gimp] plug-ins: port file-sgi to GimpProcedureConfig
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port file-sgi to GimpProcedureConfig
- Date: Mon, 23 Sep 2019 23:04:35 +0000 (UTC)
commit e34ffbff81c8de87bcc42aafbdce998465305f39
Author: Michael Natterer <mitch gimp org>
Date: Tue Sep 24 01:00:53 2019 +0200
plug-ins: port file-sgi to GimpProcedureConfig
and use the changed gimp_int_store_new() in the dialog. It appears
to be a straightforward way to replace gimp_int_radio_group_new()
which should really go away for 3.0.
plug-ins/file-sgi/sgi.c | 135 +++++++++++++++++++++++++-----------------------
1 file changed, 71 insertions(+), 64 deletions(-)
---
diff --git a/plug-ins/file-sgi/sgi.c b/plug-ins/file-sgi/sgi.c
index 4dc6c7258d..2f472754a8 100644
--- a/plug-ins/file-sgi/sgi.c
+++ b/plug-ins/file-sgi/sgi.c
@@ -43,7 +43,6 @@
#define LOAD_PROC "file-sgi-load"
#define SAVE_PROC "file-sgi-save"
#define PLUG_IN_BINARY "file-sgi"
-#define PLUG_IN_ROLE "gimp-file-sgi"
#define PLUG_IN_VERSION "1.1.1 - 17 May 1998"
@@ -88,9 +87,11 @@ static GimpImage * load_image (GFile *file,
static gint save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
+ GObject *config,
GError **error);
-static gboolean save_dialog (void);
+static gboolean save_dialog (GimpProcedure *procedure,
+ GObject *config);
G_DEFINE_TYPE (Sgi, sgi, GIMP_TYPE_PLUG_IN)
@@ -98,9 +99,6 @@ G_DEFINE_TYPE (Sgi, sgi, GIMP_TYPE_PLUG_IN)
GIMP_MAIN (SGI_TYPE)
-static gint compression = SGI_COMP_RLE;
-
-
static void
sgi_class_init (SgiClass *klass)
{
@@ -186,8 +184,8 @@ sgi_create_procedure (GimpPlugIn *plug_in,
GIMP_PROC_ARG_INT (procedure, "compression",
"Compression",
"Compression level (0 = none, 1 = RLE, 2 = ARLE)",
- 0, 2, 1,
- G_PARAM_STATIC_STRINGS);
+ 0, 2, SGI_COMP_RLE,
+ GIMP_PARAM_READWRITE);
}
return procedure;
@@ -232,13 +230,17 @@ sgi_save (GimpProcedure *procedure,
const GimpValueArray *args,
gpointer run_data)
{
- GimpPDBStatusType status = GIMP_PDB_SUCCESS;
- GimpExportReturn export = GIMP_EXPORT_CANCEL;
- GError *error = NULL;
+ GimpProcedureConfig *config;
+ GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+ GimpExportReturn export = GIMP_EXPORT_CANCEL;
+ GimpImage *orig_image;
+ GError *error = NULL;
INIT_I18N ();
gegl_init (NULL, NULL);
+ orig_image = image;
+
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
@@ -261,33 +263,21 @@ sgi_save (GimpProcedure *procedure,
break;
}
- switch (run_mode)
- {
- case GIMP_RUN_INTERACTIVE:
- gimp_get_data (SAVE_PROC, &compression);
+ config = gimp_procedure_create_config (procedure);
+ gimp_procedure_config_begin_run (config, orig_image, run_mode, args);
- if (! save_dialog ())
+ if (run_mode == GIMP_RUN_INTERACTIVE)
+ {
+ if (! save_dialog (procedure, G_OBJECT (config)))
status = GIMP_PDB_CANCEL;
- break;
-
- case GIMP_RUN_NONINTERACTIVE:
- compression = GIMP_VALUES_GET_INT (args, 0);
- break;
-
- case GIMP_RUN_WITH_LAST_VALS:
- gimp_get_data (SAVE_PROC, &compression);
- break;
-
- default:
- break;
- };
+ }
if (status == GIMP_PDB_SUCCESS)
{
- if (save_image (file, image, drawable,
+ if (save_image (file, image, drawable, G_OBJECT (config),
&error))
{
- gimp_set_data (SAVE_PROC, &compression, sizeof (compression));
+ gimp_procedure_config_end_run (config, orig_image, run_mode);
}
else
{
@@ -295,6 +285,8 @@ sgi_save (GimpProcedure *procedure,
}
}
+ g_object_unref (config);
+
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (image);
@@ -520,24 +512,30 @@ static gint
save_image (GFile *file,
GimpImage *image,
GimpDrawable *drawable,
+ GObject *config,
GError **error)
{
- gint i, j, /* Looping var */
- x, /* Current X coordinate */
- y, /* Current Y coordinate */
- width, /* Drawable width */
- height, /* Drawable height */
- tile_height, /* Height of tile in GIMP */
- count, /* Count of rows to put in image */
- zsize; /* Number of channels in file */
+ gint compression;
+ gint i, j; /* Looping var */
+ gint x; /* Current X coordinate */
+ gint y; /* Current Y coordinate */
+ gint width; /* Drawable width */
+ gint height; /* Drawable height */
+ gint tile_height; /* Height of tile in GIMP */
+ gint count; /* Count of rows to put in image */
+ gint zsize; /* Number of channels in file */
gchar *filename;
sgi_t *sgip; /* File pointer */
GeglBuffer *buffer; /* Buffer for layer */
const Babl *format;
- guchar **pixels, /* Pixel rows */
- *pptr; /* Current pixel */
+ guchar **pixels; /* Pixel rows */
+ guchar *pptr; /* Current pixel */
gushort **rows; /* SGI image data */
+ g_object_get (config,
+ "compression", &compression,
+ NULL);
+
/*
* Get the drawable for the current image...
*/
@@ -667,31 +665,40 @@ save_image (GFile *file,
}
static gboolean
-save_dialog (void)
+save_dialog (GimpProcedure *procedure,
+ GObject *config)
{
- GtkWidget *dialog;
- GtkWidget *frame;
- gboolean run;
-
- dialog = gimp_export_dialog_new (_("SGI"), PLUG_IN_BINARY, SAVE_PROC);
-
- frame = gimp_int_radio_group_new (TRUE, _("Compression type"),
- G_CALLBACK (gimp_radio_button_update),
- &compression, compression,
-
- _("_No compression"),
- SGI_COMP_NONE, NULL,
- _("_RLE compression"),
- SGI_COMP_RLE, NULL,
- _("_Aggressive RLE\n(not supported by SGI)"),
- SGI_COMP_ARLE, NULL,
-
- NULL);
-
- gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
- gtk_box_pack_start (GTK_BOX (gimp_export_dialog_get_content_area (dialog)),
- frame, TRUE, TRUE, 0);
- gtk_widget_show (frame);
+ GtkWidget *dialog;
+ GtkWidget *grid;
+ GtkListStore *store;
+ GtkWidget *combo;
+ gboolean run;
+
+ dialog = gimp_procedure_dialog_new (procedure,
+ GIMP_PROCEDURE_CONFIG (config),
+ _("Export Image as SGI"));
+
+ grid = gtk_grid_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ grid, TRUE, TRUE, 0);
+ gtk_widget_show (grid);
+
+ store = gimp_int_store_new (_("No compression"),
+ SGI_COMP_NONE,
+ _("RLE compression"),
+ SGI_COMP_RLE,
+ _("Aggressive RLE (not supported by SGI)"),
+ SGI_COMP_ARLE,
+ NULL);
+ combo = gimp_prop_int_combo_box_new (config, "compression",
+ GIMP_INT_STORE (store));
+ g_object_unref (store);
+
+ gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
+ _("Compression _type:"), 1.0, 0.5,
+ combo, 1);
gtk_widget_show (dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]