[gnome-calendar] app: initial current date marking work
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] app: initial current date marking work
- Date: Wed, 28 Jan 2015 20:24:18 +0000 (UTC)
commit 86d5a23dddabffe86a82432d85ba371fc689cde9
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Wed Jan 28 15:18:53 2015 -0500
app: initial current date marking work
src/gcal-window.c | 34 ++++++++++++++++++++++++++--------
src/gcal-year-view.c | 12 ++----------
2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 1f643f8..f688ecb 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -91,6 +91,8 @@ typedef struct
GcalWindowViewType active_view;
icaltimetype *active_date;
+ icaltimetype *current_date;
+
/* states */
gboolean new_event_mode;
gboolean search_mode;
@@ -319,6 +321,25 @@ update_active_date (GcalWindow *window,
priv->active_date = new_date;
}
+static gboolean
+update_current_date (GcalWindow *window)
+{
+ GcalWindowPrivate *priv = gcal_window_get_instance_private (window);
+ guint seconds;
+
+ if (priv->current_date == NULL)
+ priv->current_date = g_new0 (icaltimetype, 1);
+
+ *(priv->current_date) = icaltime_current_time_with_zone (gcal_manager_get_system_timezone (priv->manager));
+ *(priv->current_date) = icaltime_set_timezone (priv->current_date, gcal_manager_get_system_timezone
(priv->manager));
+
+ gcal_year_view_set_current_date (GCAL_YEAR_VIEW (priv->year_view), priv->current_date);
+
+ seconds = 24 * 60 * 60 - (icaltime_as_timet (*(priv->current_date)) % (24 * 60 * 60));
+ g_timeout_add_seconds (seconds, (GSourceFunc) update_current_date, window);
+ return FALSE;
+}
+
static void
date_updated (GtkButton *button,
gpointer user_data)
@@ -1319,7 +1340,6 @@ gcal_window_constructed (GObject *object)
gcal_month_view_set_first_weekday (GCAL_MONTH_VIEW (priv->views[GCAL_WINDOW_VIEW_MONTH]),
get_first_weekday ());
gcal_month_view_set_use_24h_format (GCAL_MONTH_VIEW (priv->views[GCAL_WINDOW_VIEW_MONTH]), use_24h_format);
- gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->views[GCAL_WINDOW_VIEW_YEAR]), priv->manager);
gcal_year_view_set_first_weekday (GCAL_YEAR_VIEW (priv->views[GCAL_WINDOW_VIEW_YEAR]), get_first_weekday
());
gcal_year_view_set_use_24h_format (GCAL_YEAR_VIEW (priv->views[GCAL_WINDOW_VIEW_YEAR]), use_24h_format);
@@ -1327,9 +1347,6 @@ gcal_window_constructed (GObject *object)
gcal_search_view_connect (GCAL_SEARCH_VIEW (priv->search_view), priv->manager);
gcal_search_view_set_time_format (GCAL_SEARCH_VIEW (priv->search_view), use_24h_format);
- /* current date hook */
- gcal_year_view_set_current_date (GCAL_YEAR_VIEW (priv->views[GCAL_WINDOW_VIEW_YEAR]), NULL);
-
/* refresh timeout, first is fast */
priv->refresh_timeout_id = g_timeout_add (FAST_REFRESH_TIMEOUT, (GSourceFunc) refresh_sources, object);
}
@@ -1375,10 +1392,11 @@ gcal_window_set_property (GObject *object,
return;
case PROP_MANAGER:
priv->manager = g_value_get_pointer (value);
- g_signal_connect (priv->manager, "source-added",
- G_CALLBACK (add_source), object);
- g_signal_connect (priv->manager, "source-removed",
- G_CALLBACK (remove_source), object);
+ g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), object);
+ g_signal_connect (priv->manager, "source-removed", G_CALLBACK (remove_source), object);
+
+ gcal_year_view_set_manager (GCAL_YEAR_VIEW (priv->year_view), priv->manager);
+ update_current_date (GCAL_WINDOW (object));
return;
}
diff --git a/src/gcal-year-view.c b/src/gcal-year-view.c
index c352752..f5f0aa7 100644
--- a/src/gcal-year-view.c
+++ b/src/gcal-year-view.c
@@ -922,10 +922,6 @@ gcal_year_view_finalize (GObject *object)
if (priv->date != NULL)
g_free (priv->date);
- /* FIXME: move into window */
- if (priv->current_date != NULL)
- g_free (priv->current_date);
-
G_OBJECT_CLASS (gcal_year_view_parent_class)->finalize (object);
}
@@ -1267,13 +1263,9 @@ void
gcal_year_view_set_current_date (GcalYearView *year_view,
icaltimetype *current_date)
{
- /* FIXME: move into window */
- year_view->priv->current_date = g_new0 (icaltimetype, 1);
- *(year_view->priv->current_date) =
- icaltime_current_time_with_zone (gcal_manager_get_system_timezone (year_view->priv->manager));
- *(year_view->priv->current_date) = icaltime_set_timezone (year_view->priv->current_date,
- gcal_manager_get_system_timezone
(year_view->priv->manager));
+ year_view->priv->current_date = current_date;
/* Launches update */
+ gtk_widget_queue_draw (GTK_WIDGET (year_view));
update_sidebar (year_view);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]