[gnome-calendar] Added regions to view.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] Added regions to view.
- Date: Wed, 11 Jul 2012 14:51:07 +0000 (UTC)
commit 55292f68ac6e84af029f874f9b3ceeb24bfbe2e3
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Fri Jul 6 01:08:03 2012 -0400
Added regions to view.
Fixed/renamed/changed some classes names for css styling.
Fixed size_allocate, now taking into account regions differents font sizes.
data/gtk-styles.css | 30 ++++++++++++++++++------------
src/gcal-event-view.c | 7 +++----
src/gcal-event-widget.c | 4 ++++
src/gcal-month-view.c | 36 ++++++++++++++++++++++++++++++------
src/gcal-week-view.c | 33 +++++++++++++++++++++++++++------
src/gcal-window.c | 5 -----
6 files changed, 82 insertions(+), 33 deletions(-)
---
diff --git a/data/gtk-styles.css b/data/gtk-styles.css
index 085db3a..3fddd75 100644
--- a/data/gtk-styles.css
+++ b/data/gtk-styles.css
@@ -30,15 +30,28 @@
background-color: transparent;
}
-.views {
- padding: 10px;
+.calendar-view header {
+ font: bold 12;
+}
+
+.calendar-view {
+ padding: 12px;
+ font: 10;
}
-.views:selected {
+.calendar-view:selected {
background-color: #555753;
}
-.event-view .frame {
+.event {
+ padding-top: 2px;
+ padding-bottom: 2px;
+ padding-left: 8px;
+ padding-right: 8px;
+ font: 10;
+}
+
+.event-details .frame {
border-style: solid;
border-color: @borders;
border-width: 0.5px;
@@ -46,17 +59,10 @@
}
/* TODO: not working */
-.event-view .view {
+.event-details .view {
box-shadow: 40px 40px black;
}
-.event {
- padding-top: 2px;
- padding-bottom: 2px;
- padding-left: 8px;
- padding-right: 8px;
-}
-
GtkClutterOffscreen.overlay {
background-color: transparent;
background-image: none;
diff --git a/src/gcal-event-view.c b/src/gcal-event-view.c
index 8d21ba6..2721d96 100644
--- a/src/gcal-event-view.c
+++ b/src/gcal-event-view.c
@@ -102,14 +102,13 @@ gcal_event_view_class_init(GcalEventViewClass *klass)
static void gcal_event_view_init(GcalEventView *self)
{
- GtkStyleContext *context;
-
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
GCAL_TYPE_EVENT_VIEW,
GcalEventViewPrivate);
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
- gtk_style_context_add_class (context, "event-view");
+ gtk_style_context_add_class (
+ gtk_widget_get_style_context (GTK_WIDGET (self)),
+ "event-details");
}
static void
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index 34e49ea..3d5a1e9 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -180,6 +180,10 @@ static void gcal_event_widget_init(GcalEventWidget *self)
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
+
+ gtk_style_context_add_class (
+ gtk_widget_get_style_context (GTK_WIDGET (self)),
+ "event");
}
static void
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 83bf382..50eef12 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -197,6 +197,10 @@ gcal_month_view_init (GcalMonthView *self)
{
priv->days[i] = NULL;
}
+
+ gtk_style_context_add_class (
+ gtk_widget_get_style_context (GTK_WIDGET (self)),
+ "calendar-view");
}
static void
@@ -388,16 +392,30 @@ gcal_month_view_size_allocate (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
-
layout = pango_layout_new (gtk_widget_get_pango_context (widget));
+
+ /* init header values */
+ gtk_style_context_save (context);
+ gtk_style_context_add_region (context, "header", 0);
+
pango_layout_set_font_description (layout,
gtk_style_context_get_font (context,
state));
pango_layout_get_pixel_size (layout, NULL, &font_height);
- /* init values */
- priv->header_size = font_height + 4;
- priv->grid_header_size = font_height + 4;
+ /* 6: is padding around the header */
+ priv->header_size = font_height + 6;
+ gtk_style_context_remove_region (context, "header");
+ gtk_style_context_restore (context);
+
+ /* init grid values */
+ pango_layout_set_font_description (layout,
+ gtk_style_context_get_font (context,
+ state));
+ pango_layout_get_pixel_size (layout, NULL, &font_height);
+ /* 6: is padding around the header */
+ priv->grid_header_size = font_height + 6;
+
priv->horizontal_step =
(allocation->width - (allocation->x + padding.left + padding.right)) / 7;
priv->vertical_step =
@@ -679,6 +697,9 @@ gcal_month_view_draw_header (GcalMonthView *view,
context = gtk_widget_get_style_context (GTK_WIDGET (view));
state = gtk_widget_get_state_flags (GTK_WIDGET (view));
+ gtk_style_context_save (context);
+ gtk_style_context_add_region (context, "header", 0);
+
gtk_style_context_get_color (context, state, &color);
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
@@ -686,6 +707,8 @@ gcal_month_view_draw_header (GcalMonthView *view,
pango_layout_set_font_description (layout,
gtk_style_context_get_font (context,
state));
+ gtk_style_context_remove_region (context, "header");
+ gtk_style_context_restore (context);
tm_date = icaltimetype_to_tm (priv->date);
e_utf8_strftime_fix_am_pm (str_date, 64, "%B", &tm_date);
@@ -778,9 +801,10 @@ gcal_month_view_draw_grid (GcalMonthView *view,
pango_layout_set_text (layout, gcal_get_weekday (i), -1);
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &font_width, &font_height);
+ /* 6: is padding around the grid-header */
cairo_move_to (cr,
- start_grid_x + priv->horizontal_step * i + 1,
- start_grid_y - font_height - 1);
+ start_grid_x + priv->horizontal_step * i + 6,
+ start_grid_y - priv->grid_header_size);
pango_cairo_show_layout (cr, layout);
for (j = 0; j < 5; j++)
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index 5ffe1c5..2ae8080 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -190,6 +190,10 @@ gcal_week_view_init (GcalWeekView *self)
{
priv->days[i] = NULL;
}
+
+ gtk_style_context_add_class (
+ gtk_widget_get_style_context (GTK_WIDGET (self)),
+ "calendar-view");
}
static void
@@ -373,18 +377,30 @@ gcal_week_view_size_allocate (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
-
layout = pango_layout_new (gtk_widget_get_pango_context (widget));
+
+ /* init header values */
+ gtk_style_context_save (context);
+ gtk_style_context_add_region (context, "header", 0);
+
pango_layout_set_font_description (layout,
gtk_style_context_get_font (context,
state));
+ pango_layout_get_pixel_size (layout, NULL, &font_height);
+
+ /* 6: is padding around the header */
+ priv->header_size = font_height + 6;
+ gtk_style_context_remove_region (context, "header");
+ gtk_style_context_restore (context);
+
+ /* init grid values */
pango_layout_set_text (layout, _("All day"), -1);
+ pango_layout_set_font_description (layout,
+ gtk_style_context_get_font (context,
+ state));
pango_layout_get_pixel_size (layout, &font_width, &font_height);
-
- /* init values */
- /* FIXME: these values should be extracted from the theme font size */
- priv->header_size = font_height + 4;
- priv->grid_header_size = font_height + 4;
+ /* 6: is padding around the header */
+ priv->grid_header_size = font_height + 6;
priv->grid_sidebar_size = font_width + 8;
priv->horizontal_step = (allocation->width - (allocation->x + padding.left + padding.right + priv->grid_sidebar_size)) / 7;
@@ -605,6 +621,9 @@ gcal_week_view_draw_header (GcalWeekView *view,
context = gtk_widget_get_style_context (GTK_WIDGET (view));
state = gtk_widget_get_state_flags (GTK_WIDGET (view));
+ gtk_style_context_add_region (context, "header", 0);
+ gtk_style_context_save (context);
+
gtk_style_context_get_color (context, state, &color);
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
@@ -612,6 +631,8 @@ gcal_week_view_draw_header (GcalWeekView *view,
pango_layout_set_font_description (layout,
gtk_style_context_get_font (context,
state));
+ gtk_style_context_remove_region (context, "header");
+ gtk_style_context_restore (context);
start_of_week = gcal_week_view_get_initial_date (view);
tm_date = icaltimetype_to_tm (start_of_week);
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 2877e0c..7e6cb48 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -225,9 +225,6 @@ gcal_window_constructed (GObject *object)
priv->views[GCAL_VIEW_TYPE_MONTHLY] = gcal_month_view_new (date);
g_free (date);
- context = gtk_widget_get_style_context (priv->views[GCAL_VIEW_TYPE_MONTHLY]);
- gtk_style_context_add_class (context, "views");
-
gtk_widget_show (priv->views[GCAL_VIEW_TYPE_MONTHLY]);
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
priv->views[GCAL_VIEW_TYPE_MONTHLY],
@@ -617,8 +614,6 @@ gcal_window_events_added (GcalManager *manager,
gtk_container_add (
GTK_CONTAINER (priv->views[priv->active_view]),
event);
- gtk_style_context_add_class (gtk_widget_get_style_context (event),
- "event");
g_signal_connect (event,
"activated",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]