From 4a4dce8ee3f510ae0269fc0bf85d863716e76158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=B6llnitz?= Date: Sun, 30 Mar 2025 04:33:34 +0200 Subject: [PATCH] views: add time direction property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The time direction property tells which orientation one needs to scroll to change the time of the view. In these directions (up/down v left/right) the new prev/next buttons will be pointing. The two buttons will be added in a subsequent commit, and will gain view-dependent tooltips. Signed-off-by: Markus Göllnitz Part-of: --- src/gui/common/gcal-date-chooser.c | 6 ++++++ src/gui/views/gcal-agenda-view.c | 6 ++++++ src/gui/views/gcal-month-view.c | 6 ++++++ src/gui/views/gcal-view.c | 33 ++++++++++++++++++++++++++++++ src/gui/views/gcal-view.h | 2 ++ src/gui/views/gcal-week-view.c | 6 ++++++ 6 files changed, 59 insertions(+) diff --git a/src/gui/common/gcal-date-chooser.c b/src/gui/common/gcal-date-chooser.c index 732c7d9b..9cf30e26 100644 --- a/src/gui/common/gcal-date-chooser.c +++ b/src/gui/common/gcal-date-chooser.c @@ -102,6 +102,7 @@ enum PROP_SPLIT_MONTH_YEAR, PROP_DATE, PROP_CONTEXT, + PROP_TIME_DIRECTION, NUM_PROPERTIES = PROP_SPLIT_MONTH_YEAR + 1, }; @@ -739,6 +740,10 @@ calendar_get_property (GObject *obj, g_value_set_boolean (value, self->split_month_year); break; + case PROP_TIME_DIRECTION: + g_value_set_enum (value, GTK_ORIENTATION_VERTICAL); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec); break; @@ -894,6 +899,7 @@ gcal_date_chooser_class_init (GcalDateChooserClass *class) g_object_class_override_property (object_class, PROP_DATE, "active-date"); g_object_class_override_property (object_class, PROP_CONTEXT, "context"); + g_object_class_override_property (object_class, PROP_TIME_DIRECTION, "time-direction"); signals[DAY_SELECTED] = g_signal_new ("day-selected", G_OBJECT_CLASS_TYPE (object_class), diff --git a/src/gui/views/gcal-agenda-view.c b/src/gui/views/gcal-agenda-view.c index d85738c8..1a46aaab 100644 --- a/src/gui/views/gcal-agenda-view.c +++ b/src/gui/views/gcal-agenda-view.c @@ -70,6 +70,7 @@ enum PROP_0, PROP_DATE, PROP_CONTEXT, + PROP_TIME_DIRECTION, N_PROPS, }; @@ -763,6 +764,10 @@ gcal_agenda_view_get_property (GObject *object, g_value_set_object (value, self->context); break; + case PROP_TIME_DIRECTION: + g_value_set_enum (value, GTK_ORIENTATION_VERTICAL); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -782,6 +787,7 @@ gcal_agenda_view_class_init (GcalAgendaViewClass *klass) g_object_class_override_property (object_class, PROP_DATE, "active-date"); g_object_class_override_property (object_class, PROP_CONTEXT, "context"); + g_object_class_override_property (object_class, PROP_TIME_DIRECTION, "time-direction"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/views/gcal-agenda-view.ui"); diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index 58e2eaad..4cf60da5 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -96,6 +96,7 @@ enum PROP_0, PROP_CONTEXT, PROP_DATE, + PROP_TIME_DIRECTION, N_PROPS, }; @@ -1592,6 +1593,10 @@ gcal_month_view_get_property (GObject *object, g_value_set_object (value, self->context); break; + case PROP_TIME_DIRECTION: + g_value_set_enum (value, GTK_ORIENTATION_VERTICAL); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -1644,6 +1649,7 @@ gcal_month_view_class_init (GcalMonthViewClass *klass) g_object_class_override_property (object_class, PROP_CONTEXT, "context"); g_object_class_override_property (object_class, PROP_DATE, "active-date"); + g_object_class_override_property (object_class, PROP_TIME_DIRECTION, "time-direction"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/views/gcal-month-view.ui"); diff --git a/src/gui/views/gcal-view.c b/src/gui/views/gcal-view.c index ae3fca95..71f5a9d9 100644 --- a/src/gui/views/gcal-view.c +++ b/src/gui/views/gcal-view.c @@ -66,6 +66,19 @@ gcal_view_default_init (GcalViewInterface *iface) GCAL_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + /** + * GcalView::time-direction: + * + * Orientation determining in which direction time is going for the view + */ + g_object_interface_install_property (iface, + g_param_spec_enum ("time-direction", + NULL, + NULL, + GTK_TYPE_ORIENTATION, + GTK_ORIENTATION_VERTICAL, + G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + /** * GcalView::create-event: * @@ -148,6 +161,26 @@ gcal_view_get_context (GcalView *self) return context; } +/** + * gcal_view_get_time_direction: + * @self: a #GcalView + * + * Retrieves the orientation of the direction in which the view visualises time. + * + * Returns: (transfer none): a #GtkOrientation + */ +GtkOrientation +gcal_view_get_time_direction (GcalView *self) +{ + GtkOrientation time_direction; + + g_return_val_if_fail (GCAL_IS_VIEW (self), GTK_ORIENTATION_VERTICAL); + + g_object_get (self, "time-direction", &time_direction, NULL); + + return time_direction; +} + /** * gcal_view_get_date: * @view: a #GcalView diff --git a/src/gui/views/gcal-view.h b/src/gui/views/gcal-view.h index d4511566..d862645f 100644 --- a/src/gui/views/gcal-view.h +++ b/src/gui/views/gcal-view.h @@ -66,6 +66,8 @@ GDateTime* gcal_view_get_date (GcalView GcalContext* gcal_view_get_context (GcalView *self); +GtkOrientation gcal_view_get_time_direction (GcalView *self); + void gcal_view_clear_marks (GcalView *view); GList* gcal_view_get_children_by_uuid (GcalView *view, diff --git a/src/gui/views/gcal-week-view.c b/src/gui/views/gcal-week-view.c index b68c8165..8b825b23 100644 --- a/src/gui/views/gcal-week-view.c +++ b/src/gui/views/gcal-week-view.c @@ -75,6 +75,7 @@ enum PROP_0, PROP_DATE, PROP_CONTEXT, + PROP_TIME_DIRECTION, NUM_PROPS }; @@ -615,6 +616,10 @@ gcal_week_view_get_property (GObject *object, g_value_set_object (value, self->context); break; + case PROP_TIME_DIRECTION: + g_value_set_enum (value, GTK_ORIENTATION_HORIZONTAL); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -637,6 +642,7 @@ gcal_week_view_class_init (GcalWeekViewClass *klass) g_object_class_override_property (object_class, PROP_DATE, "active-date"); g_object_class_override_property (object_class, PROP_CONTEXT, "context"); + g_object_class_override_property (object_class, PROP_TIME_DIRECTION, "time-direction"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/views/gcal-week-view.ui");