views: get rid of current date
We can easily track the current date with GDateTime API, so we don't actually need the current date field.
This commit is contained in:
+35
-31
@@ -99,7 +99,6 @@ struct _GcalWindow
|
|||||||
GcalWindowViewType active_view;
|
GcalWindowViewType active_view;
|
||||||
icaltimetype *active_date;
|
icaltimetype *active_date;
|
||||||
|
|
||||||
icaltimetype *current_date;
|
|
||||||
gboolean rtl;
|
gboolean rtl;
|
||||||
|
|
||||||
/* states */
|
/* states */
|
||||||
@@ -169,28 +168,31 @@ static const GActionEntry actions[] = {
|
|||||||
static void
|
static void
|
||||||
update_today_button_sensitive (GcalWindow *window)
|
update_today_button_sensitive (GcalWindow *window)
|
||||||
{
|
{
|
||||||
|
g_autoptr (GDateTime) now;
|
||||||
gboolean sensitive;
|
gboolean sensitive;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
|
||||||
switch (window->active_view)
|
switch (window->active_view)
|
||||||
{
|
{
|
||||||
case GCAL_WINDOW_VIEW_DAY:
|
case GCAL_WINDOW_VIEW_DAY:
|
||||||
sensitive = window->active_date->year != window->current_date->year ||
|
sensitive = window->active_date->year != g_date_time_get_year (now) ||
|
||||||
window->active_date->month != window->current_date->month ||
|
window->active_date->month != g_date_time_get_month (now) ||
|
||||||
window->active_date->day != window->current_date->day;
|
window->active_date->day != g_date_time_get_day_of_month (now);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GCAL_WINDOW_VIEW_WEEK:
|
case GCAL_WINDOW_VIEW_WEEK:
|
||||||
sensitive = window->active_date->year != window->current_date->year ||
|
sensitive = window->active_date->year != g_date_time_get_year (now) ||
|
||||||
icaltime_week_number (*window->active_date) != icaltime_week_number (*window->current_date);
|
icaltime_week_number (*window->active_date) != g_date_time_get_week_of_year (now);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GCAL_WINDOW_VIEW_MONTH:
|
case GCAL_WINDOW_VIEW_MONTH:
|
||||||
sensitive = window->active_date->year != window->current_date->year ||
|
sensitive = window->active_date->year != g_date_time_get_year (now) ||
|
||||||
window->active_date->month != window->current_date->month;
|
window->active_date->month != g_date_time_get_month (now);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GCAL_WINDOW_VIEW_YEAR:
|
case GCAL_WINDOW_VIEW_YEAR:
|
||||||
sensitive = window->active_date->year != window->current_date->year;
|
sensitive = window->active_date->year != g_date_time_get_year (now);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GCAL_WINDOW_VIEW_LIST:
|
case GCAL_WINDOW_VIEW_LIST:
|
||||||
@@ -301,7 +303,10 @@ date_updated (GtkButton *button,
|
|||||||
|
|
||||||
if (move_today)
|
if (move_today)
|
||||||
{
|
{
|
||||||
*new_date = *(window->current_date);
|
g_autoptr (GDateTime) now;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
new_date = datetime_to_icaltime (now);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -410,24 +415,20 @@ key_pressed (GtkWidget *widget,
|
|||||||
static gboolean
|
static gboolean
|
||||||
update_current_date (GcalWindow *window)
|
update_current_date (GcalWindow *window)
|
||||||
{
|
{
|
||||||
guint seconds;
|
|
||||||
|
|
||||||
GCAL_ENTRY;
|
GCAL_ENTRY;
|
||||||
|
|
||||||
if (window->current_date == NULL)
|
/* FIXME: we end up here before constructed(), this shouldn't happen */
|
||||||
window->current_date = g_new0 (icaltimetype, 1);
|
if (!window->views[GCAL_WINDOW_VIEW_WEEK])
|
||||||
|
GCAL_GOTO (out);
|
||||||
|
|
||||||
*(window->current_date) = icaltime_current_time_with_zone (gcal_manager_get_system_timezone (window->manager));
|
gtk_widget_queue_draw (window->views[GCAL_WINDOW_VIEW_WEEK]);
|
||||||
*(window->current_date) = icaltime_set_timezone (window->current_date, gcal_manager_get_system_timezone (window->manager));
|
gtk_widget_queue_draw (window->views[GCAL_WINDOW_VIEW_MONTH]);
|
||||||
|
gtk_widget_queue_draw (window->views[GCAL_WINDOW_VIEW_YEAR]);
|
||||||
|
|
||||||
gcal_week_view_set_current_date (GCAL_WEEK_VIEW (window->week_view), window->current_date);
|
out:
|
||||||
gcal_month_view_set_current_date (GCAL_MONTH_VIEW (window->month_view), window->current_date);
|
g_timeout_add_seconds (60, (GSourceFunc) update_current_date, window);
|
||||||
gcal_year_view_set_current_date (GCAL_YEAR_VIEW (window->year_view), window->current_date);
|
|
||||||
|
|
||||||
seconds = 24 * 60 * 60 - (icaltime_as_timet (*(window->current_date)) % (24 * 60 * 60));
|
GCAL_RETURN (G_SOURCE_CONTINUE);
|
||||||
g_timeout_add_seconds (seconds, (GSourceFunc) update_current_date, window);
|
|
||||||
|
|
||||||
GCAL_RETURN (FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1195,6 +1196,8 @@ gcal_window_constructed (GObject *object)
|
|||||||
gchar *clock_format;
|
gchar *clock_format;
|
||||||
gboolean use_24h_format;
|
gboolean use_24h_format;
|
||||||
|
|
||||||
|
GCAL_ENTRY;
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (gcal_window_parent_class)->constructed != NULL)
|
if (G_OBJECT_CLASS (gcal_window_parent_class)->constructed != NULL)
|
||||||
G_OBJECT_CLASS (gcal_window_parent_class)->constructed (object);
|
G_OBJECT_CLASS (gcal_window_parent_class)->constructed (object);
|
||||||
|
|
||||||
@@ -1251,6 +1254,8 @@ gcal_window_constructed (GObject *object)
|
|||||||
|
|
||||||
g_list_free (sources);
|
g_list_free (sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1290,7 +1295,6 @@ gcal_window_finalize (GObject *object)
|
|||||||
g_clear_object (&window->views_switcher);
|
g_clear_object (&window->views_switcher);
|
||||||
|
|
||||||
g_free (window->active_date);
|
g_free (window->active_date);
|
||||||
g_free (window->current_date);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gcal_window_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gcal_window_parent_class)->finalize (object);
|
||||||
|
|
||||||
@@ -1305,6 +1309,8 @@ gcal_window_set_property (GObject *object,
|
|||||||
{
|
{
|
||||||
GcalWindow *self = GCAL_WINDOW (object);
|
GcalWindow *self = GCAL_WINDOW (object);
|
||||||
|
|
||||||
|
GCAL_ENTRY;
|
||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
case PROP_ACTIVE_VIEW:
|
case PROP_ACTIVE_VIEW:
|
||||||
@@ -1342,6 +1348,8 @@ gcal_window_set_property (GObject *object,
|
|||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GCAL_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1594,17 +1602,12 @@ gcal_window_new_with_view_and_date (GcalApplication *app,
|
|||||||
void
|
void
|
||||||
gcal_window_new_event (GcalWindow *self)
|
gcal_window_new_event (GcalWindow *self)
|
||||||
{
|
{
|
||||||
GDateTime *start_date, *end_date;
|
g_autoptr (GDateTime) start_date, end_date;
|
||||||
icaltimetype date;
|
|
||||||
|
|
||||||
/* 1st and 2nd steps */
|
/* 1st and 2nd steps */
|
||||||
set_new_event_mode (self, TRUE);
|
set_new_event_mode (self, TRUE);
|
||||||
|
|
||||||
date = *self->current_date;
|
start_date = g_date_time_new_now_local ();
|
||||||
date.is_date = 1;
|
|
||||||
|
|
||||||
start_date = icaltime_to_datetime (&date);
|
|
||||||
end_date = icaltime_to_datetime (&date);
|
|
||||||
|
|
||||||
/* adjusting dates according to the actual view */
|
/* adjusting dates according to the actual view */
|
||||||
switch (self->active_view)
|
switch (self->active_view)
|
||||||
@@ -1620,6 +1623,7 @@ gcal_window_new_event (GcalWindow *self)
|
|||||||
case GCAL_WINDOW_VIEW_LIST:
|
case GCAL_WINDOW_VIEW_LIST:
|
||||||
case GCAL_WINDOW_VIEW_SEARCH:
|
case GCAL_WINDOW_VIEW_SEARCH:
|
||||||
default:
|
default:
|
||||||
|
end_date = g_date_time_add_days (start_date, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,6 @@ struct _GcalMonthView
|
|||||||
/* text direction factors */
|
/* text direction factors */
|
||||||
gboolean k;
|
gboolean k;
|
||||||
|
|
||||||
icaltimetype *current_date;
|
|
||||||
|
|
||||||
/* The cell hovered during Drag and Drop */
|
/* The cell hovered during Drag and Drop */
|
||||||
gint dnd_cell;
|
gint dnd_cell;
|
||||||
|
|
||||||
@@ -1496,6 +1494,8 @@ gcal_month_view_draw (GtkWidget *widget,
|
|||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
PangoFontDescription *font_desc, *sfont_desc;
|
PangoFontDescription *font_desc, *sfont_desc;
|
||||||
|
|
||||||
|
g_autoptr (GDateTime) today;
|
||||||
|
|
||||||
gint font_width, font_height, pos_x, pos_y, shown_rows;
|
gint font_width, font_height, pos_x, pos_y, shown_rows;
|
||||||
gint i, j, sw, lower_mark = 43, upper_mark = -2;
|
gint i, j, sw, lower_mark = 43, upper_mark = -2;
|
||||||
gint cell_width, cell_height;
|
gint cell_width, cell_height;
|
||||||
@@ -1505,6 +1505,8 @@ gcal_month_view_draw (GtkWidget *widget,
|
|||||||
self = GCAL_MONTH_VIEW (widget);
|
self = GCAL_MONTH_VIEW (widget);
|
||||||
ppriv = GCAL_SUBSCRIBER_VIEW (widget)->priv;
|
ppriv = GCAL_SUBSCRIBER_VIEW (widget)->priv;
|
||||||
|
|
||||||
|
today = g_date_time_new_now_local ();
|
||||||
|
|
||||||
/* fonts and colors selection */
|
/* fonts and colors selection */
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state = gtk_style_context_get_state (context);
|
state = gtk_style_context_get_state (context);
|
||||||
@@ -1705,8 +1707,9 @@ gcal_month_view_draw (GtkWidget *widget,
|
|||||||
g_object_unref (overflow_layout);
|
g_object_unref (overflow_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->date->year == self->current_date->year && self->date->month == self->current_date->month &&
|
if (self->date->year == g_date_time_get_year (today) &&
|
||||||
j == self->current_date->day)
|
self->date->month == g_date_time_get_month (today) &&
|
||||||
|
j == g_date_time_get_day_of_month (today))
|
||||||
{
|
{
|
||||||
PangoFontDescription *cfont_desc;
|
PangoFontDescription *cfont_desc;
|
||||||
PangoLayout *clayout;
|
PangoLayout *clayout;
|
||||||
@@ -2286,15 +2289,6 @@ gcal_month_view_init (GcalMonthView *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
/* Public API */
|
||||||
void
|
|
||||||
gcal_month_view_set_current_date (GcalMonthView *self,
|
|
||||||
icaltimetype *current_date)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GCAL_IS_MONTH_VIEW (self));
|
|
||||||
|
|
||||||
self->current_date = current_date;
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gcal_month_view_set_first_weekday:
|
* gcal_month_view_set_first_weekday:
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GcalMonthView, gcal_month_view, GCAL, MONTH_VIEW, GcalSubscriberView)
|
G_DECLARE_FINAL_TYPE (GcalMonthView, gcal_month_view, GCAL, MONTH_VIEW, GcalSubscriberView)
|
||||||
|
|
||||||
|
|
||||||
void gcal_month_view_set_current_date (GcalMonthView *self,
|
|
||||||
icaltimetype *current_date);
|
|
||||||
|
|
||||||
void gcal_month_view_set_first_weekday (GcalMonthView *self,
|
void gcal_month_view_set_first_weekday (GcalMonthView *self,
|
||||||
gint day_nr);
|
gint day_nr);
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ struct _GcalWeekGrid
|
|||||||
gboolean use_24h_format : 1;
|
gboolean use_24h_format : 1;
|
||||||
|
|
||||||
icaltimetype *active_date;
|
icaltimetype *active_date;
|
||||||
icaltimetype *current_date;
|
|
||||||
|
|
||||||
GcalRangeTree *events;
|
GcalRangeTree *events;
|
||||||
|
|
||||||
@@ -257,7 +256,6 @@ gcal_week_grid_finalize (GObject *object)
|
|||||||
|
|
||||||
g_clear_pointer (&self->events, gcal_range_tree_unref);
|
g_clear_pointer (&self->events, gcal_range_tree_unref);
|
||||||
g_clear_pointer (&self->active_date, g_free);
|
g_clear_pointer (&self->active_date, g_free);
|
||||||
g_clear_pointer (&self->current_date, g_free);
|
|
||||||
|
|
||||||
if (self->redraw_timeout_id > 0)
|
if (self->redraw_timeout_id > 0)
|
||||||
{
|
{
|
||||||
@@ -1179,18 +1177,6 @@ gcal_week_grid_set_use_24h_format (GcalWeekGrid *self,
|
|||||||
self->use_24h_format = use_24h_format;
|
self->use_24h_format = use_24h_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gcal_week_grid_set_current_date (GcalWeekGrid *self,
|
|
||||||
icaltimetype *current_date)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GCAL_IS_WEEK_GRID (self));
|
|
||||||
|
|
||||||
g_clear_pointer (&self->current_date, g_free);
|
|
||||||
self->current_date = gcal_dup_icaltime (current_date);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gcal_week_grid_add_event (GcalWeekGrid *self,
|
gcal_week_grid_add_event (GcalWeekGrid *self,
|
||||||
GcalEvent *event)
|
GcalEvent *event)
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ void gcal_week_grid_set_first_weekday (GcalWeekGrid
|
|||||||
void gcal_week_grid_set_use_24h_format (GcalWeekGrid *week_grid,
|
void gcal_week_grid_set_use_24h_format (GcalWeekGrid *week_grid,
|
||||||
gboolean use_24h_format);
|
gboolean use_24h_format);
|
||||||
|
|
||||||
void gcal_week_grid_set_current_date (GcalWeekGrid *week_grid,
|
|
||||||
icaltimetype *current_date);
|
|
||||||
|
|
||||||
void gcal_week_grid_add_event (GcalWeekGrid *self,
|
void gcal_week_grid_add_event (GcalWeekGrid *self,
|
||||||
GcalEvent *event);
|
GcalEvent *event);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ struct _GcalWeekHeader
|
|||||||
gint redraw_timeout_id;
|
gint redraw_timeout_id;
|
||||||
|
|
||||||
icaltimetype *active_date;
|
icaltimetype *active_date;
|
||||||
icaltimetype *current_date;
|
|
||||||
|
|
||||||
gint selection_start;
|
gint selection_start;
|
||||||
gint selection_end;
|
gint selection_end;
|
||||||
@@ -1025,7 +1024,6 @@ gcal_week_header_finalize (GObject *object)
|
|||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_clear_pointer (&self->active_date, g_free);
|
g_clear_pointer (&self->active_date, g_free);
|
||||||
g_clear_pointer (&self->current_date, g_free);
|
|
||||||
|
|
||||||
if (self->redraw_timeout_id > 0)
|
if (self->redraw_timeout_id > 0)
|
||||||
{
|
{
|
||||||
@@ -1744,20 +1742,6 @@ gcal_week_header_get_children_by_uuid (GcalWeekHeader *self,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gcal_week_header_set_current_date (GcalWeekHeader *self,
|
|
||||||
icaltimetype *current_date)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
|
|
||||||
|
|
||||||
g_clear_pointer (&self->current_date, g_free);
|
|
||||||
self->current_date = gcal_dup_icaltime (current_date);
|
|
||||||
|
|
||||||
update_title (self);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
|
||||||
}
|
|
||||||
|
|
||||||
GtkSizeGroup*
|
GtkSizeGroup*
|
||||||
gcal_week_header_get_sidebar_size_group (GcalWeekHeader *self)
|
gcal_week_header_get_sidebar_size_group (GcalWeekHeader *self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ void gcal_week_header_set_first_weekday (GcalWeekHeader
|
|||||||
void gcal_week_header_set_use_24h_format (GcalWeekHeader *self,
|
void gcal_week_header_set_use_24h_format (GcalWeekHeader *self,
|
||||||
gboolean use_24h_format);
|
gboolean use_24h_format);
|
||||||
|
|
||||||
void gcal_week_header_set_current_date (GcalWeekHeader *self,
|
|
||||||
icaltimetype *current_date);
|
|
||||||
|
|
||||||
void gcal_week_header_add_event (GcalWeekHeader *self,
|
void gcal_week_header_add_event (GcalWeekHeader *self,
|
||||||
GcalEvent *event);
|
GcalEvent *event);
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ struct _GcalWeekView
|
|||||||
|
|
||||||
/* property */
|
/* property */
|
||||||
icaltimetype *date;
|
icaltimetype *date;
|
||||||
icaltimetype *current_date;
|
|
||||||
GcalManager *manager; /* weak referenced */
|
GcalManager *manager; /* weak referenced */
|
||||||
|
|
||||||
guint scroll_grid_timeout_id;
|
guint scroll_grid_timeout_id;
|
||||||
@@ -655,16 +654,3 @@ gcal_week_view_set_use_24h_format (GcalWeekView *self,
|
|||||||
|
|
||||||
self->use_24h_format = use_24h;
|
self->use_24h_format = use_24h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gcal_week_view_set_current_date (GcalWeekView *self,
|
|
||||||
icaltimetype *current_date)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GCAL_IS_WEEK_VIEW (self));
|
|
||||||
|
|
||||||
g_clear_pointer (&self->current_date, g_free);
|
|
||||||
self->current_date = current_date;
|
|
||||||
|
|
||||||
gcal_week_header_set_current_date (GCAL_WEEK_HEADER (self->header), current_date);
|
|
||||||
gcal_week_grid_set_current_date (GCAL_WEEK_GRID (self->week_grid), current_date);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ void gcal_week_view_set_first_weekday (GcalWeekView
|
|||||||
void gcal_week_view_set_use_24h_format (GcalWeekView *self,
|
void gcal_week_view_set_use_24h_format (GcalWeekView *self,
|
||||||
gboolean use_24h);
|
gboolean use_24h);
|
||||||
|
|
||||||
void gcal_week_view_set_current_date (GcalWeekView *self,
|
|
||||||
icaltimetype *current_date);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GCAL_WEEK_VIEW_H__ */
|
#endif /* __GCAL_WEEK_VIEW_H__ */
|
||||||
|
|||||||
+31
-24
@@ -105,9 +105,6 @@ struct _GcalYearView
|
|||||||
/* text direction factors */
|
/* text direction factors */
|
||||||
gint k;
|
gint k;
|
||||||
|
|
||||||
/* weak ref to current date */
|
|
||||||
icaltimetype *current_date;
|
|
||||||
|
|
||||||
/* date property */
|
/* date property */
|
||||||
icaltimetype *date;
|
icaltimetype *date;
|
||||||
};
|
};
|
||||||
@@ -218,7 +215,17 @@ update_selected_dates_from_button_data (GcalYearView *year_view)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*(year_view->start_selected_date) = year_view->date ? *(year_view->date) : *(year_view->current_date);
|
g_autofree icaltimetype *current_date;
|
||||||
|
g_autoptr (GDateTime) now;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
current_date = datetime_to_icaltime (now);
|
||||||
|
|
||||||
|
if (year_view->date)
|
||||||
|
*(year_view->start_selected_date) = *year_view->date;
|
||||||
|
else
|
||||||
|
*(year_view->start_selected_date) = *current_date;
|
||||||
|
|
||||||
year_view->start_selected_date->hour = 0;
|
year_view->start_selected_date->hour = 0;
|
||||||
year_view->start_selected_date->minute = 0;
|
year_view->start_selected_date->minute = 0;
|
||||||
year_view->start_selected_date->second = 0;
|
year_view->start_selected_date->second = 0;
|
||||||
@@ -245,13 +252,17 @@ update_selected_dates_from_button_data (GcalYearView *year_view)
|
|||||||
static void
|
static void
|
||||||
update_no_events_page (GcalYearView *year_view)
|
update_no_events_page (GcalYearView *year_view)
|
||||||
{
|
{
|
||||||
gchar *title;
|
g_autoptr (GDateTime) start_selected_date, now;
|
||||||
gboolean has_range;
|
gboolean has_range;
|
||||||
|
gchar *title;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
start_selected_date = icaltime_to_datetime (year_view->start_selected_date);
|
||||||
|
|
||||||
has_range = (year_view->start_selected_date->day != year_view->end_selected_date->day ||
|
has_range = (year_view->start_selected_date->day != year_view->end_selected_date->day ||
|
||||||
year_view->start_selected_date->month != year_view->end_selected_date->month);
|
year_view->start_selected_date->month != year_view->end_selected_date->month);
|
||||||
|
|
||||||
if (icaltime_compare_date (year_view->current_date, year_view->start_selected_date) == 0)
|
if (datetime_compare_date (now, start_selected_date) == 0)
|
||||||
{
|
{
|
||||||
title = g_strdup_printf ("%s%s", _("Today"), has_range ? "…" : "");
|
title = g_strdup_printf ("%s%s", _("Today"), has_range ? "…" : "");
|
||||||
}
|
}
|
||||||
@@ -465,14 +476,19 @@ update_sidebar_headers (GtkListBoxRow *row,
|
|||||||
|
|
||||||
if (before_shift == -1 || before_shift != row_shift)
|
if (before_shift == -1 || before_shift != row_shift)
|
||||||
{
|
{
|
||||||
|
g_autoptr (GDateTime) now, dt;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
gchar *label_str;
|
gchar *label_str;
|
||||||
|
|
||||||
row_header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
row_header = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
|
||||||
date = *(year_view->start_selected_date);
|
date = *(year_view->start_selected_date);
|
||||||
icaltime_adjust (&date, row_shift, 0, 0, 0);
|
icaltime_adjust (&date, row_shift, 0, 0, 0);
|
||||||
|
|
||||||
if (icaltime_compare_date (&date, year_view->current_date) == 0)
|
dt = icaltime_to_datetime (&date);
|
||||||
|
|
||||||
|
if (datetime_compare_date (dt, now) == 0)
|
||||||
label_str = g_strdup (_("Today"));
|
label_str = g_strdup (_("Today"));
|
||||||
else
|
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 (date.month - 1), date.day);
|
||||||
@@ -674,6 +690,8 @@ draw_month_grid (GcalYearView *year_view,
|
|||||||
PangoLayout *layout, *slayout;
|
PangoLayout *layout, *slayout;
|
||||||
PangoFontDescription *font_desc, *sfont_desc;
|
PangoFontDescription *font_desc, *sfont_desc;
|
||||||
|
|
||||||
|
g_autoptr (GDateTime) now;
|
||||||
|
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
gint layout_width, layout_height, i, j, sw;
|
gint layout_width, layout_height, i, j, sw;
|
||||||
gint column, row;
|
gint column, row;
|
||||||
@@ -684,6 +702,8 @@ draw_month_grid (GcalYearView *year_view,
|
|||||||
GList *events;
|
GList *events;
|
||||||
icaltimetype start_date, end_date;
|
icaltimetype start_date, end_date;
|
||||||
|
|
||||||
|
now = g_date_time_new_now_local ();
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
context = gtk_widget_get_style_context (widget);
|
context = gtk_widget_get_style_context (widget);
|
||||||
state_flags = gtk_style_context_get_state (context);
|
state_flags = gtk_style_context_get_state (context);
|
||||||
@@ -845,8 +865,9 @@ draw_month_grid (GcalYearView *year_view,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (year_view->date->year == year_view->current_date->year && month_nr + 1 == year_view->current_date->month &&
|
if (year_view->date->year == g_date_time_get_year (now) &&
|
||||||
j == year_view->current_date->day)
|
month_nr + 1 == g_date_time_get_month (now) &&
|
||||||
|
j == g_date_time_get_day_of_month (now))
|
||||||
{
|
{
|
||||||
PangoLayout *clayout;
|
PangoLayout *clayout;
|
||||||
PangoFontDescription *cfont_desc;
|
PangoFontDescription *cfont_desc;
|
||||||
@@ -1237,10 +1258,7 @@ add_event_clicked_cb (GcalYearView *year_view,
|
|||||||
|
|
||||||
if (year_view->start_selected_date->day == 0)
|
if (year_view->start_selected_date->day == 0)
|
||||||
{
|
{
|
||||||
start_date = g_date_time_new_local (year_view->current_date->year,
|
start_date = g_date_time_new_now_local ();
|
||||||
year_view->current_date->month,
|
|
||||||
year_view->current_date->day,
|
|
||||||
0, 0, 0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1978,14 +1996,3 @@ gcal_year_view_set_use_24h_format (GcalYearView *year_view,
|
|||||||
{
|
{
|
||||||
year_view->use_24h_format = use_24h_format;
|
year_view->use_24h_format = use_24h_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gcal_year_view_set_current_date (GcalYearView *year_view,
|
|
||||||
icaltimetype *current_date)
|
|
||||||
{
|
|
||||||
year_view->current_date = current_date;
|
|
||||||
|
|
||||||
/* Launches update */
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (year_view));
|
|
||||||
update_sidebar (year_view);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user