Use the font #defines. (month_view_new): Set the colors of the month view

1998-10-01  Federico Mena Quintero  <federico@nuclecu.unam.mx>

	* month-view.c (month_view_init): Use the font #defines.
	(month_view_new): Set the colors of the month view upon creation.
	(mark_current_day): New function to mark the current day in the
	month view.
	(month_view_set): Mark the current day.
	(month_view_colors_changed): Mark the current day and colorify the
	month item appropriately.

	* month-view.h: Added year and month fields to the MonthView
	structure.

	* main.c: Renamed the Appointments color property, since it will
	be used by the month view as well.

	* goto.c (update): Set the current day's font and color.

	* year-view.c (year_view_init): Set the fonts of the month items
	when creating them.

	* mark.h: Added new #defines for HEADING_FONT and TITLE_FONT.

	* year-view.c (year_view_init): Use the new font #defines.

	* prop.c (prop_apply_colors): Fixed to work with the
	I-am-paranoid-and-I-need-to-size-my-ints changes to
	GnomeColorPicker.
	(color_spec_from_picker): Likewise.

svn path=/trunk/; revision=424
This commit is contained in:
Federico Mena Quintero
1998-10-01 23:47:01 +00:00
committed by Arturo Espinosa
parent e94162c0a4
commit e9a632c3c1
17 changed files with 298 additions and 74 deletions

View File

@ -1,3 +1,33 @@
1998-10-01 Federico Mena Quintero <federico@nuclecu.unam.mx>
* month-view.c (month_view_init): Use the font #defines.
(month_view_new): Set the colors of the month view upon creation.
(mark_current_day): New function to mark the current day in the
month view.
(month_view_set): Mark the current day.
(month_view_colors_changed): Mark the current day and colorify the
month item appropriately.
* month-view.h: Added year and month fields to the MonthView
structure.
* main.c: Renamed the Appointments color property, since it will
be used by the month view as well.
* goto.c (update): Set the current day's font and color.
* year-view.c (year_view_init): Set the fonts of the month items
when creating them.
* mark.h: Added new #defines for HEADING_FONT and TITLE_FONT.
* year-view.c (year_view_init): Use the new font #defines.
* prop.c (prop_apply_colors): Fixed to work with the
I-am-paranoid-and-I-need-to-size-my-ints changes to
GnomeColorPicker.
(color_spec_from_picker): Likewise.
1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx> 1998-09-30 Federico Mena Quintero <federico@nuclecu.unam.mx>
* goto.c (create_days): Colorify the month item and prepare it for * goto.c (create_days): Colorify the month item and prepare it for

View File

