Changeset 206:3cb84407dc3e

Show
Ignore:
Timestamp:
03/08/08 17:00:05 (6 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Temporary impl for Program.getExtensions on gnome 2.4

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/program/Program.d

    r191 r206  
    2929import tango.core.Array; 
    3030import tango.text.convert.Format; 
     31import tango.io.FileConduit; 
     32import tango.text.stream.LineIterator; 
    3133 
    3234version( build ){ 
     
    584586} 
    585587 
     588/++ 
     589 + DWT Extension 
     590 + This is a temporary workaround until SWT will get the real implementation. 
     591 +/ 
     592static char[][][ char[] ] gnome24_getMimeInfo() { 
     593    scope file = new FileConduit ("/usr/share/mime/globs"); 
     594    scope it = new LineIterator!(char)(file); 
     595    // process file one line at a time 
     596    char[][][ char[] ] mimeInfo; 
     597    foreach (line; it ){ 
     598        int colon = line.indexOf(':'); 
     599        if( colon is line.length ){ 
     600            continue; 
     601        } 
     602        if( line.length < colon+3 || line[colon+1 .. colon+3 ] != "*." ){ 
     603            continue; 
     604        } 
     605        char[] mimeType = line[0..colon].dup; 
     606        char[] ext      = line[colon+3 .. $].dup; 
     607        if( auto exts = mimeType in mimeInfo ){ 
     608            mimeInfo[ mimeType ] = *exts ~ ext; 
     609        } 
     610        else{ 
     611            mimeInfo[ mimeType ] = [ ext ]; 
     612        } 
     613    } 
     614    return mimeInfo; 
     615} 
    586616/** 
    587617 * GNOME - Get mime types 
     
    728758    char[][][ char[] ] mimeInfo = null; 
    729759    switch (desktop) { 
    730         case DESKTOP_GNOME_24: break; 
     760        case DESKTOP_GNOME_24: mimeInfo = gnome24_getMimeInfo(); break; 
    731761        case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break; 
    732762        //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break; 
    733763        default: 
    734764    } 
    735     if (mimeInfo is null) return new char[][0]
     765    if (mimeInfo is null) return null
    736766 
    737767    /* Create a unique set of the file extensions. */