Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java35
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java10
8 files changed, 68 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index 1d2227b12f..e1c59eae0f 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -490,12 +490,6 @@ OS_GtkTextIter_sizeof=
OS_GtkTreeIter_sizeof=
-OS_MonitorEnter=flags=no_gen
-OS_MonitorEnter_0=
-
-OS_MonitorExit=flags=no_gen
-OS_MonitorExit_0=
-
OS_PTR_sizeof=
OS_PangoAttribute_sizeof=
@@ -2278,6 +2272,10 @@ OS__gtk_image_new_from_pixmap=
OS__gtk_image_new_from_pixmap_0=cast=(GdkPixmap *)
OS__gtk_image_new_from_pixmap_1=cast=(GdkBitmap *)
+OS__gtk_image_set_from_pixbuf=
+OS__gtk_image_set_from_pixbuf_0=cast=(GtkImage *)
+OS__gtk_image_set_from_pixbuf_1=cast=(GdkPixbuf *)
+
OS__gtk_image_set_from_pixmap=
OS__gtk_image_set_from_pixmap_0=cast=(GtkImage *)
OS__gtk_image_set_from_pixmap_1=cast=(GdkBitmap *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index b575e340b4..fb46c0e741 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -6453,6 +6453,16 @@ JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1image_1new_1from_1pixmap)
}
#endif
+#ifndef NO__1gtk_1image_1set_1from_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1image_1set_1from_1pixbuf)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1image_1set_1from_1pixbuf_FUNC);
+ gtk_image_set_from_pixbuf((GtkImage *)arg0, (GdkPixbuf *)arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1image_1set_1from_1pixbuf_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1image_1set_1from_1pixmap
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1image_1set_1from_1pixmap)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index afe4df94ce..3ec7068a5f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 938;
-int OS_nativeFunctionCallCount[938];
+int OS_nativeFunctionCount = 937;
+int OS_nativeFunctionCallCount[937];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1WINDOWING_1X11",
@@ -70,8 +70,6 @@ char * OS_nativeFunctionNames[] = {
"GtkTargetPair_1sizeof",
"GtkTextIter_1sizeof",
"GtkTreeIter_1sizeof",
- "MonitorEnter",
- "MonitorExit",
"PTR_1sizeof",
"PangoAttribute_1sizeof",
"PangoItem_1sizeof",
@@ -504,6 +502,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1image_1menu_1item_1set_1image",
"_1gtk_1image_1new",
"_1gtk_1image_1new_1from_1pixmap",
+ "_1gtk_1image_1set_1from_1pixbuf",
"_1gtk_1image_1set_1from_1pixmap",
"_1gtk_1init_1check",
"_1gtk_1label_1get_1mnemonic_1keyval",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index fe74c7c912..053283d2d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -74,8 +74,6 @@ typedef enum {
GtkTargetPair_1sizeof_FUNC,
GtkTextIter_1sizeof_FUNC,
GtkTreeIter_1sizeof_FUNC,
- MonitorEnter_FUNC,
- MonitorExit_FUNC,
PTR_1sizeof_FUNC,
PangoAttribute_1sizeof_FUNC,
PangoItem_1sizeof_FUNC,
@@ -508,6 +506,7 @@ typedef enum {
_1gtk_1image_1menu_1item_1set_1image_FUNC,
_1gtk_1image_1new_FUNC,
_1gtk_1image_1new_1from_1pixmap_FUNC,
+ _1gtk_1image_1set_1from_1pixbuf_FUNC,
_1gtk_1image_1set_1from_1pixmap_FUNC,
_1gtk_1init_1check_FUNC,
_1gtk_1label_1get_1mnemonic_1keyval_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index a4f022c277..e518765107 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -4273,6 +4273,15 @@ public static final int /*long*/ gtk_image_new_from_pixmap(int /*long*/ pixmap,
lock.unlock();
}
}
+public static final native void _gtk_image_set_from_pixbuf(int /*long*/ image, int /*long*/ pixbuf);
+public static final void gtk_image_set_from_pixbuf(int /*long*/ image, int /*long*/ pixbuf) {
+ lock.lock();
+ try {
+ _gtk_image_set_from_pixbuf(image, pixbuf);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _gtk_image_set_from_pixmap(int /*long*/ image, int /*long*/ pixmap, int /*long*/ mask);
public static final void gtk_image_set_from_pixmap(int /*long*/ image, int /*long*/ pixmap, int /*long*/ mask) {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
index d2f204fe04..4cd614b0fb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ImageList.java
@@ -40,28 +40,49 @@ public int add (Image image) {
}
int [] w = new int [1], h = new int [1];
OS.gdk_drawable_get_size (image.pixmap, w, h);
- boolean hasMask = image.mask != 0;
- int /*long*/ pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasMask, 8, w [0], h [0]);
- if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
int /*long*/ colormap = OS.gdk_colormap_get_system ();
- OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+ int /*long*/ pixbuf;
+ boolean hasMask = image.mask != 0;
if (hasMask) {
+ pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
+ if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
int /*long*/ gdkMaskImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, w [0], h [0]);
if (gdkMaskImagePtr == 0) SWT.error (SWT.ERROR_NO_HANDLES);
int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
byte [] line = new byte [stride];
- for (int y=0; y<h[0]; y++) {
+ for (int y = 0; y < h [0]; y++) {
int /*long*/ offset = pixels + (y * stride);
OS.memmove (line, offset, stride);
- for (int x=0; x<w[0]; x++) {
+ for (int x = 0; x < w [0]; x++) {
if (OS.gdk_image_get_pixel (gdkMaskImagePtr, x, y) == 0) {
- line[x*4+3] = 0;
+ line [x*4+3] = 0;
}
}
OS.memmove (offset, line, stride);
}
OS.g_object_unref (gdkMaskImagePtr);
+ } else {
+ ImageData data = image.getImageData ();
+ boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
+ pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
+ if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+ if (hasAlpha) {
+ byte [] alpha = data.alphaData;
+ int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+ int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+ byte [] line = new byte [stride];
+ for (int y = 0; y < h [0]; y++) {
+ int /*long*/ offset = pixels + (y * stride);
+ OS.memmove (line, offset, stride);
+ for (int x = 0; x<w [0]; x++) {
+ line [x*4+3] = alpha [y*h [0]+x];
+ }
+ OS.memmove (offset, line, stride);
+ }
+ }
}
if (width == -1 || height == -1) {
width = w [0];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 28a2a2ee7f..5d4e8dce8e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -41,6 +41,7 @@ import org.eclipse.swt.graphics.*;
*/
public class ToolBar extends Composite {
ToolItem lastFocus;
+ ImageList imageList;
/**
* Constructs a new instance of this class given its parent
@@ -388,6 +389,10 @@ void releaseWidget () {
}
items = null;
super.releaseWidget ();
+ if (imageList != null) {
+ imageList.dispose ();
+ imageList = null;
+ }
}
void removeControl (Control control) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index bf0a4d2920..da2111822c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -795,11 +795,17 @@ public void setImage (Image image) {
if ((style & SWT.SEPARATOR) != 0) return;
super.setImage (image);
if (imageHandle == 0) return;
+ int /*long*/ pixbuf = 0;
if (image != null) {
- OS.gtk_image_set_from_pixmap (imageHandle, image.pixmap, image.mask);
+ ImageList imageList = parent.imageList;
+ if (imageList == null) imageList = parent.imageList = new ImageList ();
+ int imageIndex = imageList.indexOf (image);
+ if (imageIndex == -1) imageIndex = imageList.add (image);
+ pixbuf = imageList.getPixbuf (imageIndex);
+ OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
OS.gtk_widget_show (imageHandle);
} else {
- OS.gtk_image_set_from_pixmap (imageHandle, 0, 0);
+ OS.gtk_image_set_from_pixbuf (imageHandle, 0);
OS.gtk_widget_hide (imageHandle);
}
/*

Back to the top