Show
Ignore:
Timestamp:
05/04/08 18:42:55 (4 years ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

reverted char[] to String

Files:

Legend:

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

    r206 r238  
    178178 */ 
    179179public final class Program { 
    180     char[] name; 
    181     char[] command; 
    182     char[] iconPath; 
     180    String name; 
     181    String command; 
     182    String iconPath; 
    183183    Display display; 
    184184 
     
    191191    static int /*long*/ cdeShell; 
    192192 
    193     static const char[][] CDE_ICON_EXT = [ ".m.pm"[],   ".l.pm",   ".s.pm",   ".t.pm" ]; 
    194     static const char[][] CDE_MASK_EXT = [ ".m_m.bm"[], ".l_m.bm", ".s_m.bm", ".t_m.bm" ]; 
    195     static const char[] DESKTOP_DATA = "Program_DESKTOP"; 
    196     static const char[] ICON_THEME_DATA = "Program_GNOME_ICON_THEME"; 
     193    static const String[] CDE_ICON_EXT = [ ".m.pm"[],   ".l.pm",   ".s.pm",   ".t.pm" ]; 
     194    static const String[] CDE_MASK_EXT = [ ".m_m.bm"[], ".l_m.bm", ".s_m.bm", ".t_m.bm" ]; 
     195    static const String DESKTOP_DATA = "Program_DESKTOP"; 
     196    static const String ICON_THEME_DATA = "Program_GNOME_ICON_THEME"; 
    197197    static const int DESKTOP_UNKNOWN = 0; 
    198198    static const int DESKTOP_GNOME = 1; 
     
    237237     */ 
    238238    if (desktop is DESKTOP_UNKNOWN) { 
    239         char[] gnomeName = "_NET_SUPPORTING_WM_CHECK"; 
     239        String gnomeName = "_NET_SUPPORTING_WM_CHECK"; 
    240240        int /*long*/ gnome = OS.XInternAtom(xDisplay, gnomeName.ptr, true); 
    241241        if (gnome !is OS.None && gnome_init()) { 
     
    258258            }); 
    259259            /* Check for libgnomevfs-2 version 2.4 */ 
    260             char[] buffer = "libgnomevfs-2.so.0"; 
     260            String buffer = "libgnomevfs-2.so.0"; 
    261261            auto libgnomevfs = SharedLib.load(buffer ); 
    262262            if (libgnomevfs !is null) { 
     
    289289    */ 
    290290    if (desktop is DESKTOP_UNKNOWN) { 
    291         char[] cdeName = "_DT_SM_PREFERENCES"; 
     291        String cdeName = "_DT_SM_PREFERENCES"; 
    292292        int /*long*/ cde = OS.XInternAtom(xDisplay, cdeName.ptr, true); 
    293293        for (int index = 0; desktop is DESKTOP_UNKNOWN && index < property.length; index++) { 
     
    304304// PORTING CDE not supported 
    305305/+ 
    306 bool cde_execute(char[] fileName) { 
     306bool cde_execute(String fileName) { 
    307307    /* Use the character encoding for the default locale */ 
    308308    char* action = toStringz(command); 
     
    318318} 
    319319 
    320 static char[] cde_getAction(char[] dataType) { 
    321     char[] action  = null; 
    322     char[] actions = cde_getAttribute(dataType, CDE.DtDTS_DA_ACTION_LIST); 
     320static String cde_getAction(String dataType) { 
     321    String action  = null; 
     322    String actions = cde_getAttribute(dataType, CDE.DtDTS_DA_ACTION_LIST); 
    323323    if (actions !is null) { 
    324324        int index = actions.indexOf("Open"); 
     
    333333} 
    334334 
    335 static char[] cde_getAttribute(char[] dataType, char[] attrName) { 
     335static String cde_getAttribute(String dataType, String attrName) { 
    336336    /* Use the character encoding for the default locale */ 
    337337    byte[] dataTypeBuf = Converter.wcsToMbcs(null, dataType, true); 
     
    345345    CDE.DtDtsFreeAttributeValue(attrValue); 
    346346    /* Use the character encoding for the default locale */ 
    347     return new char[](Converter.mbcsToWcs(null, attrValueBuf)); 
    348 } 
    349  
    350 static char[][][ char[] ] cde_getDataTypeInfo() { 
    351     char[][][ char[] ] dataTypeInfo; 
     347    return new String(Converter.mbcsToWcs(null, attrValueBuf)); 
     348} 
     349 
     350static String[][ String ] cde_getDataTypeInfo() { 
     351    String[][ String ] dataTypeInfo; 
    352352    int index; 
    353353    int /*long*/ dataTypeList = CDE.DtDtsDataTypeNames(); 
     
    362362            OS.memmove(dataTypeBuf, dataType[0], length); 
    363363            /* Use the character encoding for the default locale */ 
    364             char[] dataTypeName = new char[](Converter.mbcsToWcs(null, dataTypeBuf)); 
     364            String dataTypeName = new String(Converter.mbcsToWcs(null, dataTypeBuf)); 
    365365 
    366366            /* The data type is valid if it is not an action, and it has an extension and an action. */ 
    367             char[] extension = cde_getExtension(dataTypeName); 
     367            String extension = cde_getExtension(dataTypeName); 
    368368            if (!CDE.DtDtsDataTypeIsAction(dataTypeBuf) && 
    369369                extension !is null && cde_getAction(dataTypeName) !is null) { 
    370                 char[][] exts; 
     370                String[] exts; 
    371371                exts ~= extension; 
    372372                dataTypeInfo[ dataTypeName ] = exts; 
     
    380380} 
    381381 
    382 static char[] cde_getExtension(char[] dataType) { 
    383     char[] fileExt = cde_getAttribute(dataType, CDE.DtDTS_DA_NAME_TEMPLATE); 
     382static String cde_getExtension(String dataType) { 
     383    String fileExt = cde_getAttribute(dataType, CDE.DtDTS_DA_NAME_TEMPLATE); 
    384384    if (fileExt is null || fileExt.indexOf("%s.") is -1) return null; 
    385385    int dot = fileExt.indexOf("."); 
     
    403403} 
    404404 
    405 static char[] cde_getMimeType(char[] extension) { 
    406     char[] mimeType = null; 
    407     char[][][ char[] ] mimeInfo = cde_getDataTypeInfo(); 
     405static String cde_getMimeType(String extension) { 
     406    String mimeType = null; 
     407    String[][ String ] mimeInfo = cde_getDataTypeInfo(); 
    408408    if (mimeInfo is null) return null; 
    409     char[][] keys = mimeInfo.keys(); 
     409    String[] keys = mimeInfo.keys(); 
    410410    int keyIdx = 0; 
    411411    while (mimeType is null && keyIdx < keys.length ) { 
    412         char[] type = keys[ keyIdx ]; 
    413         char[][] mimeExts = mimeInfo[type]; 
     412        String type = keys[ keyIdx ]; 
     413        String[] mimeExts = mimeInfo[type]; 
    414414        for (int index = 0; index < mimeExts.length; index++){ 
    415415            if (extension.equals(mimeExts[index])) { 
     
    423423} 
    424424 
    425 static Program cde_getProgram(Display display, char[] mimeType) { 
     425static Program cde_getProgram(Display display, String mimeType) { 
    426426    Program program = new Program(); 
    427427    program.display = display; 
     
    458458+/ 
    459459 
    460 static char[][] parseCommand(char[] cmd) { 
    461     char[][] args; 
     460static String[] parseCommand(String cmd) { 
     461    String[] args; 
    462462    int sIndex = 0; 
    463463    int eIndex; 
     
    496496    } 
    497497 
    498     char[][] strings = new char[][args.length]; 
     498    String[] strings = new String[args.length]; 
    499499    for (int index =0; index < args.length; index++) { 
    500500        strings[index] = args[index]; 
     
    506506 * GNOME 2.4 - Execute the program for the given file. 
    507507 */ 
    508 bool gnome_24_execute(char[] fileName) { 
     508bool gnome_24_execute(String fileName) { 
    509509    char* mimeTypeBuffer = toStringz(name); 
    510510    auto ptr = GNOME.gnome_vfs_mime_get_default_application(mimeTypeBuffer); 
     
    522522 * GNOME 2.4 - Launch the default program for the given file. 
    523523 */ 
    524 static bool gnome_24_launch(char[] fileName) { 
     524static bool gnome_24_launch(String fileName) { 
    525525    char* fileNameBuffer = toStringz(fileName); 
    526526    char* uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT); 
     
    533533 * GNOME 2.2 - Execute the program for the given file. 
    534534 */ 
    535 bool gnome_execute(char[] fileName) { 
     535bool gnome_execute(String fileName) { 
    536536    if (gnomeExpectUri) { 
    537537        /* Convert the given path into a URL */ 
     
    545545 
    546546    /* Parse the command into its individual arguments. */ 
    547     char[][] args = parseCommand(command); 
     547    String[] args = parseCommand(command); 
    548548    int fileArg = -1; 
    549549    int index; 
     
    551551        int j = args[index].indexOf("%f"); 
    552552        if (j !is -1) { 
    553             char[] value = args[index]; 
     553            String value = args[index]; 
    554554            fileArg = index; 
    555555            args[index] = value.substring(0, j) ~ fileName ~ value.substring(j + 2); 
     
    559559    /* If a file name was given but the command did not have "%f" */ 
    560560    if ((fileName.length > 0) && (fileArg < 0)) { 
    561         char[][] newArgs = new char[][args.length + 1]; 
     561        String[] newArgs = new String[args.length + 1]; 
    562562        for (index = 0; index < args.length; index++) newArgs[index] = args[index]; 
    563563        newArgs[args.length] = fileName; 
     
    590590 + This is a temporary workaround until SWT will get the real implementation. 
    591591 +/ 
    592 static char[][][ char[] ] gnome24_getMimeInfo() { 
     592static String[][ String ] gnome24_getMimeInfo() { 
    593593    scope file = new FileConduit ("/usr/share/mime/globs"); 
    594594    scope it = new LineIterator!(char)(file); 
    595595    // process file one line at a time 
    596     char[][][ char[] ] mimeInfo; 
     596    String[][ String ] mimeInfo; 
    597597    foreach (line; it ){ 
    598598        int colon = line.indexOf(':'); 
     
    603603            continue; 
    604604        } 
    605         char[] mimeType = line[0..colon].dup; 
    606         char[] ext      = line[colon+3 .. $].dup; 
     605        String mimeType = line[0..colon].dup; 
     606        String ext      = line[colon+3 .. $].dup; 
    607607        if( auto exts = mimeType in mimeInfo ){ 
    608608            mimeInfo[ mimeType ] = *exts ~ ext; 
     
    622622 * a vector of the associated file extensions. 
    623623 */ 
    624 static char[][][ char[] ] gnome_getMimeInfo() { 
    625     char[][][ char[] ] mimeInfo; 
     624static String[][ String ] gnome_getMimeInfo() { 
     625    String[][ String ] mimeInfo; 
    626626    GList* mimeList = GNOME.gnome_vfs_get_registered_mime_types(); 
    627627    GList* mimeElement = mimeList; 
    628628    while (mimeElement !is null) { 
    629629        char* mimePtr = cast(char*) OS.g_list_data(mimeElement); 
    630         char[] mimeTypeBuffer = fromStringz(mimePtr).dup; 
    631         char[] mimeType = mimeTypeBuffer;//new char[](Converter.mbcsToWcs(null, mimeTypeBuffer)); 
     630        String mimeTypeBuffer = fromStringz(mimePtr).dup; 
     631        String mimeType = mimeTypeBuffer;//new String(Converter.mbcsToWcs(null, mimeTypeBuffer)); 
    632632        GList* extensionList = GNOME.gnome_vfs_mime_get_extensions_list(mimePtr); 
    633633        if (extensionList !is null) { 
    634             char[][] extensions; 
     634            String[] extensions; 
    635635            GList* extensionElement = extensionList; 
    636636            while (extensionElement !is null) { 
    637637                char* extensionPtr = cast(char*) OS.g_list_data(extensionElement); 
    638                 char[] extensionBuffer = fromStringz(extensionPtr).dup; 
    639                 char[] extension = extensionBuffer; 
     638                String extensionBuffer = fromStringz(extensionPtr).dup; 
     639                String extension = extensionBuffer; 
    640640                extension = '.' ~ extension; 
    641641                extensions ~= extension; 
     
    651651} 
    652652 
    653 static char[] gnome_getMimeType(char[] extension) { 
    654     char[] mimeType = null; 
    655     char[] fileName = "swt" ~ extension; 
     653static String gnome_getMimeType(String extension) { 
     654    String mimeType = null; 
     655    String fileName = "swt" ~ extension; 
    656656    char* extensionBuffer = toStringz(fileName); 
    657657    char* typeName = GNOME.gnome_vfs_mime_type_from_name(extensionBuffer); 
     
    662662} 
    663663 
    664 static Program gnome_getProgram(Display display, char[] mimeType) { 
     664static Program gnome_getProgram(Display display, String mimeType) { 
    665665    Program program = null; 
    666666    char* mimeTypeBuffer = toStringz(mimeType); 
     
    671671        program.name = mimeType; 
    672672        GnomeVFSMimeApplication* application = ptr; 
    673         char[] buffer = fromStringz(application.command).dup; 
     673        String buffer = fromStringz(application.command).dup; 
    674674        program.command = buffer; 
    675675        program.gnomeExpectUri = application.expects_uris is GNOME.GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS; 
     
    708708 *  </ul> 
    709709 */ 
    710 public static Program findProgram(char[] extension) { 
     710public static Program findProgram(String extension) { 
    711711    return findProgram(Display.getCurrent(), extension); 
    712712} 
     
    716716 *       become public and the original method above can be deprecated. 
    717717 */ 
    718 static Program findProgram(Display display, char[] extension) { 
     718static Program findProgram(Display display, String extension) { 
    719719    if (extension is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    720720    if (extension.length is 0) return null; 
    721721    if (extension.charAt(0) !is '.') extension = "." ~ extension; 
    722722    int desktop = getDesktop(display); 
    723     char[] mimeType = null; 
     723    String mimeType = null; 
    724724    switch (desktop) { 
    725725        case DESKTOP_GNOME_24: 
     
    746746 * @return an array of extensions 
    747747 */ 
    748 public static char[][] getExtensions() { 
     748public static String[] getExtensions() { 
    749749    return getExtensions(Display.getCurrent()); 
    750750} 
     
    754754 *       become public and the original method above can be deprecated. 
    755755 */ 
    756 static char[][] getExtensions(Display display) { 
     756static String[] getExtensions(Display display) { 
    757757    int desktop = getDesktop(display); 
    758     char[][][ char[] ] mimeInfo = null; 
     758    String[][ String ] mimeInfo = null; 
    759759    switch (desktop) { 
    760760        case DESKTOP_GNOME_24: mimeInfo = gnome24_getMimeInfo(); break; 
     
    766766 
    767767    /* Create a unique set of the file extensions. */ 
    768     char[][] extensions; 
    769     char[][] keys = mimeInfo.keys; 
     768    String[] extensions; 
     769    String[] keys = mimeInfo.keys; 
    770770    int keyIdx = 0; 
    771771    while ( keyIdx < keys.length ) { 
    772         char[] mimeType = keys[ keyIdx ]; 
    773         char[][] mimeExts = mimeInfo[mimeType]; 
     772        String mimeType = keys[ keyIdx ]; 
     773        String[] mimeExts = mimeInfo[mimeType]; 
    774774        for (int index = 0; index < mimeExts.length; index++){ 
    775775            if (!extensions.contains(mimeExts[index])) { 
     
    781781 
    782782    /* Return the list of extensions. */ 
    783     char[][] extStrings = new char[][]( extensions.length ); 
     783    String[] extStrings = new String[]( extensions.length ); 
    784784    for (int index = 0; index < extensions.length; index++) { 
    785785        extStrings[index] = extensions[index]; 
     
    805805static Program[] getPrograms(Display display) { 
    806806    int desktop = getDesktop(display); 
    807     char[][][ char[] ] mimeInfo = null; 
     807    String[][ String ] mimeInfo = null; 
    808808    switch (desktop) { 
    809809        case DESKTOP_GNOME_24: break; 
     
    814814    if (mimeInfo is null) return new Program[0]; 
    815815    Program[] programs; 
    816     char[][] keys = mimeInfo.keys; 
     816    String[] keys = mimeInfo.keys; 
    817817    int keyIdx = 0; 
    818818    while ( keyIdx < keys.length ) { 
    819         char[] mimeType = keys[ keyIdx ]; 
     819        String mimeType = keys[ keyIdx ]; 
    820820        Program program = null; 
    821821        switch (desktop) { 
     
    848848 * </ul> 
    849849 */ 
    850 public static bool launch(char[] fileName) { 
     850public static bool launch(String fileName) { 
    851851    return launch(Display.getCurrent(), fileName); 
    852852} 
     
    856856 *       become public and the original method above can be deprecated. 
    857857 */ 
    858 static bool launch(Display display, char[] fileName) { 
     858static bool launch(Display display, String fileName) { 
    859859    if (fileName is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 
    860860    switch(getDesktop(display)) { 
     
    864864            int index = fileName.lastIndexOf('.'); 
    865865            if (index !is -1) { 
    866                 char[] extension = fileName.substring (index); 
     866                String extension = fileName.substring (index); 
    867867                Program program = Program.findProgram (display, extension); 
    868868                if (program !is null && program.execute (fileName)) return true; 
     
    908908 * </ul> 
    909909 */ 
    910 public bool execute(char[] fileName) { 
     910public bool execute(String fileName) { 
    911911    if (fileName is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    912912    int desktop = getDesktop(display); 
     
    945945 * @return the name of the program 
    946946 */ 
    947 public char[] getName() { 
     947public String getName() { 
    948948    return name; 
    949949} 
     
    969969 * @return a string representation of the program 
    970970 */ 
    971 public char[] toString() { 
     971public String toString() { 
    972972    return Format( "Program {{{}}", name ); 
    973973}