aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@nuclecu.unam.mx>1998-10-02 07:47:01 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-10-02 07:47:01 +0800
commite9a632c3c15bac86946af5f6d75a79517b4c6a07 (patch)
tree76b462c8b3b8304c727788a314b8c65c46b284c7
parente94162c0a48defcaa3869dc9b82638170a62bab2 (diff)
downloadgsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar.gz
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar.bz2
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar.lz
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar.xz
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.tar.zst
gsoc2013-evolution-e9a632c3c15bac86946af5f6d75a79517b4c6a07.zip
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
-rw-r--r--calendar/ChangeLog30
-rw-r--r--calendar/gnome-month-item.c5
-rw-r--r--calendar/goto.c63
-rw-r--r--calendar/gui/gnome-month-item.c5
-rw-r--r--calendar/gui/goto.c63
-rw-r--r--calendar/gui/main.c2
-rw-r--r--calendar/gui/mark.h10
-rw-r--r--calendar/gui/month-view.c67
-rw-r--r--calendar/gui/month-view.h5
-rw-r--r--calendar/gui/prop.c11
-rw-r--r--calendar/gui/year-view.c8
-rw-r--r--calendar/main.c2
-rw-r--r--calendar/mark.h10
-rw-r--r--calendar/month-view.c67
-rw-r--r--calendar/month-view.h5
-rw-r--r--calendar/prop.c11
-rw-r--r--calendar/year-view.c8
17 files changed, 298 insertions, 74 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 23fcfcc68c..690276863f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -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>
* goto.c (create_days): Colorify the month item and prepare it for
diff --git a/calendar/gnome-month-item.c b/calendar/gnome-month-item.c
index fa1ea79e48..1eb8412f5c 100644
--- a/calendar/gnome-month-item.c
+++ b/calendar/gnome-month-item.c
@@ -12,6 +12,7 @@
#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 */
@@ -767,13 +768,13 @@ gnome_month_item_init (GnomeMonthItem *mitem)
/* 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) {
mitem->head_font = gdk_font_load ("fixed");
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) {
mitem->day_font = gdk_font_load ("fixed");
g_assert (mitem->day_font != NULL);
diff --git a/calendar/goto.c b/calendar/goto.c
index bbc489ddee..b645f02b6b 100644
--- a/calendar/goto.c
+++ b/calendar/goto.c
@@ -15,24 +15,55 @@
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 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
- * to. */
+ * to. Also marks the current day if appropriate.
+ */
static void
update (void)
{
- unmark_month_item (GNOME_MONTH_ITEM (month_item));
- mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal);
+ GnomeCanvasItem *item;
+ 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 */
static void
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,
NULL);
update ();
@@ -72,7 +103,7 @@ month_toggled (GtkToggleButton *toggle, gpointer data)
if (!toggle->active)
return;
- gnome_canvas_item_set (month_item,
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", GPOINTER_TO_INT (data),
NULL);
update ();
@@ -130,7 +161,7 @@ create_months (int month)
static void
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),
"height", (double) (allocation->height - 1),
NULL);
@@ -148,15 +179,14 @@ day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
int child_num, day;
- child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (month_item), item);
- day = gnome_month_item_num2day (GNOME_MONTH_ITEM (month_item), child_num);
+ child_num = gnome_month_item_child2num (month_item, item);
+ day = gnome_month_item_num2day (month_item, child_num);
switch (event->type) {
case GDK_BUTTON_PRESS:
if ((event->button.button == 1) && (day != 0)) {
gnome_calendar_goto (gnome_calendar,
- time_from_day (GNOME_MONTH_ITEM (month_item)->year,
- GNOME_MONTH_ITEM (month_item)->month, day));
+ time_from_day (month_item->year, month_item->month, day));
gtk_widget_destroy (goto_win);
}
break;
@@ -179,14 +209,14 @@ create_days (int day, int month, int year)
canvas = gnome_canvas_new ();
gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
- month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)));
- gnome_canvas_item_set (month_item,
+ month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", month,
"year", year,
"start_on_monday", week_starts_on_monday,
NULL);
- colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
+ colorify_month_item (month_item, default_color_func, NULL);
+ month_item_prepare_prelight (month_item, default_color_func, NULL);
update ();
/* 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 */
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",
(GtkSignalFunc) day_event,
NULL);
@@ -227,6 +257,7 @@ goto_dialog (GnomeCalendar *gcal)
struct tm *tm;
gnome_calendar = gcal;
+ current_index = -1;
tm = localtime (&gnome_calendar->current_display);
diff --git a/calendar/gui/gnome-month-item.c b/calendar/gui/gnome-month-item.c
index fa1ea79e48..1eb8412f5c 100644
--- a/calendar/gui/gnome-month-item.c
+++ b/calendar/gui/gnome-month-item.c
@@ -12,6 +12,7 @@
#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 */
@@ -767,13 +768,13 @@ gnome_month_item_init (GnomeMonthItem *mitem)
/* 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) {
mitem->head_font = gdk_font_load ("fixed");
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) {
mitem->day_font = gdk_font_load ("fixed");
g_assert (mitem->day_font != NULL);
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index bbc489ddee..b645f02b6b 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -15,24 +15,55 @@
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 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
- * to. */
+ * to. Also marks the current day if appropriate.
+ */
static void
update (void)
{
- unmark_month_item (GNOME_MONTH_ITEM (month_item));
- mark_month_item (GNOME_MONTH_ITEM (month_item), gnome_calendar->cal);
+ GnomeCanvasItem *item;
+ 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 */
static void
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,
NULL);
update ();
@@ -72,7 +103,7 @@ month_toggled (GtkToggleButton *toggle, gpointer data)
if (!toggle->active)
return;
- gnome_canvas_item_set (month_item,
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", GPOINTER_TO_INT (data),
NULL);
update ();
@@ -130,7 +161,7 @@ create_months (int month)
static void
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),
"height", (double) (allocation->height - 1),
NULL);
@@ -148,15 +179,14 @@ day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
{
int child_num, day;
- child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (month_item), item);
- day = gnome_month_item_num2day (GNOME_MONTH_ITEM (month_item), child_num);
+ child_num = gnome_month_item_child2num (month_item, item);
+ day = gnome_month_item_num2day (month_item, child_num);
switch (event->type) {
case GDK_BUTTON_PRESS:
if ((event->button.button == 1) && (day != 0)) {
gnome_calendar_goto (gnome_calendar,
- time_from_day (GNOME_MONTH_ITEM (month_item)->year,
- GNOME_MONTH_ITEM (month_item)->month, day));
+ time_from_day (month_item->year, month_item->month, day));
gtk_widget_destroy (goto_win);
}
break;
@@ -179,14 +209,14 @@ create_days (int day, int month, int year)
canvas = gnome_canvas_new ();
gnome_canvas_set_size (GNOME_CANVAS (canvas), 150, 120);
- month_item = gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)));
- gnome_canvas_item_set (month_item,
+ month_item = GNOME_MONTH_ITEM (gnome_month_item_new (gnome_canvas_root (GNOME_CANVAS (canvas))));
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (month_item),
"month", month,
"year", year,
"start_on_monday", week_starts_on_monday,
NULL);
- colorify_month_item (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
- month_item_prepare_prelight (GNOME_MONTH_ITEM (month_item), default_color_func, NULL);
+ colorify_month_item (month_item, default_color_func, NULL);
+ month_item_prepare_prelight (month_item, default_color_func, NULL);
update ();
/* 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 */
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",
(GtkSignalFunc) day_event,
NULL);
@@ -227,6 +257,7 @@ goto_dialog (GnomeCalendar *gcal)
struct tm *tm;
gnome_calendar = gcal;
+ current_index = -1;
tm = localtime (&gnome_calendar->current_display);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index e889d223d6..9b468de7f8 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -49,7 +49,7 @@ struct color_prop color_props[] = {
{ 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
{ 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" },
{ 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }
diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h
index 0d9491e0a5..18ec39b76b 100644
--- a/calendar/gui/mark.h
+++ b/calendar/gui/mark.h
@@ -14,8 +14,14 @@
/* 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 CURRENT_DAY_FONT "-adobe-helvetica-bold-r-normal--12-*-72-72-p-*-iso8859-1"
+#define HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
+#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
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index d84d7c98cc..4fc8fbbe3f 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -10,6 +10,7 @@
#include "month-view.h"
#include "main.h"
#include "mark.h"
+#include "timeutil.h"
#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)),
gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1",
+ "font", HEADING_FONT,
"fill_color", "black",
NULL);
@@ -82,10 +83,12 @@ month_view_init (MonthView *mv)
"anchor", GTK_ANCHOR_NW,
"day_anchor", GTK_ANCHOR_NE,
"start_on_monday", week_starts_on_monday,
- "heading_height", 18.0,
- "heading_font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1",
- "day_font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1",
+ "heading_padding", 2.0,
+ "heading_font", BIG_DAY_HEADING_FONT,
+ "day_font", BIG_NORMAL_DAY_FONT,
NULL);
+
+ mv->old_current_index = -1;
}
GtkWidget *
@@ -99,6 +102,7 @@ month_view_new (GnomeCalendar *calendar, time_t month)
mv = gtk_type_new (month_view_get_type ());
mv->calendar = calendar;
+ month_view_colors_changed (mv);
month_view_set (mv, month);
return GTK_WIDGET (mv);
}
@@ -166,6 +170,45 @@ month_view_update (MonthView *mv, iCalObject *object, int flags)
/* 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
month_view_set (MonthView *mv, time_t month)
{
@@ -178,6 +221,10 @@ month_view_set (MonthView *mv, time_t month)
/* Title */
tm = localtime (&month);
+
+ mv->year = tm->tm_year + 1900;
+ mv->month = tm->tm_mon;
+
strftime (buf, 100, "%B %Y", tm);
gnome_canvas_item_set (mv->title,
@@ -187,11 +234,13 @@ month_view_set (MonthView *mv, time_t month)
/* Month item */
gnome_canvas_item_set (mv->mitem,
- "year", tm->tm_year + 1900,
- "month", tm->tm_mon,
+ "year", mv->year,
+ "month", mv->month,
NULL);
/* FIXME: update events */
+
+ mark_current_day (mv);
}
void
@@ -204,7 +253,7 @@ month_view_time_format_changed (MonthView *mv)
"start_on_monday", week_starts_on_monday,
NULL);
- /* FIXME: update events */
+ month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
}
void
@@ -213,6 +262,6 @@ month_view_colors_changed (MonthView *mv)
g_return_if_fail (mv != NULL);
g_return_if_fail (IS_MONTH_VIEW (mv));
- unmark_month_item (GNOME_MONTH_ITEM (mv->mitem));
- /* FIXME */
+ colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
+ mark_current_day (mv);
}
diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h
index 70476c82f2..77c418e947 100644
--- a/calendar/gui/month-view.h
+++ b/calendar/gui/month-view.h
@@ -31,6 +31,11 @@ struct _MonthView {
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 *mitem; /* The canvas month item used by this month view */
};
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index f0809a45dc..fe8e52fe23 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -87,11 +87,14 @@ prop_apply_colors (void)
{
int i;
char *cspec;
+ gushort r, g, b;
for (i = 0; i < COLOR_PROP_LAST; i++) {
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]),
- &color_props[i].r, &color_props[i].g, &color_props[i].b, NULL);
-
+ gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &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);
gnome_config_set_string (color_props[i].key, cspec);
}
@@ -338,7 +341,7 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer dat
static char *
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);
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index 93cd591292..6878080d3a 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -522,7 +522,7 @@ year_view_init (YearView *yv)
yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1",
+ "font", HEADING_FONT,
"fill_color", "black",
NULL);
@@ -538,7 +538,7 @@ year_view_init (YearView *yv)
gnome_canvas_text_get_type (),
"text", buf,
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1",
+ "font", TITLE_FONT,
"fill_color", "black",
NULL);
@@ -548,6 +548,8 @@ year_view_init (YearView *yv)
gnome_canvas_item_set (yv->mitems[i],
"anchor", GTK_ANCHOR_NW,
"start_on_monday", week_starts_on_monday,
+ "heading_font", DAY_HEADING_FONT,
+ "day_font", NORMAL_DAY_FONT,
NULL);
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)));
}
-/* 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
mark_current_day (YearView *yv)
{
diff --git a/calendar/main.c b/calendar/main.c
index e889d223d6..9b468de7f8 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -49,7 +49,7 @@ struct color_prop color_props[] = {
{ 0x3e72, 0x35ec, 0x8ba2, "Outline:", "/calendar/Colors/outline" },
{ 0xffff, 0xffff, 0xffff, "Headings:", "/calendar/Colors/headings" },
{ 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" },
{ 0x01f0, 0x01f0, 0x01f0, "Day numbers:", "/calendar/Colors/day_fg" },
{ 0x0000, 0x0000, 0xffff, "Current day's number:", "/calendar/Colors/current_fg" }
diff --git a/calendar/mark.h b/calendar/mark.h
index 0d9491e0a5..18ec39b76b 100644
--- a/calendar/mark.h
+++ b/calendar/mark.h
@@ -14,8 +14,14 @@
/* 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 CURRENT_DAY_FONT "-adobe-helvetica-bold-r-normal--12-*-72-72-p-*-iso8859-1"
+#define HEADING_FONT "-*-helvetica-bold-r-normal--14-*-*-*-p-*-*-*"
+#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
diff --git a/calendar/month-view.c b/calendar/month-view.c
index d84d7c98cc..4fc8fbbe3f 100644
--- a/calendar/month-view.c
+++ b/calendar/month-view.c
@@ -10,6 +10,7 @@
#include "month-view.h"
#include "main.h"
#include "mark.h"
+#include "timeutil.h"
#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)),
gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1",
+ "font", HEADING_FONT,
"fill_color", "black",
NULL);
@@ -82,10 +83,12 @@ month_view_init (MonthView *mv)
"anchor", GTK_ANCHOR_NW,
"day_anchor", GTK_ANCHOR_NE,
"start_on_monday", week_starts_on_monday,
- "heading_height", 18.0,
- "heading_font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1",
- "day_font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1",
+ "heading_padding", 2.0,
+ "heading_font", BIG_DAY_HEADING_FONT,
+ "day_font", BIG_NORMAL_DAY_FONT,
NULL);
+
+ mv->old_current_index = -1;
}
GtkWidget *
@@ -99,6 +102,7 @@ month_view_new (GnomeCalendar *calendar, time_t month)
mv = gtk_type_new (month_view_get_type ());
mv->calendar = calendar;
+ month_view_colors_changed (mv);
month_view_set (mv, month);
return GTK_WIDGET (mv);
}
@@ -166,6 +170,45 @@ month_view_update (MonthView *mv, iCalObject *object, int flags)
/* 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
month_view_set (MonthView *mv, time_t month)
{
@@ -178,6 +221,10 @@ month_view_set (MonthView *mv, time_t month)
/* Title */
tm = localtime (&month);
+
+ mv->year = tm->tm_year + 1900;
+ mv->month = tm->tm_mon;
+
strftime (buf, 100, "%B %Y", tm);
gnome_canvas_item_set (mv->title,
@@ -187,11 +234,13 @@ month_view_set (MonthView *mv, time_t month)
/* Month item */
gnome_canvas_item_set (mv->mitem,
- "year", tm->tm_year + 1900,
- "month", tm->tm_mon,
+ "year", mv->year,
+ "month", mv->month,
NULL);
/* FIXME: update events */
+
+ mark_current_day (mv);
}
void
@@ -204,7 +253,7 @@ month_view_time_format_changed (MonthView *mv)
"start_on_monday", week_starts_on_monday,
NULL);
- /* FIXME: update events */
+ month_view_set (mv, time_month_begin (time_from_day (mv->year, mv->month, 1)));
}
void
@@ -213,6 +262,6 @@ month_view_colors_changed (MonthView *mv)
g_return_if_fail (mv != NULL);
g_return_if_fail (IS_MONTH_VIEW (mv));
- unmark_month_item (GNOME_MONTH_ITEM (mv->mitem));
- /* FIXME */
+ colorify_month_item (GNOME_MONTH_ITEM (mv->mitem), default_color_func, NULL);
+ mark_current_day (mv);
}
diff --git a/calendar/month-view.h b/calendar/month-view.h
index 70476c82f2..77c418e947 100644
--- a/calendar/month-view.h
+++ b/calendar/month-view.h
@@ -31,6 +31,11 @@ struct _MonthView {
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 *mitem; /* The canvas month item used by this month view */
};
diff --git a/calendar/prop.c b/calendar/prop.c
index f0809a45dc..fe8e52fe23 100644
--- a/calendar/prop.c
+++ b/calendar/prop.c
@@ -87,11 +87,14 @@ prop_apply_colors (void)
{
int i;
char *cspec;
+ gushort r, g, b;
for (i = 0; i < COLOR_PROP_LAST; i++) {
- gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]),
- &color_props[i].r, &color_props[i].g, &color_props[i].b, NULL);
-
+ gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (color_pickers[i]), &r, &g, &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);
gnome_config_set_string (color_props[i].key, cspec);
}
@@ -338,7 +341,7 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer dat
static char *
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);
diff --git a/calendar/year-view.c b/calendar/year-view.c
index 93cd591292..6878080d3a 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -522,7 +522,7 @@ year_view_init (YearView *yv)
yv->heading = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (yv)),
gnome_canvas_text_get_type (),
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--14-*-*-*-*-*-iso8859-1",
+ "font", HEADING_FONT,
"fill_color", "black",
NULL);
@@ -538,7 +538,7 @@ year_view_init (YearView *yv)
gnome_canvas_text_get_type (),
"text", buf,
"anchor", GTK_ANCHOR_N,
- "font", "-*-helvetica-bold-r-normal--12-*-*-*-*-*-iso8859-1",
+ "font", TITLE_FONT,
"fill_color", "black",
NULL);
@@ -548,6 +548,8 @@ year_view_init (YearView *yv)
gnome_canvas_item_set (yv->mitems[i],
"anchor", GTK_ANCHOR_NW,
"start_on_monday", week_starts_on_monday,
+ "heading_font", DAY_HEADING_FONT,
+ "day_font", NORMAL_DAY_FONT,
NULL);
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)));
}
-/* 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
mark_current_day (YearView *yv)
{