week-header, week-grid: remove duplicate code
This commit is contained in:
@@ -524,6 +524,43 @@ icaltime_compare_with_current (const icaltimetype *date1,
|
||||
return result;
|
||||
}
|
||||
|
||||
GDateTime*
|
||||
get_start_of_week (icaltimetype *date)
|
||||
{
|
||||
icaltimetype *new_date;
|
||||
GDateTime *dt;
|
||||
|
||||
new_date = g_new0 (icaltimetype, 1);
|
||||
*new_date = icaltime_from_day_of_year (icaltime_start_doy_week (*date, get_first_weekday () + 1),
|
||||
date->year);
|
||||
new_date->is_date = 0;
|
||||
new_date->hour = 0;
|
||||
new_date->minute = 0;
|
||||
new_date->second = 0;
|
||||
|
||||
dt = g_date_time_new_local (new_date->year,
|
||||
new_date->month,
|
||||
new_date->day,
|
||||
0, 0, 0);
|
||||
|
||||
g_clear_pointer (&new_date, g_free);
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
GDateTime*
|
||||
get_end_of_week (icaltimetype *date)
|
||||
{
|
||||
GDateTime *week_start, *week_end;
|
||||
|
||||
week_start = get_start_of_week (date);
|
||||
week_end = g_date_time_add_days (week_start, 7);
|
||||
|
||||
g_clear_pointer (&week_start, g_date_time_unref);
|
||||
|
||||
return week_end;
|
||||
}
|
||||
|
||||
/* Function to do a last minute fixup of the AM/PM stuff if the locale
|
||||
* and gettext haven't done it right. Most English speaking countries
|
||||
* except the USA use the 24 hour clock (UK, Australia etc). However
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
|
||||
#define ICAL_TIME_TYPE (icaltime_get_type ())
|
||||
|
||||
#define ALIGNED(x) (round (x) + 0.5)
|
||||
#define MINUTES_PER_DAY 1440
|
||||
#define MAX_MINUTES (7 * MINUTES_PER_DAY)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GCAL_WINDOW_VIEW_DAY,
|
||||
@@ -95,6 +99,10 @@ gint icaltime_compare_with_current (const icaltimet
|
||||
const icaltimetype *date2,
|
||||
time_t *current_time_t);
|
||||
|
||||
GDateTime* get_start_of_week (icaltimetype *date);
|
||||
|
||||
GDateTime* get_end_of_week (icaltimetype *date);
|
||||
|
||||
/* code brought from evolution */
|
||||
gsize e_strftime_fix_am_pm (gchar *str,
|
||||
gsize max,
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define ALIGNED(x) (round (x) + 0.5)
|
||||
#define MINUTES_PER_DAY 1440
|
||||
#define MAX_MINUTES (7 * MINUTES_PER_DAY)
|
||||
|
||||
static const double dashed [] =
|
||||
{
|
||||
5.0,
|
||||
@@ -125,30 +121,6 @@ destroy_event_widget (GcalWeekGrid *self,
|
||||
}
|
||||
|
||||
/* Auxiliary methods */
|
||||
static GDateTime*
|
||||
get_start_of_week (icaltimetype *date)
|
||||
{
|
||||
icaltimetype *new_date;
|
||||
GDateTime *dt;
|
||||
|
||||
new_date = g_new0 (icaltimetype, 1);
|
||||
*new_date = icaltime_from_day_of_year (icaltime_start_doy_week (*date, get_first_weekday () + 1),
|
||||
date->year);
|
||||
new_date->is_date = 0;
|
||||
new_date->hour = 0;
|
||||
new_date->minute = 0;
|
||||
new_date->second = 0;
|
||||
|
||||
dt = g_date_time_new_local (new_date->year,
|
||||
new_date->month,
|
||||
new_date->day,
|
||||
0, 0, 0);
|
||||
|
||||
g_clear_pointer (&new_date, g_free);
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
static void
|
||||
get_event_range (GcalWeekGrid *self,
|
||||
GcalEvent *event,
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define ALIGNED(x) (round (x) + 0.5)
|
||||
#define COLUMN_PADDING 6
|
||||
|
||||
struct _GcalWeekHeader
|
||||
@@ -161,43 +160,6 @@ get_event_by_uuid (GcalWeekHeader *self,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
get_start_of_week (icaltimetype *date)
|
||||
{
|
||||
icaltimetype *new_date;
|
||||
GDateTime *dt;
|
||||
|
||||
new_date = g_new0 (icaltimetype, 1);
|
||||
*new_date = icaltime_from_day_of_year (icaltime_start_doy_week (*date, get_first_weekday () + 1),
|
||||
date->year);
|
||||
new_date->is_date = 0;
|
||||
new_date->hour = 0;
|
||||
new_date->minute = 0;
|
||||
new_date->second = 0;
|
||||
|
||||
dt = g_date_time_new_local (new_date->year,
|
||||
new_date->month,
|
||||
new_date->day,
|
||||
0, 0, 0);
|
||||
|
||||
g_clear_pointer (&new_date, g_free);
|
||||
|
||||
return dt;
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
get_end_of_week (icaltimetype *date)
|
||||
{
|
||||
GDateTime *week_start, *week_end;
|
||||
|
||||
week_start = get_start_of_week (date);
|
||||
week_end = g_date_time_add_days (week_start, 7);
|
||||
|
||||
g_clear_pointer (&week_start, g_date_time_unref);
|
||||
|
||||
return week_end;
|
||||
}
|
||||
|
||||
static inline gint
|
||||
get_today_column (GcalWeekHeader *self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user