event-editor: Improve event name validation handling

- Fix a bug where clicking the "Add Event" button created an empty title in the event editor dialog.
- Add "error" class when the user writes an invalid event name.
- Add new function to validate event name.

Because the sections are split into files, the event editor will need a signal to check that each section is correct, and each section will have to emit the signal. This will need to be done in a future commit.
This commit is contained in:
Hari Rana
2024-02-25 08:55:17 -05:00
parent 71955d6786
commit ddb54c8c1c
6 changed files with 52 additions and 14 deletions
@@ -773,6 +773,10 @@ gcal_event_editor_dialog_set_event (GcalEventEditorDialog *self,
g_object_add_weak_pointer (G_OBJECT (self->event_title_binding),
(gpointer*) &self->event_title_binding);
/* change title when event name is empty */
if (!gcal_is_valid_event_name (gtk_label_get_label (GTK_LABEL (self->title_label))))
gtk_label_set_label (GTK_LABEL (self->title_label), _("New Event"));
gtk_label_set_label (GTK_LABEL (self->subtitle_label), gcal_calendar_get_name (calendar));
self->selected_calendar = calendar;