Skip to content

Commit

Permalink
[GTK4] Migrate deprecated ColorChooser to ColorDialog
Browse files Browse the repository at this point in the history
The Color Chooser has been moved to the GTK3 class and all references
inside the GTK4 blocks have been updated to use the new API.

Note that the GTK4 API doesn't provide the means to set a custom
palette, meaning that the colors specified with setRGBS(RGB[]) are
effectively ignored.
  • Loading branch information
ptziegler committed Nov 28, 2024
1 parent fa71076 commit 7a4a404
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 144 deletions.
76 changes: 76 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,82 @@ JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1clipboard_1wait_1for_1contents)
}
#endif

#ifndef NO_gtk_1color_1chooser_1add_1palette
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1color_1chooser_1add_1palette)
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3, jlong arg4)
{
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1add_1palette_FUNC);
gtk_color_chooser_add_palette((GtkColorChooser *)arg0, (GtkOrientation)arg1, (gint)arg2, (gint)arg3, (GdkRGBA *)arg4);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1add_1palette_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1dialog_1new
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1color_1chooser_1dialog_1new)
(JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1)
{
jbyte *lparg0=NULL;
jlong rc = 0;
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1dialog_1new_FUNC);
if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
rc = (jlong)gtk_color_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1);
fail:
if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1dialog_1new_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1chooser_1get_1rgba
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1color_1chooser_1get_1rgba)
(JNIEnv *env, jclass that, jlong arg0, jobject arg1)
{
GdkRGBA _arg1, *lparg1=NULL;
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1get_1rgba_FUNC);
if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
gtk_color_chooser_get_rgba((GtkColorChooser *)arg0, (GdkRGBA *)lparg1);
fail:
if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1get_1rgba_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1get_1use_1alpha
JNIEXPORT jboolean JNICALL GTK3_NATIVE(gtk_1color_1chooser_1get_1use_1alpha)
(JNIEnv *env, jclass that, jlong arg0)
{
jboolean rc = 0;
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1get_1use_1alpha_FUNC);
rc = (jboolean)gtk_color_chooser_get_use_alpha((GtkColorChooser *)arg0);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1get_1use_1alpha_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1chooser_1set_1rgba
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1color_1chooser_1set_1rgba)
(JNIEnv *env, jclass that, jlong arg0, jobject arg1)
{
GdkRGBA _arg1, *lparg1=NULL;
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1set_1rgba_FUNC);
if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
gtk_color_chooser_set_rgba((GtkColorChooser *)arg0, (GdkRGBA *)lparg1);
fail:
if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1set_1rgba_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1set_1use_1alpha
JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1color_1chooser_1set_1use_1alpha)
(JNIEnv *env, jclass that, jlong arg0, jboolean arg1)
{
GTK3_NATIVE_ENTER(env, that, gtk_1color_1chooser_1set_1use_1alpha_FUNC);
gtk_color_chooser_set_use_alpha((GtkColorChooser *)arg0, (gboolean)arg1);
GTK3_NATIVE_EXIT(env, that, gtk_1color_1chooser_1set_1use_1alpha_FUNC);
}
#endif

#ifndef NO_gtk_1combo_1box_1get_1wrap_1width
JNIEXPORT jint JNICALL GTK3_NATIVE(gtk_1combo_1box_1get_1wrap_1width)
(JNIEnv *env, jclass that, jlong arg0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ typedef enum {
gtk_1clipboard_1set_1with_1owner_FUNC,
gtk_1clipboard_1store_FUNC,
gtk_1clipboard_1wait_1for_1contents_FUNC,
gtk_1color_1chooser_1add_1palette_FUNC,
gtk_1color_1chooser_1dialog_1new_FUNC,
gtk_1color_1chooser_1get_1rgba_FUNC,
gtk_1color_1chooser_1get_1use_1alpha_FUNC,
gtk_1color_1chooser_1set_1rgba_FUNC,
gtk_1color_1chooser_1set_1use_1alpha_FUNC,
gtk_1combo_1box_1get_1wrap_1width_FUNC,
gtk_1combo_1box_1set_1wrap_1width_FUNC,
gtk_1container_1add_FUNC,
Expand Down
166 changes: 166 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,172 @@ JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1check_1button_1set_1use_1underline)
}
#endif

