Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] patch for gtk2 binding

Attached is a patch that replaces calls to the old GtkPixmap
with calls to the newer (not deprecated) GtkImage.  I have
tested this patch to the best of my ability.  Everything 
seems to work correctly in the ControlExample and in the few
examples that I wrote myself.

On a related topic, what is the status of the 
org.eclipse.swt.tests project?  I have noticed that many of the
tests fail.  I have also noticed that there are not that many
updates to the test project.  Is there going to be an effort
to make sure that all tests are valid and the each platform
passes all tests?

Thanks
-Jeff




Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java,v
retrieving revision 1.22
diff -u -r1.22 Button.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java	18 Jun 2002 13:12:15 -0000	1.22
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java	9 Jul 2002 00:50:35 -0000
@@ -186,7 +186,7 @@
 		labelHandle = OS.gtk_label_new_with_mnemonic (null);
 		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		Display display = getDisplay ();
-		pixmapHandle = OS.gtk_pixmap_new (display.nullPixmap, 0);
+		pixmapHandle = OS.gtk_image_new_from_pixmap (display.nullPixmap, 0);
 		if (pixmapHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		OS.gtk_container_add (handle, boxHandle);
 		OS.gtk_container_add (boxHandle, labelHandle);
@@ -503,11 +503,11 @@
 	if ((style & SWT.ARROW) != 0) return;
 	OS.gtk_widget_hide (labelHandle);
 	if (image != null) {
-		OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, image.pixmap, image.mask);
 		OS.gtk_widget_show (pixmapHandle);
 	} else {
 		Display display = getDisplay ();
-		OS.gtk_pixmap_set (pixmapHandle, display.nullPixmap, 0);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, display.nullPixmap, 0);
 		OS.gtk_widget_hide (pixmapHandle);
 	}
 	if (oldImage == image) OS.gtk_widget_queue_draw (pixmapHandle);
Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java,v
retrieving revision 1.22
diff -u -r1.22 Label.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java	18 Jun 2002 13:12:15 -0000	1.22
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java	9 Jul 2002 00:50:34 -0000
@@ -149,7 +149,7 @@
 		labelHandle = OS.gtk_label_new_with_mnemonic (null);
 		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		Display display = getDisplay ();
-		pixmapHandle = OS.gtk_pixmap_new (display.nullPixmap, 0);
+		pixmapHandle = OS.gtk_image_new_from_pixmap (display.nullPixmap, 0);
 		if (pixmapHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		OS.gtk_container_add (handle, labelHandle);
 		OS.gtk_container_add (handle, pixmapHandle);
@@ -407,11 +407,11 @@
 	if ((style & SWT.SEPARATOR) != 0) return;
 	OS.gtk_widget_hide (labelHandle);
 	if (image != null) {
-		OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, image.pixmap, image.mask);
 		OS.gtk_widget_show (pixmapHandle);
 	} else {
 		Display display = getDisplay ();
-		OS.gtk_pixmap_set (pixmapHandle, display.nullPixmap, 0);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, display.nullPixmap, 0);
 		OS.gtk_widget_hide (pixmapHandle);
 	}
 	if (oldImage == image) OS.gtk_widget_queue_draw (pixmapHandle);
Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java,v
retrieving revision 1.27
diff -u -r1.27 MenuItem.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java	8 Jul 2002 21:15:58 -0000	1.27
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java	9 Jul 2002 00:50:35 -0000
@@ -557,7 +557,7 @@
 	super.setImage (image);
 	if ((style & SWT.PUSH) == 0) return;
 	if (image != null) {
-		int pixmap = OS.gtk_pixmap_new (image.pixmap, image.mask);
+		int pixmap = OS.gtk_image_new_from_pixmap (image.pixmap, image.mask);
 		OS.gtk_image_menu_item_set_image (handle, pixmap);
 		OS.gtk_widget_show (pixmap);
 	} else {
Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java,v
retrieving revision 1.16
diff -u -r1.16 TabFolder.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java	18 Jun 2002 13:12:15 -0000	1.16
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java	9 Jul 2002 00:50:35 -0000
@@ -203,7 +203,7 @@
 	int labelHandle = OS.gtk_label_new_with_mnemonic (null);
 	if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
 	Display display = getDisplay ();
-	int pixmapHandle = OS.gtk_pixmap_new (display.nullPixmap, 0);
+	int pixmapHandle = OS.gtk_image_new_from_pixmap (display.nullPixmap, 0);
 	if (pixmapHandle == 0) error (SWT.ERROR_NO_HANDLES);
 	OS.gtk_container_add (boxHandle, pixmapHandle);
 	OS.gtk_container_add (boxHandle, labelHandle);
Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java,v
retrieving revision 1.15
diff -u -r1.15 TabItem.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java	18 Jun 2002 13:12:15 -0000	1.15
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java	9 Jul 2002 00:50:35 -0000
@@ -223,11 +223,11 @@
 	Image oldImage = this.image;
 	super.setImage (image);
 	if (image != null) {
-		OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, image.pixmap, image.mask);
 		OS.gtk_widget_show (pixmapHandle);
 	} else {
 		Display display = getDisplay ();
-		OS.gtk_pixmap_set (pixmapHandle, display.nullPixmap, 0);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, display.nullPixmap, 0);
 		OS.gtk_widget_hide (pixmapHandle);
 	}
 	if (oldImage == image) OS.gtk_widget_queue_draw (pixmapHandle);
Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java,v
retrieving revision 1.36
diff -u -r1.36 ToolItem.java
--- Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java	3 Jul 2002 16:00:13 -0000	1.36
+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java	9 Jul 2002 00:50:34 -0000
@@ -163,7 +163,7 @@
 		labelHandle = OS.gtk_label_new_with_mnemonic (null);
 		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		Display display = getDisplay ();
