From 7764b4dc0a1fea5847478a696bb48e77c75ab194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=B6llnitz?= Date: Thu, 13 Feb 2025 11:18:01 +0100 Subject: [PATCH] window: reintroduce back and forward buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They reappear in the newest adaptive layout wireframes. These were dropped in 54a8445abbebe66e17ce3eb7fe75f42bac847682 ("window: Drop the back and forward buttons") Closes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/933 Signed-off-by: Markus Göllnitz Part-of: --- src/gui/gcal-window.c | 45 ++++++++++++++++++++++++++++++++++++++++++ src/gui/gcal-window.ui | 14 +++++++++++++ 2 files changed, 59 insertions(+) diff --git a/src/gui/gcal-window.c b/src/gui/gcal-window.c index 1e46ad61..ac9431fb 100644 --- a/src/gui/gcal-window.c +++ b/src/gui/gcal-window.c @@ -122,6 +122,9 @@ struct _GcalWindow GtkWidget *last_focused_widget; + GtkButton *next_date_button; + GtkButton *previous_date_button; + /* new event popover widgets */ GtkWidget *quick_add_popover; @@ -220,6 +223,45 @@ update_today_action_enabled (GcalWindow *window) GCAL_EXIT; } +static void +update_view_buttons (GcalWindow *window) +{ + GCAL_ENTRY; + + switch (gcal_view_get_time_direction (GCAL_VIEW (window->views[window->active_view]))) + { + case GTK_ORIENTATION_VERTICAL: + gtk_button_set_icon_name (window->previous_date_button, "go-up-symbolic"); + gtk_button_set_icon_name (window->next_date_button, "go-down-symbolic"); + break; + case GTK_ORIENTATION_HORIZONTAL: + gtk_button_set_icon_name (window->previous_date_button, "go-previous-symbolic"); + gtk_button_set_icon_name (window->next_date_button, "go-next-symbolic"); + break; + } + + switch (window->active_view) + { + case GCAL_WINDOW_VIEW_WEEK: + gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous week")); + gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next week")); + break; + case GCAL_WINDOW_VIEW_MONTH: + gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous month")); + gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next month")); + break; + case GCAL_WINDOW_VIEW_AGENDA: + gtk_widget_set_tooltip_text (GTK_WIDGET (window->previous_date_button), _("Go to previous day")); + gtk_widget_set_tooltip_text (GTK_WIDGET (window->next_date_button), _("Go to next day")); + break; + default: + g_assert_not_reached (); + break; + } + + GCAL_EXIT; +} + static void maybe_add_subscribers_to_timeline (GcalWindow *self) { @@ -657,6 +699,7 @@ view_changed (GObject *object, window->active_view = view_type; update_today_action_enabled (window); + update_view_buttons (window); g_object_notify_by_pspec (G_OBJECT (user_data), properties[PROP_ACTIVE_VIEW]); } @@ -1308,8 +1351,10 @@ gcal_window_class_init (GcalWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, GcalWindow, header_bar); gtk_widget_class_bind_template_child (widget_class, GcalWindow, menu_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, month_view); + gtk_widget_class_bind_template_child (widget_class, GcalWindow, next_date_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover); gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay); + gtk_widget_class_bind_template_child (widget_class, GcalWindow, previous_date_button); gtk_widget_class_bind_template_child (widget_class, GcalWindow, split_view); gtk_widget_class_bind_template_child (widget_class, GcalWindow, sync_indicator); gtk_widget_class_bind_template_child (widget_class, GcalWindow, search_button); diff --git a/src/gui/gcal-window.ui b/src/gui/gcal-window.ui index 0608bd35..4a221adc 100644 --- a/src/gui/gcal-window.ui +++ b/src/gui/gcal-window.ui @@ -296,6 +296,18 @@ + + + go-previous-symbolic + win.previous-date + + + + + go-next-symbolic + win.next-date + + win.today @@ -362,6 +374,8 @@ True False + False + False False False