aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnatoly Spektor2013-01-24 15:58:07 (EST)
committerArun Thondapu2013-02-06 05:05:49 (EST)
commit93a94094191ba6bab3d01c83b707e1431df666a6 (patch)
tree4a2fd6e7acc0543bfcd968ea6f0952654ff3a412
parent1a14ea69ecd8828d401196778d87114e683d18b8 (diff)
downloadeclipse.platform.swt-93a94094191ba6bab3d01c83b707e1431df666a6.zip
eclipse.platform.swt-93a94094191ba6bab3d01c83b707e1431df666a6.tar.gz
eclipse.platform.swt-93a94094191ba6bab3d01c83b707e1431df666a6.tar.bz2
Replace GtkColorSelection with GtkColorChooser for GTK 3.4 and up
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java50
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java92
7 files changed, 208 insertions, 34 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 21d7da2..78e127d 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
@@ -9004,6 +9004,92 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1clipboard_1wait_1for_1contents)
}
#endif
+#ifndef NO__1gtk_1color_1chooser_1dialog_1new
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1color_1chooser_1dialog_1new)
+ (JNIEnv *env, jclass that, jbyteArray arg0, jintLong arg1)
+{
+ jbyte *lparg0=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1color_1chooser_1dialog_1new_FUNC);
+ if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)gtk_color_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_color_chooser_dialog_new)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(const gchar *, GtkWindow *))fp)((const gchar *)lparg0, (GtkWindow *)arg1);
+ }
+ }
+fail:
+ if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1color_1chooser_1dialog_1new_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1color_1chooser_1get_1rgba
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1chooser_1get_1rgba)
+ (JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
+{
+ GdkRGBA _arg1, *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1color_1chooser_1get_1rgba_FUNC);
+ if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
+/*
+ gtk_color_chooser_get_rgba(arg0, lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_color_chooser_get_rgba)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, GdkRGBA *))fp)(arg0, lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1color_1chooser_1get_1rgba_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1color_1chooser_1set_1rgba
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1chooser_1set_1rgba)
+ (JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
+{
+ GdkRGBA _arg1, *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1color_1chooser_1set_1rgba_FUNC);
+ if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
+/*
+ gtk_color_chooser_set_rgba(arg0, lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_color_chooser_set_rgba)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, GdkRGBA *))fp)(arg0, lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1color_1chooser_1set_1rgba_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1color_1chooser_1set_1use_1alpha
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1chooser_1set_1use_1alpha)
+ (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1color_1chooser_1set_1use_1alpha_FUNC);
+/*
+ gtk_color_chooser_set_use_alpha(arg0, arg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_color_chooser_set_use_alpha)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(jintLong, jboolean))fp)(arg0, arg1);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gtk_1color_1chooser_1set_1use_1alpha_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1color_1selection_1dialog_1get_1color_1selection
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1color_1selection_1dialog_1get_1color_1selection)
(JNIEnv *env, jclass that, jintLong arg0)
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 6369bdb..2bbc1af 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
@@ -181,6 +181,8 @@
#define NO__1gtk_1style_1context_1restore
#define NO__1gtk_1style_1context_1save
#define NO__1gtk_1style_1context_1set_1state
+#define NO__1gtk_1color_1chooser_1get_1rgba
+#define NO__1gtk_1color_1chooser_1set_1rgba
#endif
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index d79623c..397f369 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -108,6 +108,10 @@
#define gtk_cell_renderer_get_preferred_size_LIB LIB_GTK
#define gtk_cell_renderer_get_size_LIB LIB_GTK
#define gtk_color_selection_dialog_get_color_selection_LIB LIB_GTK
+#define gtk_color_chooser_get_rgba_LIB LIB_GTK
+#define gtk_color_chooser_dialog_new_LIB LIB_GTK
+#define gtk_color_chooser_set_rgba_LIB LIB_GTK
+#define gtk_color_chooser_set_use_alpha_LIB LIB_GTK
#define gtk_combo_box_entry_new_text_LIB LIB_GTK
#define gtk_combo_box_new_text_LIB LIB_GTK
#define gtk_combo_box_text_insert_LIB LIB_GTK
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 6e27260..6633acb 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
@@ -675,6 +675,10 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1clipboard_1set_1with_1owner",
"_1gtk_1clipboard_1store",
"_1gtk_1clipboard_1wait_1for_1contents",
+ "_1gtk_1color_1chooser_1dialog_1new",
+ "_1gtk_1color_1chooser_1get_1rgba",
+ "_1gtk_1color_1chooser_1set_1rgba",
+ "_1gtk_1color_1chooser_1set_1use_1alpha",
"_1gtk_1color_1selection_1dialog_1get_1color_1selection",
"_1gtk_1color_1selection_1dialog_1new",
"_1gtk_1color_1selection_1get_1current_1color",
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 f69c366..d58537b 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
@@ -685,6 +685,10 @@ typedef enum {
_1gtk_1clipboard_1set_1with_1owner_FUNC,
_1gtk_1clipboard_1store_FUNC,
_1gtk_1clipboard_1wait_1for_1contents_FUNC,
+ _1gtk_1color_1chooser_1dialog_1new_FUNC,
+ _1gtk_1color_1chooser_1get_1rgba_FUNC,
+ _1gtk_1color_1chooser_1set_1rgba_FUNC,
+ _1gtk_1color_1chooser_1set_1use_1alpha_FUNC,
_1gtk_1color_1selection_1dialog_1get_1color_1selection_FUNC,
_1gtk_1color_1selection_1dialog_1new_FUNC,
_1gtk_1color_1selection_1get_1current_1color_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 f8a0c6e..e20523f 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
@@ -6511,6 +6511,32 @@ public static final long /*int*/ gtk_color_selection_dialog_new(byte[] title) {
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param title cast=(const gchar *)
+ * @param parent cast=(GtkWindow *)
+ */
+public static final native long /*int*/ _gtk_color_chooser_dialog_new (byte[] title, long /*int*/ parent);
+public static final long /*int*/ gtk_color_chooser_dialog_new (byte[] title, long /*int*/ parent) {
+ lock.lock();
+ try {
+ return _gtk_color_chooser_dialog_new (title, parent);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ */
+public static final native void _gtk_color_chooser_set_use_alpha (long /*int*/ chooser, boolean use_alpha);
+public static final void gtk_color_chooser_set_use_alpha (long /*int*/ chooser, boolean use_alpha) {
+ lock.lock();
+ try {
+ _gtk_color_chooser_set_use_alpha (chooser, use_alpha);
+ } finally {
+ lock.unlock();
+ }
+}
/**
* @method flags=dynamic
* @param color_dialog cast=(GtkColorSelectionDialog *)
@@ -6525,6 +6551,30 @@ public static final long /*int*/ gtk_color_selection_dialog_get_color_selection(
}
}
/**
+ * @method flags=dynamic
+ */
+public static final native void _gtk_color_chooser_set_rgba(long /*int*/ chooser, GdkRGBA color);
+public static final void gtk_color_chooser_get_rgba(long /*int*/ chooser, GdkRGBA color) {
+ lock.lock();
+ try {
+ _gtk_color_chooser_get_rgba(chooser, color);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
+ * @method flags=dynamic
+ */
+public static final native void _gtk_color_chooser_get_rgba(long /*int*/ chooser, GdkRGBA color);
+public static final void gtk_color_chooser_set_rgba(long /*int*/ chooser, GdkRGBA color) {
+ lock.lock();
+ try {
+ _gtk_color_chooser_set_rgba(chooser, color);
+ } finally {
+ lock.unlock();
+ }
+}
+/**
* @param colorsel cast=(GtkColorSelection *)
* @param color cast=(GdkColor *),flags=no_in
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
index a76e001..2c90133 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
@@ -126,39 +126,51 @@ public RGB[] getRGBs() {
*/
public RGB open () {
byte [] buffer = Converter.wcsToMbcs (null, title, true);
- long /*int*/ handle = OS.gtk_color_selection_dialog_new (buffer);
+ long /*int*/ handle = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(3, 4, 0)) {
+ handle = OS.gtk_color_chooser_dialog_new(buffer, parent.topHandle());
+ } else {
+ handle = OS.gtk_color_selection_dialog_new(buffer);
+ }
Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
- if (parent != null) {
- long /*int*/ shellHandle = parent.topHandle ();
- OS.gtk_window_set_transient_for (handle, shellHandle);
- long /*int*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
- if (pixbufs != 0) {
- OS.gtk_window_set_icon_list (handle, pixbufs);
- OS.g_list_free (pixbufs);
+ long /*int*/ colorsel = 0;
+ GdkColor color = new GdkColor();
+ GdkRGBA rgba = new GdkRGBA();
+ if (OS.GTK_VERSION <= OS.VERSION(3, 4, 0)){
+ if (parent != null) {
+ long /*int*/ shellHandle = parent.topHandle ();
+ OS.gtk_window_set_transient_for (handle, shellHandle);
+ long /*int*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+ if (pixbufs != 0) {
+ OS.gtk_window_set_icon_list (handle, pixbufs);
+ OS.g_list_free (pixbufs);
+ }
}
- }
- if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
- long /*int*/ group = OS.gtk_window_get_group(0);
- OS.gtk_window_group_add_window (group, handle);
- }
- OS.gtk_window_set_modal (handle, true);
- long /*int*/ colorsel;
- if (OS.GTK_VERSION >= OS.VERSION(2, 14, 0)) {
- colorsel = OS.gtk_color_selection_dialog_get_color_selection(handle);
- } else{
- GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
- OS.memmove (dialog, handle);
- colorsel = dialog.colorsel;
+ if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
+ long /*int*/ group = OS.gtk_window_get_group(0);
+ OS.gtk_window_group_add_window (group, handle);
+ }
+ OS.gtk_window_set_modal (handle, true);
+
+ if (OS.GTK_VERSION >= OS.VERSION(2, 14, 0)) {
+ colorsel = OS.gtk_color_selection_dialog_get_color_selection(handle);
+ } else{
+ GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+ OS.memmove (dialog, handle);
+ colorsel = dialog.colorsel;
+ }
+ if (rgb != null) {
+ color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
+ color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
+ color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
+ OS.gtk_color_selection_set_current_color (colorsel, color);
+ }
+ OS.gtk_color_selection_set_has_palette (colorsel, true);
+ } else {
+ OS.gtk_color_chooser_set_use_alpha(handle,false);
+ OS.gtk_color_chooser_set_rgba(handle, rgba);
}
- GdkColor color = new GdkColor();
- if (rgb != null) {
- color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
- color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
- color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
- OS.gtk_color_selection_set_current_color (colorsel, color);
- }
- OS.gtk_color_selection_set_has_palette (colorsel, true);
if (rgbs != null) {
long /*int*/ colors = OS.g_malloc(GdkColor.sizeof * rgbs.length);
for (int i=0; i<rgbs.length; i++) {
@@ -210,11 +222,23 @@ public RGB open () {
}
boolean success = response == OS.GTK_RESPONSE_OK;
if (success) {
- OS.gtk_color_selection_get_current_color (colorsel, color);
- int red = (color.red >> 8) & 0xFF;
- int green = (color.green >> 8) & 0xFF;
- int blue = (color.blue >> 8) & 0xFF;
- rgb = new RGB (red, green, blue);
+ int red = 0;
+ int green = 0;
+ int blue = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(3, 4, 0)){
+ OS.gtk_color_chooser_get_rgba(handle, rgba);
+ red = (int) (rgba.red * 255);
+ green = (int) (rgba.green * 255);
+ blue = (int) (rgba.blue * 255);
+ } else {
+ OS.gtk_color_selection_get_current_color (colorsel, color);
+ red = (color.red >> 8) & 0xFF;
+ green = (color.green >> 8) & 0xFF;
+ blue = (color.blue >> 8) & 0xFF;
+
+ }
+ rgb = new RGB (red, green, blue);
+
}
long /*int*/ settings = OS.gtk_settings_get_default ();
if (settings != 0) {