/* ------------------------------- * p_parse_frame_nr_from_layerId * ------------------------------- */ static gint32 p_parse_frame_nr_from_layerId(gint32 layerId) { char *layername; gint32 frameNr; gint len; gint ii; frameNr = 0; layername = gimp_item_get_name(layerId); if(layername) { len = strlen(layername); for(ii=1; ii < len; ii++) { if ((layername[ii-1] == '_') && (layername[ii] <= '9') && (layername[ii] >= '0')) { frameNr = g_ascii_strtod(&layername[ii], NULL); break; } } g_free(layername); } return (frameNr); } /* end p_parse_frame_nr_from_layerId */
static PyObject * vectors_repr(PyGimpVectors *self) { PyObject *s; char *name; name = gimp_item_get_name(self->ID); s = PyString_FromFormat("<gimp.Vectors '%s'>", name ? name : "(null)"); g_free(name); return s; }
static PyObject * pr_repr(PyGimpPixelRgn *self) { PyObject *s; gchar *name; name = gimp_item_get_name(self->drawable->drawable->drawable_id); s = PyString_FromFormat("<gimp.PixelRgn for drawable '%s'>", name); g_free(name); return s; }
static PyObject * vbs_repr(PyGimpVectorsStroke *self) { PyObject *s; char *name; name = gimp_item_get_name(self->vectors_ID); s = PyString_FromFormat("<gimp.VectorsBezierStroke %d of gimp.Vectors '%s'>", self->stroke, name ? name : "(null)"); g_free(name); return s; }
/* ----------------------------------------------- * gap_image_get_tree_position_list * ----------------------------------------------- * return a list that represents the stack positions * of the specified item_id (typically a layer) * which contains positions within the image * and within all its parent group layers. * * The 1st element in the stack position list refers to the stackposition * at toplevel of the image. * Note: * The caller shall g_free the returned list * after use by calling: gap_image_gfree_tree_position_list */ GapImageStackPositionsList * gap_image_get_tree_position_list(gint32 item_id) { gint32 l_image_id; gint32 l_curr_item_id; GapImageStackPositionsList *posRootPtr; posRootPtr = NULL; l_image_id = gimp_item_get_image (item_id); if(gap_debug) { printf("gap_image_get_tree_position_list Start image_id: %d\n" , (int)l_image_id ); } if (l_image_id < 0) { return (NULL); } l_curr_item_id = item_id; while(l_curr_item_id > 0) { GapImageStackPositionsList *posPtr; posPtr = g_new(GapImageStackPositionsList, 1); posPtr->stack_position = gimp_image_get_item_position (l_image_id, l_curr_item_id); if(gap_debug) { printf("item_id:%d stack_position: %d name:%s\n" , (int)l_curr_item_id , (int)posPtr->stack_position , gimp_item_get_name(l_curr_item_id) ); } posPtr->next = posRootPtr; posRootPtr = posPtr; l_curr_item_id = gimp_item_get_parent (l_curr_item_id); } return (posRootPtr); } /* end gap_image_get_tree_position_list */
/* ----------------------------- * gap_image_reorder_layer * ----------------------------- * move the specified layer to another position within the same image. * (done by removing and then re-inserting the layer) * new_groupname * Name of a group or group/subgroup where the specified layer_id shall be moved to. * Note that the string new_groupname uses the delimiter string * to split nested group/sugrup names. * use new_groupname = NULL to move the specified layer_id to image toplevel. * enableGroupCreation * TRUE: * in case the group layer with new_groupname does not exist * it will be created automatically. * FALSE: * in case the group layer with new_groupname does not exist * -1 is returned and the reorder operation is not performed. * new_position * the desired new stackposition within the specified new_groupname * or toplevel image (when new_groupname is NULL or empty) * returns -1 on error */ gint32 gap_image_reorder_layer(gint32 image_id, gint32 layer_id, gint32 new_position, char *new_groupname, char *delimiter, gboolean enableGroupCreation, char *new_layername) { gint32 l_parent_id; gint32 l_dup_layer_id; gchar *l_name; l_parent_id = gap_image_find_or_create_group_layer(image_id , new_groupname , delimiter , 0 /* stackposition for the group in case it is created at toplevel */ , enableGroupCreation ); if (l_parent_id < 0) { return (-1); } l_dup_layer_id = gimp_layer_copy(layer_id); l_name = NULL; if (new_layername != NULL) { if (*new_layername != '\0') { l_name = g_strdup(new_layername); } } if (l_name == NULL) { l_name = gimp_item_get_name(layer_id); } gimp_image_remove_layer(image_id, layer_id); gimp_image_insert_layer(image_id, l_dup_layer_id, l_parent_id, new_position); gimp_item_set_name(l_dup_layer_id, l_name); g_free(l_name); return (0); /* OK */ } /* end gap_image_reorder_layer */
static PyObject * pf_repr(PyGimpPixelFetcher *self) { PyObject *s; char *name; name = gimp_item_get_name(self->drawable->drawable->drawable_id); if (self->shadow) s = PyString_FromFormat("<gimp.PixelFetcher for drawable '%s' (shadow)>", name); else s = PyString_FromFormat("<gimp.PixelFetcher for drawable '%s'>", name); g_free(name); return s; }
static PyObject * tile_repr(PyGimpTile *self) { PyObject *s; gchar *name; name = gimp_item_get_name(self->tile->drawable->drawable_id); if (self->tile->shadow) s = PyString_FromFormat("<gimp.Tile for drawable '%s' (shadow)>", name); else s = PyString_FromFormat("<gimp.Tile for drawable '%s'>", name); g_free(name); return s; }
static PyObject * vectors_get_name(PyGimpVectors *self, void *closure) { return PyString_FromString(gimp_item_get_name(self->ID)); }
/** * gimp_vectors_get_name: * @vectors_ID: The vectors object. * * Deprecated: Use gimp_item_get_name() instead. * * Returns: The name of the vectors object. * * Since: GIMP 2.4 */ gchar * gimp_vectors_get_name (gint32 vectors_ID) { return gimp_item_get_name (vectors_ID); }
static GimpPDBStatusType plt_add_layers(gint32 image_id) { unsigned int i, j; GimpImageBaseType img_basetype; gint img_num_layers; gint *img_layer_ids; gint img_width = 0; gint img_height = 0; gboolean plt_layer_detected = FALSE; GimpImageType layer_type= GIMP_GRAYA_IMAGE; gint32 layer_id; // Set type of the layer depending on the type of the image img_basetype = gimp_image_base_type(image_id); switch(img_basetype) { case GIMP_GRAY: { layer_type = GIMP_GRAYA_IMAGE; break; } case GIMP_RGB: { layer_type = GIMP_RGBA_IMAGE; break; } case GIMP_INDEXED: // You're still out of luck default: { g_message("Image type has to be Grayscale or RGB.\n"); return (GIMP_PDB_EXECUTION_ERROR); } } // We don't want to create already existing plt layers // Get all layers from the current image and look for missing layers //TODO img_width = gimp_image_width(image_id); img_height = gimp_image_height(image_id); img_layer_ids = gimp_image_get_layers(image_id, &img_num_layers); for (i = 0; i < PLT_NUM_LAYERS; i++) { plt_layer_detected = FALSE; for (j = 0; j < img_num_layers; j++) { if (!g_ascii_strcasecmp(plt_layernames[i], gimp_item_get_name(img_layer_ids[j]))) { plt_layer_detected = TRUE; break; } } if (!plt_layer_detected) { layer_id = gimp_layer_new(image_id, plt_layernames[i], img_width, img_height, layer_type, 100.0, GIMP_NORMAL_MODE); gimp_image_insert_layer(image_id, layer_id, 0, 0); } } g_free(img_layer_ids); return (GIMP_PDB_SUCCESS); }
static GimpPDBStatusType plt_save(gchar *filename, gint32 image_id) { FILE *stream = 0; unsigned int i, j; uint8_t plt_version[8] = PLT_HEADER_VERSION; uint8_t plt_info[8] = {10, 0, 0, 0, 0, 0, 0, 0}; uint32_t plt_width = 0; uint32_t plt_height = 0; uint8_t *buffer; uint8_t *pixel; uint32_t num_px = 0; GimpImageBaseType img_basetype; gint img_num_layers; // num layers in image gint *img_layer_ids; // all layers in image gint32 layer_id; gint *plt_layer_ids; gint max_layer_id; gint32 detected_plt_layers = 0; gint x, y; gint num_channels; // Channels in image // Only get image data if it's valid if (!gimp_image_is_valid(image_id)) { g_message("Invalid image.\n"); return (GIMP_PDB_EXECUTION_ERROR); } plt_width = gimp_image_width(image_id); plt_height = gimp_image_height(image_id); img_basetype = gimp_image_base_type(image_id); gimp_progress_init_printf("Exporting %s", filename); gimp_progress_update(0.0); img_layer_ids = gimp_image_get_layers(image_id, &img_num_layers); if (img_num_layers < PLT_NUM_LAYERS) { g_message("Requires an image with at least 10 layers.\n"); g_free(img_layer_ids); return (GIMP_PDB_EXECUTION_ERROR); } max_layer_id = -1; for (i = 0; i < img_num_layers; i++) { if (img_layer_ids[i] > max_layer_id) { max_layer_id = img_layer_ids[i]; } } // Try to find the 10 plt layers by looking for matching layer names plt_layer_ids = g_malloc(sizeof(gint)*max_layer_id); for (i = 0; i < max_layer_id; i++) { plt_layer_ids[i] = -1; } for (i = 0; i < PLT_NUM_LAYERS; i++) { for (j = 0; j < img_num_layers; j++) { if (!g_ascii_strcasecmp(plt_layernames[i], gimp_item_get_name(img_layer_ids[j]))) { plt_layer_ids[img_layer_ids[j]] = i; detected_plt_layers++; break; } } } // If we can't find the layers by name, use the 10 topmost layers instead // (Interpreted as tattoo2, tattoo1, ... from the top) if (detected_plt_layers < PLT_NUM_LAYERS) { for (i = 0; i < PLT_NUM_LAYERS; i++) { plt_layer_ids[img_layer_ids[i]] = PLT_NUM_LAYERS-i-1; } } // Write image data to buffer num_px = plt_width * plt_height; buffer = (uint8_t*) g_malloc(sizeof(uint8_t)*2*num_px); switch(img_basetype) { case GIMP_GRAY: { // Gray Image // >= 1 channels: value (+ alpha). We ignore alpha though, so it // doesn't matter wether its present or not. for (i = 0; i < num_px; i++) { x = (gint)(i % plt_width); y = plt_height - (gint)(floor(i / plt_width)) - 1; layer_id = gimp_image_pick_correlate_layer(image_id, x, y); if ((layer_id >= 0) && (plt_layer_ids[layer_id] >= 0)) { pixel = gimp_drawable_get_pixel(layer_id, x, y, &num_channels); buffer[2*i] = pixel[0]; buffer[2*i+1] = plt_layer_ids[layer_id]; } else { buffer[2*i] = 255; buffer[2*i+1] = 0; } gimp_progress_update((float) i/ (float) num_px); } break; } case GIMP_RGB: { // RGB Image // >= 3 channels: r +g + b (+ alpha). We ignore alpha though, so it // doesn't matter wether its present or not. // We'll calculate gray value with (r+g+b)/3. for (i = 0; i < num_px; i++) { x = (gint)(i % plt_width); y = plt_height - (gint)(floor(i / plt_width)) - 1; layer_id = gimp_image_pick_correlate_layer(image_id, x, y); if ((layer_id >= 0) && (plt_layer_ids[layer_id] >= 0)) { pixel = gimp_drawable_get_pixel(layer_id, x, y, &num_channels); buffer[2*i] = pixel[0]; buffer[2*i+1] = plt_layer_ids[layer_id]; } else { buffer[2*i] = 255; buffer[2*i+1] = 0; } gimp_progress_update((float) i/ (float) num_px); } break; } case GIMP_INDEXED: // You're out of luck buddy default: { g_message("Image type has to be Grayscale or RGB.\n"); g_free(buffer); g_free(img_layer_ids); g_free(plt_layer_ids); return (GIMP_PDB_EXECUTION_ERROR); } } gimp_progress_update(1.0); stream = fopen(filename, "wb"); if (stream == 0) { g_message("Error opening %s\n", filename); g_free(buffer); g_free(img_layer_ids); g_free(plt_layer_ids); return (GIMP_PDB_EXECUTION_ERROR); } // Write header fwrite(plt_version, 1, 8, stream); fwrite(plt_info, 1, 8, stream); fwrite(&plt_width, 4, 1, stream); fwrite(&plt_height, 4, 1, stream); // Write image data fwrite(buffer, 1, 2*num_px, stream); fclose(stream); g_free(buffer); g_free(img_layer_ids); g_free(plt_layer_ids); return (GIMP_PDB_SUCCESS); }
/* ----------------------------------------------- * gap_image_get_layer_id_by_tree_position_list * ----------------------------------------------- * return the item_id of the layer that matches * the specified stack position list. * (where each list element describes the position * in the next tree level * The 1st element in the stack position list refers to the stackposition * at toplevel of the image) * */ gint32 gap_image_get_layer_id_by_tree_position_list(gint32 image_id, GapImageStackPositionsList *rootPosPtr) { GapImageStackPositionsList *posPtr; gint l_nlayers; gint l_treelevel; gint32 *l_src_layers; gint32 l_layer_id; gint32 l_wanted_layer_id; l_layer_id = -1; l_wanted_layer_id = -1; l_treelevel = 0; posPtr = rootPosPtr; if (posPtr == NULL) { return (l_layer_id); } l_src_layers = gimp_image_get_layers (image_id, &l_nlayers); if (l_src_layers == NULL) { return (-1); } while(posPtr != NULL) { if ((posPtr->stack_position >= 0) && (posPtr->stack_position < l_nlayers)) { l_layer_id = l_src_layers[posPtr->stack_position]; if(gap_debug) { printf("get_layer_id_by_tree_pos layer_id: treelevel:%d %d name:%s N:%d stackPos:%d\n" , (int)l_treelevel , (int)l_layer_id , gimp_item_get_name(l_layer_id) , l_nlayers , posPtr->stack_position ); } } g_free(l_src_layers); if (l_layer_id < 0) { if(gap_debug) { printf("get_layer_id_by_tree_pos l_treelevel:%d stack_position:%d NOT found!\n" , (int)l_treelevel , (int)posPtr->stack_position ); } break; } posPtr = posPtr->next; if(posPtr != NULL) { if (gimp_item_is_group(l_layer_id)) { l_src_layers = gimp_item_get_children (l_layer_id, &l_nlayers); if (l_src_layers == NULL) { if(gap_debug) { printf("get_layer_id_by_tree_pos l_treelevel:%d NO CHILD LAYERS FOUND ! for item_id:%d\n" , (int)l_treelevel , (int)l_layer_id ); } return (-1); /* failed to get group members */ } } else { if(gap_debug) { printf("get_layer_id_by_tree_pos l_treelevel:%d item_id:%d IS NOT A GROUP !\n" , (int)l_treelevel , (int)l_layer_id ); } return (-1); /* group was expected, but not found, cant evaluate rest of the list */ } } else { l_wanted_layer_id = l_layer_id; } l_treelevel++; } /* end while */ return (l_wanted_layer_id); } /* end gap_image_get_layer_id_by_tree_position_list */
/* ----------------------------------------------- * gap_image_get_layers_at_parentpositions * ----------------------------------------------- * returns the list layers at toplevel image (when parentpositions == NULL) * otherwise return the list of layers of the nested group * where parentpositions specifies a list of integer stackpositions * from toplevel to the deepest nested group delimited by "/" * note that all specified parentpositions MUST refer to group layers. * return NULL in case no matching layerstack was found in the image. */ gint32 * gap_image_get_layers_at_parentpositions(gint32 image_id, gint *nlayers, const char *parentpositions) { gint l_nlayers; gint32 *l_toplevel_layers_list; gint32 *l_layers_list; gboolean l_has_parents; *nlayers = 0; l_toplevel_layers_list = gimp_image_get_layers(image_id, &l_nlayers); if (l_toplevel_layers_list == NULL) { return (NULL); } l_layers_list = l_toplevel_layers_list; l_has_parents = FALSE; if(parentpositions != NULL) { if (*parentpositions != '\0') { l_has_parents = TRUE; } } if (l_has_parents == TRUE) { gchar **posValueArray; gint l_ii; posValueArray = g_strsplit(parentpositions , "/" , -1 /* max_tokens less than 1 splits the string completely. */ ); for(l_ii = 0; posValueArray[l_ii] != NULL; l_ii++) { long l_pos; l_pos = atol(posValueArray[l_ii]); if ((l_pos >= 0) && (l_pos < l_nlayers)) { gint32 l_layer_id; l_layer_id = l_layers_list[l_pos]; if (gimp_item_is_group(l_layer_id)) { g_free(l_layers_list); l_layers_list = gimp_item_get_children(l_layer_id, &l_nlayers); } else /* error: position is not a group */ if(gap_debug) { printf("gap_image_get_layers_at_parentpositions: position %d is no GROUP" "(l_nlayers:%d) l_layer_id:%d (%s) parentpositions: %s \n" , (int) l_pos , (int) l_nlayers , (int) l_layer_id , gimp_item_get_name(l_layer_id) , parentpositions ); } g_strfreev(posValueArray); g_free(l_layers_list); return (NULL); { } } else { /* error: position is invalid (not an integer within valid stackposition range */ if(gap_debug) { printf("gap_image_get_layers_at_parentpositions: position %d not in valid range" " (l_nlayers:%d) parentpositions: %s \n" , (int) l_pos , (int) l_nlayers , parentpositions ); } g_strfreev(posValueArray); g_free(l_layers_list); return (NULL); } } g_strfreev(posValueArray); *nlayers = l_nlayers; return (l_layers_list); } /* has no parents: deliver toplevel layers list */ *nlayers = l_nlayers; return (l_toplevel_layers_list); } /* end gap_image_get_layers_at_parentpositions */
/* ------------------------------------ * gap_image_merge_group_layer * ------------------------------------ * merge the specified group layer and return the id of the resulting layer. * * The merge strategy * o) create a temporary image of same size/type (l_tmp_img_id) * o) copy the specified grouplayer to the temporary image (l_tmp_img_id) * o) call gimp_image_merge_visible_layers on the temporary image (l_tmp_img_id, mode) * o) copy the merged layer back to the original image * to the same group at the position of the original layergroup * o) remove the temporary image * o) remove original layergroup * o) rename the resuling merged layer. * * returns 0 if all done OK * (or -1 on error) */ gint32 gap_image_merge_group_layer(gint32 image_id, gint32 group_layer_id, gint merge_mode) { gint32 l_tmp_img_id; gint32 l_new_layer_id; gint32 l_merged_layer_id; gint32 l_parent_id; gint32 l_position; gint l_src_offset_x; gint l_src_offset_y; gboolean l_visible; char *l_name; if (!gimp_item_is_group(group_layer_id)) { /* the specified group_layer_id is not a group * -- no merge is done, return its id as result -- */ return(group_layer_id); } l_visible = gimp_item_get_visible(group_layer_id); l_name = gimp_item_get_name(group_layer_id); /* create a temporary image */ l_tmp_img_id = gap_image_new_of_samesize(image_id); /* copy the grouplayer to the temporary image */ l_new_layer_id = gap_layer_copy_to_dest_image(l_tmp_img_id, group_layer_id, 100.0, /* full opacity */ 0, /* NORMAL paintmode */ &l_src_offset_x, &l_src_offset_y ); gimp_image_insert_layer (l_tmp_img_id, l_new_layer_id, 0, 0); gimp_layer_set_offsets(l_new_layer_id, l_src_offset_x, l_src_offset_y); gimp_item_set_visible(l_new_layer_id, TRUE); /* merge visible layers in the temporary image */ l_merged_layer_id = gimp_image_merge_visible_layers (l_tmp_img_id, merge_mode); l_new_layer_id = gap_layer_copy_to_dest_image(image_id, l_merged_layer_id, gimp_layer_get_opacity(group_layer_id), gimp_layer_get_mode(group_layer_id), &l_src_offset_x, &l_src_offset_y ); l_position = gimp_image_get_item_position (image_id, group_layer_id); l_parent_id = gimp_item_get_parent(group_layer_id); if (l_parent_id < 0) { l_parent_id = 0; } gimp_image_insert_layer (image_id, l_new_layer_id, l_parent_id, l_position); gimp_layer_set_offsets(l_new_layer_id, l_src_offset_x, l_src_offset_y); /* remove the original group layer from the original image */ gimp_image_remove_layer(image_id, group_layer_id); /* restore the original layer name */ if (l_name != NULL) { gimp_item_set_name(l_new_layer_id, l_name); g_free(l_name); } gimp_item_set_visible(l_new_layer_id, l_visible); /* remove the temporary image */ gap_image_delete_immediate(l_tmp_img_id); return(l_new_layer_id); } /* end gap_image_merge_group_layer */
/** * gimp_drawable_get_name: * @drawable_ID: The drawable. * * Deprecated: Use gimp_item_get_name() instead. * * Returns: The drawable name. */ gchar * gimp_drawable_get_name (gint32 drawable_ID) { return gimp_item_get_name (drawable_ID); }
/* ----------------------------------------------- * gap_image_find_or_create_group_layer * ----------------------------------------------- * find the group layer where the name * (and concateneated names of all its parent group layers when present) * is equal to the specified group_name_path. * and return its item_id * Group_layer names levels are concatenated with the specified separator character. * * an empty group_name_path_string (NULL or \0) will return 0 * which refers to the toplevel (indicating that no group is relevant) * * in case the wanted group was not found * the result depends on the flag enableCreate. * when enableCreate == TRUE * the group layer (and all missing parent groups) are created * and its item_id is returned. * when enableCreate == FALSE * -1 is returned (indicating that the wanted group was not found) * * Example (separator character '/' is assumed) * * layertree example * -------------------- * toplayer id:4 * gr-sky id:3 * subgr-1.1 id:7 * layer-sun id:13 * gr-2 id:2 * subgr-animals id:6 * layer-cat id:12 * layer-dog id:11 * subgr-house id:5 * layer-roof id:10 * layer-window id:9 * layer-wall id:8 * background id:1 * * o) a call with group_name_path_string = "gr-2/subgr-animals" * will return 6, because the group layer with name "subgr-animals" * can be found. * o) a call with group_name_path_string = "gr-2/subgr-animals/flying/birds" * will either return -1 * or create both missing groups "flying" and "birds" * and will return the item_id of the "birds" group. * gr-2 id:2 * subgr-animals id:6 * flying id:14 # newly created group layer * birds id:15 # newly created group layer * layer-cat id:12 * layer-dog id:11 * o) a call with group_name_path_string = "toplayer" * will return -1, because this layer already exists * but is not a group layer. * */ gint32 gap_image_find_or_create_group_layer(gint32 image_id , gchar *group_name_path_string , gchar *delimiter , gint stackposition , gboolean enableCreate ) { gchar **nameArray; gchar *namePtr; gint l_nlayers; gint l_ii; gint l_idx; gint l_position; gint32 *l_src_layers; gint32 l_parent_layer_id; gint32 l_group_layer_id; if (group_name_path_string == NULL) { return (0); } if (*group_name_path_string == '\0') { return (0); } l_parent_layer_id = 0; /* start at top imagelevel */ l_group_layer_id = -1; l_position = stackposition; if(delimiter != NULL) { nameArray = g_strsplit(group_name_path_string , delimiter , -1 /* max_tokens less than 1 splits the string completely. */ ); } else { nameArray = g_malloc(sizeof(gchar*) * 2); nameArray[0] = g_strdup(group_name_path_string); nameArray[1] = NULL; } if (nameArray == NULL) { return (0); } l_src_layers = gimp_image_get_layers (image_id, &l_nlayers); if (l_src_layers == NULL) { if (enableCreate) { l_group_layer_id = gap_image_greate_group_layer_path(image_id , l_parent_layer_id /* 0 is on top imagelevel */ , l_position /* 0 on top stackposition */ , nameArray , 0 ); } g_strfreev(nameArray); return (l_group_layer_id); } for(l_ii = 0; nameArray[l_ii] != NULL; l_ii++) { gboolean l_found; l_found = FALSE; namePtr = nameArray[l_ii]; if(gap_debug) { printf("gap_image_find_or_create_group_layer: name[%d]:%s\n" , (int)l_ii , namePtr ); } for(l_idx = 0; l_idx < l_nlayers; l_idx++) { gchar *l_name; l_name = gimp_item_get_name(l_src_layers[l_idx]); if(gap_debug) { printf("cmp: name[%d]:%s with item[%d]:%d name:%s\n" , (int)l_ii , namePtr , (int)l_idx , (int)l_src_layers[l_idx] , l_name ); } if (strcmp(l_name, namePtr) == 0) { if (gimp_item_is_group(l_src_layers[l_idx])) { l_parent_layer_id = l_src_layers[l_idx]; l_position = 0; l_found = TRUE; } else { if(gap_debug) { printf("ERROR: gap_image_find_or_create_group_layer the path\n %s\n" " refers to an already existing item that is NOT a GROUP\n" , group_name_path_string ); } g_free(l_name); g_free(l_src_layers); return (-1); } } g_free(l_name); if (l_found) { break; } } g_free(l_src_layers); l_src_layers = NULL; if(gap_debug) { printf(" l_found:%d l_parent_layer_id:%d\n" , (int)l_found , (int)l_parent_layer_id ); } if (l_found) { if (nameArray[l_ii +1] == NULL) { /* no more names to compare and all did match, we are done */ l_group_layer_id = l_parent_layer_id; } else { /* check next treelevel i.e. members of the current group */ l_src_layers = gimp_item_get_children (l_parent_layer_id, &l_nlayers); } } else { if (enableCreate) { /* create all missing groups/subgroups */ l_group_layer_id = gap_image_greate_group_layer_path(image_id , l_parent_layer_id /* 0 is on top imagelevel */ , l_position /* 0 on top stackposition */ , nameArray , l_ii ); } break; } } if(gap_debug) { printf("gap_image_find_or_create_group_layer BEFORE g_strfreev l_group_layer_id:%d\n" ,(int)l_group_layer_id ); } g_strfreev(nameArray); return(l_group_layer_id); } /* end gap_image_find_or_create_group_layer */