From 3e4ef6f9c78a73265216c844a5ce908cbd0a2bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Fortin=20Tam?= Date: Fri, 23 Feb 2024 13:26:27 -0500 Subject: [PATCH] event-editor: Hide Cancel & Delete when read-only Read-only events show a "Done" button instead of the "Save" button. The "Done" button does the same thing as "Cancel", so the "Cancel" button is then redundant. Likewise, it is impossible to delete events from read-only calendars, as stated by the banner message in that dialog. In that case, there's no reason to show a big "Delete" button that you can't click on. Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1168 --- src/gui/event-editor/gcal-event-editor-dialog.blp | 1 - src/gui/event-editor/gcal-event-editor-dialog.c | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/event-editor/gcal-event-editor-dialog.blp b/src/gui/event-editor/gcal-event-editor-dialog.blp index 2b441a12..a013ba83 100644 --- a/src/gui/event-editor/gcal-event-editor-dialog.blp +++ b/src/gui/event-editor/gcal-event-editor-dialog.blp @@ -78,7 +78,6 @@ template $GcalEventEditorDialog: Adw.Dialog { Adw.PreferencesGroup delete_group { Adw.ButtonRow { activated => $on_delete_row_activated_cb(template) not-swapped; - sensitive: bind template.writable no-sync-create; title: _("Delete Event"); styles [ diff --git a/src/gui/event-editor/gcal-event-editor-dialog.c b/src/gui/event-editor/gcal-event-editor-dialog.c index e56723b9..0c6b2596 100644 --- a/src/gui/event-editor/gcal-event-editor-dialog.c +++ b/src/gui/event-editor/gcal-event-editor-dialog.c @@ -702,8 +702,10 @@ gcal_event_editor_dialog_set_event (GcalEventEditorDialog *self, set_writable (self, !gcal_calendar_is_read_only (calendar)); + gtk_widget_set_visible (self->cancel_button, self->writable); + self->event_is_new = new_event; - gtk_widget_set_visible (self->delete_group, !new_event); + gtk_widget_set_visible (self->delete_group, !new_event && self->writable); if (!self->writable) gtk_widget_grab_focus (self->done_button);