Skip to content

Commit 93ec30a

Browse files
committed
[Gtk] Stop using deprecated gtk_calendar_select_day
Gtk 4.20 added gtk_calendar_set_date as a replacement
1 parent 582fc89 commit 93ec30a

4 files changed

Lines changed: 36 additions & 4 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -751,13 +751,33 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1calendar_1get_1date)
751751
#endif
752752

753753
#ifndef NO_gtk_1calendar_1select_1day
754+
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
754755
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1calendar_1select_1day)
755756
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
756757
{
757758
GTK4_NATIVE_ENTER(env, that, gtk_1calendar_1select_1day_FUNC);
758759
gtk_calendar_select_day((GtkCalendar *)arg0, (GDateTime *)arg1);
759760
GTK4_NATIVE_EXIT(env, that, gtk_1calendar_1select_1day_FUNC);
760761
}
762+
G_GNUC_END_IGNORE_DEPRECATIONS
763+
#endif
764+
765+
#ifndef NO_gtk_1calendar_1set_1date
766+
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1calendar_1set_1date)
767+
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
768+
{
769+
GTK4_NATIVE_ENTER(env, that, gtk_1calendar_1set_1date_FUNC);
770+
/*
771+
gtk_calendar_set_date((GtkCalendar *)arg0, (GDateTime *)arg1);
772+
*/
773+
{
774+
GTK4_LOAD_FUNCTION(fp, gtk_calendar_set_date)
775+
if (fp) {
776+
((void (CALLING_CONVENTION*)(GtkCalendar *, GDateTime *))fp)((GtkCalendar *)arg0, (GDateTime *)arg1);
777+
}
778+
}
779+
GTK4_NATIVE_EXIT(env, that, gtk_1calendar_1set_1date_FUNC);
780+
}
761781
#endif
762782

763783
#ifndef NO_gtk_1calendar_1set_1show_1day_1names

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -80,6 +80,7 @@ typedef enum {
8080
gtk_1button_1set_1child_FUNC,
8181
gtk_1calendar_1get_1date_FUNC,
8282
gtk_1calendar_1select_1day_FUNC,
83+
gtk_1calendar_1set_1date_FUNC,
8384
gtk_1calendar_1set_1show_1day_1names_FUNC,
8485
gtk_1calendar_1set_1show_1heading_FUNC,
8586
gtk_1calendar_1set_1show_1week_1numbers_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2021, 2025 Syntevo and others.
2+
* Copyright (c) 2021, 2026 Syntevo and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -81,10 +81,17 @@ public class GTK4 {
8181
/** @param calendar cast=(GtkCalendar *) */
8282
public static final native long gtk_calendar_get_date(long calendar);
8383
/**
84+
* @method flags=ignore_deprecations
8485
* @param calendar cast=(GtkCalendar *)
8586
* @param date cast=(GDateTime *)
8687
*/
8788
public static final native void gtk_calendar_select_day(long calendar, long date);
89+
/**
90+
* @method flags=dynamic
91+
* @param calendar cast=(GtkCalendar *)
92+
* @param date cast=(GDateTime *)
93+
*/
94+
public static final native void gtk_calendar_set_date(long calendar, long date);
8895
/**
8996
* @param calendar cast=(GtkCalendar *)
9097
* @param value cast=(gboolean)

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,11 @@ public void setDate (int year, int month, int day) {
14991499

15001500
if (GTK.GTK4) {
15011501
long dateTime = OS.g_date_time_new_local(year, month + 1, day, 0, 0, 0);
1502-
GTK4.gtk_calendar_select_day(calendarHandle, dateTime);
1502+
if (GTK.GTK_VERSION >= OS.VERSION(4, 20, 0)) {
1503+
GTK4.gtk_calendar_set_date(calendarHandle, dateTime);
1504+
} else {
1505+
GTK4.gtk_calendar_select_day(calendarHandle, dateTime);
1506+
}
15031507
OS.g_date_time_unref(dateTime);
15041508
} else {
15051509
GTK3.gtk_calendar_select_month (calendarHandle, month, year);

0 commit comments

Comments
 (0)