[gnome-calendar/wip/pandusonu/week-view] week-header, week-grid: update drawing when time changes
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/pandusonu/week-view] week-header, week-grid: update drawing when time changes
- Date: Thu, 8 Dec 2016 22:34:07 +0000 (UTC)
commit 6d4f7198292474900b414945916d8fa392cd33ec
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Dec 8 19:33:20 2016 -0200
week-header, week-grid: update drawing when time changes
When minutes change, the week grid should update the today strip
if it's visible and, if the day change, week header should update
the blue week name.
src/views/gcal-week-grid.c | 17 +++++++++++++++++
src/views/gcal-week-header.c | 15 +++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/views/gcal-week-grid.c b/src/views/gcal-week-grid.c
index 27f54ce..2aca228 100644
--- a/src/views/gcal-week-grid.c
+++ b/src/views/gcal-week-grid.c
@@ -58,6 +58,7 @@ struct _GcalWeekGrid
GcalRangeTree *events;
gboolean children_changed;
+ gint redraw_timeout_id;
GcalManager *manager;
};
@@ -172,6 +173,12 @@ gcal_week_grid_finalize (GObject *object)
g_clear_pointer (&self->active_date, g_free);
g_clear_pointer (&self->current_date, g_free);
+ if (self->redraw_timeout_id > 0)
+ {
+ g_source_remove (self->redraw_timeout_id);
+ self->redraw_timeout_id = 0;
+ }
+
G_OBJECT_CLASS (gcal_week_grid_parent_class)->finalize (object);
}
@@ -364,6 +371,7 @@ gcal_week_grid_draw (GtkWidget *widget,
{
GtkStyleContext *context;
GtkStateFlags state;
+ GcalWeekGrid *self;
GtkBorder padding;
GdkRGBA color;
@@ -372,6 +380,7 @@ gcal_week_grid_draw (GtkWidget *widget,
PangoLayout *layout;
PangoFontDescription *font_desc;
+ self = GCAL_WEEK_GRID (widget);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
@@ -450,6 +459,14 @@ gcal_week_grid_draw (GtkWidget *widget,
GTK_WIDGET_CLASS (gcal_week_grid_parent_class)->draw (widget, cr);
+ /* Fire the redraw timeout if needed */
+ if (self->redraw_timeout_id == 0)
+ {
+ self->redraw_timeout_id = g_timeout_add_seconds (5,
+ (GSourceFunc) gtk_widget_queue_draw,
+ self);
+ }
+
return FALSE;
}
diff --git a/src/views/gcal-week-header.c b/src/views/gcal-week-header.c
index 4a7f335..73593b6 100644
--- a/src/views/gcal-week-header.c
+++ b/src/views/gcal-week-header.c
@@ -64,6 +64,7 @@ struct _GcalWeekHeader
gboolean expanded;
gboolean use_24h_format;
+ gint redraw_timeout_id;
icaltimetype *active_date;
icaltimetype *current_date;
@@ -921,6 +922,12 @@ gcal_week_header_finalize (GObject *object)
g_clear_pointer (&self->active_date, g_free);
g_clear_pointer (&self->current_date, g_free);
+ if (self->redraw_timeout_id > 0)
+ {
+ g_source_remove (self->redraw_timeout_id);
+ self->redraw_timeout_id = 0;
+ }
+
for (i = 0; i < 7; i++)
g_list_free (self->events[i]);
}
@@ -1143,6 +1150,14 @@ gcal_week_header_draw (GtkWidget *widget,
GTK_WIDGET_CLASS (gcal_week_header_parent_class)->draw (widget, cr);
+ /* Fire the redraw timeout if needed */
+ if (self->redraw_timeout_id == 0)
+ {
+ self->redraw_timeout_id = g_timeout_add_seconds (5,
+ (GSourceFunc) gtk_widget_queue_draw,
+ self);
+ }
+
g_clear_pointer (&week_start, g_date_time_unref);
g_clear_pointer (&week_end, g_date_time_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]