New function to mark the current day in the year view.
1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx> * year-view.c (mark_current_day): New function to mark the current day in the year view. * mark.c: Removed mark_current_day from here. svn path=/trunk/; revision=418
This commit is contained in:

committed by
Arturo Espinosa

parent
63d572bcbc
commit
d1769d5646
@ -1,3 +1,10 @@
|
|||||||
|
1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
* year-view.c (mark_current_day): New function to mark the current
|
||||||
|
day in the year view.
|
||||||
|
|
||||||
|
* mark.c: Removed mark_current_day from here.
|
||||||
|
|
||||||
1998-09-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
1998-09-29 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||||
|
|
||||||
* prop.c (fetch_color_spec): Changed name from fetch_prelight_spec
|
* prop.c (fetch_color_spec): Changed name from fetch_prelight_spec
|
||||||
|
@ -100,27 +100,6 @@ mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
mark_current_day (GnomeMonthItem *mitem)
|
|
||||||
{
|
|
||||||
struct tm *tm;
|
|
||||||
time_t t;
|
|
||||||
int day_index;
|
|
||||||
GnomeCanvasItem *item;
|
|
||||||
|
|
||||||
t = time (NULL);
|
|
||||||
tm = localtime (&t);
|
|
||||||
|
|
||||||
if (((tm->tm_year + 1900) == mitem->year) && (tm->tm_mon == mitem->month)) {
|
|
||||||
day_index = gnome_month_item_day2index (mitem, tm->tm_mday);
|
|
||||||
item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
|
||||||
gnome_canvas_item_set (item,
|
|
||||||
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
|
|
||||||
"font", CURRENT_DAY_FONT,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
|
mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
|
||||||
{
|
{
|
||||||
|
@ -479,6 +479,7 @@ year_view_init (YearView *yv)
|
|||||||
|
|
||||||
/* We will need to resize the items when we paint for the first time */
|
/* We will need to resize the items when we paint for the first time */
|
||||||
|
|
||||||
|
yv->old_marked_day = -1;
|
||||||
yv->idle_id = -1;
|
yv->idle_id = -1;
|
||||||
need_resize (yv);
|
need_resize (yv);
|
||||||
}
|
}
|
||||||
@ -568,6 +569,52 @@ year_view_update (YearView *yv, iCalObject *object, int flags)
|
|||||||
year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
|
year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unmarks the old day that was marked as current and marks the current day */
|
||||||
|
static void
|
||||||
|
mark_current_day (YearView *yv)
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
struct tm *tm;
|
||||||
|
int month_index, day_index;
|
||||||
|
GnomeCanvasItem *item;
|
||||||
|
|
||||||
|
/* Unmark the old day */
|
||||||
|
|
||||||
|
if (yv->old_marked_day != -1) {
|
||||||
|
month_index = yv->old_marked_day / 42;
|
||||||
|
day_index = yv->old_marked_day % 42;
|
||||||
|
|
||||||
|
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
|
||||||
|
GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
||||||
|
gnome_canvas_item_set (item,
|
||||||
|
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
|
||||||
|
"font", NORMAL_DAY_FONT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
yv->old_marked_day = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark the new day */
|
||||||
|
|
||||||
|
t = time (NULL);
|
||||||
|
tm = localtime (&t);
|
||||||
|
|
||||||
|
if ((tm->tm_year + 1900) == yv->year) {
|
||||||
|
month_index = tm->tm_mon;
|
||||||
|
day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm->tm_mday);
|
||||||
|
g_assert (day_index != -1);
|
||||||
|
|
||||||
|
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
|
||||||
|
GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
||||||
|
gnome_canvas_item_set (item,
|
||||||
|
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
|
||||||
|
"font", CURRENT_DAY_FONT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
yv->old_marked_day = month_index * 42 + day_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
year_view_set (YearView *yv, time_t year)
|
year_view_set (YearView *yv, time_t year)
|
||||||
{
|
{
|
||||||
@ -602,6 +649,8 @@ year_view_set (YearView *yv, time_t year)
|
|||||||
unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
|
unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
|
||||||
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark_current_day (yv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -628,9 +677,10 @@ year_view_colors_changed (YearView *yv)
|
|||||||
g_return_if_fail (yv != NULL);
|
g_return_if_fail (yv != NULL);
|
||||||
g_return_if_fail (IS_YEAR_VIEW (yv));
|
g_return_if_fail (IS_YEAR_VIEW (yv));
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
|
colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
|
||||||
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark_current_day (yv);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ struct _YearView {
|
|||||||
GnomeCanvasItem *titles[12]; /* Titles for months */
|
GnomeCanvasItem *titles[12]; /* Titles for months */
|
||||||
GnomeCanvasItem *mitems[12]; /* Month items */
|
GnomeCanvasItem *mitems[12]; /* Month items */
|
||||||
|
|
||||||
|
int old_marked_day; /* The day that is marked as the current day */
|
||||||
|
|
||||||
guint idle_id; /* ID of idle handler for resize */
|
guint idle_id; /* ID of idle handler for resize */
|
||||||
|
|
||||||
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
|
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
|
||||||
|
@ -100,27 +100,6 @@ mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
mark_current_day (GnomeMonthItem *mitem)
|
|
||||||
{
|
|
||||||
struct tm *tm;
|
|
||||||
time_t t;
|
|
||||||
int day_index;
|
|
||||||
GnomeCanvasItem *item;
|
|
||||||
|
|
||||||
t = time (NULL);
|
|
||||||
tm = localtime (&t);
|
|
||||||
|
|
||||||
if (((tm->tm_year + 1900) == mitem->year) && (tm->tm_mon == mitem->month)) {
|
|
||||||
day_index = gnome_month_item_day2index (mitem, tm->tm_mday);
|
|
||||||
item = gnome_month_item_num2child (mitem, GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
|
||||||
gnome_canvas_item_set (item,
|
|
||||||
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
|
|
||||||
"font", CURRENT_DAY_FONT,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
|
mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
|
||||||
{
|
{
|
||||||
|
@ -479,6 +479,7 @@ year_view_init (YearView *yv)
|
|||||||
|
|
||||||
/* We will need to resize the items when we paint for the first time */
|
/* We will need to resize the items when we paint for the first time */
|
||||||
|
|
||||||
|
yv->old_marked_day = -1;
|
||||||
yv->idle_id = -1;
|
yv->idle_id = -1;
|
||||||
need_resize (yv);
|
need_resize (yv);
|
||||||
}
|
}
|
||||||
@ -568,6 +569,52 @@ year_view_update (YearView *yv, iCalObject *object, int flags)
|
|||||||
year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
|
year_view_set (yv, time_year_begin (time_from_day (yv->year, 0, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unmarks the old day that was marked as current and marks the current day */
|
||||||
|
static void
|
||||||
|
mark_current_day (YearView *yv)
|
||||||
|
{
|
||||||
|
time_t t;
|
||||||
|
struct tm *tm;
|
||||||
|
int month_index, day_index;
|
||||||
|
GnomeCanvasItem *item;
|
||||||
|
|
||||||
|
/* Unmark the old day */
|
||||||
|
|
||||||
|
if (yv->old_marked_day != -1) {
|
||||||
|
month_index = yv->old_marked_day / 42;
|
||||||
|
day_index = yv->old_marked_day % 42;
|
||||||
|
|
||||||
|
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
|
||||||
|
GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
||||||
|
gnome_canvas_item_set (item,
|
||||||
|
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
|
||||||
|
"font", NORMAL_DAY_FONT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
yv->old_marked_day = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark the new day */
|
||||||
|
|
||||||
|
t = time (NULL);
|
||||||
|
tm = localtime (&t);
|
||||||
|
|
||||||
|
if ((tm->tm_year + 1900) == yv->year) {
|
||||||
|
month_index = tm->tm_mon;
|
||||||
|
day_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (yv->mitems[month_index]), tm->tm_mday);
|
||||||
|
g_assert (day_index != -1);
|
||||||
|
|
||||||
|
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (yv->mitems[month_index]),
|
||||||
|
GNOME_MONTH_ITEM_DAY_LABEL + day_index);
|
||||||
|
gnome_canvas_item_set (item,
|
||||||
|
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
|
||||||
|
"font", CURRENT_DAY_FONT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
yv->old_marked_day = month_index * 42 + day_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
year_view_set (YearView *yv, time_t year)
|
year_view_set (YearView *yv, time_t year)
|
||||||
{
|
{
|
||||||
@ -602,6 +649,8 @@ year_view_set (YearView *yv, time_t year)
|
|||||||
unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
|
unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
|
||||||
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark_current_day (yv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -628,9 +677,10 @@ year_view_colors_changed (YearView *yv)
|
|||||||
g_return_if_fail (yv != NULL);
|
g_return_if_fail (yv != NULL);
|
||||||
g_return_if_fail (IS_YEAR_VIEW (yv));
|
g_return_if_fail (IS_YEAR_VIEW (yv));
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
|
colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
|
||||||
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark_current_day (yv);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ struct _YearView {
|
|||||||
GnomeCanvasItem *titles[12]; /* Titles for months */
|
GnomeCanvasItem *titles[12]; /* Titles for months */
|
||||||
GnomeCanvasItem *mitems[12]; /* Month items */
|
GnomeCanvasItem *mitems[12]; /* Month items */
|
||||||
|
|
||||||
|
int old_marked_day; /* The day that is marked as the current day */
|
||||||
|
|
||||||
guint idle_id; /* ID of idle handler for resize */
|
guint idle_id; /* ID of idle handler for resize */
|
||||||
|
|
||||||
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
|
int need_resize : 1; /* Specifies whether we need to resize the canvas items or not */
|
||||||
|
Reference in New Issue
Block a user