window: only allow changing to visible view

As of now, every view is visible. That however, will
change with a subsequent commit moving the agenda view to
the main area and introducing breakpoint-dependent view
visibilities.

Signed-off-by: Markus Göllnitz <camelcasenick@bewares.it>
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/542>
This commit is contained in:
Markus Göllnitz
2025-06-08 09:59:00 +00:00
committed by Marge Bot
parent 3dce4414a8
commit 26db7e1627
+11 -7
View File
@@ -446,16 +446,21 @@ on_view_action_activated (GSimpleAction *action,
view = g_variant_get_int32 (param);
/* -1 means next view */
/* -1 means next view, -2 means previous view */
if (view == -1)
view = ++(window->active_view);
view = window->active_view + 1;
else if (view == -2)
view = --(window->active_view);
view = window->active_view - 1;
window->active_view = CLAMP (view, 0, GCAL_WINDOW_VIEW_N_VIEWS - 1);
adw_view_stack_set_visible_child (window->views_stack, window->views[window->active_view]);
view = CLAMP (view, 0, GCAL_WINDOW_VIEW_N_VIEWS - 1);
g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]);
if (adw_view_stack_page_get_visible (adw_view_stack_get_page (window->views_stack, window->views[view])))
{
window->active_view = view;
adw_view_stack_set_visible_child (window->views_stack, window->views[window->active_view]);
g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]);
}
GCAL_EXIT;
}
@@ -1110,7 +1115,6 @@ gcal_window_set_property (GObject *object,
{
case PROP_ACTIVE_VIEW:
self->active_view = g_value_get_enum (value);
gtk_widget_set_visible (self->views[self->active_view], TRUE);
adw_view_stack_set_visible_child (self->views_stack, self->views[self->active_view]);
break;