event-widget: Set the squeezer's margin via CSS
This ensure the style is consistent and updates itself automatically as the CSS classes change, and also makes the code simpler.
This commit is contained in:
committed by
Georges Basile Stavracas Neto
parent
4cf8b51de1
commit
0d27b08803
@@ -129,6 +129,7 @@ gcal_event_widget_update_style (GcalEventWidget *self)
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "slanted");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "slanted-start");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "slanted-end");
|
||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "timed");
|
||||
|
||||
/*
|
||||
* If the event's dates differs from the widget's dates,
|
||||
@@ -166,22 +167,10 @@ gcal_event_widget_update_style (GcalEventWidget *self)
|
||||
*/
|
||||
timed = !gcal_event_get_all_day (self->event) && !gcal_event_is_multiday (self->event);
|
||||
|
||||
gtk_widget_set_visible (self->color_box, timed);
|
||||
gtk_widget_set_visible (self->color_box, timed && self->orientation == GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
if (timed)
|
||||
{
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "timed");
|
||||
|
||||
if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||
{
|
||||
gtk_widget_set_margin_start (self->squeezer, 0);
|
||||
gtk_widget_set_margin_end (self->squeezer, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_visible (self->color_box, FALSE);
|
||||
}
|
||||
}
|
||||
gtk_widget_add_css_class (GTK_WIDGET (self), "timed");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
<object class="AdwSqueezer" id="squeezer">
|
||||
<property name="hexpand">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="margin-top">1</property>
|
||||
<property name="margin-bottom">1</property>
|
||||
<property name="margin-start">6</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<!-- Vertical page -->
|
||||
|
||||
@@ -74,6 +74,14 @@ event {
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
event squeezer {
|
||||
margin: 1px 4px 1px 6px;
|
||||
}
|
||||
|
||||
event.horizontal.timed squeezer {
|
||||
margin: 1px 2px 1px 0px;
|
||||
}
|
||||
|
||||
event.vertical.timed {
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user