From ff170561084299bc52a456e7f92e0bf31a5b4ec1 Mon Sep 17 00:00:00 2001 From: Hari Rana Date: Wed, 4 Jun 2025 12:46:40 -0400 Subject: [PATCH] gui/event-widget: Use GtkBoxLayout The GTK inspector would always target and inspect the `main_widget` box rather than the parent widget, which became repetitive to keep pressing the "Parent widget" button when working with accessibility, as the parent widget contained the accessible properties and states. GtkBoxLayout solves that by allowing us to get rid of the box completely, which exclusively makes it inspect the widget we actually want to target. Part-of: --- src/gui/gcal-event-widget.blp | 100 ++++++++++++++++------------------ src/gui/gcal-event-widget.c | 12 ++-- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/gui/gcal-event-widget.blp b/src/gui/gcal-event-widget.blp index 7bb889d6..26ad25b5 100644 --- a/src/gui/gcal-event-widget.blp +++ b/src/gui/gcal-event-widget.blp @@ -17,72 +17,68 @@ template $GcalEventWidget: Widget { released => $on_click_gesture_release_cb(template) not-swapped; } - Box main_widget { - hexpand: false; + Adw.Bin edge { + styles [ + "edge", + ] + } - Adw.Bin edge { - styles [ - "edge", - ] - } + $GcalOverflowBin overflow_bin { + hexpand: true; + request-mode: width-for-height; - $GcalOverflowBin { - hexpand: true; - request-mode: width-for-height; + styles [ + "content", + ] - styles [ - "content", - ] + Adw.Squeezer squeezer { + hexpand: false; + homogeneous: false; + orientation: vertical; - Adw.Squeezer squeezer { - hexpand: false; - homogeneous: false; + Box vertical_box { + visible: bind $get_vertical_enabled(template.event, template.orientation) as ; orientation: vertical; - Box vertical_box { - visible: bind $get_vertical_enabled(template.event, template.orientation) as ; - orientation: vertical; + $GcalOverflowBin { + request-mode: width-for-height; - $GcalOverflowBin { - request-mode: width-for-height; - - Label { - label: bind timestamp_label.label no-sync-create; - xalign: 0.0; - - styles [ - "dim-label", - ] - } - } - - Inscription { - text: bind summary_inscription.text no-sync-create; - hexpand: true; - vexpand: true; + Label { + label: bind timestamp_label.label no-sync-create; xalign: 0.0; - yalign: 0.0; - min-lines: 1; - text-overflow: ellipsize_end; - } - } - Box horizontal_box { - spacing: 4; - - Inscription summary_inscription { - hexpand: true; - xalign: 0.0; - min-lines: 1; - text-overflow: ellipsize_end; - } - - Label timestamp_label { styles [ "dim-label", ] } } + + Inscription { + text: bind summary_inscription.text no-sync-create; + hexpand: true; + vexpand: true; + xalign: 0.0; + yalign: 0.0; + min-lines: 1; + text-overflow: ellipsize_end; + } + } + + Box horizontal_box { + spacing: 4; + + Inscription summary_inscription { + hexpand: true; + xalign: 0.0; + min-lines: 1; + text-overflow: ellipsize_end; + } + + Label timestamp_label { + styles [ + "dim-label", + ] + } } } } diff --git a/src/gui/gcal-event-widget.c b/src/gui/gcal-event-widget.c index d448704d..d5077200 100644 --- a/src/gui/gcal-event-widget.c +++ b/src/gui/gcal-event-widget.c @@ -53,8 +53,9 @@ struct _GcalEventWidget /* widgets */ GtkWidget *horizontal_box; - GtkWidget *main_widget; GtkWidget *timestamp_label; + GtkWidget *edge; + GtkWidget *overflow_bin; GtkWidget *squeezer; GtkWidget *summary_inscription; GtkWidget *vertical_box; @@ -723,7 +724,9 @@ gcal_event_widget_dispose (GObject *object) GcalEventWidget *self = GCAL_EVENT_WIDGET (object); g_clear_pointer (&self->preview_popover, gtk_widget_unparent); - g_clear_pointer (&self->main_widget, gtk_widget_unparent); + g_clear_pointer (&self->overflow_bin, gtk_widget_unparent); + g_clear_pointer (&self->horizontal_box, gtk_widget_unparent); + g_clear_pointer (&self->edge, gtk_widget_unparent); G_OBJECT_CLASS (gcal_event_widget_parent_class)->dispose (object); } @@ -877,7 +880,8 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass) gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, drag_source); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, horizontal_box); - gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, main_widget); + gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, edge); + gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, overflow_bin); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, timestamp_label); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, squeezer); gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, summary_inscription); @@ -892,7 +896,7 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass) gtk_widget_class_set_css_name (widget_class, "event"); gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_BUTTON); - gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT); + gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BOX_LAYOUT); } static void