Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2015-03-04 20:38:15 +0000
committerAlexander Kurtakov2015-03-12 10:27:40 +0000
commitf33dffd35460bbb5ed61c774ae7f89f06ed9eb7f (patch)
tree6589c032dd247c2771dcf87eb534d01fcfbae6d9
parentfa178f2b62440efe879306b93d060820738ed4b5 (diff)
downloadeclipse.platform.swt-f33dffd35460bbb5ed61c774ae7f89f06ed9eb7f.tar.gz
eclipse.platform.swt-f33dffd35460bbb5ed61c774ae7f89f06ed9eb7f.tar.xz
eclipse.platform.swt-f33dffd35460bbb5ed61c774ae7f89f06ed9eb7f.zip
Bug 461616 - Combo improvements in background/foreground for gtk3
Incremental change to make Combo use rgba for foreground on Gtk3. This also fixes combo's background for Gtk3, so that the Junit test now works in gtk3. object_set_..rgba required special attention. I added a line to os.h so that it would also compile on gtk2 (as the GdkRGBA in the paramater list is gtk3 only) Change-Id: Iacb608f773f54028bfacbb7d1e0b15d0567d14f1 Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java35
6 files changed, 92 insertions, 4 deletions
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 4430e97eb1..bf8c2e3ec4 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
@@ -3862,6 +3862,34 @@ fail:
}
#endif
+#if (!defined(NO__1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I) && !defined(JNI64)) || (!defined(NO__1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J) && defined(JNI64))
+#ifndef JNI64
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I)(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jobject arg2, jintLong arg3)
+#else
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J)(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jobject arg2, jintLong arg3)
+#endif
+{
+ jbyte *lparg1=NULL;
+ GdkRGBA _arg2, *lparg2=NULL;
+#ifndef JNI64
+ OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I_FUNC);
+#else
+ OS_NATIVE_ENTER(env, that, _1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J_FUNC);
+#endif
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail;
+ g_object_set((gpointer)arg0, (const gchar *)lparg1, lparg2, (const gchar *)NULL);
+fail:
+ if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2);
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+#ifndef JNI64
+ OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I_FUNC);
+#else
+ OS_NATIVE_EXIT(env, that, _1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J_FUNC);
+#endif
+}
+#endif
+
#if (!defined(NO__1g_1object_1set__I_3BZI) && !defined(JNI64)) || (!defined(NO__1g_1object_1set__J_3BZJ) && defined(JNI64))
#ifndef JNI64
JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BZI)(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jboolean arg2, jintLong arg3)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index 088803aced..a026510e8b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
@@ -185,6 +185,9 @@
#define NO__1gtk_1color_1chooser_1get_1rgba
#define NO__1gtk_1color_1chooser_1set_1rgba
+#define NO__1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I
+#define NO__1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J
+
#endif
#include "os_custom.h"
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 7960fe0fc3..6b9791d334 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
@@ -325,6 +325,11 @@ char * OS_nativeFunctionNames[] = {
"_1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkColor_2J",
#endif
#ifndef JNI64
+ "_1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I",
+#else
+ "_1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J",
+#endif
+#ifndef JNI64
"_1g_1object_1set__I_3BZI",
#else
"_1g_1object_1set__J_3BZJ",
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 0d3aa0060f..4f337a13ca 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
@@ -335,6 +335,11 @@ typedef enum {
_1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkColor_2J_FUNC,
#endif
#ifndef JNI64
+ _1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I_FUNC,
+#else
+ _1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J_FUNC,
+#endif
+#ifndef JNI64
_1g_1object_1set__I_3BZI_FUNC,
#else
_1g_1object_1set__J_3BZJ_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 382f70028d..a21af54bf7 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
@@ -619,6 +619,7 @@ public class OS extends C {
public static final byte[] focus_padding = ascii("focus-padding");
public static final byte[] font_desc = ascii("font-desc");
public static final byte[] foreground_gdk = ascii("foreground-gdk");
+ public static final byte[] foreground_rgba = ascii("foreground-rgba");
public static final byte[] grid_line_width = ascii("grid-line-width");
public static final byte[] gtk_alternative_button_order = ascii("gtk-alternative-button-order");
public static final byte[] gtk_color_palette = ascii("gtk-color-palette");
@@ -671,6 +672,7 @@ public class OS extends C {
public static final int GTK_VERSION = VERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version());
public static final int GLIB_VERSION = VERSION(glib_major_version(), glib_minor_version(), glib_micro_version());
+
public static final boolean GTK3 = GTK_VERSION >= VERSION(3, 0, 0);
public static final boolean USE_CAIRO, INIT_CAIRO;
static {
@@ -2957,6 +2959,24 @@ public static final void g_object_set(long /*int*/ object, byte[] first_property
lock.unlock();
}
}
+
+//Note, the function below is handled in a special way in os.h because of the GdkRGBA (gtk3 only) struct. See os.h
+//So although it is not marked as dynamic, it is only build on gtk3.
+/**
+ * @param object cast=(gpointer)
+ * @param first_property_name cast=(const gchar *)
+ * @param terminator cast=(const gchar *),flags=sentinel
+ */
+public static final native void _g_object_set(long /*int*/ object, byte[] first_property_name, GdkRGBA data, long /*int*/ terminator);
+public static final void g_object_set(long /*int*/ object, byte[] first_property_name, GdkRGBA data, long /*int*/ terminator) {
+ lock.lock();
+ try {
+ _g_object_set(object, first_property_name, data, terminator);
+ } finally {
+ lock.unlock();
+ }
+}
+
/**
* @param object cast=(gpointer)
* @param first_property_name cast=(const gchar *),flags=no_out
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index 08e600732e..31e25b376b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -1845,23 +1845,29 @@ public void select (int index) {
}
}
+
@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) {
super.setBackgroundColor (context, handle, rgba);
- return;
+ } else {
+ setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
+ super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
}
- setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
}
@Override
void setBackgroundColor (GdkColor color) {
+ //Note: This function is reached by Gtk2 and Gtk3.
super.setBackgroundColor (color);
if (!OS.GTK3) {
if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
if (cellHandle != 0) OS.g_object_set (cellHandle, OS.background_gdk, color, 0);
OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
}
+
+ if (entryHandle != 0) setBackgroundColor(entryHandle, color);
+ setBackgroundColor (fixedHandle, color);
}
@Override
@@ -1921,8 +1927,29 @@ void setFontDescription (long /*int*/ font) {
@Override
void setForegroundColor (GdkColor color) {
super.setForegroundColor (handle, color, false);
- if (entryHandle != 0) setForegroundColor (entryHandle, color, false);
- OS.g_object_set (textRenderer, OS.foreground_gdk, color, 0);
+ if (entryHandle != 0) {
+ setForegroundColor (entryHandle, color, false);
+ }
+ if (OS.GTK3) {
+ GdkRGBA rgba = gdk_color_to_rgba (color);
+ OS.g_object_set (textRenderer, OS.foreground_rgba, rgba, 0);
+ } else {
+ OS.g_object_set (textRenderer, OS.foreground_gdk, color, 0);
+ }
+}
+
+GdkRGBA gdk_color_to_rgba (GdkColor color) {
+ GdkRGBA rgba = null;
+ if (color != null) {
+ rgba = new GdkRGBA();
+ rgba.alpha = 1; //TODO, we are loosing Alpha in Control:setForeground(Color color),
+ //as alpha is only defined in Color and not GtkColor.
+ //This function should ideally be factored out to Control, and convert Color to GdkRGBA.
+ rgba.red = (color.red & 0xFFFF) / (float)0xFFFF;
+ rgba.green = (color.green & 0xFFFF) / (float)0xFFFF;
+ rgba.blue = (color.blue & 0xFFFF) / (float)0xFFFF;
+ }
+ return rgba;
}
/**

Back to the top