@ -12,6 +12,7 @@
#include "gnome-month-item.h" #include "gnome-month-item.h"
#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
/* Number of days in a month, for normal and leap years */ /* Number of days in a month, for normal and leap years */
@ -767,13 +768,13 @@ gnome_month_item_init (GnomeMonthItem *mitem)
/* Load the default fonts */ /* Load the default fonts */
mitem->head_font = gdk_font_load ("-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1"); mitem->head_font = gdk_font_load (DEFAULT_FONT);
if (!mitem->head_font) { if (!mitem->head_font) {
mitem->head_font = gdk_font_load ("fixed"); mitem->head_font = gdk_font_load ("fixed");
g_assert (mitem->head_font != NULL); g_assert (mitem->head_font != NULL);
} }
mitem->day_font = gdk_font_load ("-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1"); mitem->day_font = gdk_font_load (DEFAULT_FONT);
if (!mitem->day_font) { if (!mitem->day_font) {
mitem->day_font = gdk_font_load ("fixed"); mitem->day_font = gdk_font_load ("fixed");
g_assert (mitem->day_font != NULL); g_assert (mitem->day_font != NULL);

View File

@ -15,24 +15,55 @@
static GtkWidget *goto_win; /* The goto dialog window */ static GtkWidget *goto_win; /* The goto dialog window */
static GnomeCanvasItem *month_item; /* The month item in the dialog */ static GnomeMonthItem *month_item; /* The month item in the dialog */
static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */ static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */
static int current_index; /* The index of the day marked as current, or -1 if none */
/* Updates the specified month item by marking it appropriately from the calendar the dialog refers /* Updates the specified month item by marking it appropriately from the calendar the dialog refers
* to. */ * to. Also marks the current day if appropriate.
*/
static void static void
update (void) update (void)
{ {
unmark_month_item (GNOME_MONTH_ITEM (month_item)); GnomeCanvasItem *item;
mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal); time_t t;
struct tm *tm;
unmark_month_item (month_item);
mark_month_item (month_item, gnome_calendar->cal);
if (current_index != -1) {
item = gnome_month_item_num2child (month_item,
GNOME_MONTH_ITEM_DAY_LABEL + current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
"font", NORMAL_DAY_FONT,
NULL);
current_index = -1;
}
t = time (NULL);
tm = localtime (&t);
if (((tm->tm_year + 1900) == month_item->year) && (tm->tm_mon == month_item->month)) {
current_index = gnome_month_item_day2index (month_item, tm->tm_mday);
g_assert (current_index != -1);
item = gnome_month_item_num2child (month_item,
GNOME_MONTH_ITEM_DAY_LABEL + current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
"font", CURRENT_DAY_FONT,
NULL);
}
} }
/* Callback used when the year adjustment is changed */ /* Callback used when the year adjustment is changed */
static void static void
year_changed (GtkAdjustment *adj, gpointer data) year_changed (GtkAdjustment *adj, gpointer data)
{ {
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"year", (int) adj->value, "year", (int) adj->value,
NULL); NULL);
update (); update ();
@ -72,7 +103,7 @@ month_toggled (GtkToggleButton *toggle, gpointer data)
if (!toggle->active) if (!toggle->active)
return; return;
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", GPOINTER_TO_INT (data), "month", GPOINTER_TO_INT (data),
NULL); NULL);
update (); update ();
@ -130,7 +161,7 @@ create_months (int month)
static void static void
set_scroll_region (GtkWidget *widget, GtkAllocation *allocation) set_scroll_region (GtkWidget *widget, GtkAllocation *allocation)
{ {
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"width", (double) (allocation->width - 1), "width", (double) (allocation->width - 1),
"height", (double) (allocation->height - 1), "height", (double) (allocation->height - 1),
NULL); NULL);
@ -148,15 +179,14 @@ day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{ {
int child_num, day; int child_num, day;
child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (month_item), item); child_num = gnome_month_item_child2num (month_item, item);
day = gnome_month_item_num2day (GNOME_MONTH_ITEM (month_item), child_num); day = gnome_month_item_num2day (month_item, child_num);
switch (event->type) { switch (event->type) {
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
if ((event->button.button == 1) && (day != 0)) { if ((event->button.button == 1) && (day != 0)) {
gnome_calendar_goto (gnome_calendar, gnome_calendar_goto (gnome_calendar,
time_from_day (GNOME_MONTH_ITEM (month_item)->year, time_from_day (month_item->year, month_item->month, day));
GNOME_MONTH_ITEM (month_item)->month, day));
gtk_widget_destroy (goto_win); gtk_widget_destroy (goto_win);
} }
break; break;
@ -179,14 +209,14 @@ create_days (int day, int month, int year)
canvas = gnome_canvas_new (); canvas = gnome_canvas_new ();
gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120); gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))); month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", month, "month", month,
"year", year, "year", year,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
NULL); NULL);
colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL); colorify_month_item (month_item, default_color_func, NULL);
month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL); month_item_prepare_prelight (month_item, default_color_func, NULL);
update (); update ();
/* Connect to size_allocate so that we can change the size of the month item and the /* Connect to size_allocate so that we can change the size of the month item and the
@ -200,7 +230,7 @@ create_days (int day, int month, int year)
/* Bind the day groups to our event handler */ /* Bind the day groups to our event handler */
for (i = 0; i < 42; i++) { for (i = 0; i < 42; i++) {
day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), i + GNOME_MONTH_ITEM_DAY_GROUP); day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP);
gtk_signal_connect (GTK_OBJECT (day_group), "event", gtk_signal_connect (GTK_OBJECT (day_group), "event",
(GtkSignalFunc) day_event, (GtkSignalFunc) day_event,
NULL); NULL);
@ -227,6 +257,7 @@ goto_dialog (GnomeCalendar *gcal)
struct tm *tm; struct tm *tm;
gnome_calendar = gcal; gnome_calendar = gcal;
current_index = -1;
tm = localtime (&gnome_calendar->current_display); tm = localtime (&gnome_calendar->current_display);

