views/week-view: Adapt to high contrast

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/710>
This commit is contained in:
Hari Rana
2026-03-31 21:55:32 -04:00
parent 1baefcc465
commit 49e0521b67
2 changed files with 16 additions and 2 deletions
+8
View File
@@ -862,6 +862,7 @@ gcal_week_grid_init (GcalWeekGrid *self)
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
GtkDropTarget *drop_target;
GtkGesture *click_gesture;
AdwStyleManager *manager;
self->selection.start = -1;
self->selection.end = -1;
@@ -905,6 +906,13 @@ gcal_week_grid_init (GcalWeekGrid *self)
G_CALLBACK (gtk_widget_queue_resize),
self->now_strip,
G_CONNECT_SWAPPED);
manager = adw_style_manager_get_default ();
g_signal_connect_object (manager,
"notify::high-contrast",
G_CALLBACK (gtk_widget_queue_draw),
self,
G_CONNECT_SWAPPED);
}
/* Public API */
+8 -2
View File
@@ -18,6 +18,8 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <adwaita.h>
#include "gcal-week-view-common.h"
#include "gcal-utils.h"
@@ -28,16 +30,20 @@ gcal_week_view_common_snapshot_hour_lines (GtkWidget *widget,
gint width,
gint height)
{
AdwStyleManager *manager;
GdkRGBA color;
gboolean ltr;
gboolean ltr, is_high_contrast;
gdouble column_width;
guint i;
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
manager = adw_style_manager_get_default ();
is_high_contrast = adw_style_manager_get_high_contrast (manager);
gtk_snapshot_save (snapshot);
gtk_widget_get_color (widget, &color);
color.alpha = 0.15;
color.alpha = is_high_contrast ? 0.65 : 0.15;
gtk_snapshot_restore (snapshot);
column_width = width / (float) N_WEEKDAYS;