[gimp] Issue #1611 - plug-in-screenshot does not work in non-interactive run mode
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #1611 - plug-in-screenshot does not work in non-interactive run mode
- Date: Sun, 17 Jun 2018 18:58:20 +0000 (UTC)
commit d94b954c2a96dfbb59b5f0fec494826caf80c1f1
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 17 20:55:09 2018 +0200
Issue #1611 - plug-in-screenshot does not work in non-interactive run mode
Turn the boolean "root" argument into enum ShootType and reorder that
enum to { WINDOW, ROOT, REGION } so that the "0", and "1" values match
the former boolean. Adapt parameter checking accordingly so that
callers without optional arguments (e.g. script-fu) can call all the
plug-ins's features.
plug-ins/screenshot/screenshot.c | 67 +++++++++++++++++++++++-----------------
plug-ins/screenshot/screenshot.h | 4 +--
2 files changed, 41 insertions(+), 30 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index ee83291ef1..e2c81ed74a 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -109,13 +109,13 @@ query (void)
{
static const GimpParamDef args[] =
{
- { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
- { GIMP_PDB_INT32, "root", "Root window { TRUE, FALSE }" },
- { GIMP_PDB_INT32, "window-id", "Window id" },
- { GIMP_PDB_INT32, "x1", "(optional) Region left x coord" },
- { GIMP_PDB_INT32, "y1", "(optional) Region top y coord" },
- { GIMP_PDB_INT32, "x2", "(optional) Region right x coord" },
- { GIMP_PDB_INT32, "y2", "(optional) Region bottom y coord" }
+ { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
+ { GIMP_PDB_INT32, "shoot-type", "The Shoot type { SHOOT-WINDOW (0), SHOOT-ROOT (1), SHOOT-REGION (2) }"
},
+ { GIMP_PDB_INT32, "window-id", "Window id for SHOOT-WINDOW" },
+ { GIMP_PDB_INT32, "x1", "(optional) Region left x coord" },
+ { GIMP_PDB_INT32, "y1", "(optional) Region top y coord" },
+ { GIMP_PDB_INT32, "x2", "(optional) Region right x coord" },
+ { GIMP_PDB_INT32, "y2", "(optional) Region bottom y coord" }
};
static const GimpParamDef return_vals[] =
@@ -251,38 +251,49 @@ run (const gchar *name,
break;
case GIMP_RUN_NONINTERACTIVE:
- if (nparams == 3)
+ if (nparams == 3 || nparams == 7)
{
- gboolean do_root = param[1].data.d_int32;
-
- shootvals.shoot_type = do_root ? SHOOT_ROOT : SHOOT_WINDOW;
+ shootvals.shoot_type = param[1].data.d_int32;
shootvals.window_id = param[2].data.d_int32;
shootvals.select_delay = 0;
- }
- else if (nparams == 7)
- {
- shootvals.shoot_type = SHOOT_REGION;
- shootvals.window_id = param[2].data.d_int32;
- shootvals.select_delay = 0;
- shootvals.x1 = param[3].data.d_int32;
- shootvals.y1 = param[4].data.d_int32;
- shootvals.x2 = param[5].data.d_int32;
- shootvals.y2 = param[6].data.d_int32;
+
+ if (shootvals.shoot_type < SHOOT_WINDOW ||
+ shootvals.shoot_type > SHOOT_REGION)
+ {
+ status = GIMP_PDB_CALLING_ERROR;
+ }
+ else if (shootvals.shoot_type == SHOOT_REGION)
+ {
+ if (nparams == 7)
+ {
+ shootvals.x1 = param[3].data.d_int32;
+ shootvals.y1 = param[4].data.d_int32;
+ shootvals.x2 = param[5].data.d_int32;
+ shootvals.y2 = param[6].data.d_int32;
+ }
+ else
+ {
+ status = GIMP_PDB_CALLING_ERROR;
+ }
+ }
}
else
{
status = GIMP_PDB_CALLING_ERROR;
}
- if (! gdk_init_check (NULL, NULL))
- status = GIMP_PDB_CALLING_ERROR;
-
- if (! (capabilities & SCREENSHOT_CAN_PICK_NONINTERACTIVELY))
+ if (status == GIMP_PDB_SUCCESS)
{
- if (shootvals.shoot_type == SHOOT_WINDOW ||
- shootvals.shoot_type == SHOOT_REGION)
+ if (! gdk_init_check (NULL, NULL))
+ status = GIMP_PDB_CALLING_ERROR;
+
+ if (! (capabilities & SCREENSHOT_CAN_PICK_NONINTERACTIVELY))
{
- status = GIMP_PDB_CALLING_ERROR;
+ if (shootvals.shoot_type == SHOOT_WINDOW ||
+ shootvals.shoot_type == SHOOT_REGION)
+ {
+ status = GIMP_PDB_CALLING_ERROR;
+ }
}
}
break;
diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h
index b8682647c6..1f920ea870 100644
--- a/plug-ins/screenshot/screenshot.h
+++ b/plug-ins/screenshot/screenshot.h
@@ -52,9 +52,9 @@ typedef enum
typedef enum
{
+ SHOOT_WINDOW,
SHOOT_ROOT,
- SHOOT_REGION,
- SHOOT_WINDOW
+ SHOOT_REGION
} ShootType;
typedef struct
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]