summaryrefslogtreecommitdiffstats
path: root/xcfinfo.c
diff options
context:
space:
mode:
authorJulien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:31:25 (EST)
committer Julien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:31:25 (EST)
commitc29082d538224219586ef453f1291151a01c15bb (patch)
tree562684ed5430cdf5dad195f25707a6b3f4a4e716 /xcfinfo.c
parent30aef48ae5ee252dd42f206c4b5b9e770694417c (diff)
downloadxcftools-c29082d538224219586ef453f1291151a01c15bb.zip
xcftools-c29082d538224219586ef453f1291151a01c15bb.tar.gz
xcftools-c29082d538224219586ef453f1291151a01c15bb.tar.bz2
Add layer group support introduced in Gimp 2.8.
Changes introduced by this commit: - Update xcf-private.h with the file from the head of git's branch named gimp-2-8 (commit acebb4ad205901a9e8029a66ed5bca62cf13bc96). - Increase supported version number from 2 to 3. - Add the cases for PROP_GROUP_ITEM and PROP_ITEM_PATH in getBasicXcfInfo(). - Add the function printLayerPath() to print the groups containing a given layer. - Add an option --path-separator (string) to set the string to use to separate the groups in the paths. The output is unchanged for files whose version is lower than 3. Otherwise, the name of the layer now contains its path in the image and the marker "group" is added for the group layers in the fourth field. For example, here is the output of a file containing a single layer named "a", then one group named "G 1", which contains two layers named "b 1" and "c 2". The path separator is "|" by default: Version 3, 10x10 RGB color, 4 layers, compressed RLE + 10x10+0+0 RGB-alpha Normal |a + 10x10+0+0 RGB-alpha Normal/group |G 1 + 10x10+0+0 RGB-alpha Normal |G 1|b 1 + 10x10+0+0 RGB-alpha Normal |G 1|c 2
Diffstat (limited to 'xcfinfo.c')
-rw-r--r--xcfinfo.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/xcfinfo.c b/xcfinfo.c
index 7054fb5..21f4f93 100644
--- a/xcfinfo.c
+++ b/xcfinfo.c
@@ -42,6 +42,23 @@ usage(FILE *where)
}
}
+static void
+printLayerPath
+( unsigned layerIndex, const char* pathSeparator )
+{
+ int depth = XCF.layers[layerIndex].pathLength ;
+ int i = layerIndex;
+
+ if ( depth != 0 ) {
+ do {
+ i++;
+ } while ( XCF.layers[i].pathLength != depth - 1 );
+
+ printLayerPath( i, pathSeparator ) ;
+ printf( "%s%s", pathSeparator, XCF.layers[i].name );
+ }
+}
+
int
main(int argc,char **argv)
{
@@ -49,6 +66,7 @@ main(int argc,char **argv)
int option ;
const char *unzipper = NULL ;
const char *infile = NULL ;
+ const char *pathSeparator = "|";
setlocale(LC_ALL,"");
progname = argv[0] ;
@@ -95,7 +113,17 @@ main(int argc,char **argv)
printf("/%02d%%",XCF.layers[i].opacity * 100 / 255);
if( XCF.layers[i].hasMask )
printf(_("/mask"));
- printf(" %s\n",XCF.layers[i].name);
+ if( XCF.layers[i].isGroup )
+ printf(_("/group"));
+
+ printf( " " );
+
+ if ( XCF.version > 2 ) {
+ printLayerPath( i, pathSeparator );
+ printf( "%s", pathSeparator );
+ }
+
+ printf("%s\n",XCF.layers[i].name);
}
return 0 ;