#ifndef NO_gtk_1color_1dialog_1choose_1rgba
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1color_1dialog_1choose_1rgba)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jobject arg2, jlong arg3, jlong arg4, jlong arg5)
{
GdkRGBA _arg2, *lparg2=NULL;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1choose_1rgba_FUNC);
if (arg2) if ((lparg2 = getGdkRGBAFields(env, arg2, &_arg2)) == NULL) goto fail;
/*
gtk_color_dialog_choose_rgba(arg0, (GtkWindow *)arg1, (GdkRGBA *)lparg2, (GCancellable *)arg3, (GAsyncReadyCallback)arg4, (gpointer)arg5);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_choose_rgba)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, GtkWindow *, GdkRGBA *, GCancellable *, GAsyncReadyCallback, gpointer))fp)(arg0, (GtkWindow *)arg1, (GdkRGBA *)lparg2, (GCancellable *)arg3, (GAsyncReadyCallback)arg4, (gpointer)arg5);
}
}
fail:
if (arg2 && lparg2) setGdkRGBAFields(env, arg2, lparg2);
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1choose_1rgba_FUNC);
}
#endif

#ifndef NO_gtk_1color_1dialog_1choose_1rgba_1finish
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1color_1dialog_1choose_1rgba_1finish)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jlongArray arg2)
{
jlong *lparg2=NULL;
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1choose_1rgba_1finish_FUNC);
if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
/*
rc = (jlong)gtk_color_dialog_choose_rgba_finish(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_choose_rgba_finish)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, GAsyncResult *, GError **))fp)(arg0, (GAsyncResult *)arg1, (GError **)lparg2);
}
}
fail:
if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1choose_1rgba_1finish_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1dialog_1get_1modal
JNIEXPORT jboolean JNICALL GTK4_NATIVE(gtk_1color_1dialog_1get_1modal)
(JNIEnv *env, jclass that, jlong arg0)
{
jboolean rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1get_1modal_FUNC);
/*
rc = (jboolean)gtk_color_dialog_get_modal(arg0);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_get_modal)
if (fp) {
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jlong))fp)(arg0);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1get_1modal_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1dialog_1get_1with_1alpha
JNIEXPORT jboolean JNICALL GTK4_NATIVE(gtk_1color_1dialog_1get_1with_1alpha)
(JNIEnv *env, jclass that, jlong arg0)
{
jboolean rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1get_1with_1alpha_FUNC);
/*
rc = (jboolean)gtk_color_dialog_get_with_alpha(arg0);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_get_with_alpha)
if (fp) {
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jlong))fp)(arg0);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1get_1with_1alpha_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1dialog_1new
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1color_1dialog_1new)
(JNIEnv *env, jclass that)
{
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1new_FUNC);
/*
rc = (jlong)gtk_color_dialog_new();
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_new)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)())fp)();
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1new_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1dialog_1set_1modal
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1color_1dialog_1set_1modal)
(JNIEnv *env, jclass that, jlong arg0, jboolean arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1set_1modal_FUNC);
/*
gtk_color_dialog_set_modal(arg0, (gboolean)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_set_modal)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, gboolean))fp)(arg0, (gboolean)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1set_1modal_FUNC);
}
#endif

#ifndef NO_gtk_1color_1dialog_1set_1title
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1color_1dialog_1set_1title)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
{
jbyte *lparg1=NULL;
jlong rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1set_1title_FUNC);
if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
/*
rc = (jlong)gtk_color_dialog_set_title(arg0, (char *)lparg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_set_title)
if (fp) {
rc = (jlong)((jlong (CALLING_CONVENTION*)(jlong, char *))fp)(arg0, (char *)lparg1);
}
}
fail:
if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1set_1title_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1dialog_1set_1with_1alpha
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1color_1dialog_1set_1with_1alpha)
(JNIEnv *env, jclass that, jlong arg0, jboolean arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1color_1dialog_1set_1with_1alpha_FUNC);
/*
gtk_color_dialog_set_with_alpha(arg0, (gboolean *)arg1);
*/
{
GTK4_LOAD_FUNCTION(fp, gtk_color_dialog_set_with_alpha)
if (fp) {
((void (CALLING_CONVENTION*)(jlong, gboolean *))fp)(arg0, (gboolean *)arg1);
}
}
GTK4_NATIVE_EXIT(env, that, gtk_1color_1dialog_1set_1with_1alpha_FUNC);
}
#endif

