view: Remove first weekday helpers when unecessary
Not all views need to know the first weekday, and those who need, it can be stored internally.
This commit is contained in:
@@ -1579,10 +1579,6 @@ gcal_window_init (GcalWindow *self)
|
||||
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
|
||||
self->views[GCAL_WINDOW_VIEW_YEAR] = self->year_view;
|
||||
|
||||
gcal_week_view_set_first_weekday (GCAL_WEEK_VIEW (self->views[GCAL_WINDOW_VIEW_WEEK]), get_first_weekday ());
|
||||
gcal_month_view_set_first_weekday (GCAL_MONTH_VIEW (self->views[GCAL_WINDOW_VIEW_MONTH]), get_first_weekday ());
|
||||
gcal_year_view_set_first_weekday (GCAL_YEAR_VIEW (self->views[GCAL_WINDOW_VIEW_YEAR]), get_first_weekday ());
|
||||
|
||||
/* refresh timeout, first is fast */
|
||||
self->refresh_timeout_id = g_timeout_add (FAST_REFRESH_TIMEOUT, (GSourceFunc) refresh_sources, self);
|
||||
|
||||
|
||||
@@ -2190,6 +2190,9 @@ gcal_month_view_init (GcalMonthView *self)
|
||||
self->overflow_cells = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_list_free);
|
||||
self->pending_event_allocation = FALSE;
|
||||
|
||||
/* First weekday */
|
||||
self->first_weekday = get_first_weekday ();
|
||||
|
||||
/* Weekday header labels */
|
||||
self->weekday_label[0] = self->label_0;
|
||||
self->weekday_label[1] = self->label_1;
|
||||
@@ -2216,28 +2219,3 @@ gcal_month_view_init (GcalMonthView *self)
|
||||
self);
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
|
||||
/**
|
||||
* gcal_month_view_set_first_weekday:
|
||||
* @view: A #GcalMonthView instance
|
||||
* @day_nr: Integer representing the first day of the week
|
||||
*
|
||||
* Set the first day of the week according to the locale, being
|
||||
* 0 for Sunday, 1 for Monday and so on.
|
||||
*/
|
||||
void
|
||||
gcal_month_view_set_first_weekday (GcalMonthView *self,
|
||||
gint day_nr)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_MONTH_VIEW (self));
|
||||
|
||||
self->first_weekday = day_nr;
|
||||
|
||||
/* update days_delay */
|
||||
if (self->date)
|
||||
self->days_delay = (time_day_of_week (1, self->date->month - 1, self->date->year) - self->first_weekday + 7) % 7;
|
||||
|
||||
update_weekday_labels (self);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,6 @@ G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GcalMonthView, gcal_month_view, GCAL, MONTH_VIEW, GtkContainer)
|
||||
|
||||
void gcal_month_view_set_first_weekday (GcalMonthView *self,
|
||||
gint day_nr);
|
||||
|
||||
void gcal_month_view_set_use_24h_format (GcalMonthView *self,
|
||||
gboolean use_24h);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GCAL_MONTH_VIEW_H__ */
|
||||
|
||||
@@ -49,11 +49,8 @@ struct _GcalWeekGrid
|
||||
GtkContainer parent;
|
||||
|
||||
GtkWidget *hours_sidebar;
|
||||
|
||||
GdkWindow *event_window;
|
||||
|
||||
gint first_weekday;
|
||||
|
||||
icaltimetype *active_date;
|
||||
|
||||
GcalRangeTree *events;
|
||||
@@ -1144,15 +1141,6 @@ gcal_week_grid_set_manager (GcalWeekGrid *self,
|
||||
self);
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_grid_set_first_weekday (GcalWeekGrid *self,
|
||||
gint nr_day)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_GRID (self));
|
||||
|
||||
self->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_grid_add_event (GcalWeekGrid *self,
|
||||
GcalEvent *event)
|
||||
|
||||
@@ -1671,7 +1671,7 @@ gcal_week_header_init (GcalWeekHeader *self)
|
||||
self->selection_start = -1;
|
||||
self->selection_end = -1;
|
||||
self->dnd_cell = -1;
|
||||
self->weather_service = NULL;
|
||||
self->first_weekday = get_first_weekday ();
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
@@ -1823,15 +1823,6 @@ gcal_week_header_set_manager (GcalWeekHeader *self,
|
||||
self);
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_header_set_first_weekday (GcalWeekHeader *self,
|
||||
gint nr_day)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
|
||||
|
||||
self->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
void
|
||||
gcal_week_header_add_event (GcalWeekHeader *self,
|
||||
GcalEvent *event)
|
||||
|
||||
@@ -35,9 +35,6 @@ G_DECLARE_FINAL_TYPE (GcalWeekHeader, gcal_week_header, GCAL, WEEK_HEADER, GtkGr
|
||||
void gcal_week_header_set_manager (GcalWeekHeader *self,
|
||||
GcalManager *manager);
|
||||
|
||||
void gcal_week_header_set_first_weekday (GcalWeekHeader *self,
|
||||
gint nr_day);
|
||||
|
||||
void gcal_week_header_add_event (GcalWeekHeader *self,
|
||||
GcalEvent *event);
|
||||
|
||||
|
||||
@@ -49,13 +49,6 @@ struct _GcalWeekView
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *week_grid;
|
||||
|
||||
/*
|
||||
* first day of the week according to user locale, being
|
||||
* 0 for Sunday, 1 for Monday and so on
|
||||
*/
|
||||
gint first_weekday;
|
||||
|
||||
|
||||
GcalTimeFormat time_format;
|
||||
|
||||
/* property */
|
||||
@@ -646,37 +639,3 @@ gcal_week_view_init (GcalWeekView *self)
|
||||
g_object_bind_property (self, "weather-service", self->header, "weather-service", G_BINDING_DEFAULT);
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
/**
|
||||
* gcal_week_view_new:
|
||||
*
|
||||
* Create a week-view widget
|
||||
*
|
||||
* Returns: (transfer full):
|
||||
**/
|
||||
GtkWidget*
|
||||
gcal_week_view_new (void)
|
||||
{
|
||||
return g_object_new (GCAL_TYPE_WEEK_VIEW, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gcal_week_view_set_first_weekday:
|
||||
* @view:
|
||||
* @day_nr:
|
||||
*
|
||||
* Set the first day of the week according to the locale, being
|
||||
* 0 for Sunday, 1 for Monday and so on.
|
||||
**/
|
||||
void
|
||||
gcal_week_view_set_first_weekday (GcalWeekView *self,
|
||||
gint day_nr)
|
||||
{
|
||||
g_return_if_fail (GCAL_IS_WEEK_VIEW (self));
|
||||
|
||||
self->first_weekday = day_nr;
|
||||
|
||||
gcal_week_header_set_first_weekday (GCAL_WEEK_HEADER (self->header), self->first_weekday);
|
||||
gcal_week_grid_set_first_weekday (GCAL_WEEK_GRID (self->week_grid), self->first_weekday);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GcalWeekView, gcal_week_view, GCAL, WEEK_VIEW, GtkBox)
|
||||
|
||||
GtkWidget* gcal_week_view_new (void);
|
||||
|
||||
void gcal_week_view_set_first_weekday (GcalWeekView *self,
|
||||
gint day_nr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GCAL_WEEK_VIEW_H__ */
|
||||
|
||||
@@ -2009,6 +2009,8 @@ gcal_year_view_init (GcalYearView *self)
|
||||
else if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL)
|
||||
self->k = 1;
|
||||
|
||||
self->first_weekday = get_first_weekday ();
|
||||
|
||||
self->navigator_grid = g_new0 (GridData, 1);
|
||||
self->selected_data = g_new0 (ButtonData, 1);
|
||||
|
||||
@@ -2096,10 +2098,3 @@ update_weather (GcalYearView *self)
|
||||
}
|
||||
}
|
||||
|
||||
/* Public API */
|
||||
void
|
||||
gcal_year_view_set_first_weekday (GcalYearView *year_view,
|
||||
gint nr_day)
|
||||
{
|
||||
year_view->first_weekday = nr_day;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GcalYearView, gcal_year_view, GCAL, YEAR_VIEW, GtkBox)
|
||||
|
||||
void gcal_year_view_set_first_weekday (GcalYearView *year_view,
|
||||
gint nr_day);
|
||||
|
||||
void gcal_year_view_set_current_date (GcalYearView *year_view,
|
||||
icaltimetype *current_date);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user