-		pixmapHandle = OS.gtk_pixmap_new (display.nullPixmap, 0);
+		pixmapHandle = OS.gtk_image_new_from_pixmap (display.nullPixmap, 0);
 		if (pixmapHandle == 0) error (SWT.ERROR_NO_HANDLES);
 		OS.gtk_container_add (boxHandle, pixmapHandle);
 		OS.gtk_container_add (boxHandle, labelHandle);
@@ -473,7 +473,7 @@
 int processMouseEnter (int int0, int int1, int int2) {
 	drawHotImage = (parent.style & SWT.FLAT) != 0 && hotImage != null;
 	if (drawHotImage && pixmapHandle != 0) {
-		OS.gtk_pixmap_set (pixmapHandle, hotImage.pixmap, hotImage.mask);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, hotImage.pixmap, hotImage.mask);
 	}
 	return 0;
 }
@@ -482,7 +482,7 @@
 	if (drawHotImage) {
 		drawHotImage = false;
 		if (pixmapHandle != 0 && image != null) {
-			OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+			OS.gtk_image_set_from_pixmap (pixmapHandle, image.pixmap, image.mask);
 		}	
 	}
 	return 0;
@@ -699,11 +699,11 @@
 	super.setImage (image);
 	if (pixmapHandle == 0) return;
 	if (image != null) {
-		OS.gtk_pixmap_set (pixmapHandle, image.pixmap, image.mask);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, image.pixmap, image.mask);
 		OS.gtk_widget_show (pixmapHandle);
 	} else {
 		Display display = getDisplay ();
-		OS.gtk_pixmap_set (pixmapHandle, display.nullPixmap, 0);
+		OS.gtk_image_set_from_pixmap (pixmapHandle, display.nullPixmap, 0);
 		OS.gtk_widget_hide (pixmapHandle);
 	}
 	if (oldImage == image) OS.gtk_widget_queue_draw (pixmapHandle);
Index: Eclipse SWT PI/gtk/library/swt.c
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt.c,v
retrieving revision 1.66
diff -u -r1.66 swt.c
--- Eclipse SWT PI/gtk/library/swt.c	18 Jun 2002 14:27:48 -0000	1.66
+++ Eclipse SWT PI/gtk/library/swt.c	9 Jul 2002 00:50:33 -0000
@@ -2916,6 +2981,23 @@
 	return rc;
 }
 
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1image_1new_1from_1pixmap
+        (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+        DEBUG_CALL("gtk_1image_1new_1from_1pixmap\n")
+
+        return (jint)gtk_image_new_from_pixmap((GdkPixmap *)arg0, (GdkBitmap *)arg1);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1image_1set_1from_1pixmap
+        (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+        DEBUG_CALL("gtk_1image_1set_1from_1pixmap\n")
+
+        gtk_image_set_from_pixmap((GtkImage *)arg0, (GdkPixmap *)arg1, (GdkBitmap *)arg2);
+}
+
+
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1image_1menu_1item_1get_1image
 	(JNIEnv *env, jclass that, jint arg0, jint arg1)
 {
@@ -3106,22 +3196,6 @@
 	gtk_object_sink((GtkObject *)arg0);
 }
 
-JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1pixmap_1new
-	(JNIEnv *env, jclass that, jint arg0, jint arg1)
-{
-	DEBUG_CALL("gtk_1pixmap_1new\n")
-
-	return (jint)gtk_pixmap_new((GdkPixmap *)arg0, (GdkBitmap *)arg1);
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1pixmap_1set
-	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
-{
-	DEBUG_CALL("gtk_1pixmap_1set\n")
-
-	gtk_pixmap_set((GtkPixmap *)arg0, (GdkPixmap *)arg1, (GdkBitmap *)arg2);
-}
-
 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gtk_1progress_1bar_1new
 	(JNIEnv *env, jclass that)
 {
Index: Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
===================================================================
RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java,v
retrieving revision 1.109
diff -u -r1.109 OS.java
--- Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java	18 Jun 2002 14:38:14 -0000	1.109
+++ Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java	9 Jul 2002 00:50:33 -0000
@@ -571,6 +579,8 @@
 public static final native int gtk_main_iteration();
 public static final native void gtk_main_quit();
 public static final native int gtk_menu_bar_new();
+public static final native int gtk_image_new_from_pixmap(int pixmap, int mask);
+public static final native void gtk_image_set_from_pixmap(int image, int pixmap, int mask);
 public static final native int gtk_image_menu_item_new_with_label(byte[] label);
 public static final native int  gtk_image_menu_item_get_image(int menu_item);
 public static final native void gtk_image_menu_item_set_image(int menu_item, int image);
@@ -595,6 +606,4 @@
 public static final native int gtk_object_get_user_data(int object);
 public static final native void gtk_object_set_user_data(int object, int data);
 public static final native void gtk_object_sink(int object);
-public static final native int gtk_pixmap_new(int pixmap, int mask);
-public static final native void gtk_pixmap_set(int pixmap, int val, int mask);
 public static final native int gtk_progress_bar_new();

Back to the top