gui/event-widget: Set child depending on the orientation

Commit https://gitlab.gnome.org/GNOME/gnome-calendar/-/commit/73abcf19b0e70fb6fdd45394169b00e21ea0734a
introduced a bug where it uses the wrong widget on
vertical orientation.

This patch fixes that bug by using the correct widget
for their respective orientation. It also removes the use of
AdwClamp, as it was clamping labels above a certain height requested.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/1414

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/607>
This commit is contained in:
Hari Rana
2025-06-30 15:00:59 -04:00
parent b368e1f674
commit 6ab0ef7386
2 changed files with 45 additions and 45 deletions
+32 -37
View File
@@ -34,53 +34,48 @@ template $GcalEventWidget: Widget {
"content",
]
Adw.Clamp clamp {
Box vertical_box {
orientation: vertical;
child: Box vertical_box {
visible: bind $get_vertical_enabled(template.event, template.orientation) as <bool>;
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",
]
}
}
}
}
+13 -8
View File
@@ -115,12 +115,19 @@ G_DEFINE_TYPE_WITH_CODE (GcalEventWidget, gcal_event_widget, GTK_TYPE_WIDGET,
* Auxiliary methods
*/
static gboolean
get_vertical_enabled (gpointer user_data,
GcalEvent *event,
GtkOrientation orientation)
static void
gcal_event_widget_update_orientation_widgets (GcalEventWidget *self)
{
return orientation == GTK_ORIENTATION_VERTICAL && !gcal_event_get_all_day (event);
gboolean is_vertical;
gboolean is_all_day;
is_vertical = self->orientation == GTK_ORIENTATION_VERTICAL;
is_all_day = gcal_event_get_all_day (self->event);
if (is_vertical && !is_all_day)
gcal_overflow_bin_set_child (GCAL_OVERFLOW_BIN (self->overflow_bin), self->vertical_box);
else
gcal_overflow_bin_set_child (GCAL_OVERFLOW_BIN (self->overflow_bin), self->horizontal_box);
}
static void
@@ -670,7 +677,7 @@ gcal_event_widget_set_property (GObject *object,
case PROP_ORIENTATION:
self->orientation = g_value_get_enum (value);
gtk_widget_set_visible (self->vertical_box, self->orientation == GTK_ORIENTATION_VERTICAL);
gcal_event_widget_update_orientation_widgets (self);
gcal_event_widget_update_style (self);
gcal_event_widget_update_timestamp (self);
g_object_notify (object, "orientation");
@@ -727,7 +734,6 @@ gcal_event_widget_dispose (GObject *object)
g_clear_pointer (&self->preview_popover, 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);
@@ -888,7 +894,6 @@ gcal_event_widget_class_init (GcalEventWidgetClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, summary_inscription);
gtk_widget_class_bind_template_child (widget_class, GcalEventWidget, vertical_box);
gtk_widget_class_bind_template_callback (widget_class, get_vertical_enabled);
gtk_widget_class_bind_template_callback (widget_class, on_click_gesture_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_click_gesture_release_cb);
gtk_widget_class_bind_template_callback (widget_class, on_drag_source_begin_cb);