[gnome-calendar] year-view: adding second header to sidebar
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] year-view: adding second header to sidebar
- Date: Tue, 20 Jan 2015 18:16:39 +0000 (UTC)
commit f7beeadbb22fe06b7b152dc05e6752fec2c78a4d
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Mon Jan 19 15:34:25 2015 -0500
year-view: adding second header to sidebar
data/theme/gtk-styles.css | 10 ++++----
src/gcal-year-view.c | 46 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 47 insertions(+), 9 deletions(-)
---
diff --git a/data/theme/gtk-styles.css b/data/theme/gtk-styles.css
index 9f32a77..7204df1 100644
--- a/data/theme/gtk-styles.css
+++ b/data/theme/gtk-styles.css
@@ -112,6 +112,11 @@
font-weight: bold;
}
+.sidebar-header {
+ font-weight: bold;
+ font-size: 11px;
+}
+
GcalYearView GtkScrolledWindow {
border-top-width: 0;
border-bottom-width: 0;
@@ -128,11 +133,6 @@ GcalYearView GtkListBox {
background-color: @theme_bg_color;
}
-GcalYearView GtkListBox GtkLabel {
- font-weight: bold;
- font-size: 11px;
-}
-
GcalEventWidget.slanted-start:dir(ltr) {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index 8e8dd75..dd85859 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -21,6 +21,7 @@
#include "gcal-view.h"
#include "gcal-utils.h"
+#include <glib/gi18n.h>
#include <math.h>
#include <string.h>
@@ -292,15 +293,18 @@ update_sidebar_headers (GtkListBoxRow *row,
{
GcalYearViewPrivate *priv;
GtkWidget *row_child, *before_child = NULL, *row_header = NULL;
- icaltimetype row_date;
+ const icaltimetype *row_date, *before_date = NULL;
+ icaltimetype date;
gint row_shift, before_shift =-1;
priv = GCAL_YEAR_VIEW (user_data)->priv;
row_child = gtk_bin_get_child (GTK_BIN (row));
+ row_date = gcal_event_widget_peek_start_date (GCAL_EVENT_WIDGET (row_child));
row_shift = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row_child), "shift"));
if (before != NULL)
{
before_child = gtk_bin_get_child (GTK_BIN (before));
+ before_date = gcal_event_widget_peek_start_date (GCAL_EVENT_WIDGET (before_child));
before_shift = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (before_child), "shift"));
}
@@ -310,15 +314,49 @@ update_sidebar_headers (GtkListBoxRow *row,
gchar *label_str;
row_header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- row_date = *(priv->start_selected_date);
- icaltime_adjust (&row_date, row_shift, 0, 0, 0);
+ date = *(priv->start_selected_date);
+ icaltime_adjust (&date, row_shift, 0, 0, 0);
+
+ if (icaltime_compare_date_only (date, *(priv->current_date)) == 0)
+ label_str = g_strdup (_("Today"));
+ else
+ label_str = g_strdup_printf ("%s %d", gcal_get_month_name (date.month - 1), date.day);
- label_str = g_strdup_printf ("%s %d", gcal_get_month_name (row_date.month - 1), row_date.day);
label = gtk_label_new (label_str);
+ gtk_style_context_add_class (gtk_widget_get_style_context (label), "sidebar-header");
g_object_set (label, "margin", 6, "halign", GTK_ALIGN_START, NULL);
g_free (label_str);
gtk_container_add (GTK_CONTAINER (row_header), label);
+ }
+
+ if (!gcal_event_widget_is_multiday (GCAL_EVENT_WIDGET (row_child)) &&
+ !gcal_event_widget_get_all_day (GCAL_EVENT_WIDGET (row_child)) &&
+ (before_date == NULL || before_date->hour != row_date->hour))
+ {
+ gchar *time;
+ GtkWidget *label;
+
+ if (priv->use_24h_format)
+ time = g_strdup_printf ("%.2d:00", row_date->hour);
+ else
+ time = g_strdup_printf ("%.2d:00 %s", row_date->hour % 12, row_date->hour < 12 ? "AM" : "PM");
+
+ label = gtk_label_new (time);
+ gtk_style_context_add_class (gtk_widget_get_style_context (label), GTK_STYLE_CLASS_DIM_LABEL);
+ g_object_set (label, "margin", 6, "halign", GTK_ALIGN_START, NULL);
+
+ if (row_header == NULL)
+ row_header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+
+ gtk_container_add (GTK_CONTAINER (row_header), label);
+ gtk_container_add (GTK_CONTAINER (row_header), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+
+ g_free (time);
+ }
+
+ if (row_header != NULL)
+ {
gtk_widget_show_all (row_header);
gtk_list_box_row_set_header (row, row_header);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]