Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 20615 Details for
Bug 79268
Program API does not work with GNOME 2.8 (libgnomevfs-WARNING)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Adds static icon retrieval methods to Mac OS X Carbon variant
swt-3.1M6-macosx-carbon_icon.patch (text/plain), 11.11 KB, created by
Ty C
on 2005-05-02 20:23:23 EDT
(
hide
)
Description:
Adds static icon retrieval methods to Mac OS X Carbon variant
Filename:
MIME Type:
Creator:
Ty C
Created:
2005-05-02 20:23:23 EDT
Size:
11.11 KB
patch
obsolete
>Index: Eclipse SWT PI/carbon/library/os.c >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/carbon/library/os.c,v >retrieving revision 1.60 >diff -u -r1.60 os.c >--- Eclipse SWT PI/carbon/library/os.c 28 Mar 2005 21:48:15 -0000 1.60 >+++ Eclipse SWT PI/carbon/library/os.c 2 May 2005 23:42:55 -0000 >@@ -5285,6 +5285,23 @@ > } > #endif > >+ >+#ifndef NO_GetIconRefFromTypeInfo >+JNIEXPORT jint JNICALL OS_NATIVE(GetIconRefFromTypeInfo) >+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5) >+{ >+ jint *lparg5=NULL; >+ jint rc = 0; >+ OS_NATIVE_ENTER(env, that, GetIconRefFromTypeInfo_FUNC); >+ if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail; >+ rc = (jint)GetIconRefFromTypeInfo((OSType)arg0, (OSType)arg1, (CFStringRef)arg2, (CFStringRef)arg3, arg4, (IconRef *)lparg5); >+fail: >+ if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0); >+ OS_NATIVE_EXIT(env, that, GetIconRefFromTypeInfo_FUNC); >+ return rc; >+} >+#endif >+ > #ifndef NO_GetIndMenuItemWithCommandID > JNIEXPORT jint JNICALL OS_NATIVE(GetIndMenuItemWithCommandID) > (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jshortArray arg4) >@@ -8276,6 +8293,26 @@ > } > #endif > >+#ifndef NO_PlotIconRefInContext >+JNIEXPORT jint JNICALL OS_NATIVE(PlotIconRefInContext) >+ (JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jint arg6) >+{ >+ jint rc = 0; >+ CGRect _arg1, *lparg1 = NULL; >+ RGBColor _arg4, *lparg4 = NULL; >+ OS_NATIVE_ENTER(env, that, PlotIconRefInContext_FUNC); >+ if (arg1) if ((lparg1 = getCGRectFields(env, arg1, &_arg1)) == NULL) goto failCGRect; >+ if (arg4) if ((lparg4 = getRGBColorFields(env, arg4, &_arg4)) == NULL) goto failRGBColor; >+ rc = (jint)PlotIconRefInContext((CGContextRef)arg0, (const CGRect *)lparg1, arg2, arg3, (const RGBColor *)lparg4, arg5, (IconRef)arg6); >+failRGBColor: >+ if (arg4 && lparg4) setRGBColorFields(env, arg4, lparg4); >+failCGRect: >+ if (arg1 && lparg1) setCGRectFields(env, arg1, lparg1); >+ OS_NATIVE_EXIT(env, that, PlotIconRefInContext_FUNC); >+ return rc; >+} >+#endif >+ > #ifndef NO_PopUpMenuSelect > JNIEXPORT jint JNICALL OS_NATIVE(PopUpMenuSelect) > (JNIEnv *env, jclass that, jint arg0, jshort arg1, jshort arg2, jshort arg3) >Index: Eclipse SWT PI/carbon/library/os_stats.h >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.h,v >retrieving revision 1.30 >diff -u -r1.30 os_stats.h >--- Eclipse SWT PI/carbon/library/os_stats.h 28 Mar 2005 21:48:15 -0000 1.30 >+++ Eclipse SWT PI/carbon/library/os_stats.h 2 May 2005 23:42:55 -0000 >@@ -396,6 +396,7 @@ > GetHandleSize_FUNC, > GetIconFamilyData_FUNC, > GetIconRef_FUNC, >+ GetIconRefFromTypeInfo_FUNC, > GetIndMenuItemWithCommandID_FUNC, > GetIndexedSubControl_FUNC, > GetItemMark_FUNC, >@@ -609,6 +610,7 @@ > PaintRoundRect_FUNC, > PenSize_FUNC, > PickColor_FUNC, >+ PlotIconRefInContext_FUNC, > PopUpMenuSelect_FUNC, > PostEvent_FUNC, > PostEventToQueue_FUNC, >Index: Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java,v >retrieving revision 1.166 >diff -u -r1.166 OS.java >--- Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java 28 Mar 2005 21:48:15 -0000 1.166 >+++ Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java 2 May 2005 23:42:57 -0000 >@@ -56,6 +56,7 @@ > public static final int kAlertStdAlertOKButton = 1; > public static final int kAlertStdAlertCancelButton = 2; > public static final int kAlertStdAlertOtherButton = 3; >+ public static final int kAlignNone = 0; > public static final int kAtSpecifiedOrigin = 0; > public static final int kATSDeletedGlyphcode = 0xFFFF; > public static final int kATSUDirectDataBaselineDeltaFixedArray = 1; >@@ -380,6 +381,8 @@ > public static final int kFontNoLanguageCode = -1; > public static final int kFontSelectionQDStyleVersionZero = 0; > public static final int kFontSelectionQDType = ('q'<<24) + ('s'<<16) + ('t'<<8) + 'l'; >+ public static final int kGenericDocumentIcon = ('d'<<24) + ('o'<<16) + ('c'<<8) + 'u'; >+ public static final int kGenericFolderIcon = ('f'<<24) + ('l'<<16) + ('d'<<8) + 'r'; > public static final int kHIComboBoxAutoCompletionAttribute = (1 << 0); > public static final int kHIComboBoxAutoSizeListAttribute = (1 << 3); > public static final int kHIComboBoxEditTextPart = 5; >@@ -496,6 +499,7 @@ > public static final int kNavUserActionSaveAs = 3; > public static final short kOnSystemDisk = -32768; > public static final int kOverlayWindowClass = 14; >+ public static final int kPlotIconRefNormalFlags = 0; > public static final int kPMCancel = 0x0080; > public static final int kPMDestinationFax = 3; > public static final int kPMDestinationFile = 2; >@@ -515,6 +519,7 @@ > public static final int kSystemIconsCreator = ('m'<<24) + ('a'<<16) + ('c'<<8) + 's'; > public static final int kSymbolLigaturesOffSelector = 17; > public static final int kControlSliderDoesNotPoint = 2; >+ public static final int kTransformNone = 0; > public static final int kTXNAlwaysWrapAtViewEdgeMask = 1 << 11; > public static final int kTXNBackgroundTypeRGB = 1; > public static final int kTXNDefaultFontSize = 0x000C0000; >@@ -1079,6 +1084,7 @@ > public static final native int GetHandleSize(int handle); > public static final native int GetIconFamilyData(int iconFamily, int iconType, int h); > public static final native int GetIconRef(short vRefNum, int creator, int iconType, int[] theIconRef); >+public static final native int GetIconRefFromTypeInfo(int inCreator, int inType, int inExtension, int inMIMEType, int inUsageFlags, int[] outIconRef); > public static final native int GetIndMenuItemWithCommandID(int mHandle, int commandId, int index, int[] outMenu, short[] outIndex); > public static final native int GetIndexedSubControl(int cHandle, short index, int[] outHandle); > public static final native void GetItemMark (int theMenu, short item, short[] markChar); >@@ -1250,6 +1256,7 @@ > public static final native void PaintRoundRect(Rect bounds, short ovalWidth, short ovalHeight); > public static final native void PenSize(short h, short v); > public static final native int PickColor(ColorPickerInfo theColorInfo); >+public static final native int PlotIconRefInContext(int inContext, CGRect inRect, int inAlign, int inTransform, RGBColor inLabelColor, int inFlags, int inIconRef); > public static final native int PopUpMenuSelect(int mHandle, short top, short left, short popUpItem); > public static final native int PostEvent(short eventNum, int eventMsg); > public static final native int PostEventToQueue(int inQueue, int inEvent, short inPriority); >Index: Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java,v >retrieving revision 1.19 >diff -u -r1.19 Program.java >--- Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java 1 Mar 2005 13:08:50 -0000 1.19 >+++ Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java 2 May 2005 23:42:58 -0000 >@@ -12,6 +12,8 @@ > > > import org.eclipse.swt.internal.*; >+import org.eclipse.swt.internal.carbon.CGRect; >+import org.eclipse.swt.internal.carbon.OS; > import org.eclipse.swt.*; > import org.eclipse.swt.graphics.*; > >@@ -24,7 +26,11 @@ > * system. > */ > public final class Program { >- String name; >+ >+ private static final int BYTES_PER_PIXEL = 4; >+ private static final int MAXIMUM_IMAGE_DIMENSION_LENGTH = 128; >+ >+ String name; > String command; > String iconName; > >@@ -276,6 +282,118 @@ > return data; > } > >+public static ImageData getImageData ( String extension, int iconSize ) { >+ int iconRef = getIconRefForExtension ( extension ); >+ if ( iconRef == 0 ) { >+ iconRef = getIconRefForConstant ( OS.kGenericDocumentIcon ); >+ } >+ >+ return getImageDataForIconRef ( iconRef, iconSize ); >+} >+ >+public static ImageData getSystemFolderImageData ( int iconSize ) { >+ int iconRef = getIconRefForConstant ( OS.kGenericFolderIcon ); >+ return getImageDataForIconRef ( iconRef, iconSize ); >+} >+ >+private static ImageData getImageDataForIconRef ( int iconRef, int iconSize ) { >+ if ( iconRef != 0 ) { >+ ImageData imageData = loadImageDataForIconRef ( iconRef, iconSize ); >+ OS.ReleaseIconRef ( iconRef ); >+ return imageData; >+ } >+ >+ return null; >+} >+ >+private static int getIconRefForConstant ( int iconConstant ) { >+ int status; >+ int[] iconRef = new int[1]; >+ >+ status = OS.GetIconRef ( OS.kOnSystemDisk, >+ OS.kSystemIconsCreator, >+ iconConstant, >+ iconRef >+ ); >+ >+ return status == 0 ? iconRef[0] : 0; >+} >+ >+private static int getIconRefForExtension ( String extension ) { >+ int status = -1; // Start off with an error condition >+ int[] iconRef = new int[1]; >+ >+ // Convert the java.lang.String into a CFString >+ >+ int length = extension.length(); >+ char[] buffer = new char[ length ]; >+ extension.getChars ( 0, length, buffer, 0 ); >+ int extensionAsACFString = OS.CFStringCreateWithCharacters ( 0, buffer, length ); >+ if ( extensionAsACFString != 0 ) { >+ >+ // Get the icon reference for this extension >+ >+ status = OS.GetIconRefFromTypeInfo ( 0, // OSType inCreator >+ 0, // OSType inType >+ extensionAsACFString, >+ 0, // CFStringRef inMIMEType >+ 0, // IconServicesUsageFlags inUsageFlags >+ iconRef >+ ); >+ >+ OS.CFRelease ( extensionAsACFString ); >+ } >+ >+ return status == 0 ? iconRef[0] : 0; >+} >+ >+private static ImageData loadImageDataForIconRef ( final int iconRef, final int iconSize ) { >+ int size = Math.max ( 1, Math.min ( MAXIMUM_IMAGE_DIMENSION_LENGTH, iconSize ) ); >+ >+ Image image = new Image ( null, size, size ); >+ >+ int colorSpace = OS.CGColorSpaceCreateDeviceRGB(); >+ if ( colorSpace != 0 ) { >+ int bpc = OS.CGImageGetBitsPerComponent ( image.handle ); >+ int context = OS.CGBitmapContextCreate ( image.data, >+ size, >+ size, >+ bpc, >+ size * BYTES_PER_PIXEL, // bytesPerRow >+ colorSpace, >+ OS.kCGImageAlphaNoneSkipFirst >+ ); >+ >+ CGRect rect = new CGRect(); >+ rect.x = rect.y = 0; >+ rect.height = rect.width = size; >+ >+ int status = OS.PlotIconRefInContext ( context, >+ rect, >+ OS.kAlignNone, >+ OS.kTransformNone, >+ null, // inlabelColor >+ OS.kPlotIconRefNormalFlags, >+ iconRef >+ ); >+ if ( status != 0) { >+ image.dispose(); >+ image = null; >+ } >+ >+ OS.CGContextRelease ( context ); >+ } >+ >+ // We intend to return a copy of the image data >+ ImageData ret = ( ImageData ) image.getImageData().clone(); >+ >+ // Release resources >+ image.dispose(); >+ OS.CGColorSpaceRelease ( colorSpace ); >+ >+ return ret; >+} >+ > /** > * Returns the receiver's name. This is as short and > * descriptive a name as possible for the program. If
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 79268
:
20490
| 20615 |
20616