Mercurial > projects > dwt-linux
comparison dwt/program/Program.d @ 206:3cb84407dc3e
Temporary impl for Program.getExtensions on gnome 2.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 08 Mar 2008 23:00:05 +0100 |
parents | 5db57b8ff1a9 |
children | 380bad9f6852 |
comparison
equal
deleted
inserted
replaced
205:0fca38f4a7c0 | 206:3cb84407dc3e |
---|---|
26 import tango.sys.SharedLib; | 26 import tango.sys.SharedLib; |
27 import tango.stdc.stringz; | 27 import tango.stdc.stringz; |
28 import tango.core.Exception; | 28 import tango.core.Exception; |
29 import tango.core.Array; | 29 import tango.core.Array; |
30 import tango.text.convert.Format; | 30 import tango.text.convert.Format; |
31 import tango.io.FileConduit; | |
32 import tango.text.stream.LineIterator; | |
31 | 33 |
32 version( build ){ | 34 version( build ){ |
33 pragma(link, "gnomeui-2" ); | 35 pragma(link, "gnomeui-2" ); |
34 } | 36 } |
35 | 37 |
581 return new ImageData(iconPath); | 583 return new ImageData(iconPath); |
582 } catch (Exception e) {} | 584 } catch (Exception e) {} |
583 return null; | 585 return null; |
584 } | 586 } |
585 | 587 |
588 /++ | |
589 + DWT Extension | |
590 + This is a temporary workaround until SWT will get the real implementation. | |
591 +/ | |
592 static 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 } | |
586 /** | 616 /** |
587 * GNOME - Get mime types | 617 * GNOME - Get mime types |
588 * | 618 * |
589 * Obtain the registered mime type information and | 619 * Obtain the registered mime type information and |
590 * return it in a map. The key of each entry | 620 * return it in a map. The key of each entry |
725 */ | 755 */ |
726 static char[][] getExtensions(Display display) { | 756 static char[][] getExtensions(Display display) { |
727 int desktop = getDesktop(display); | 757 int desktop = getDesktop(display); |
728 char[][][ char[] ] mimeInfo = null; | 758 char[][][ char[] ] mimeInfo = null; |
729 switch (desktop) { | 759 switch (desktop) { |
730 case DESKTOP_GNOME_24: break; | 760 case DESKTOP_GNOME_24: mimeInfo = gnome24_getMimeInfo(); break; |
731 case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break; | 761 case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break; |
732 //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break; | 762 //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break; |
733 default: | 763 default: |
734 } | 764 } |
735 if (mimeInfo is null) return new char[][0]; | 765 if (mimeInfo is null) return null; |
736 | 766 |
737 /* Create a unique set of the file extensions. */ | 767 /* Create a unique set of the file extensions. */ |
738 char[][] extensions; | 768 char[][] extensions; |
739 char[][] keys = mimeInfo.keys; | 769 char[][] keys = mimeInfo.keys; |
740 int keyIdx = 0; | 770 int keyIdx = 0; |