-
-unsigned char pnd_emit_dotdesktop ( char *targetpath, pnd_disco_t *p ) {
- char filename [ FILENAME_MAX ];
- char buffer [ 1024 ];
- FILE *f;
-
- // specification
- // http://standards.freedesktop.org/desktop-entry-spec
-
- // validation
-
- if ( ! p -> unique_id ) {
- return ( 0 );
- }
-
- if ( ! p -> exec ) {
- return ( 0 );
- }
-
- // set up
-
- sprintf ( filename, "%s/%s.desktop", targetpath, p -> unique_id );
-
- // emit
-
- //printf ( "EMIT DOTDESKTOP '%s'\n", filename );
-
- f = fopen ( filename, "w" );
-
- if ( ! f ) {
- return ( 0 );
- }
-
- if ( p -> title_en ) {
- snprintf ( buffer, 1020, "Name=%s\n", p -> title_en );
- fprintf ( f, "%s", buffer );
- }
-
- fprintf ( f, "Type=Application\n" );
- fprintf ( f, "Version=1.0\n" );
-
- if ( p -> icon ) {
- snprintf ( buffer, 1020, "Icon=%s\n", p -> icon );
- fprintf ( f, "%s", buffer );
- }
-
-#if 0
- if ( p -> description_en ) {
- snprintf ( buffer, 1020, "Comment=%s\n", p -> description_en );
- fprintf ( f, "%s", buffer );
- }
-#endif
-
-#if 0
- if ( p -> startdir ) {
- snprintf ( buffer, 1020, "Path=%s\n", p -> startdir );
- fprintf ( f, "%s", buffer );
- } else {
- fprintf ( f, "Path=%s\n", PND_DEFAULT_WORKDIR );
- }
-#endif
-
- if ( p -> exec ) {
- snprintf ( buffer, 1020, "Exec=%s\n", p -> exec );
- fprintf ( f, "%s", buffer );
- }
-
- fprintf ( f, "_Source=libpnd\n" ); // should we need to know 'who' created the file during trimming
-
- fclose ( f );
-
- return ( 1 );
-}