[gimp] plug-ins: add "Create New Layer" option to map-object
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: add "Create New Layer" option to map-object
- Date: Sun, 20 Feb 2011 12:54:54 +0000 (UTC)
commit e2710c83715c39f0e1e67fed0e701cce018230f8
Author: Mikael Magnusson <mikachu src gnome org>
Date: Sun Feb 20 13:00:13 2011 +0100
plug-ins: add "Create New Layer" option to map-object
plug-ins/map-object/map-object-apply.c | 48 ++++++++++++-------------------
plug-ins/map-object/map-object-image.c | 2 +-
plug-ins/map-object/map-object-image.h | 2 +-
plug-ins/map-object/map-object-main.c | 9 ++++--
plug-ins/map-object/map-object-main.h | 1 +
plug-ins/map-object/map-object-ui.c | 13 ++++++++
6 files changed, 41 insertions(+), 34 deletions(-)
---
diff --git a/plug-ins/map-object/map-object-apply.c b/plug-ins/map-object/map-object-apply.c
index 5824a8a..680428f 100644
--- a/plug-ins/map-object/map-object-apply.c
+++ b/plug-ins/map-object/map-object-apply.c
@@ -231,37 +231,27 @@ compute_image (void)
init_compute ();
- if (mapvals.create_new_image == TRUE ||
- (mapvals.transparent_background == TRUE &&
- input_drawable->bpp != 4))
+ if (mapvals.create_new_image == TRUE)
{
- /* Create a new image */
- /* ================== */
-
new_image_id = gimp_image_new (width, height, GIMP_RGB);
+ }
+ else
+ {
+ new_image_id = image_id;
+ }
- if (mapvals.transparent_background == TRUE)
- {
- /* Add a layer with an alpha channel */
- /* ================================= */
-
- new_layer_id = gimp_layer_new (new_image_id, "Background",
- width, height,
- GIMP_RGBA_IMAGE,
- 100.0,
- GIMP_NORMAL_MODE);
- }
- else
- {
- /* Create a "normal" layer */
- /* ======================= */
-
- new_layer_id = gimp_layer_new (new_image_id, "Background",
- width, height,
- GIMP_RGB_IMAGE,
- 100.0,
- GIMP_NORMAL_MODE);
- }
+ if (mapvals.create_new_image ||
+ mapvals.create_new_layer ||
+ (mapvals.transparent_background &&
+ output_drawable->bpp != 4))
+ {
+
+ new_layer_id = gimp_layer_new (new_image_id, "Background",
+ width, height,
+ mapvals.transparent_background ? GIMP_RGBA_IMAGE
+ : GIMP_RGB_IMAGE,
+ 100.0,
+ GIMP_NORMAL_MODE);
gimp_image_insert_layer (new_image_id, new_layer_id, -1, 0);
output_drawable = gimp_drawable_get (new_layer_id);
@@ -323,7 +313,7 @@ compute_image (void)
gimp_drawable_merge_shadow (output_drawable->drawable_id, TRUE);
gimp_drawable_update (output_drawable->drawable_id, 0, 0, width, height);
- if (new_image_id != -1)
+ if (new_image_id != image_id)
{
gimp_display_new (new_image_id);
gimp_displays_flush ();
diff --git a/plug-ins/map-object/map-object-image.c b/plug-ins/map-object/map-object-image.c
index a38efae..42de2be 100644
--- a/plug-ins/map-object/map-object-image.c
+++ b/plug-ins/map-object/map-object-image.c
@@ -37,7 +37,7 @@ gint preview_rgb_stride;
cairo_surface_t *preview_surface = NULL;
glong maxcounter,old_depth,max_depth;
-gint imgtype,width,height,in_channels,out_channels;
+gint imgtype,width,height,in_channels,out_channels,image_id;
GimpRGB background;
gdouble oldtreshold;
diff --git a/plug-ins/map-object/map-object-image.h b/plug-ins/map-object/map-object-image.h
index db9bb31..f7d6129 100644
--- a/plug-ins/map-object/map-object-image.h
+++ b/plug-ins/map-object/map-object-image.h
@@ -18,7 +18,7 @@ extern gint preview_rgb_stride;
extern cairo_surface_t *preview_surface;
extern glong maxcounter, old_depth, max_depth;
-extern gint imgtype, width,height, in_channels, out_channels;
+extern gint imgtype, width,height, in_channels, out_channels, image_id;
extern GimpRGB background;
extern gdouble oldtreshold;
diff --git a/plug-ins/map-object/map-object-main.c b/plug-ins/map-object/map-object-main.c
index d899d02..ff0a491 100644
--- a/plug-ins/map-object/map-object-main.c
+++ b/plug-ins/map-object/map-object-main.c
@@ -78,6 +78,7 @@ set_default_settings (void)
mapvals.antialiasing = TRUE;
mapvals.create_new_image = FALSE;
+ mapvals.create_new_layer = FALSE;
mapvals.transparent_background = FALSE;
mapvals.tiled = FALSE;
mapvals.livepreview = TRUE;
@@ -228,6 +229,7 @@ run (const gchar *name,
/* Get the specified drawable */
/* ========================== */
+ image_id = param[1].data.d_int32;
drawable = gimp_drawable_get (param[2].data.d_drawable);
switch (run_mode)
@@ -255,7 +257,7 @@ run (const gchar *name,
break;
case GIMP_RUN_NONINTERACTIVE:
- if (nparams != 49)
+ if (nparams != 50)
{
status = GIMP_PDB_CALLING_ERROR;
}
@@ -293,6 +295,7 @@ run (const gchar *name,
mapvals.antialiasing = (gint) param[32].data.d_int32;
mapvals.tiled = (gint) param[33].data.d_int32;
mapvals.create_new_image = (gint) param[34].data.d_int32;
+ mapvals.create_new_layer = (gint) param[34].data.d_int32;
mapvals.transparent_background = (gint) param[35].data.d_int32;
mapvals.radius = param[36].data.d_float;
mapvals.cylinder_radius = param[36].data.d_float;
@@ -302,10 +305,10 @@ run (const gchar *name,
mapvals.cylinder_length = param[40].data.d_float;
for (i = 0; i < 6; i++)
- mapvals.boxmap_id[i] = param[41+i].data.d_drawable;
+ mapvals.boxmap_id[i] = param[42+i].data.d_drawable;
for (i = 0; i < 2; i++)
- mapvals.cylindermap_id[i] = param[47+i].data.d_drawable;
+ mapvals.cylindermap_id[i] = param[48+i].data.d_drawable;
check_drawables (drawable);
image_setup (drawable, FALSE);
diff --git a/plug-ins/map-object/map-object-main.h b/plug-ins/map-object/map-object-main.h
index 5766907..6c78c8c 100644
--- a/plug-ins/map-object/map-object-main.h
+++ b/plug-ins/map-object/map-object-main.h
@@ -61,6 +61,7 @@ typedef struct
gint antialiasing;
gint create_new_image;
+ gint create_new_layer;
gint transparent_background;
gint tiled;
gint livepreview;
diff --git a/plug-ins/map-object/map-object-ui.c b/plug-ins/map-object/map-object-ui.c
index bdc7656..10aebae 100644
--- a/plug-ins/map-object/map-object-ui.c
+++ b/plug-ins/map-object/map-object-ui.c
@@ -474,6 +474,19 @@ create_options_page (void)
gimp_help_set_help_data (toggle,
_("Create a new image when applying filter"), NULL);
+ toggle = gtk_check_button_new_with_label (_("Create new layer"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
+ mapvals.create_new_layer);
+ gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
+ gtk_widget_show (toggle);
+
+ g_signal_connect (toggle, "toggled",
+ G_CALLBACK (gimp_toggle_button_update),
+ &mapvals.create_new_layer);
+
+ gimp_help_set_help_data (toggle,
+ _("Create a new layer when applying filter"), NULL);
+
/* Antialiasing options */
frame = gimp_frame_new (NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]