Mercurial > projects > dwt2
changeset 50:d5075f5226e5
[swt lin]
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 15:30:20 +0100 |
parents | 7a2dd761a8b2 |
children | c01d033c633a |
files | base/src/java/lang/String.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTError.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTException.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/DefaultContent.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/c/Xlib.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/DirectoryDialog.d org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/FileDialog.d |
diffstat | 8 files changed, 72 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/base/src/java/lang/String.d Fri Mar 27 12:59:54 2009 +0100 +++ b/base/src/java/lang/String.d Fri Mar 27 15:30:20 2009 +0100 @@ -21,11 +21,19 @@ alias char[] CString; alias wchar[] String16; alias wchar[] CString16; + alias char* ICharPtr; + alias char* CCharPtr; + alias wchar* CWCharPtr; + alias wchar* IWCharPtr; } else { // Phobos alias string String; alias wstring String16; - mixin("alias const(char)[] CString;"); - mixin("alias const(wchar)[] CString16;"); + mixin("alias const(char)[] CString;"); + mixin("alias const(wchar)[] CString16;"); + mixin("alias invariant(char*) ICharPtr;"); + mixin("alias const(char*) CCharPtr;"); + mixin("alias const(wchar*) CWCharPtr;"); + mixin("alias invariant(wchar*) IWCharPtr;"); } int codepointIndexToIndex( String str, int cpIndex ){ @@ -724,19 +732,19 @@ public alias tango.stdc.stringz.fromStringz fromStringz; public alias tango.stdc.stringz.fromString16z fromString16z; } else { // Phobos - public char* toStringz( String s ){ + public char* toStringz( CString s ){ implMissing(__FILE__,__LINE__); return null; } - public wchar* toString16z( String16 s ){ + public wchar* toString16z( CString16 s ){ implMissing(__FILE__,__LINE__); return null; } - public char[] fromStringz( String s ){ + public char[] fromStringz( CCharPtr s ){ implMissing(__FILE__,__LINE__); return null; } - public char[] fromString16z( String16 s ){ + public char[] fromString16z( CWCharPtr s ){ implMissing(__FILE__,__LINE__); return null; }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTError.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTError.d Fri Mar 27 15:30:20 2009 +0100 @@ -54,11 +54,11 @@ * The underlying throwable that caused the problem, * or null if this information is not available. */ - public Exception throwable( Exception e ){ + public Throwable throwable( Throwable e ){ this.next = e; return this.next; } - public Exception throwable(){ + public Throwable throwable(){ return this.next; } @@ -121,7 +121,7 @@ * * @since 3.1 */ -public Exception getCause() { +public Throwable getCause() { return throwable; }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTException.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/SWTException.d Fri Mar 27 15:30:20 2009 +0100 @@ -48,11 +48,11 @@ * The underlying throwable that caused the problem, * or null if this information is not available. */ - public Exception throwable( Exception e ){ + public Throwable throwable( Throwable e ){ this.next = e; return this.next; } - public Exception throwable(){ + public Throwable throwable(){ return this.next; } @@ -116,7 +116,7 @@ * * @since 3.1 */ -public Exception getCause() { +public Throwable getCause() { return throwable; }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/DefaultContent.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/DefaultContent.d Fri Mar 27 15:30:20 2009 +0100 @@ -26,6 +26,7 @@ version(Tango){ static import tango.io.model.IFile; } else { // Phobos + static import std.string; }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/c/Xlib.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/c/Xlib.d Fri Mar 27 15:30:20 2009 +0100 @@ -1341,7 +1341,7 @@ extern (C) uint function(void *, uint, Visual *, int)XCreateColormap; extern (C) uint function(void *, uint)XCopyColormapAndFree; extern (C) int function(void *, char * *, int, int, uint *)XInternAtoms; -extern (C) uint function(void *, char *, int)XInternAtom; +extern (C) uint function(void *, in char *, int)XInternAtom; extern (C) _BCD_func__894 function(void *, _BCD_func__894)XSetAfterFunction; extern (C) _BCD_func__894 function(void *, int)XSynchronize; extern (C) char * function(uint)XKeysymToString; @@ -2169,7 +2169,7 @@ extern (C) uint XCreateColormap(void *, uint, Visual *, int); extern (C) uint XCopyColormapAndFree(void *, uint); extern (C) int XInternAtoms(void *, char * *, int, int, uint *); -extern (C) uint XInternAtom(void *, char *, int); +extern (C) uint XInternAtom(void *, in char *, int); extern (C) _BCD_func__894 XSetAfterFunction(void *, _BCD_func__894); extern (C) _BCD_func__894 XSynchronize(void *, int); extern (C) char * XKeysymToString(uint);
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/program/Program.d Fri Mar 27 15:30:20 2009 +0100 @@ -22,13 +22,17 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import java.lang.all; +import java.nonstandard.SharedLib; version(Tango){ -import tango.sys.SharedLib; -import tango.core.Array; -import tango.io.device.File; -import tango.io.stream.Lines; + static import tango.core.Array; + static import tango.io.device.File; + static import tango.io.stream.Lines; } else { // Phobos + static import std.string; + static import std.file; + static import std.algorithm; + static import std.iterator; } version( build ){ @@ -169,6 +173,19 @@ GList* function() gnome_vfs_get_registered_mime_types; char* function(char*) gnome_vfs_mime_type_from_name; } + Symbol symbols[] = [ + { "gnome_vfs_mime_get_default_application", cast(void**)&gnome_vfs_mime_get_default_application }, + { "gnome_vfs_make_uri_from_input_with_dirs", cast(void**)&gnome_vfs_make_uri_from_input_with_dirs }, + { "gnome_vfs_mime_application_launch", cast(void**)&gnome_vfs_mime_application_launch }, + { "gnome_vfs_mime_application_free", cast(void**)&gnome_vfs_mime_application_free }, + { "gnome_vfs_url_show", cast(void**)&gnome_vfs_url_show }, + { "gnome_vfs_make_uri_from_input", cast(void**)&gnome_vfs_make_uri_from_input }, + { "gnome_vfs_get_registered_mime_types", cast(void**)&gnome_vfs_get_registered_mime_types }, + { "gnome_vfs_mime_get_extensions_list", cast(void**)&gnome_vfs_mime_get_extensions_list }, + { "gnome_vfs_mime_extensions_list_free", cast(void**)&gnome_vfs_mime_extensions_list_free }, + { "gnome_vfs_mime_registered_mime_type_list_free", cast(void**)&gnome_vfs_mime_registered_mime_type_list_free }, + { "gnome_vfs_mime_type_from_name", cast(void**)&gnome_vfs_mime_type_from_name } + ]; } /** @@ -263,24 +280,11 @@ }); /* Check for libgnomevfs-2 version 2.4 */ String buffer = "libgnomevfs-2.so.0"; - auto libgnomevfs = SharedLib.load(buffer ); - if (libgnomevfs !is null) { - buffer = "gnome_vfs_url_show"; - void* gnome_vfs_url_show = libgnomevfs.getSymbol( buffer.ptr ); - if (gnome_vfs_url_show !is null) { + SharedLib.tryUseSymbol( "gnome_vfs_url_show", buffer, (void*){ desktop = DESKTOP_GNOME_24; - } - *cast(void**)&GNOME.gnome_vfs_mime_get_default_application = libgnomevfs.getSymbol( "gnome_vfs_mime_get_default_application" ); - *cast(void**)&GNOME.gnome_vfs_make_uri_from_input_with_dirs = libgnomevfs.getSymbol( "gnome_vfs_make_uri_from_input_with_dirs" ); - *cast(void**)&GNOME.gnome_vfs_mime_application_launch = libgnomevfs.getSymbol( "gnome_vfs_mime_application_launch" ); - *cast(void**)&GNOME.gnome_vfs_mime_application_free = libgnomevfs.getSymbol( "gnome_vfs_mime_application_free" ); - *cast(void**)&GNOME.gnome_vfs_url_show = libgnomevfs.getSymbol( "gnome_vfs_url_show" ); - *cast(void**)&GNOME.gnome_vfs_make_uri_from_input = libgnomevfs.getSymbol( "gnome_vfs_make_uri_from_input" ); - *cast(void**)&GNOME.gnome_vfs_get_registered_mime_types = libgnomevfs.getSymbol( "gnome_vfs_get_registered_mime_types" ); - *cast(void**)&GNOME.gnome_vfs_mime_get_extensions_list = libgnomevfs.getSymbol( "gnome_vfs_mime_get_extensions_list" ); - *cast(void**)&GNOME.gnome_vfs_mime_extensions_list_free = libgnomevfs.getSymbol( "gnome_vfs_mime_extensions_list_free" ); - *cast(void**)&GNOME.gnome_vfs_mime_registered_mime_type_list_free = libgnomevfs.getSymbol( "gnome_vfs_mime_registered_mime_type_list_free" ); - *cast(void**)&GNOME.gnome_vfs_mime_type_from_name = libgnomevfs.getSymbol( "gnome_vfs_mime_type_from_name" ); + }); + if( desktop is DESKTOP_GNOME_24 ){ + SharedLib.loadLibSymbols( GNOME.symbols, buffer ); } } } @@ -543,7 +547,7 @@ char* fileNameBuffer = toStringz(fileName); char* uri = GNOME.gnome_vfs_make_uri_from_input(fileNameBuffer); if (uri !is null) { - fileName = fromStringz( uri ).dup; + fileName = fromStringz( uri )._idup(); OS.g_free(uri); } } @@ -595,8 +599,11 @@ + This is a temporary workaround until SWT will get the real implementation. +/ static String[][ String ] gnome24_getMimeInfo() { - scope file = new tango.io.device.File.File ("/usr/share/mime/globs"); - scope it = new Lines!(char)(file); + version(Tango){ + scope it = new Lines!(char)(tango.io.device.File.get("/usr/share/mime/globs")); + } else { // Phobos + scope it = std.string.splitlines( cast(String)std.file.read("/usr/share/mime/globs")); + } // process file one line at a time String[][ String ] mimeInfo; foreach (line; it ){ @@ -607,8 +614,8 @@ if( line.length < colon+3 || line[colon+1 .. colon+3 ] != "*." ){ continue; } - String mimeType = line[0..colon].dup; - String ext = line[colon+3 .. $].dup; + String mimeType = line[0..colon]._idup(); + String ext = line[colon+3 .. $]._idup(); if( auto exts = mimeType in mimeInfo ){ mimeInfo[ mimeType ] = *exts ~ ext; } @@ -631,8 +638,8 @@ GList* mimeList = GNOME.gnome_vfs_get_registered_mime_types(); GList* mimeElement = mimeList; while (mimeElement !is null) { - char* mimePtr = cast(char*) OS.g_list_data(mimeElement); - String mimeTypeBuffer = fromStringz(mimePtr).dup; + auto mimePtr = cast(char*) OS.g_list_data(mimeElement); + String mimeTypeBuffer = fromStringz(mimePtr)._idup(); String mimeType = mimeTypeBuffer;//new String(Converter.mbcsToWcs(null, mimeTypeBuffer)); GList* extensionList = GNOME.gnome_vfs_mime_get_extensions_list(mimePtr); if (extensionList !is null) { @@ -640,7 +647,7 @@ GList* extensionElement = extensionList; while (extensionElement !is null) { char* extensionPtr = cast(char*) OS.g_list_data(extensionElement); - String extensionBuffer = fromStringz(extensionPtr).dup; + String extensionBuffer = fromStringz(extensionPtr)._idup(); String extension = extensionBuffer; extension = '.' ~ extension; extensions ~= extension; @@ -661,7 +668,7 @@ char* extensionBuffer = toStringz(fileName); char* typeName = GNOME.gnome_vfs_mime_type_from_name(extensionBuffer); if (typeName !is null) { - mimeType = fromStringz(typeName).dup; + mimeType = fromStringz(typeName)._idup(); } return mimeType; } @@ -675,18 +682,18 @@ program.display = display; program.name = mimeType; GnomeVFSMimeApplication* application = ptr; - String buffer = fromStringz(application.command).dup; + String buffer = fromStringz(application.command)._idup(); program.command = buffer; program.gnomeExpectUri = application.expects_uris is GNOME.GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS; - buffer = fromStringz( application.id) ~ '\0'; + buffer = (fromStringz( application.id) ~ '\0')._idup(); ValueWrapperInt gnomeIconTheme = cast(ValueWrapperInt)display.getData(ICON_THEME_DATA); - char* icon_name = GNOME.gnome_icon_lookup( cast(GtkIconTheme*) gnomeIconTheme.value, null, null, buffer.ptr, null, mimeTypeBuffer, + char* icon_name = GNOME.gnome_icon_lookup( cast(GtkIconTheme*) gnomeIconTheme.value, null, null, cast(char*)buffer.ptr, null, mimeTypeBuffer, GNOME.GNOME_ICON_LOOKUP_FLAGS_NONE, null); char* path = null; if (icon_name !is null) path = GNOME.gnome_icon_theme_lookup_icon(cast(GtkIconTheme*)gnomeIconTheme.value, icon_name, PREFERRED_ICON_SIZE, null, null); if (path !is null) { - program.iconPath = fromStringz( path).dup; + program.iconPath = fromStringz( path)._idup(); OS.g_free(path); } if (icon_name !is null) OS.g_free(icon_name); @@ -775,7 +782,12 @@ String mimeType = keys[ keyIdx ]; String[] mimeExts = mimeInfo[mimeType]; for (int index = 0; index < mimeExts.length; index++){ - if (!extensions.contains(mimeExts[index])) { + version(Tango){ + bool contains = extensions.contains(mimeExts[index]); + } else { // Phobos + bool contains = std.algorithm.find(extensions, mimeExts[index]) != std.iterator.end(extension); + } + if (!contains) { extensions ~= mimeExts[index]; } }
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/DirectoryDialog.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/DirectoryDialog.d Fri Mar 27 15:30:20 2009 +0100 @@ -52,7 +52,7 @@ version(Tango){ static const String SEPARATOR = tango.io.model.IFile.FileConst.PathSeparatorString; } else { // Phobos - static const String SEPARATOR = std.path.sep; + static String SEPARATOR = std.path.sep; } /**
--- a/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/FileDialog.d Fri Mar 27 12:59:54 2009 +0100 +++ b/org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/FileDialog.d Fri Mar 27 15:30:20 2009 +0100 @@ -60,7 +60,7 @@ version(Tango){ static const char SEPARATOR = tango.io.model.IFile.FileConst.PathSeparatorChar; } else { // Phobos - static const char SEPARATOR = std.path.sep; + static const char SEPARATOR = std.path.sep[0]; } static const char EXTENSION_SEPARATOR = ';';