#ifndef NO_gtk_1combo_1box_1get_1child
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1combo_1box_1get_1child)
(JNIEnv *env, jclass that, jlong arg0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ typedef enum {
gtk_1check_1button_1set_1group_FUNC,
gtk_1check_1button_1set_1inconsistent_FUNC,
gtk_1check_1button_1set_1use_1underline_FUNC,
gtk_1color_1dialog_1choose_1rgba_FUNC,
gtk_1color_1dialog_1choose_1rgba_1finish_FUNC,
gtk_1color_1dialog_1get_1modal_FUNC,
gtk_1color_1dialog_1get_1with_1alpha_FUNC,
gtk_1color_1dialog_1new_FUNC,
gtk_1color_1dialog_1set_1modal_FUNC,
gtk_1color_1dialog_1set_1title_FUNC,
gtk_1color_1dialog_1set_1with_1alpha_FUNC,
gtk_1combo_1box_1get_1child_FUNC,
gtk_1css_1provider_1load_1from_1data_FUNC,
gtk_1drag_1source_1new_FUNC,
Expand Down
76 changes: 0 additions & 76 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -4078,82 +4078,6 @@ JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1check_1version)
}
#endif

#ifndef NO_gtk_1color_1chooser_1add_1palette
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1color_1chooser_1add_1palette)
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3, jlong arg4)
{
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1add_1palette_FUNC);
gtk_color_chooser_add_palette((GtkColorChooser *)arg0, (GtkOrientation)arg1, (gint)arg2, (gint)arg3, (GdkRGBA *)arg4);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1add_1palette_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1dialog_1new
JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1color_1chooser_1dialog_1new)
(JNIEnv *env, jclass that, jbyteArray arg0, jlong arg1)
{
jbyte *lparg0=NULL;
jlong rc = 0;
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1dialog_1new_FUNC);
if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
rc = (jlong)gtk_color_chooser_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1);
fail:
if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1dialog_1new_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1chooser_1get_1rgba
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1color_1chooser_1get_1rgba)
(JNIEnv *env, jclass that, jlong arg0, jobject arg1)
{
GdkRGBA _arg1, *lparg1=NULL;
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1get_1rgba_FUNC);
if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
gtk_color_chooser_get_rgba((GtkColorChooser *)arg0, (GdkRGBA *)lparg1);
fail:
if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1get_1rgba_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1get_1use_1alpha
JNIEXPORT jboolean JNICALL GTK_NATIVE(gtk_1color_1chooser_1get_1use_1alpha)
(JNIEnv *env, jclass that, jlong arg0)
{
jboolean rc = 0;
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1get_1use_1alpha_FUNC);
rc = (jboolean)gtk_color_chooser_get_use_alpha((GtkColorChooser *)arg0);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1get_1use_1alpha_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1color_1chooser_1set_1rgba
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1color_1chooser_1set_1rgba)
(JNIEnv *env, jclass that, jlong arg0, jobject arg1)
{
GdkRGBA _arg1, *lparg1=NULL;
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1set_1rgba_FUNC);
if (arg1) if ((lparg1 = getGdkRGBAFields(env, arg1, &_arg1)) == NULL) goto fail;
gtk_color_chooser_set_rgba((GtkColorChooser *)arg0, (GdkRGBA *)lparg1);
fail:
if (arg1 && lparg1) setGdkRGBAFields(env, arg1, lparg1);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1set_1rgba_FUNC);
}
#endif

#ifndef NO_gtk_1color_1chooser_1set_1use_1alpha
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1color_1chooser_1set_1use_1alpha)
(JNIEnv *env, jclass that, jlong arg0, jboolean arg1)
{
GTK_NATIVE_ENTER(env, that, gtk_1color_1chooser_1set_1use_1alpha_FUNC);
gtk_color_chooser_set_use_alpha((GtkColorChooser *)arg0, (gboolean)arg1);
GTK_NATIVE_EXIT(env, that, gtk_1color_1chooser_1set_1use_1alpha_FUNC);
}
#endif

#ifndef NO_gtk_1combo_1box_1get_1active
JNIEXPORT jint JNICALL GTK_NATIVE(gtk_1combo_1box_1get_1active)
(JNIEnv *env, jclass that, jlong arg0)
Expand Down
6 changes: 0 additions & 6 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,6 @@ typedef enum {
gtk_1cell_1view_1set_1fit_1model_FUNC,
gtk_1check_1button_1new_FUNC,
gtk_1check_1version_FUNC,
gtk_1color_1chooser_1add_1palette_FUNC,
gtk_1color_1chooser_1dialog_1new_FUNC,
gtk_1color_1chooser_1get_1rgba_FUNC,
gtk_1color_1chooser_1get_1use_1alpha_FUNC,
gtk_1color_1chooser_1set_1rgba_FUNC,
gtk_1color_1chooser_1set_1use_1alpha_FUNC,
gtk_1combo_1box_1get_1active_FUNC,
gtk_1combo_1box_1get_1model_FUNC,
gtk_1combo_1box_1popdown_FUNC,
Expand Down
Loading

0 comments on commit 7a4a404

Please sign in to comment.