From 569233f9484cb842e95ada1ef44f745a0745ed30 Mon Sep 17 00:00:00 2001 From: Titouan Real Date: Tue, 5 Nov 2024 21:55:34 +0100 Subject: [PATCH 1/5] event-editor: Create GcalTimeChooserRow Create a new GcalTimeChooserRow widget from AdwEntryRow that parses the entry into a time, or lets the user pick a time from a popover. [feaneron] Improved code style, reworked regex management. --- meson.build | 2 +- .../event-editor/event-editor.gresource.xml | 1 + src/gui/event-editor/gcal-time-chooser-row.c | 399 ++++++++++++++++++ src/gui/event-editor/gcal-time-chooser-row.h | 39 ++ src/gui/event-editor/gcal-time-chooser-row.ui | 45 ++ src/gui/event-editor/meson.build | 1 + src/gui/icons/clock-alt-symbolic.svg | 2 + src/gui/icons/icons.gresource.xml | 1 + 8 files changed, 489 insertions(+), 1 deletion(-) create mode 100644 src/gui/event-editor/gcal-time-chooser-row.c create mode 100644 src/gui/event-editor/gcal-time-chooser-row.h create mode 100644 src/gui/event-editor/gcal-time-chooser-row.ui create mode 100644 src/gui/icons/clock-alt-symbolic.svg diff --git a/meson.build b/meson.build index 089e2006f..744069007 100644 --- a/meson.build +++ b/meson.build @@ -164,7 +164,7 @@ libedataserverui_dep = dependency('libedataserverui4-1.0', version: '>= 3.45.1') libedataserver_dep = dependency('libedataserver-1.2', version: '>= 3.45.1') libecal_dep = dependency('libecal-2.0', version: '>= 3.45.1') libsoup_dep = dependency('libsoup-3.0') -libadwaita_dep = dependency('libadwaita-1', version: '>= 1.6.alpha') +libadwaita_dep = dependency('libadwaita-1', version: '>= 1.7.alpha') glib_dep = dependency('glib-2.0', version: '>= 2.67.5') gtk_dep = dependency('gtk4', version: '>= 4.15.2') gio_dep = dependency('gio-2.0', version: '>= 2.58.0') diff --git a/src/gui/event-editor/event-editor.gresource.xml b/src/gui/event-editor/event-editor.gresource.xml index 38165c51f..f54919017 100644 --- a/src/gui/event-editor/event-editor.gresource.xml +++ b/src/gui/event-editor/event-editor.gresource.xml @@ -11,6 +11,7 @@ gcal-reminders-section.ui gcal-schedule-section.ui gcal-summary-section.ui + gcal-time-chooser-row.ui gcal-time-selector.ui diff --git a/src/gui/event-editor/gcal-time-chooser-row.c b/src/gui/event-editor/gcal-time-chooser-row.c new file mode 100644 index 000000000..0612d058e --- /dev/null +++ b/src/gui/event-editor/gcal-time-chooser-row.c @@ -0,0 +1,399 @@ +/* gcal-time-chooser-row.c + * + * Copyright (C) 2024 Titouan Real + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#define G_LOG_DOMAIN "GcalTimeChooserRow" + +#include "gcal-time-chooser-row.h" +#include "gcal-time-selector.h" + +#include +#include +#include +#include + +struct _GcalTimeChooserRow +{ + AdwEntryRow parent; + + /* widgets */ + GcalTimeSelector *time_selector; + + GcalTimeFormat time_format; +}; + +G_DEFINE_TYPE (GcalTimeChooserRow, gcal_time_chooser_row, ADW_TYPE_ENTRY_ROW); + +enum +{ + PROP_0, + PROP_TIME_FORMAT, + PROP_TIME, + N_PROPS +}; + +static GParamSpec* properties[N_PROPS] = { NULL, }; + + +/* + * Auxiliary methods + */ + +static void +update_entry (GcalTimeChooserRow *self) +{ + g_autofree gchar *label = NULL; + GDateTime *time; + + time = gcal_time_selector_get_time (self->time_selector); + + switch (self->time_format) + { + case GCAL_TIME_FORMAT_12H: + label = g_date_time_format (time, "%I:%M %p"); + break; + + case GCAL_TIME_FORMAT_24H: + label = g_date_time_format (time, "%R"); + break; + + default: + g_assert_not_reached (); + } + + gtk_editable_set_text (GTK_EDITABLE (self), label); +} + +static GRegex* +get_12h_regex (void) +{ + static GRegex *regex = NULL; + + if (g_once_init_enter_pointer (®ex)) + { + g_autoptr (GError) error = NULL; + g_autofree gchar *str = NULL; + + str = g_strdup_printf ("^(?[0-9]{1,2})([\\-:./_,'a-z](?[0-9]{1,2}))? ?(?%s|%s)", + _("AM"), _("PM")); + + regex = g_regex_new (str, G_REGEX_CASELESS, 0, &error); + + if (error) + g_error ("Failed to compile regex: %s. Aborting...", error->message); + } + + return regex; +} + +static GRegex* +get_24h_regex (void) +{ + static GRegex *regex = NULL; + + if (g_once_init_enter_pointer (®ex)) + { + g_autoptr (GError) error = NULL; + + regex = g_regex_new ("^(?[0-9]{1,2})([\\-:./_,'a-z](?[0-9]{1,2}))?", G_REGEX_CASELESS, 0, &error); + + if (error) + g_error ("Failed to compile regex: %s. Aborting...", error->message); + } + + return regex; +} + +static void +parse_time (GcalTimeChooserRow *self) +{ + g_autoptr (GDateTime) now = NULL; + const gchar *text; + + text = gtk_editable_get_text (GTK_EDITABLE (self)); + now = g_date_time_new_now_local (); + + switch (self->time_format) + { + case GCAL_TIME_FORMAT_12H: + { + g_autoptr (GMatchInfo) match_info = NULL; + g_autoptr (GDateTime) time = NULL; + g_autofree gchar *minute_str = NULL; + g_autofree gchar *hour_str = NULL; + g_autofree gchar *ampm_str = NULL; + gboolean am; + gint64 hour, minute; + + if (!g_regex_match (get_12h_regex (), text, 0, &match_info)) + { + update_entry (self); + break; + } + + hour_str = g_match_info_fetch_named (match_info, "hour"); + minute_str = g_match_info_fetch_named (match_info, "minute"); + ampm_str = g_match_info_fetch_named (match_info, "ampm"); + + hour = g_ascii_strtoll (hour_str, NULL, 10); + minute = g_ascii_strtoll (minute_str, NULL, 10); + am = (strcmp (g_ascii_strup (ampm_str, -1), _("AM")) == 0); + + /* Allow 12AM and 12PM */ + if ((hour > 11 || minute > 59) && !(hour == 12 && minute == 0)) + { + update_entry (self); + break; + } + + if (hour == 12) + { + g_assert (minute == 0); + hour = 0; + } + + if (!am) + hour += 12; + + now = g_date_time_new_now_local (); + time = g_date_time_new_local (g_date_time_get_year (now), + g_date_time_get_month (now), + g_date_time_get_day_of_month (now), + hour, minute, 0); + + gcal_time_chooser_row_set_time (self, time); + + } + break; + + case GCAL_TIME_FORMAT_24H: + { + g_autoptr (GMatchInfo) match_info = NULL; + g_autoptr (GDateTime) time = NULL; + g_autofree gchar *minute_str = NULL; + g_autofree gchar *hour_str = NULL; + g_autofree gchar *ampm_str = NULL; + gint64 hour, minute; + + if (!g_regex_match (get_24h_regex (), text, 0, &match_info)) + { + update_entry (self); + break; + } + + hour_str = g_match_info_fetch_named (match_info, "hour"); + minute_str = g_match_info_fetch_named (match_info, "minute"); + + hour = g_ascii_strtoll (hour_str, NULL, 10); + minute = g_ascii_strtoll (minute_str, NULL, 10); + + if (hour > 23 || minute > 59) + { + update_entry (self); + break; + } + + time = g_date_time_new_local (g_date_time_get_year (now), + g_date_time_get_month (now), + g_date_time_get_day_of_month (now), + hour, minute, 0); + + gcal_time_chooser_row_set_time (self, time); + + } + break; + + default: + g_assert_not_reached (); + } +} + + +/* + * Callbacks + */ + +static void +on_contains_focus_changed_cb (GtkEventControllerFocus *focus_controller, + GParamSpec *pspec, + GcalTimeChooserRow *self) +{ + parse_time (self); +} + +static void +on_time_selected_changed_cb (GcalTimeSelector *selector, + GParamSpec *pspec, + GcalTimeChooserRow *self) +{ + update_entry (self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TIME]); +} + +static void +on_time_popover_shown_cb (GtkPopover *popover, + GcalTimeChooserRow *self) +{ + parse_time (self); +} + + +/* + * GObject overrides + */ + +static void +gcal_time_chooser_row_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GcalTimeChooserRow *self = GCAL_TIME_CHOOSER_ROW (object); + + switch (prop_id) + { + case PROP_TIME_FORMAT: + g_value_set_enum (value, self->time_format); + break; + + case PROP_TIME: + g_value_set_boxed (value, gcal_time_chooser_row_get_time (self)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gcal_time_chooser_row_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GcalTimeChooserRow *self = GCAL_TIME_CHOOSER_ROW (object); + + switch (prop_id) + { + case PROP_TIME_FORMAT: + gcal_time_chooser_row_set_time_format (self, g_value_get_enum (value)); + break; + + case PROP_TIME: + gcal_time_chooser_row_set_time (self, g_value_get_boxed (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gcal_time_chooser_row_class_init (GcalTimeChooserRowClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = gcal_time_chooser_row_get_property; + object_class->set_property = gcal_time_chooser_row_set_property; + + properties[PROP_TIME_FORMAT] = g_param_spec_enum ("time-format", NULL, NULL, + GCAL_TYPE_TIME_FORMAT, + GCAL_TIME_FORMAT_24H, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + + properties[PROP_TIME] = g_param_spec_boxed ("time", NULL, NULL, + G_TYPE_DATE_TIME, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/event-editor/gcal-time-chooser-row.ui"); + + gtk_widget_class_bind_template_child (widget_class, GcalTimeChooserRow, time_selector); + + gtk_widget_class_bind_template_callback (widget_class, on_contains_focus_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_time_selected_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_time_popover_shown_cb); +} + +static void +gcal_time_chooser_row_init (GcalTimeChooserRow *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); + + self->time_format = GCAL_TIME_FORMAT_24H; +} + +GcalTimeFormat +gcal_time_chooser_row_get_time_format (GcalTimeChooserRow *self) +{ + g_return_val_if_fail (GCAL_IS_TIME_CHOOSER_ROW (self), 0); + + return self->time_format; +} + +void +gcal_time_chooser_row_set_time_format (GcalTimeChooserRow *self, + GcalTimeFormat time_format) +{ + g_return_if_fail (GCAL_IS_TIME_CHOOSER_ROW (self)); + + if (self->time_format == time_format) + return; + + self->time_format = time_format; + + gcal_time_selector_set_time_format (self->time_selector, time_format); + update_entry (self); +} + +/** + * gcal_time_chooser_row_set_time: + * @selector: a #GcalTimeChooserRow + * @date: a valid #GDateTime + * + * Set the value of the shown time. + */ +void +gcal_time_chooser_row_set_time (GcalTimeChooserRow *self, + GDateTime *time) +{ + g_return_if_fail (GCAL_IS_TIME_CHOOSER_ROW (self)); + + gcal_time_selector_set_time (self->time_selector, time); + update_entry (self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TIME]); +} + +/** + * gcal_time_chooser_row_get_time: + * @selector: a #GcalTimeChooserRow + * + * Get the value of the time shown + * + * Returns: (transfer none): the time of the selector. + */ +GDateTime* +gcal_time_chooser_row_get_time (GcalTimeChooserRow *self) +{ + g_return_val_if_fail (GCAL_IS_TIME_CHOOSER_ROW (self), NULL); + + return gcal_time_selector_get_time (self->time_selector); +} diff --git a/src/gui/event-editor/gcal-time-chooser-row.h b/src/gui/event-editor/gcal-time-chooser-row.h new file mode 100644 index 000000000..4fc01b084 --- /dev/null +++ b/src/gui/event-editor/gcal-time-chooser-row.h @@ -0,0 +1,39 @@ +/* gcal-time-chooser-row.h + * + * Copyright (C) 2024 Titouan Real + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#pragma once + +#include "gcal-enums.h" + +#include + +G_BEGIN_DECLS + +#define GCAL_TYPE_TIME_CHOOSER_ROW (gcal_time_chooser_row_get_type ()) + +G_DECLARE_FINAL_TYPE (GcalTimeChooserRow, gcal_time_chooser_row, GCAL, TIME_CHOOSER_ROW, AdwEntryRow) + +GcalTimeFormat gcal_time_chooser_row_get_time_format (GcalTimeChooserRow *self); +void gcal_time_chooser_row_set_time_format (GcalTimeChooserRow *self, + GcalTimeFormat time_format); + +GDateTime* gcal_time_chooser_row_get_time (GcalTimeChooserRow *self); +void gcal_time_chooser_row_set_time (GcalTimeChooserRow *self, + GDateTime *date); + +G_END_DECLS diff --git a/src/gui/event-editor/gcal-time-chooser-row.ui b/src/gui/event-editor/gcal-time-chooser-row.ui new file mode 100644 index 000000000..0c2e15eb8 --- /dev/null +++ b/src/gui/event-editor/gcal-time-chooser-row.ui @@ -0,0 +1,45 @@ + + + + diff --git a/src/gui/event-editor/meson.build b/src/gui/event-editor/meson.build index 1c9707ff7..0b498ae45 100644 --- a/src/gui/event-editor/meson.build +++ b/src/gui/event-editor/meson.build @@ -18,5 +18,6 @@ sources += files( 'gcal-reminders-section.c', 'gcal-schedule-section.c', 'gcal-summary-section.c', + 'gcal-time-chooser-row.c', 'gcal-time-selector.c', ) diff --git a/src/gui/icons/clock-alt-symbolic.svg b/src/gui/icons/clock-alt-symbolic.svg new file mode 100644 index 000000000..b4b5066ba --- /dev/null +++ b/src/gui/icons/clock-alt-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/gui/icons/icons.gresource.xml b/src/gui/icons/icons.gresource.xml index e586223d6..b77b922a1 100644 --- a/src/gui/icons/icons.gresource.xml +++ b/src/gui/icons/icons.gresource.xml @@ -5,6 +5,7 @@ calendar-month-symbolic.svg calendar-week-symbolic.svg calendar-today-symbolic.svg + clock-alt-symbolic.svg external-link-symbolic.svg edit-symbolic.svg eye-not-looking-symbolic.svg -- GitLab From f883de2d0298a7a7d93e4d474a512a664c2e39f1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 16 Dec 2024 15:55:09 -0300 Subject: [PATCH 2/5] core/context: Properly initialize time format The property default and the actual initialization didn't agree on 24h. --- src/core/gcal-context.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/gcal-context.c b/src/core/gcal-context.c index 6ff1a2e23..f882577ed 100644 --- a/src/core/gcal-context.c +++ b/src/core/gcal-context.c @@ -310,6 +310,7 @@ gcal_context_init (GcalContext *self) self->clock = gcal_clock_new (); self->settings = g_settings_new ("org.gnome.calendar"); self->weather_service = gcal_weather_service_new (); + self->time_format = GCAL_TIME_FORMAT_24H; self->timezone_monitor = gcal_time_zone_monitor_new (); g_signal_connect_object (self->timezone_monitor, -- GitLab From a37b0551ea35244e11398fece931fe5a26bcbb0b Mon Sep 17 00:00:00 2001 From: Titouan Real Date: Wed, 27 Nov 2024 15:50:22 +0100 Subject: [PATCH 3/5] event-editor: Create GcalDateChooserRow Create a new GcalDateChooserRow widget from AdwEntryRow that parses the entry into a date, or lets the user pick a date from a popover. --- .../event-editor/event-editor.gresource.xml | 1 + src/gui/event-editor/gcal-date-chooser-row.c | 325 ++++++++++++++++++ src/gui/event-editor/gcal-date-chooser-row.h | 32 ++ src/gui/event-editor/gcal-date-chooser-row.ui | 48 +++ src/gui/event-editor/meson.build | 1 + 5 files changed, 407 insertions(+) create mode 100644 src/gui/event-editor/gcal-date-chooser-row.c create mode 100644 src/gui/event-editor/gcal-date-chooser-row.h create mode 100644 src/gui/event-editor/gcal-date-chooser-row.ui diff --git a/src/gui/event-editor/event-editor.gresource.xml b/src/gui/event-editor/event-editor.gresource.xml index f54919017..196b62db4 100644 --- a/src/gui/event-editor/event-editor.gresource.xml +++ b/src/gui/event-editor/event-editor.gresource.xml @@ -4,6 +4,7 @@ gcal-alarm-row.ui gcal-date-chooser.ui gcal-date-chooser-day.ui + gcal-date-chooser-row.ui gcal-date-selector.ui gcal-event-editor-dialog.ui gcal-multi-choice.ui diff --git a/src/gui/event-editor/gcal-date-chooser-row.c b/src/gui/event-editor/gcal-date-chooser-row.c new file mode 100644 index 000000000..301a07fe2 --- /dev/null +++ b/src/gui/event-editor/gcal-date-chooser-row.c @@ -0,0 +1,325 @@ +/* gcal-date-chooser-row.c + * + * Copyright (C) 2024 Titouan Real + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#define G_LOG_DOMAIN "GcalDateChooserRow" + +#include "gcal-date-chooser-row.h" +#include "gcal-date-chooser.h" +#include "gcal-view.h" + +#include +#include +#include +#include +#include "gcal-utils.h" + +struct _GcalDateChooserRow +{ + AdwEntryRow parent; + + /* widgets */ + GcalDateChooser *date_chooser; + + GDBusProxy *settings_portal; +}; + +G_DEFINE_TYPE (GcalDateChooserRow, gcal_date_chooser_row, ADW_TYPE_ENTRY_ROW); + +enum +{ + PROP_0, + PROP_DATE, + N_PROPS +}; + +static GParamSpec* properties[N_PROPS] = { NULL, }; + + +static void +update_entry (GcalDateChooserRow *self) +{ + g_autofree gchar *formatted_date = NULL; + GDateTime *date; + + date = gcal_date_chooser_row_get_date (self); + formatted_date = g_date_time_format (date, "%x"); + + gtk_editable_set_text (GTK_EDITABLE (self), formatted_date); +} + +static void +parse_date (GcalDateChooserRow *self) +{ + g_autoptr (GDateTime) new_date = NULL; + GDate parsed_date; + + g_date_clear (&parsed_date, 1); + g_date_set_parse (&parsed_date, gtk_editable_get_text (GTK_EDITABLE (self))); + + if (!g_date_valid (&parsed_date)) + { + update_entry (self); + return; + } + + new_date = g_date_time_new_local (g_date_get_year (&parsed_date), + g_date_get_month (&parsed_date), + g_date_get_day (&parsed_date), + 0, 0, 0); + + gcal_date_chooser_row_set_date (self, new_date); +} + +static void +set_show_weekdate_from_variant (GcalDateChooserRow *self, + GVariant *variant) +{ + g_assert (g_variant_type_equal (g_variant_get_type (variant), "b")); + + gcal_date_chooser_set_show_week_numbers (GCAL_DATE_CHOOSER (self->date_chooser), + g_variant_get_boolean (variant)); +} + +static gboolean +read_show_weekdate (GcalDateChooserRow *self) +{ + g_autoptr (GVariant) other_child = NULL; + g_autoptr (GVariant) child = NULL; + g_autoptr (GVariant) ret = NULL; + g_autoptr (GError) error = NULL; + + ret = g_dbus_proxy_call_sync (self->settings_portal, + "Read", + g_variant_new ("(ss)", "org.gnome.desktop.calendar", "show-weekdate"), + G_DBUS_CALL_FLAGS_NONE, + G_MAXINT, + NULL, + &error); + + if (error) + return FALSE; + + g_variant_get (ret, "(v)", &child); + g_variant_get (child, "v", &other_child); + + set_show_weekdate_from_variant (self, other_child); + + return TRUE; +} + + +/* + * Callbacks + */ + +static void +on_contains_focus_changed_cb (GtkEventControllerFocus *focus_controller, + GParamSpec *pspec, + GcalDateChooserRow *self) +{ + parse_date (self); +} + +static void +on_date_selected_changed_cb (GcalDateChooser *selector, + GParamSpec *pspec, + GcalDateChooserRow *self) +{ + update_entry (self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DATE]); +} + +static void +on_date_popover_shown_cb (GtkPopover *popover, + GcalDateChooserRow *self) +{ + parse_date (self); +} + +static void +on_portal_proxy_signal_cb (GDBusProxy *proxy, + const char *sender_name, + const char *signal_name, + GVariant *parameters, + GcalDateChooserRow *self) +{ + g_autoptr (GVariant) value = NULL; + const char *namespace; + const char *name; + + if (g_strcmp0 (signal_name, "SettingChanged") != 0) + return; + + g_variant_get (parameters, "(&s&sv)", &namespace, &name, &value); + + if (g_strcmp0 (namespace, "org.gnome.desktop.calendar") == 0 && + g_strcmp0 (name, "show-weekdate") == 0) + { + set_show_weekdate_from_variant (self, value); + } +} + + +/* + * GObject overrides + */ + +static void +gcal_date_chooser_row_dispose (GObject *object) +{ + GcalDateChooserRow *self = GCAL_DATE_CHOOSER_ROW (object); + + g_clear_object (&self->settings_portal); + + G_OBJECT_CLASS (gcal_date_chooser_row_parent_class)->dispose (object); +} + +static void +gcal_date_chooser_row_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GcalDateChooserRow *self = GCAL_DATE_CHOOSER_ROW (object); + + switch (prop_id) + { + case PROP_DATE: + g_value_set_boxed (value, gcal_date_chooser_row_get_date(self)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gcal_date_chooser_row_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GcalDateChooserRow *self = GCAL_DATE_CHOOSER_ROW (object); + + switch (prop_id) + { + case PROP_DATE: + gcal_date_chooser_row_set_date (self, g_value_get_boxed (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +gcal_date_chooser_row_class_init (GcalDateChooserRowClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->dispose = gcal_date_chooser_row_dispose; + object_class->get_property = gcal_date_chooser_row_get_property; + object_class->set_property = gcal_date_chooser_row_set_property; + + /** + * GcalDateChooserRow::date: + * + * The current date of the selector. + */ + properties[PROP_DATE] = g_param_spec_boxed ("date", + "Date of the chooser row", + "The current date of the chooser row", + G_TYPE_DATE_TIME, + G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPS, properties); + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/event-editor/gcal-date-chooser-row.ui"); + + gtk_widget_class_bind_template_child (widget_class, GcalDateChooserRow, date_chooser); + + gtk_widget_class_bind_template_callback (widget_class, on_contains_focus_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_date_selected_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_date_popover_shown_cb); +} + +static void +gcal_date_chooser_row_init (GcalDateChooserRow *self) +{ + g_autoptr (GError) error = NULL; + + gtk_widget_init_template (GTK_WIDGET (self)); + + self->settings_portal = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "org.freedesktop.portal.Desktop", + "/org/freedesktop/portal/desktop", + "org.freedesktop.portal.Settings", + NULL, + &error); + + if (error) + g_error ("Failed to load portals: %s. Aborting...", error->message); + + if (read_show_weekdate (self)) + { + g_signal_connect (self->settings_portal, + "g-signal", + G_CALLBACK (on_portal_proxy_signal_cb), + self); + } +} + +/** + * gcal_date_chooser_row_set_date: + * @self: a #GcalDateChooserRow + * @date: a valid #GDateTime + * + * Set the value of the shown date. + */ +void +gcal_date_chooser_row_set_date (GcalDateChooserRow *self, + GDateTime *date) +{ + g_return_if_fail (GCAL_IS_DATE_CHOOSER_ROW (self)); + + gcal_view_set_date (GCAL_VIEW (self->date_chooser), date); + + update_entry (self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DATE]); +} + +/** + * gcal_date_chooser_row_get_date: + * @self: a #GcalDateChooserRow + * + * Get the value of the date shown + * + * Returns: (transfer none): the date of the selector. + */ +GDateTime* +gcal_date_chooser_row_get_date (GcalDateChooserRow *self) +{ + g_return_val_if_fail (GCAL_IS_DATE_CHOOSER_ROW (self), NULL); + + return gcal_view_get_date (GCAL_VIEW (self->date_chooser)); +} diff --git a/src/gui/event-editor/gcal-date-chooser-row.h b/src/gui/event-editor/gcal-date-chooser-row.h new file mode 100644 index 000000000..67f4cd8b4 --- /dev/null +++ b/src/gui/event-editor/gcal-date-chooser-row.h @@ -0,0 +1,32 @@ +/* gcal-date-chooser-row.h + * + * Copyright (C) 2024 Titouan Real + * + * gnome-calendar is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gnome-calendar is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#pragma once + +#include + +G_BEGIN_DECLS + +#define GCAL_TYPE_DATE_CHOOSER_ROW (gcal_date_chooser_row_get_type ()) +G_DECLARE_FINAL_TYPE (GcalDateChooserRow, gcal_date_chooser_row, GCAL, DATE_CHOOSER_ROW, AdwEntryRow) + +GDateTime* gcal_date_chooser_row_get_date (GcalDateChooserRow *self); +void gcal_date_chooser_row_set_date (GcalDateChooserRow *self, + GDateTime *date); + +G_END_DECLS diff --git a/src/gui/event-editor/gcal-date-chooser-row.ui b/src/gui/event-editor/gcal-date-chooser-row.ui new file mode 100644 index 000000000..b9e5e88f2 --- /dev/null +++ b/src/gui/event-editor/gcal-date-chooser-row.ui @@ -0,0 +1,48 @@ + + + + diff --git a/src/gui/event-editor/meson.build b/src/gui/event-editor/meson.build index 0b498ae45..dcc40a13d 100644 --- a/src/gui/event-editor/meson.build +++ b/src/gui/event-editor/meson.build @@ -10,6 +10,7 @@ sources += files( 'gcal-alarm-row.c', 'gcal-date-chooser.c', 'gcal-date-chooser-day.c', + 'gcal-date-chooser-row.c', 'gcal-date-selector.c', 'gcal-event-editor-dialog.c', 'gcal-event-editor-section.c', -- GitLab From ca32033c60812bed834e5e20fa5132236e89dc63 Mon Sep 17 00:00:00 2001 From: Titouan Real Date: Wed, 27 Nov 2024 19:38:03 +0100 Subject: [PATCH 4/5] event-editor: Use new rows for date and time Make the event editor use GcalTimeChooserRows and GcalDateChooserRows to prompt the user. --- .../event-editor/gcal-event-editor-dialog.ui | 1 - src/gui/event-editor/gcal-schedule-section.c | 293 ++++++------------ src/gui/event-editor/gcal-schedule-section.ui | 151 ++++----- 3 files changed, 150 insertions(+), 295 deletions(-) diff --git a/src/gui/event-editor/gcal-event-editor-dialog.ui b/src/gui/event-editor/gcal-event-editor-dialog.ui index 01bebd723..6f6d46995 100644 --- a/src/gui/event-editor/gcal-event-editor-dialog.ui +++ b/src/gui/event-editor/gcal-event-editor-dialog.ui @@ -67,7 +67,6 @@ - Schedule diff --git a/src/gui/event-editor/gcal-schedule-section.c b/src/gui/event-editor/gcal-schedule-section.c index d41a1af43..9e40a35fb 100644 --- a/src/gui/event-editor/gcal-schedule-section.c +++ b/src/gui/event-editor/gcal-schedule-section.c @@ -22,12 +22,13 @@ #include "gcal-context.h" #include "gcal-date-selector.h" +#include "gcal-date-chooser-row.h" #include "gcal-debug.h" #include "gcal-event.h" #include "gcal-event-editor-section.h" #include "gcal-recurrence.h" #include "gcal-schedule-section.h" -#include "gcal-time-selector.h" +#include "gcal-time-chooser-row.h" #include "gcal-utils.h" #include @@ -36,16 +37,14 @@ struct _GcalScheduleSection { GtkBox parent; - GtkSwitch *all_day_switch; - GtkWidget *end_date_selector; - GtkWidget *end_time_selector; - GtkLabel *event_end_label; - GtkLabel *event_start_label; + AdwToggleGroup *schedule_type_toggle_group; + GcalDateChooserRow *start_date_row; + GcalTimeChooserRow *start_time_row; + GcalDateChooserRow *end_date_row; + GcalTimeChooserRow *end_time_row; GtkWidget *number_of_occurrences_spin; GtkWidget *repeat_combo; GtkWidget *repeat_duration_combo; - GtkWidget *start_date_selector; - GtkWidget *start_time_selector; GtkWidget *until_date_selector; GcalContext *context; @@ -71,6 +70,13 @@ enum * Auxiliary methods */ +static inline gboolean +all_day_selected (GcalScheduleSection *self) +{ + const gchar *active = adw_toggle_group_get_active_name (self->schedule_type_toggle_group); + return g_strcmp0 (active, "all-day") == 0; +} + static void find_best_timezones_for_event (GcalScheduleSection *self, GTimeZone **out_tz_start, @@ -81,7 +87,7 @@ find_best_timezones_for_event (GcalScheduleSection *self, gboolean new_event; /* Update all day */ - all_day = gtk_switch_get_active (self->all_day_switch); + all_day = all_day_selected (self); was_all_day = gcal_event_get_all_day (self->event); new_event = self->flags & GCAL_EVENT_EDITOR_FLAG_NEW_EVENT; @@ -139,8 +145,8 @@ find_best_timezones_for_event (GcalScheduleSection *self, static GDateTime* return_datetime_for_widgets (GcalScheduleSection *self, GTimeZone *timezone, - GcalDateSelector *date_selector, - GcalTimeSelector *time_selector) + GcalDateChooserRow *date_chooser_row, + GcalTimeChooserRow *time_chooser_row) { g_autoptr (GDateTime) date_in_local_tz = NULL; g_autoptr (GDateTime) date_in_best_tz = NULL; @@ -149,9 +155,9 @@ return_datetime_for_widgets (GcalScheduleSection *self, GDateTime *retval; gboolean all_day; - all_day = gtk_switch_get_active (self->all_day_switch); - date = gcal_date_selector_get_date (date_selector); - time = gcal_time_selector_get_time (time_selector); + all_day = all_day_selected (self); + date = gcal_date_chooser_row_get_date (date_chooser_row); + time = gcal_time_chooser_row_get_time (time_chooser_row); date_in_local_tz = g_date_time_new_local (g_date_time_get_year (date), g_date_time_get_month (date), @@ -185,8 +191,8 @@ get_date_start (GcalScheduleSection *self) return return_datetime_for_widgets (self, start_tz, - GCAL_DATE_SELECTOR (self->start_date_selector), - GCAL_TIME_SELECTOR (self->start_time_selector)); + self->start_date_row, + self->start_time_row); } static GDateTime* @@ -198,8 +204,8 @@ get_date_end (GcalScheduleSection *self) return return_datetime_for_widgets (self, end_tz, - GCAL_DATE_SELECTOR (self->end_date_selector), - GCAL_TIME_SELECTOR (self->end_time_selector)); + self->end_date_row, + self->end_time_row); } static void @@ -214,106 +220,6 @@ remove_recurrence_properties (GcalEvent *event) e_cal_component_commit_sequence (comp); } -static gchar* -format_datetime_for_display (GDateTime *date, - GcalTimeFormat format, - gboolean all_day) -{ - g_autofree gchar *formatted_date = NULL; - g_autoptr (GDateTime) local_dt = NULL; - g_autoptr (GDateTime) now = NULL; - GString *string; - gint days_diff; - - string = g_string_new (""); - - now = g_date_time_new_now_local (); - local_dt = all_day ? g_date_time_ref (date) : g_date_time_to_local (date); - days_diff = gcal_date_time_compare_date (local_dt, now); - - switch (days_diff) - { - case -7 ... -2: - /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (local_dt, gcal_util_translate_time_string (_("Last %A"))); - break; - - case -1: - formatted_date = g_strdup (_("Yesterday")); - break; - - case 0: - formatted_date = g_strdup (_("Today")); - break; - - case 1: - formatted_date = g_strdup (_("Tomorrow")); - break; - - case 2 ... 6: - /* Translators: %A is the weekday name (e.g. Sunday, Monday, etc) */ - formatted_date = g_date_time_format (local_dt, gcal_util_translate_time_string (_("This %A"))); - break; - - default: - formatted_date = g_date_time_format (local_dt, "%x"); - break; - } - - if (!all_day) - { - g_autofree gchar *formatted_time = NULL; - - switch (format) - { - case GCAL_TIME_FORMAT_12H: - formatted_time = g_date_time_format (local_dt, "%I:%M %P"); - break; - - case GCAL_TIME_FORMAT_24H: - formatted_time = g_date_time_format (local_dt, "%R"); - break; - - default: - g_assert_not_reached (); - } - - /* - * Translators: %1$s is the formatted date (e.g. Today, Sunday, or even 2019-10-11) and %2$s is the - * formatted time (e.g. 03:14 PM, or 21:29) - */ - g_string_printf (string, _("%1$s, %2$s"), formatted_date, formatted_time); - } - else - { - g_string_printf (string, "%s", formatted_date); - } - - return g_string_free (string, FALSE); -} - -static void -update_date_labels (GcalScheduleSection *self) -{ - g_autofree gchar *start_label = NULL; - g_autofree gchar *end_label = NULL; - g_autoptr (GDateTime) start = NULL; - g_autoptr (GDateTime) end = NULL; - GcalTimeFormat time_format; - gboolean all_day; - - time_format = gcal_context_get_time_format (self->context); - - all_day = gtk_switch_get_active (self->all_day_switch); - start = get_date_start (self); - end = get_date_end (self); - start_label = format_datetime_for_display (start, time_format, all_day); - end_label = format_datetime_for_display (end, time_format, all_day); - - gtk_label_set_label (self->event_start_label, start_label); - gtk_label_set_label (self->event_end_label, end_label); -} - static void sync_datetimes (GcalScheduleSection *self, GParamSpec *pspec, @@ -325,8 +231,8 @@ sync_datetimes (GcalScheduleSection *self, GCAL_ENTRY; - is_start = (widget == self->start_time_selector || widget == self->start_date_selector); - is_all_day = gtk_switch_get_active (self->all_day_switch); + is_start = (widget == GTK_WIDGET (self->start_time_row) || widget == GTK_WIDGET (self->start_date_row)); + is_all_day = all_day_selected (self); start = get_date_start (self); end = get_date_end (self); @@ -345,22 +251,22 @@ sync_datetimes (GcalScheduleSection *self, { new_date = is_all_day ? g_date_time_add_hours (start, 0) : g_date_time_add_hours (start_local, 1); - date_widget = self->end_date_selector; - time_widget = self->end_time_selector; + date_widget = GTK_WIDGET (self->end_date_row); + time_widget = GTK_WIDGET (self->end_time_row); } else { new_date = is_all_day ? g_date_time_add_hours (end, 0) : g_date_time_add_hours (end_local, -1); - date_widget = self->start_date_selector; - time_widget = self->start_time_selector; + date_widget = GTK_WIDGET (self->start_date_row); + time_widget = GTK_WIDGET (self->start_time_row); } g_signal_handlers_block_by_func (date_widget, sync_datetimes, self); g_signal_handlers_block_by_func (time_widget, sync_datetimes, self); - gcal_date_selector_set_date (GCAL_DATE_SELECTOR (date_widget), new_date); - gcal_time_selector_set_time (GCAL_TIME_SELECTOR (time_widget), new_date); + gcal_date_chooser_row_set_date (GCAL_DATE_CHOOSER_ROW (date_widget), new_date); + gcal_time_chooser_row_set_time (GCAL_TIME_CHOOSER_ROW (time_widget), new_date); g_signal_handlers_unblock_by_func (date_widget, sync_datetimes, self); g_signal_handlers_unblock_by_func (time_widget, sync_datetimes, self); @@ -373,8 +279,6 @@ out: g_clear_pointer (&start, g_date_time_unref); g_clear_pointer (&end, g_date_time_unref); - update_date_labels (self); - GCAL_EXIT; } @@ -383,6 +287,17 @@ out: * Callbacks */ +static void +on_schedule_type_changed_cb (GtkWidget *widget, + GParamSpec *pspec, + GcalScheduleSection *self) +{ + gboolean all_day = all_day_selected (self); + + gtk_widget_set_visible (GTK_WIDGET (self->start_time_row), !all_day); + gtk_widget_set_visible (GTK_WIDGET (self->end_time_row), !all_day); +} + static void on_repeat_duration_changed_cb (GtkWidget *widget, GParamSpec *pspec, @@ -409,28 +324,13 @@ on_repeat_type_changed_cb (GtkWidget *widget, gtk_widget_set_visible (self->repeat_duration_combo, frequency != GCAL_RECURRENCE_NO_REPEAT); } -static void -on_all_day_switch_active_changed_cb (GtkSwitch *all_day_switch, - GParamSpec *pspec, - GcalScheduleSection *self) -{ - gboolean active = gtk_switch_get_active (all_day_switch); - - gtk_widget_set_sensitive (self->start_time_selector, !active); - gtk_widget_set_sensitive (self->end_time_selector, !active); - - update_date_labels (self); -} - static void on_time_format_changed_cb (GcalScheduleSection *self) { - GcalTimeFormat time_format; - - time_format = gcal_context_get_time_format (self->context); + GcalTimeFormat time_format = gcal_context_get_time_format (self->context); - gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (self->start_time_selector), time_format); - gcal_time_selector_set_time_format (GCAL_TIME_SELECTOR (self->end_time_selector), time_format); + gcal_time_chooser_row_set_time_format (self->start_time_row, time_format); + gcal_time_chooser_row_set_time_format (self->end_time_row, time_format); } @@ -461,6 +361,46 @@ gcal_schedule_section_set_event (GcalEventEditorSection *section, if (!event) GCAL_RETURN (); + all_day = gcal_event_get_all_day (event); + + /* schedule type */ + adw_toggle_group_set_active_name (self->schedule_type_toggle_group, + all_day ? "all-day" : "time-slot"); + + gtk_widget_set_visible (GTK_WIDGET (self->start_time_row), !all_day); + gtk_widget_set_visible (GTK_WIDGET (self->end_time_row), !all_day); + + /* retrieve start and end dates */ + date_start = gcal_event_get_date_start (event); + date_start = all_day ? g_date_time_ref (date_start) : g_date_time_to_local (date_start); + + date_end = gcal_event_get_date_end (event); + /* + * This is subtracting what has been added in action_button_clicked (). + * See bug 769300. + */ + date_end = all_day ? g_date_time_add_days (date_end, -1) : g_date_time_to_local (date_end); + + /* date */ + g_signal_handlers_block_by_func (self->end_date_row, sync_datetimes, self); + g_signal_handlers_block_by_func (self->start_date_row, sync_datetimes, self); + + gcal_date_chooser_row_set_date (self->start_date_row, date_start); + gcal_date_chooser_row_set_date (self->end_date_row, date_end); + + g_signal_handlers_unblock_by_func (self->start_date_row, sync_datetimes, self); + g_signal_handlers_unblock_by_func (self->end_date_row, sync_datetimes, self); + + /* time */ + g_signal_handlers_block_by_func (self->end_time_row, sync_datetimes, self); + g_signal_handlers_block_by_func (self->start_time_row, sync_datetimes, self); + + gcal_time_chooser_row_set_time (self->start_time_row, date_start); + gcal_time_chooser_row_set_time (self->end_time_row, date_end); + + g_signal_handlers_unblock_by_func (self->start_time_row, sync_datetimes, self); + g_signal_handlers_unblock_by_func (self->end_time_row, sync_datetimes, self); + /* Recurrences */ recur = gcal_event_get_recurrence (event); frequency = recur ? recur->frequency : GCAL_RECURRENCE_NO_REPEAT; @@ -494,44 +434,6 @@ gcal_schedule_section_set_event (GcalEventEditorSection *section, break; } - all_day = gcal_event_get_all_day (event); - - /* retrieve start and end dates */ - date_start = gcal_event_get_date_start (event); - date_start = all_day ? g_date_time_ref (date_start) : g_date_time_to_local (date_start); - - date_end = gcal_event_get_date_end (event); - /* - * This is subtracting what has been added in action_button_clicked (). - * See bug 769300. - */ - date_end = all_day ? g_date_time_add_days (date_end, -1) : g_date_time_to_local (date_end); - - /* date */ - g_signal_handlers_block_by_func (self->end_date_selector, sync_datetimes, self); - g_signal_handlers_block_by_func (self->start_date_selector, sync_datetimes, self); - - gcal_date_selector_set_date (GCAL_DATE_SELECTOR (self->start_date_selector), date_start); - gcal_date_selector_set_date (GCAL_DATE_SELECTOR (self->end_date_selector), date_end); - - g_signal_handlers_unblock_by_func (self->start_date_selector, sync_datetimes, self); - g_signal_handlers_unblock_by_func (self->end_date_selector, sync_datetimes, self); - - /* time */ - g_signal_handlers_block_by_func (self->end_time_selector, sync_datetimes, self); - g_signal_handlers_block_by_func (self->start_time_selector, sync_datetimes, self); - - gcal_time_selector_set_time (GCAL_TIME_SELECTOR (self->start_time_selector), date_start); - gcal_time_selector_set_time (GCAL_TIME_SELECTOR (self->end_time_selector), date_end); - - g_signal_handlers_unblock_by_func (self->start_time_selector, sync_datetimes, self); - g_signal_handlers_unblock_by_func (self->end_time_selector, sync_datetimes, self); - - /* all_day */ - gtk_switch_set_active (self->all_day_switch, all_day); - - update_date_labels (self); - GCAL_EXIT; } @@ -549,7 +451,7 @@ gcal_schedule_section_apply (GcalEventEditorSection *section) GCAL_ENTRY; self = GCAL_SCHEDULE_SECTION (section); - all_day = gtk_switch_get_active (self->all_day_switch); + all_day = all_day_selected (self); was_all_day = gcal_event_get_all_day (self->event); if (!was_all_day && all_day) @@ -655,7 +557,7 @@ gcal_schedule_section_changed (GcalEventEditorSection *section) GCAL_ENTRY; self = GCAL_SCHEDULE_SECTION (section); - all_day = gtk_switch_get_active (self->all_day_switch); + all_day = all_day_selected (self); was_all_day = gcal_event_get_all_day (self->event); /* All day */ @@ -669,7 +571,7 @@ gcal_schedule_section_changed (GcalEventEditorSection *section) /* End date */ end_date = get_date_end (self); - if (gtk_switch_get_active (self->all_day_switch)) + if (all_day) { g_autoptr (GDateTime) fake_end_date = g_date_time_add_days (end_date, 1); gcal_set_date_time (&end_date, fake_end_date); @@ -780,24 +682,19 @@ gcal_schedule_section_class_init (GcalScheduleSectionClass *klass) g_object_class_override_property (object_class, PROP_CONTEXT, "context"); - g_type_ensure (GCAL_TYPE_DATE_SELECTOR); - g_type_ensure (GCAL_TYPE_TIME_SELECTOR); - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/event-editor/gcal-schedule-section.ui"); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, all_day_switch); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, start_time_selector); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, start_date_selector); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, end_time_selector); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, end_date_selector); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, event_start_label); - gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, event_end_label); + gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, schedule_type_toggle_group); + gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, start_date_row); + gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, start_time_row); + gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, end_date_row); + gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, end_time_row); gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, number_of_occurrences_spin); gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, repeat_combo); gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, repeat_duration_combo); gtk_widget_class_bind_template_child (widget_class, GcalScheduleSection, until_date_selector); - gtk_widget_class_bind_template_callback (widget_class, on_all_day_switch_active_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_schedule_type_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_repeat_duration_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_repeat_type_changed_cb); gtk_widget_class_bind_template_callback (widget_class, sync_datetimes); diff --git a/src/gui/event-editor/gcal-schedule-section.ui b/src/gui/event-editor/gcal-schedule-section.ui index dedaf26ce..dbc2fe123 100644 --- a/src/gui/event-editor/gcal-schedule-section.ui +++ b/src/gui/event-editor/gcal-schedule-section.ui @@ -2,118 +2,87 @@ -- GitLab