View File

@ -12,6 +12,7 @@
#include "gnome-month-item.h" #include "gnome-month-item.h"
#define DEFAULT_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
/* Number of days in a month, for normal and leap years */ /* Number of days in a month, for normal and leap years */
@ -767,13 +768,13 @@ gnome_month_item_init (GnomeMonthItem *mitem)
/* Load the default fonts */ /* Load the default fonts */
mitem->head_font = gdk_font_load ("-*-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1"); mitem->head_font = gdk_font_load (DEFAULT_FONT);
if (!mitem->head_font) { if (!mitem->head_font) {
mitem->head_font = gdk_font_load ("fixed"); mitem->head_font = gdk_font_load ("fixed");
g_assert (mitem->head_font != NULL); g_assert (mitem->head_font != NULL);
} }
mitem->day_font = gdk_font_load ("-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1"); mitem->day_font = gdk_font_load (DEFAULT_FONT);
if (!mitem->day_font) { if (!mitem->day_font) {
mitem->day_font = gdk_font_load ("fixed"); mitem->day_font = gdk_font_load ("fixed");
g_assert (mitem->day_font != NULL); g_assert (mitem->day_font != NULL);

View File

@ -15,24 +15,55 @@
static GtkWidget *goto_win; /* The goto dialog window */ static GtkWidget *goto_win; /* The goto dialog window */
static GnomeCanvasItem *month_item; /* The month item in the dialog */ static GnomeMonthItem *month_item; /* The month item in the dialog */
static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */ static GnomeCalendar *gnome_calendar; /* The gnome calendar the dialog refers to */
static int current_index; /* The index of the day marked as current, or -1 if none */
/* Updates the specified month item by marking it appropriately from the calendar the dialog refers /* Updates the specified month item by marking it appropriately from the calendar the dialog refers
* to. */ * to. Also marks the current day if appropriate.
*/
static void static void
update (void) update (void)
{ {
unmark_month_item (GNOME_MONTH_ITEM (month_item)); GnomeCanvasItem *item;
mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal); time_t t;
struct tm *tm;
unmark_month_item (month_item);
mark_month_item (month_item, gnome_calendar->cal);
if (current_index != -1) {
item = gnome_month_item_num2child (month_item,
GNOME_MONTH_ITEM_DAY_LABEL + current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
"font", NORMAL_DAY_FONT,
NULL);
current_index = -1;
}
t = time (NULL);
tm = localtime (&t);
if (((tm->tm_year + 1900) == month_item->year) && (tm->tm_mon == month_item->month)) {
current_index = gnome_month_item_day2index (month_item, tm->tm_mday);
g_assert (current_index != -1);
item = gnome_month_item_num2child (month_item,
GNOME_MONTH_ITEM_DAY_LABEL + current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
"font", CURRENT_DAY_FONT,
NULL);
}
} }
/* Callback used when the year adjustment is changed */ /* Callback used when the year adjustment is changed */
static void static void
year_changed (GtkAdjustment *adj, gpointer data) year_changed (GtkAdjustment *adj, gpointer data)
{ {
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"year", (int) adj->value, "year", (int) adj->value,
NULL); NULL);
update (); update ();
@ -72,7 +103,7 @@ month_toggled (GtkToggleButton *toggle, gpointer data)
if (!toggle->active) if (!toggle->active)
return; return;
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", GPOINTER_TO_INT (data), "month", GPOINTER_TO_INT (data),
NULL); NULL);
update (); update ();
@ -130,7 +161,7 @@ create_months (int month)
static void static void
set_scroll_region (GtkWidget *widget, GtkAllocation *allocation) set_scroll_region (GtkWidget *widget, GtkAllocation *allocation)
{ {
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"width", (double) (allocation->width - 1), "width", (double) (allocation->width - 1),
"height", (double) (allocation->height - 1), "height", (double) (allocation->height - 1),
NULL); NULL);
@ -148,15 +179,14 @@ day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{ {
int child_num, day; int child_num, day;
child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (month_item), item); child_num = gnome_month_item_child2num (month_item, item);
day = gnome_month_item_num2day (GNOME_MONTH_ITEM (month_item), child_num); day = gnome_month_item_num2day (month_item, child_num);
switch (event->type) { switch (event->type) {
case GDK_BUTTON_PRESS: case GDK_BUTTON_PRESS:
if ((event->button.button == 1) && (day != 0)) { if ((event->button.button == 1) && (day != 0)) {
gnome_calendar_goto (gnome_calendar, gnome_calendar_goto (gnome_calendar,
time_from_day (GNOME_MONTH_ITEM (month_item)->year, time_from_day (month_item->year, month_item->month, day));
GNOME_MONTH_ITEM (month_item)->month, day));
gtk_widget_destroy (goto_win); gtk_widget_destroy (goto_win);
} }
break; break;
@ -179,14 +209,14 @@ create_days (int day, int month, int year)
canvas = gnome_canvas_new (); canvas = gnome_canvas_new ();
gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120); gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))); month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
gnome_canvas_item_set (month_item, gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", month, "month", month,
"year", year, "year", year,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
NULL); NULL);
colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL); colorify_month_item (month_item, default_color_func, NULL);
month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL); month_item_prepare_prelight (month_item, default_color_func, NULL);
update (); update ();
/* Connect to size_allocate so that we can change the size of the month item and the /* Connect to size_allocate so that we can change the size of the month item and the
@ -200,7 +230,7 @@ create_days (int day, int month, int year)
/* Bind the day groups to our event handler */ /* Bind the day groups to our event handler */
for (i = 0; i < 42; i++) { for (i = 0; i < 42; i++) {
day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (month_item), i + GNOME_MONTH_ITEM_DAY_GROUP); day_group = gnome_month_item_num2child (month_item, i + GNOME_MONTH_ITEM_DAY_GROUP);
gtk_signal_connect (GTK_OBJECT (day_group), "event", gtk_signal_connect (GTK_OBJECT (day_group), "event",
(GtkSignalFunc) day_event, (GtkSignalFunc) day_event,
NULL); NULL);
@ -227,6 +257,7 @@ goto_dialog (GnomeCalendar *gcal)
struct tm *tm; struct tm *tm;
gnome_calendar = gcal; gnome_calendar = gcal;
current_index = -1;
tm = localtime (&gnome_calendar->current_display); tm = localtime (&gnome_calendar->current_display);

View File

@ -49,7 +49,7 @@ struct color_prop color_props[] = {
{ 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" }, { 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" }, { 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
{ 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" }, { 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" },
{ 0xfc1e, 0xf87f, 0x5f80, "Appointment days:", "/calendar/Colors/mark_bg" }, { 0xfc1e, 0xf87f, 0x5f80, "Appointments:", "/calendar/Colors/mark_bg" },
{ 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" }, { 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" },
{ 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" }, { 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" } { 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }

View File

@ -14,8 +14,14 @@
/* These are the fonts used for the montly calendars */ /* These are the fonts used for the montly calendars */
#define NORMAL_DAY_FONT "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1" #define HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
#define CURRENT_DAY_FONT "-adobe-helvetica-bold-r-normal--12-*-72-72-p-*-iso8859-1" #define TITLE_FONT "-*-helvetica-bold-r-normal--12-*-*-*-p-*-*-*"
#define DAY_HEADING_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
#define NORMAL_DAY_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
#define CURRENT_DAY_FONT "-*-helvetica-bold-r-normal--12-*-*-*-p-*-*-*"
#define BIG_DAY_HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
#define BIG_NORMAL_DAY_FONT "-*-helvetica-medium-r-normal--14-*-*-*-p-*-*-*"
#define BIG_CURRENT_DAY_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
/* Functions of this type are used by the marking functions to fetch color specifications. Such /* Functions of this type are used by the marking functions to fetch color specifications. Such

View File

@ -10,6 +10,7 @@
#include "month-view.h" #include "month-view.h"
#include "main.h" #include "main.h"
#include "mark.h" #include "mark.h"
#include "timeutil.h"
#define SPACING 4 /* Spacing between title and calendar */ #define SPACING 4 /* Spacing between title and calendar */
@ -70,7 +71,7 @@ month_view_init (MonthView *mv)
mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)), mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)),
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1", "font", HEADING_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -82,10 +83,12 @@ month_view_init (MonthView *mv)
"anchor", GTK_ANCHOR_NW, "anchor", GTK_ANCHOR_NW,
"day_anchor", GTK_ANCHOR_NE, "day_anchor", GTK_ANCHOR_NE,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
"heading_height", 18.0, "heading_padding", 2.0,
"heading_font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1", "heading_font", BIG_DAY_HEADING_FONT,
"day_font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1", "day_font", BIG_NORMAL_DAY_FONT,
NULL); NULL);
mv->old_current_index = -1;
} }
GtkWidget * GtkWidget *
@ -99,6 +102,7 @@ month_view_new (GnomeCalendar *calendar, time_t month)
mv = gtk_type_new (month_view_get_type ()); mv = gtk_type_new (month_view_get_type ());
mv->calendar = calendar; mv->calendar = calendar;
month_view_colors_changed (mv);
month_view_set (mv, month); month_view_set (mv, month);
return GTK_WIDGET (mv); return GTK_WIDGET (mv);
} }
@ -166,6 +170,45 @@ month_view_update (MonthView *mv, iCalObject *object, int flags)
/* FIXME */ /* FIXME */
} }
/* Unmarks the old day that was marked as current and marks the current day if appropriate */
static void
mark_current_day (MonthView *mv)
{
time_t t;
struct tm *tm;
GnomeCanvasItem *item;
/* Unmark the old day */
if (mv->old_current_index != -1) {
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
"font", BIG_NORMAL_DAY_FONT,
NULL);
mv->old_current_index = -1;
}
/* Mark the new day */
t = time (NULL);
tm = localtime (&t);
if (((tm->tm_year + 1900) == mv->year) && (tm->tm_mon == mv->month)) {
mv->old_current_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), tm->tm_mday);
g_assert (mv->old_current_index != -1);
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
"font", BIG_CURRENT_DAY_FONT,
NULL);
}
}
void void
month_view_set (MonthView *mv, time_t month) month_view_set (MonthView *mv, time_t month)
{ {
@ -178,6 +221,10 @@ month_view_set (MonthView *mv, time_t month)
/* Title */ /* Title */
tm = localtime (&month); tm = localtime (&month);
mv->year = tm->tm_year + 1900;
mv->month = tm->tm_mon;
strftime (buf, 100, "%B %Y", tm); strftime (buf, 100, "%B %Y", tm);
gnome_canvas_item_set (mv->title, gnome_canvas_item_set (mv->title,
@ -187,11 +234,13 @@ month_view_set (MonthView *mv, time_t month)
/* Month item */ /* Month item */
gnome_canvas_item_set (mv->mitem, gnome_canvas_item_set (mv->mitem,
"year", tm->tm_year + 1900, "year", mv->year,
"month", tm->tm_mon, "month", mv->month,
NULL); NULL);
/* FIXME: update events */ /* FIXME: update events */
mark_current_day (mv);
} }
void void
@ -204,7 +253,7 @@ month_view_time_format_changed (MonthView *mv)
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
NULL); NULL);
/* FIXME: update events */ month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
} }
void void
@ -213,6 +262,6 @@ month_view_colors_changed (MonthView *mv)
g_return_if_fail (mv != NULL); g_return_if_fail (mv != NULL);
g_return_if_fail (IS_MONTH_VIEW (mv)); g_return_if_fail (IS_MONTH_VIEW (mv));
unmark_month_item (GNOME_MONTH_ITEM (mv->mitem)); colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
/* FIXME */ mark_current_day (mv);
} }

