month-cell: Display temperatures

This commit is contained in:
Florian Brosch
2017-12-11 22:06:52 -02:00
committed by Georges Basile Stavracas Neto
parent e9e403ce7a
commit 67f3a2057e
2 changed files with 22 additions and 3 deletions
+14
View File
@@ -28,16 +28,30 @@
</style>
</object>
</child>
<!-- Weather forecast -->
<child>
<object class="GtkImage" id="weather_icon">
<property name="can-focus">False</property>
<property name="visible">True</property>
<property name="pixel_size">16</property>
<property name="margin-start">12</property>
<style>
<class name="dim-label" />
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="temp_label">
<property name="visible">True</property>
<property name="can-focus">True</property>
<style>
<class name="dim-label" />
<class name="temp-label" />
</style>
</object>
</child>
</object>
</child>
+8 -3
View File
@@ -34,6 +34,7 @@ struct _GcalMonthCell
GtkLabel *day_label;
GtkWidget *header_box;
GtkImage *weather_icon;
GtkLabel *temp_label;
GtkWidget *overflow_button;
GtkWidget *overflow_label;
@@ -429,6 +430,7 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
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);
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, temp_label);
gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, weather_icon);
gtk_widget_class_bind_template_callback (widget_class, enter_notify_event_cb);
@@ -508,16 +510,19 @@ gcal_month_cell_set_weather (GcalMonthCell *self,
if (info == NULL)
{
gtk_image_clear (self->weather_icon);
gtk_label_set_text (self->temp_label, "");
}
else
{
const gchar* icon_name; /* unowned */
const gchar* temp_str; /* unwoned */
icon_name = gcal_weather_info_get_icon_name (info);
gtk_image_set_from_icon_name (self->weather_icon, icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
}
temp_str = gcal_weather_info_get_temperature (info);
gtk_widget_show (GTK_WIDGET (self->weather_icon));
gtk_image_set_from_icon_name (self->weather_icon, icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_label_set_text (self->temp_label, temp_str);
}
}
gboolean