From 12c34dd353ccc970e90f3c2424bf523ca3580d2f Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Thu, 2 Oct 2025 20:33:52 +0300 Subject: [PATCH] fix: GTK 4.20 deprecations --- meson.build | 4 +++ src/Dialogs/Composer/Schedule.vala | 34 +++++++++++++++------ src/Views/Search.vala | 48 ++++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/meson.build b/meson.build index d3b399045..5a703aaa4 100644 --- a/meson.build +++ b/meson.build @@ -126,6 +126,10 @@ if gtk_dep.version().version_compare('>=4.19.1') add_project_arguments(['--define=GTK_4_19_1'], language: 'vala') endif +if gtk_dep.version().version_compare('>=4.20.0') + add_project_arguments(['--define=GTK_4_20_0'], language: 'vala') +endif + if meson.get_compiler('vala').version().version_compare('>=0.56.19') add_project_arguments(['--define=VALAC_05619'], language: 'vala') endif diff --git a/src/Dialogs/Composer/Schedule.vala b/src/Dialogs/Composer/Schedule.vala index 58a2bb649..f49903a46 100644 --- a/src/Dialogs/Composer/Schedule.vala +++ b/src/Dialogs/Composer/Schedule.vala @@ -45,9 +45,13 @@ public class Tuba.Dialogs.Schedule : Adw.NavigationPage, Composer.PreferredSizea minutes_spin_button.value = (double) iso8601_datetime.get_minute (); seconds_spin_button.value = (double) iso8601_datetime.get_second (); - calendar.year = iso8601_datetime.get_year (); - calendar.month = iso8601_datetime.get_month () - 1; - calendar.day = iso8601_datetime.get_day_of_month (); + #if GTK_4_20_0 + calendar.date = iso8601_datetime; + #else + calendar.year = iso8601_datetime.get_year (); + calendar.month = iso8601_datetime.get_month () - 1; + calendar.day = iso8601_datetime.get_day_of_month (); + #endif } if (button_label != null) schedule_button.label = button_label; @@ -69,18 +73,30 @@ public class Tuba.Dialogs.Schedule : Adw.NavigationPage, Composer.PreferredSizea GLib.DateTime now = new GLib.DateTime.now_utc (); if (timezone_combo_row.selected != Gtk.INVALID_LIST_POSITION && ((Gtk.StringObject) timezone_combo_row.selected_item).string == "UTC") { result_dt = new GLib.DateTime.utc ( - calendar.year, - calendar.month + 1, - calendar.day, + #if GTK_4_20_0 + calendar.date.get_year (), + calendar.date.get_month (), + calendar.date.get_day_of_month (), + #else + calendar.year, + calendar.month + 1, + calendar.day, + #endif (int) hours_spin_button.value, (int) minutes_spin_button.value, seconds_spin_button.value ); } else { result_dt = new GLib.DateTime.local ( - calendar.year, - calendar.month + 1, - calendar.day, + #if GTK_4_20_0 + calendar.date.get_year (), + calendar.date.get_month (), + calendar.date.get_day_of_month (), + #else + calendar.year, + calendar.month + 1, + calendar.day, + #endif (int) hours_spin_button.value, (int) minutes_spin_button.value, seconds_spin_button.value diff --git a/src/Views/Search.vala b/src/Views/Search.vala index 92770013a..15cd97b8d 100644 --- a/src/Views/Search.vala +++ b/src/Views/Search.vala @@ -423,9 +423,19 @@ public class Tuba.Views.Search : Views.TabbedBase { if (year > 0 && month > 0 && day > 0) { before_expander_row.expanded = true; - before_calendar.year = year; - before_calendar.month = month; - before_calendar.day = day; + + #if GTK_4_20_0 + before_calendar.date = new GLib.DateTime.utc ( + year, + month, + day, + 0, 0 ,0 + ); + #else + before_calendar.year = year; + before_calendar.month = month; + before_calendar.day = day; + #endif } } } else if (down_word.has_prefix ("during:")) { @@ -438,9 +448,19 @@ public class Tuba.Views.Search : Views.TabbedBase { if (year > 0 && month > 0 && day > 0) { during_expander_row.expanded = true; - during_calendar.year = year; - during_calendar.month = month; - during_calendar.day = day; + + #if GTK_4_20_0 + during_calendar.date = new GLib.DateTime.utc ( + year, + month, + day, + 0, 0 ,0 + ); + #else + during_calendar.year = year; + during_calendar.month = month; + during_calendar.day = day; + #endif } } } else if (down_word.has_prefix ("after:")) { @@ -453,9 +473,19 @@ public class Tuba.Views.Search : Views.TabbedBase { if (year > 0 && month > 0 && day > 0) { after_expander_row.expanded = true; - after_calendar.year = year; - after_calendar.month = month; - after_calendar.day = day; + + #if GTK_4_20_0 + after_calendar.date = new GLib.DateTime.utc ( + year, + month, + day, + 0, 0 ,0 + ); + #else + after_calendar.year = year; + after_calendar.month = month; + after_calendar.day = day; + #endif } } } else {