View File

@ -31,6 +31,11 @@ struct _MonthView {
GnomeCalendar *calendar; /* The calendar we are associated to */ GnomeCalendar *calendar; /* The calendar we are associated to */
int year; /* The year of the month we are displaying */
int month; /* The month we are displaying */
int old_current_index; /* The index of the day marked as current, or -1 if none */
GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *title; /* The title heading with the month/year */
GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
}; };

View File

@ -87,11 +87,14 @@ prop_apply_colors (void)
{ {
int i; int i;
char *cspec; char *cspec;
gushort r, g, b;
for (i = 0; i < COLOR_PROP_LAST; i++) { for (i = 0; i < COLOR_PROP_LAST; i++) {
gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL);
&color_props[i].r, &color_props[i].g, &color_props[i].b, NULL); color_props[i].r = r;
color_props[i].g = g;
color_props[i].b = b;
cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
gnome_config_set_string (color_props[i].key, cspec); gnome_config_set_string (color_props[i].key, cspec);
} }
@ -338,7 +341,7 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer dat
static char * static char *
color_spec_from_picker (int num) color_spec_from_picker (int num)
{ {
int r, g, b; gushort r, g, b;
gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL); gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL);

View File

@ -522,7 +522,7 @@ year_view_init (YearView *yv)
yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)), yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1", "font", HEADING_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -538,7 +538,7 @@ year_view_init (YearView *yv)
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"text", buf, "text", buf,
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1", "font", TITLE_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -548,6 +548,8 @@ year_view_init (YearView *yv)
gnome_canvas_item_set (yv->mitems[i], gnome_canvas_item_set (yv->mitems[i],
"anchor", GTK_ANCHOR_NW, "anchor", GTK_ANCHOR_NW,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
"heading_font", DAY_HEADING_FONT,
"day_font", NORMAL_DAY_FONT,
NULL); NULL);
setup_month_item (yv, i); setup_month_item (yv, i);
} }
@ -642,7 +644,7 @@ 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 */ /* Unmarks the old day that was marked as current and marks the current day if appropriate */
static void static void
mark_current_day (YearView *yv) mark_current_day (YearView *yv)
{ {

View File

@ -49,7 +49,7 @@ struct color_prop color_props[] = {
{ 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" }, { 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" }, { 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
{ 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" }, { 0xf26c, 0xecec, 0xbbe7, "Empty days:", "/calendar/Colors/empty_bg" },
{ 0xfc1e, 0xf87f, 0x5f80, "Appointment days:", "/calendar/Colors/mark_bg" }, { 0xfc1e, 0xf87f, 0x5f80, "Appointments:", "/calendar/Colors/mark_bg" },
{ 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" }, { 0xd364, 0xc6b7, 0x7969, "Highlighted day:", "/calendar/Colors/prelight_bg" },
{ 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" }, { 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" } { 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }

View File

@ -14,8 +14,14 @@
/* These are the fonts used for the montly calendars */ /* These are the fonts used for the montly calendars */
#define NORMAL_DAY_FONT "-adobe-helvetica-medium-r-normal--10-*-72-72-p-*-iso8859-1" #define HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
#define CURRENT_DAY_FONT "-adobe-helvetica-bold-r-normal--12-*-72-72-p-*-iso8859-1" #define TITLE_FONT "-*-helvetica-bold-r-normal--12-*-*-*-p-*-*-*"
#define DAY_HEADING_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
#define NORMAL_DAY_FONT "-*-helvetica-medium-r-normal--10-*-*-*-p-*-*-*"
#define CURRENT_DAY_FONT "-*-helvetica-bold-r-normal--12-*-*-*-p-*-*-*"
#define BIG_DAY_HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
#define BIG_NORMAL_DAY_FONT "-*-helvetica-medium-r-normal--14-*-*-*-p-*-*-*"
#define BIG_CURRENT_DAY_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
/* Functions of this type are used by the marking functions to fetch color specifications. Such /* Functions of this type are used by the marking functions to fetch color specifications. Such

View File

@ -10,6 +10,7 @@
#include "month-view.h" #include "month-view.h"
#include "main.h" #include "main.h"
#include "mark.h" #include "mark.h"
#include "timeutil.h"
#define SPACING 4 /* Spacing between title and calendar */ #define SPACING 4 /* Spacing between title and calendar */
@ -70,7 +71,7 @@ month_view_init (MonthView *mv)
mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)), mv->title = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (mv)),
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1", "font", HEADING_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -82,10 +83,12 @@ month_view_init (MonthView *mv)
"anchor", GTK_ANCHOR_NW, "anchor", GTK_ANCHOR_NW,
"day_anchor", GTK_ANCHOR_NE, "day_anchor", GTK_ANCHOR_NE,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
"heading_height", 18.0, "heading_padding", 2.0,
"heading_font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1", "heading_font", BIG_DAY_HEADING_FONT,
"day_font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1", "day_font", BIG_NORMAL_DAY_FONT,
NULL); NULL);
mv->old_current_index = -1;
} }
GtkWidget * GtkWidget *
@ -99,6 +102,7 @@ month_view_new (GnomeCalendar *calendar, time_t month)
mv = gtk_type_new (month_view_get_type ()); mv = gtk_type_new (month_view_get_type ());
mv->calendar = calendar; mv->calendar = calendar;
month_view_colors_changed (mv);
month_view_set (mv, month); month_view_set (mv, month);
return GTK_WIDGET (mv); return GTK_WIDGET (mv);
} }
@ -166,6 +170,45 @@ month_view_update (MonthView *mv, iCalObject *object, int flags)
/* FIXME */ /* FIXME */
} }
/* Unmarks the old day that was marked as current and marks the current day if appropriate */
static void
mark_current_day (MonthView *mv)
{
time_t t;
struct tm *tm;
GnomeCanvasItem *item;
/* Unmark the old day */
if (mv->old_current_index != -1) {
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_DAY_FG),
"font", BIG_NORMAL_DAY_FONT,
NULL);
mv->old_current_index = -1;
}
/* Mark the new day */
t = time (NULL);
tm = localtime (&t);
if (((tm->tm_year + 1900) == mv->year) && (tm->tm_mon == mv->month)) {
mv->old_current_index = gnome_month_item_day2index (GNOME_MONTH_ITEM (mv->mitem), tm->tm_mday);
g_assert (mv->old_current_index != -1);
item = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem),
GNOME_MONTH_ITEM_DAY_LABEL + mv->old_current_index);
gnome_canvas_item_set (item,
"fill_color", color_spec_from_prop (COLOR_PROP_CURRENT_DAY_FG),
"font", BIG_CURRENT_DAY_FONT,
NULL);
}
}
void void
month_view_set (MonthView *mv, time_t month) month_view_set (MonthView *mv, time_t month)
{ {
@ -178,6 +221,10 @@ month_view_set (MonthView *mv, time_t month)
/* Title */ /* Title */
tm = localtime (&month); tm = localtime (&month);
mv->year = tm->tm_year + 1900;
mv->month = tm->tm_mon;
strftime (buf, 100, "%B %Y", tm); strftime (buf, 100, "%B %Y", tm);
gnome_canvas_item_set (mv->title, gnome_canvas_item_set (mv->title,
@ -187,11 +234,13 @@ month_view_set (MonthView *mv, time_t month)
/* Month item */ /* Month item */
gnome_canvas_item_set (mv->mitem, gnome_canvas_item_set (mv->mitem,
"year", tm->tm_year + 1900, "year", mv->year,
"month", tm->tm_mon, "month", mv->month,
NULL); NULL);
/* FIXME: update events */ /* FIXME: update events */
mark_current_day (mv);
} }
void void
@ -204,7 +253,7 @@ month_view_time_format_changed (MonthView *mv)
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
NULL); NULL);
/* FIXME: update events */ month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
} }
void void
@ -213,6 +262,6 @@ month_view_colors_changed (MonthView *mv)
g_return_if_fail (mv != NULL); g_return_if_fail (mv != NULL);
g_return_if_fail (IS_MONTH_VIEW (mv)); g_return_if_fail (IS_MONTH_VIEW (mv));
unmark_month_item (GNOME_MONTH_ITEM (mv->mitem)); colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
/* FIXME */ mark_current_day (mv);
} }

