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:
@@ -1343,3 +1343,18 @@ gcal_util_get_app_timezone_or_local ()
|
||||
context = gcal_application_get_context (application);
|
||||
return g_time_zone_ref (gcal_context_get_timezone (context));
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_is_valid_event_name:
|
||||
* @event_name: the name of the event to check
|
||||
*
|
||||
* Check if the event name is valid
|
||||
*
|
||||
* Returns: %TRUE if the name is valid, %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gcal_is_valid_event_name (const gchar *event_name)
|
||||
{
|
||||
g_autofree gchar *aux = g_strstrip (g_strdup (event_name));
|
||||
return g_utf8_strlen (aux, -1) > 0;
|
||||
}
|
||||
|
||||
@@ -138,4 +138,6 @@ const gchar * gcal_util_translate_time_string (const gchar
|
||||
|
||||
GTimeZone * gcal_util_get_app_timezone_or_local ();
|
||||
|
||||
gboolean gcal_is_valid_event_name (const gchar *event_name);
|
||||
|
||||
#endif /* __GCAL_UTILS_H__ */
|
||||
|
||||
Reference in New Issue
Block a user