month-cell: Move day label to top, split from overflow
This commit is contained in:
+30
-22
@@ -11,6 +11,36 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
|
||||
<child type="overlay">
|
||||
<object class="GtkBox" id="header_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="day_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<style>
|
||||
<class name="day-label" />
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="weather_icon">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- HACK: in Gtk3, insensitive widgets receive no events. We "fix" this
|
||||
limitation by adding an always-sensitive GtkEventBox above the event,
|
||||
and when the event is insensitive, the event box's event window is
|
||||
@@ -37,7 +67,6 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="valign">center</property>
|
||||
<child type="center">
|
||||
<object class="GtkLabel" id="overflow_label">
|
||||
<property name="visible">True</property>
|
||||
@@ -45,27 +74,6 @@
|
||||
<property name="ellipsize">end</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="day_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<style>
|
||||
<class name="day-label" />
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="weather_icon">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -32,6 +32,7 @@ struct _GcalMonthCell
|
||||
guint n_overflow;
|
||||
|
||||
GtkLabel *day_label;
|
||||
GtkWidget *header_box;
|
||||
GtkWidget *overflow_button;
|
||||
GtkWidget *overflow_label;
|
||||
GtkWidget *overlay;
|
||||
@@ -422,6 +423,7 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/month-cell.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, day_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, header_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_button);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overlay);
|
||||
@@ -580,10 +582,19 @@ gcal_month_cell_get_real_height (GcalMonthCell *self)
|
||||
|
||||
return gtk_widget_get_allocated_height (GTK_WIDGET (self)) -
|
||||
gtk_widget_get_allocated_height (self->overflow_button) -
|
||||
gtk_widget_get_allocated_height (self->header_box) -
|
||||
padding.top - padding.bottom -
|
||||
border.top - border.bottom;
|
||||
}
|
||||
|
||||
gint
|
||||
gcal_month_cell_get_header_height (GcalMonthCell *self)
|
||||
{
|
||||
g_return_val_if_fail (GCAL_IS_MONTH_CELL (self), -1);
|
||||
|
||||
return gtk_widget_get_allocated_height (self->header_box);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gcal_month_cell_get_selected (GcalMonthCell *self)
|
||||
{
|
||||
|
||||
@@ -53,6 +53,8 @@ void gcal_month_cell_set_overflow (GcalMonthCell
|
||||
|
||||
gint gcal_month_cell_get_real_height (GcalMonthCell *self);
|
||||
|
||||
gint gcal_month_cell_get_header_height (GcalMonthCell *self);
|
||||
|
||||
gboolean gcal_month_cell_get_selected (GcalMonthCell *self);
|
||||
|
||||
void gcal_month_cell_set_selected (GcalMonthCell *self,
|
||||
|
||||
@@ -1398,16 +1398,19 @@ remove_cell_border_and_padding (GtkWidget *cell,
|
||||
GtkStyleContext *cell_context;
|
||||
GtkBorder cell_padding;
|
||||
GtkBorder cell_border;
|
||||
gint header_height;
|
||||
|
||||
cell_context = gtk_widget_get_style_context (cell);
|
||||
gtk_style_context_get_border (cell_context, gtk_style_context_get_state (cell_context), &cell_border);
|
||||
gtk_style_context_get_padding (cell_context, gtk_style_context_get_state (cell_context), &cell_padding);
|
||||
|
||||
header_height = gcal_month_cell_get_header_height (GCAL_MONTH_CELL (cell));
|
||||
|
||||
if (x)
|
||||
*x += cell_border.left + cell_padding.left;
|
||||
|
||||
if (y)
|
||||
*y += cell_border.top + cell_padding.top;
|
||||
*y += cell_border.top + cell_padding.top + header_height;
|
||||
|
||||
if (width)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user