View File

@ -31,6 +31,11 @@ struct _MonthView {
GnomeCalendar *calendar; /* The calendar we are associated to */ GnomeCalendar *calendar; /* The calendar we are associated to */
int year; /* The year of the month we are displaying */
int month; /* The month we are displaying */
int old_current_index; /* The index of the day marked as current, or -1 if none */
GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *title; /* The title heading with the month/year */
GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */
}; };

View File

@ -87,11 +87,14 @@ prop_apply_colors (void)
{ {
int i; int i;
char *cspec; char *cspec;
gushort r, g, b;
for (i = 0; i < COLOR_PROP_LAST; i++) { for (i = 0; i < COLOR_PROP_LAST; i++) {
gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &b, NULL);
&color_props[i].r, &color_props[i].g, &color_props[i].b, NULL); color_props[i].r = r;
color_props[i].g = g;
color_props[i].b = b;
cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b); cspec = build_color_spec (color_props[i].r, color_props[i].g, color_props[i].b);
gnome_config_set_string (color_props[i].key, cspec); gnome_config_set_string (color_props[i].key, cspec);
} }
@ -338,7 +341,7 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer dat
static char * static char *
color_spec_from_picker (int num) color_spec_from_picker (int num)
{ {
int r, g, b; gushort r, g, b;
gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL); gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[num]), &r, &g, &b, NULL);

