[gnome-calendar] year-view: show no events label when needed
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] year-view: show no events label when needed
- Date: Fri, 23 Jan 2015 18:33:23 +0000 (UTC)
commit 7ee9be263c2e102aab5aaaa2120a8e5a725ea5b2
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Thu Jan 22 22:04:36 2015 -0500
year-view: show no events label when needed
data/ui/year-view.ui | 2 +-
src/gcal-year-view.c | 28 +++++++++++++++++++++++++---
2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/data/ui/year-view.ui b/data/ui/year-view.ui
index cb96cfb..6497027 100644
--- a/data/ui/year-view.ui
+++ b/data/ui/year-view.ui
@@ -53,7 +53,7 @@
<class name="sidebar" />
</style>
<child>
- <object class="GtkLabel">
+ <object class="GtkLabel" id="no_events_title">
<property name="visible">True</property>
<property name="halign">start</property>
<property name="margin">6</property>
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index bbc3f20..ba60773 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -49,6 +49,7 @@ struct _GcalYearViewPrivate
GtkWidget *sidebar;
GtkWidget *events_sidebar;
GtkWidget *navigator_stack;
+ GtkWidget *no_events_title;
GtkWidget *navigator_sidebar;
GtkWidget *popover; /* Popover for popover_mode */
@@ -247,17 +248,37 @@ update_sidebar (GcalYearView *year_view)
events = gcal_manager_get_events (priv->manager, priv->start_selected_date, priv->end_selected_date);
/* XXX: compare_date_only does not work if is_date field is different */
- priv->start_selected_date->is_date = priv->current_date->is_date;
- if (events == NULL && icaltime_compare_date_only (*(priv->start_selected_date), *(priv->current_date)) ==
0)
+ if (events == NULL)
{
+ gchar *title;
+ gboolean has_range = FALSE;
days_span = 0;
+
+ has_range = (priv->start_selected_date->day != priv->end_selected_date->day ||
+ priv->start_selected_date->month != priv->end_selected_date->month);
+
+ if (priv->current_date->day == priv->start_selected_date->day &&
+ priv->current_date->month == priv->start_selected_date->month &&
+ priv->current_date->year == priv->start_selected_date->year)
+ {
+ title = g_strdup_printf ("%s%s", _("Today"), has_range ? "…" : "");
+ }
+ else
+ {
+ title = g_strdup_printf ("%s %d%s",
+ gcal_get_month_name (priv->start_selected_date->month - 1),
+ priv->start_selected_date->day,
+ has_range ? "…" : "");
+ }
+
+ gtk_label_set_text (GTK_LABEL (priv->no_events_title), title);
+ g_free (title);
gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "no-events");
}
else
{
gtk_stack_set_visible_child_name (GTK_STACK (priv->navigator_stack), "events-list");
}
- priv->start_selected_date->is_date = 0;
for (l = events; l != NULL; l = g_list_next (l))
{
@@ -1186,6 +1207,7 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, events_sidebar);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, navigator_stack);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, navigator_sidebar);
+ gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, no_events_title);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, popover);
gtk_widget_class_bind_template_child_private (widget_class, GcalYearView, popover_sidebar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]