View File

@ -522,7 +522,7 @@ year_view_init (YearView *yv)
yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)), yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1", "font", HEADING_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -538,7 +538,7 @@ year_view_init (YearView *yv)
gnome_canvas_text_get_type (), gnome_canvas_text_get_type (),
"text", buf, "text", buf,
"anchor", GTK_ANCHOR_N, "anchor", GTK_ANCHOR_N,
"font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1", "font", TITLE_FONT,
"fill_color", "black", "fill_color", "black",
NULL); NULL);
@ -548,6 +548,8 @@ year_view_init (YearView *yv)
gnome_canvas_item_set (yv->mitems[i], gnome_canvas_item_set (yv->mitems[i],
"anchor", GTK_ANCHOR_NW, "anchor", GTK_ANCHOR_NW,
"start_on_monday", week_starts_on_monday, "start_on_monday", week_starts_on_monday,
"heading_font", DAY_HEADING_FONT,
"day_font", NORMAL_DAY_FONT,
NULL); NULL);
setup_month_item (yv, i); setup_month_item (yv, i);
} }
@ -642,7 +644,7 @@ 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 */ /* Unmarks the old day that was marked as current and marks the current day if appropriate */
static void static void
mark_current_day (YearView *yv) mark_current_day (YearView *yv)
{ {