aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/cal-util/calobj.c14
-rw-r--r--calendar/cal-util/calobj.h17
-rw-r--r--calendar/calobj.c14
-rw-r--r--calendar/calobj.h17
-rw-r--r--calendar/eventedit.c141
-rw-r--r--calendar/eventedit.h6
-rw-r--r--calendar/gnome-cal.c36
-rw-r--r--calendar/gnome-cal.h1
-rw-r--r--calendar/gui/eventedit.c141
-rw-r--r--calendar/gui/eventedit.h6
-rw-r--r--calendar/gui/gnome-cal.c36
-rw-r--r--calendar/gui/gnome-cal.h1
-rw-r--r--calendar/pcs/calobj.c14
-rw-r--r--calendar/pcs/calobj.h17
-rw-r--r--calendar/timeutil.c48
-rw-r--r--calendar/timeutil.h4
17 files changed, 335 insertions, 190 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index cd5a1c5bfa..47533ab9cd 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+1998-04-11 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * gnome-cal.c (gnome_calendar_goto): Add support for navigating
+ on the day view.
+
+ * timeutil.c (time_start_of_day, time_end_of_day, time_day_hour):
+ New time manipulation functions.
+
+ * eventedit.c (ee_rp_init_frequency): Add the different frequency
+ editors to a notebook. Make the notebook startup on the entry
+ selected recurrence type;
+
1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (recompute_motion): Now we support selecting a
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 8504d7a95b..a5832e469d 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -103,7 +103,7 @@ ical_object_destroy (iCalObject *ico)
g_free (ico);
}
-GList *
+static GList *
set_list (char *str, char *sc)
{
GList *list = 0;
@@ -115,6 +115,12 @@ set_list (char *str, char *sc)
return list;
}
+static void
+load_recurrence (iCalObject *o, char *str)
+{
+
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -246,13 +252,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
if (has (o, VCMAlarmProp))
;
- /* FIXME: rdate */
- if (has (o, VCRDateProp))
- ;
-
/* FIXME: rrule */
if (has (o, VCRRuleProp))
- ;
+ load_recurrence (ical, str_val (vo));
return ical;
}
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 0fe85c6ca3..560c4ca99e 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -70,6 +70,21 @@ typedef enum {
typedef char NotYet;
+enum RecurType {
+ RECUR_DAILY,
+ RECUR_WEEKLY,
+ RECUR_MONTHLY_BY_POS,
+ RECUR_MONTHLY_BY_DAY,
+ RECUR_YEARLY_BY_MONTH,
+ RECUR_YEARLY_BY_DAY,
+};
+
+typedef struct {
+ enum RecurType type;
+
+ int frequency;
+} Recurrence;
+
/*
* This describes an iCalendar object, note that we never store durations, instead we
* always compute the end time computed from the start + duration.
@@ -114,6 +129,8 @@ typedef struct {
CalendarAlarm aalarm;
CalendarAlarm palarm;
CalendarAlarm malarm;
+
+ Recurrence *recur;
} iCalObject;
iCalObject *ical_new (char *comment, char *organizer, char *summary);
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 8504d7a95b..a5832e469d 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -103,7 +103,7 @@ ical_object_destroy (iCalObject *ico)
g_free (ico);
}
-GList *
+static GList *
set_list (char *str, char *sc)
{
GList *list = 0;
@@ -115,6 +115,12 @@ set_list (char *str, char *sc)
return list;
}
+static void
+load_recurrence (iCalObject *o, char *str)
+{
+
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -246,13 +252,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
if (has (o, VCMAlarmProp))
;
- /* FIXME: rdate */
- if (has (o, VCRDateProp))
- ;
-
/* FIXME: rrule */
if (has (o, VCRRuleProp))
- ;
+ load_recurrence (ical, str_val (vo));
return ical;
}
diff --git a/calendar/calobj.h b/calendar/calobj.h
index 0fe85c6ca3..560c4ca99e 100644
--- a/calendar/calobj.h
+++ b/calendar/calobj.h
@@ -70,6 +70,21 @@ typedef enum {
typedef char NotYet;
+enum RecurType {
+ RECUR_DAILY,
+ RECUR_WEEKLY,
+ RECUR_MONTHLY_BY_POS,
+ RECUR_MONTHLY_BY_DAY,
+ RECUR_YEARLY_BY_MONTH,
+ RECUR_YEARLY_BY_DAY,
+};
+
+typedef struct {
+ enum RecurType type;
+
+ int frequency;
+} Recurrence;
+
/*
* This describes an iCalendar object, note that we never store durations, instead we
* always compute the end time computed from the start + duration.
@@ -114,6 +129,8 @@ typedef struct {
CalendarAlarm aalarm;
CalendarAlarm palarm;
CalendarAlarm malarm;
+
+ Recurrence *recur;
} iCalObject;
iCalObject *ical_new (char *comment, char *organizer, char *summary);
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index ac11841581..d87f838f0e 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -509,45 +509,24 @@ recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
if (!GTK_TOGGLE_BUTTON (radio)->active)
return;
- {
- GtkWidget *child = GTK_BIN (ee->recur_content)->child;
-
- if (child){
- gtk_widget_ref (child);
- gtk_container_remove (GTK_CONTAINER (ee->recur_content), child);
- }
- }
- printf ("Aņadiendo\n");
for (which = 0; list; list = list->next, which++){
if (list->data == radio){
- GtkWidget *w;
-
- switch (which){
- case 3:
- w = ee->recur_content_daily;
- break;
- case 2:
- w = ee->recur_content_weekly;
- break;
- case 1:
- w = ee->recur_content_monthly;
- break;
- default:
- return;
- }
- printf ("Aņadiendo\n");
- gtk_widget_show_all (w);
- gtk_container_add (GTK_CONTAINER (ee->recur_content), w);
+ gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_content), 3-which);
+ return;
}
}
}
static GtkWidget *
-small_entry (void)
+small_entry (int v)
{
GtkWidget *entry = gtk_entry_new ();
-
+ char buffer [40];
+
+ sprintf (buffer, "%d", v);
gtk_widget_set_usize (GTK_WIDGET (entry), gdk_string_width (entry->style->font, "WWW"), 0);
+ gtk_entry_set_text (GTK_ENTRY (entry), buffer);
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
return entry;
}
@@ -636,45 +615,72 @@ ee_rp_init_frequency (EventEditor *ee)
{
char *day_names [] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *content, *week_hbox, *week_day, *w;
+ GtkWidget *daily, *weekly, *monthly, *yearly;
+ GtkNotebook *notebook;
GSList *group;
- int i;
+ int i, page, day_period, week_period, month_period, year_period;
f = gtk_frame_new (_("Frequency"));
vbox = gtk_vbox_new (0, 0);
hbox = gtk_hbox_new (0, 0);
- ee->recur_content = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
+ ee->recur_content = gtk_notebook_new ();
+ notebook = (GtkNotebook *) ee->recur_content;
+
gtk_container_add (GTK_CONTAINER (f), hbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_content, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), ee->recur_content, TRUE, TRUE, 10);
+
+ day_period = 1;
+ week_period = 1;
+ month_period = 1;
+ year_period = 1;
+
+ /* Determine which should be the default selection */
+ if (ee->ical->recur){
+ enum RecurType type = ee->ical->recur->type;
+ int freq = ee->ical->recur->frequency;
+
+ switch (type){
+ case RECUR_DAILY: page = 0; day_period = freq; break;
+ case RECUR_WEEKLY: page = 1; week_period = freq; break;
+ case RECUR_MONTHLY_BY_POS: page = 2; month_period = freq; break;
+ case RECUR_MONTHLY_BY_DAY: page = 2; month_period = freq; break;
+ case RECUR_YEARLY_BY_MONTH: page = 3; year_period = freq; break;
+ case RECUR_YEARLY_BY_DAY: page = 4; year_period = freq; break;
+ }
+ } else {
+ page = 0;
+ }
/* The recureency selector */
for (i = 0, group = NULL; recurrence_types [i].name; i++){
r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == 0);
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
gtk_box_pack_start_defaults (GTK_BOX (vbox), r);
}
ee->recur_group = group;
/* 1. The daily recurrence */
- ee->recur_content_daily = gtk_hbox_new (0, 0);
- ee->recur_day_period = small_entry ();
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), gtk_label_new (_("Every")), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), ee->recur_day_period, 0, 0, 5);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), gtk_label_new (_("day(s)")), 0, 0, 0);
+ daily = gtk_hbox_new (0, 0);
+ ee->recur_day_period = small_entry (day_period);
+ gtk_box_pack_start (GTK_BOX (daily), gtk_label_new (_("Every")), 0, 0, 0);
+ gtk_box_pack_start (GTK_BOX (daily), ee->recur_day_period, 0, 0, 5);
+ gtk_box_pack_start (GTK_BOX (daily), gtk_label_new (_("day(s)")), 0, 0, 0);
/* 2. The weekly recurrence */
- ee->recur_content_weekly = gtk_vbox_new (0, 0);
+ weekly = gtk_vbox_new (0, 0);
week_hbox = gtk_hbox_new (0, 0);
/* 2.1 The week period selector */
- ee->recur_week_period = small_entry ();
+ ee->recur_week_period = small_entry (week_period);
gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new _("Every"), 0, 0, 0);
gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_week_period, 0, 0, 5);
gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_weekly), week_hbox, 1, 1, 0);
+ gtk_box_pack_start (GTK_BOX (weekly), week_hbox, 1, 1, 0);
/* 2.2 The week day selector */
week_day = gtk_hbox_new (0, 0);
@@ -682,48 +688,63 @@ ee_rp_init_frequency (EventEditor *ee)
ee->recur_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
gtk_box_pack_start (GTK_BOX (week_day), ee->recur_week_days [i], 1, 1, 5);
}
- gtk_box_pack_start (GTK_BOX (ee->recur_content_weekly), week_day, 1, 1, 0);
+ gtk_box_pack_start (GTK_BOX (weekly), week_day, 1, 1, 0);
/* 3. The monthly recurrence */
- ee->recur_content_monthly = gtk_table_new (0, 0, 0);
+ monthly = gtk_table_new (0, 0, 0);
re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
ee->recur_month_date = make_day_list_widget (numeral_day_names);
w = gtk_label_new (_("day"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), re,
+ gtk_table_attach (GTK_TABLE (monthly), re,
0, 1, 0, 1, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_date,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_date,
1, 2, 0, 1, 0, 0, 5, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), w,
+ gtk_table_attach (GTK_TABLE (monthly), w,
2, 3, 0, 1, 0, 0, 0, 0);
gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (r)), _("Recur on the"));
ee->recur_month_day = make_day_list_widget (numeral_day_names);
ee->recur_month_weekday = make_day_list_widget (weekday_names);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), r1,
+ gtk_table_attach (GTK_TABLE (monthly), r1,
0, 1, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_day,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_day,
1, 2, 1, 2, 0, 0, 5, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_weekday,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_weekday,
2, 3, 1, 2, 0, 0, 5, 0);
- month_sensitize (ee, 0);
-
-/* recurrence_toggled (GTK_RADIO_BUTTON (r), ee); */
- gtk_container_add (GTK_CONTAINER (ee->recur_content), gtk_label_new ("hola!"));
- gtk_widget_show_all (ee->recur_content);
+ gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("Every")),
+ 3, 4, 0, 2, 0, 0, 0, 0);
+ ee->recur_month_period = small_entry (month_period);
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_period,
+ 4, 5, 0, 2, 0, 0, 5, 0);
+ gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
+ 5, 6, 0, 2, 0, 0, 0, 0);
+ /* 4. The yearly recurrence */
+ yearly = gtk_hbox_new (0, 0);
+ ee->recur_year_period = small_entry (year_period);
+ gtk_box_pack_start (GTK_BOX (yearly), gtk_label_new (_("Every")), 0, 0, 0);
+ gtk_box_pack_start (GTK_BOX (yearly), ee->recur_year_period, 0, 0, 5);
+ gtk_box_pack_start (GTK_BOX (yearly), gtk_label_new (_("year(s)")), 0, 0, 0);
+
+ /* Finish setting this up */
+ gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
+ gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_border (notebook, FALSE);
+
+ gtk_notebook_set_page (notebook, page);
/* Attach to the main table */
- gtk_table_attach (GTK_TABLE (ee->recur_table), f,
- 0, 1, 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
-}
+ gtk_box_pack_start (GTK_BOX (ee->recur_table), f, 1, 0, 0);
+};
static void
ee_init_recurrent_page (EventEditor *ee)
{
- ee->recur_table = gtk_table_new (1, 1, 0);
+ ee->recur_table = gtk_vbox_new (0, 0);
gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->recur_table),
gtk_label_new (_("Repeating")));
ee_rp_init_frequency (ee);
diff --git a/calendar/eventedit.h b/calendar/eventedit.h
index c2d5d1123f..6de4d09256 100644
--- a/calendar/eventedit.h
+++ b/calendar/eventedit.h
@@ -38,17 +38,17 @@ typedef struct {
GSList *recur_group;
GtkWidget *recur_content;
- GtkWidget *recur_content_daily;
GtkWidget *recur_day_period; /* GtkEntry */
- GtkWidget *recur_content_weekly;
GtkWidget *recur_week_period; /* GtkEntry */
GtkWidget *recur_week_days [7];
- GtkWidget *recur_content_monthly;
GtkWidget *recur_month_date;
GtkWidget *recur_month_day;
GtkWidget *recur_month_weekday;
+ GtkWidget *recur_month_period; /* GtkEntry */
+
+ GtkWidget *recur_year_period; /* GtkEntry */
/* The associated ical object */
iCalObject *ical;
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 873ee3f908..18409e3318 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -41,44 +41,32 @@ static void
setup_widgets (GnomeCalendar *gcal)
{
time_t now;
- GtkWidget *sw;
now = time (NULL);
gcal->notebook = gtk_notebook_new ();
- gcal->day_view = day_view_create (gcal);
gcal->week_view = gncal_week_view_new (gcal, now);
gcal->year_view = year_view_create (gcal);
gcal->task_view = tasks_create (gcal);
if (1)
{
- struct tm tm;
time_t a, b;
- tm = *localtime (&now);
-/* tm.tm_mday = 2; */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- a = mktime (&tm);
-
- tm.tm_mday++;
-
- b = mktime (&tm);
-
+ a = time_start_of_day (now);
+ b = time_end_of_day (now);
+
gcal->day_view = gncal_full_day_new (gcal, a, b);
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ gcal->day_view_container = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gcal->day_view_container),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (sw), gcal->day_view);
+ gtk_container_add (GTK_CONTAINER (gcal->day_view_container), gcal->day_view);
gtk_widget_show (gcal->day_view);
}
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), sw, gtk_label_new (_("Day View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view_container, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo")));
@@ -114,9 +102,11 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
if (current == gcal->week_view)
gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->day_view)
- printf ("updating day view\n");
- else if (current == gcal->year_view)
+ else if (current == gcal->day_view_container){
+ gncal_full_day_set_bounds (GNCAL_FULL_DAY (gcal->day_view),
+ time_start_of_day (new_time),
+ time_end_of_day (new_time));
+ } else if (current == gcal->year_view)
printf ("updating year view\n");
else
printf ("My penguin is gone!\n");
@@ -131,7 +121,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
if (cp == gcal->week_view)
new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->day_view)
+ else if (cp == gcal->day_view_container)
new_time = time_add_day (gcal->current_display, 1 * direction);
else if (cp == gcal->year_view)
new_time = time_add_year (gcal->current_display, 1 * direction);
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
index 2a91237f81..dcb4b2ffa1 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/gnome-cal.h
@@ -25,6 +25,7 @@ typedef struct {
GtkWidget *notebook;
GtkWidget *week_view;
GtkWidget *day_view;
+ GtkWidget *day_view_container;
GtkWidget *year_view;
GtkWidget *task_view;
void *event_editor;
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index ac11841581..d87f838f0e 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -509,45 +509,24 @@ recurrence_toggled (GtkRadioButton *radio, EventEditor *ee)
if (!GTK_TOGGLE_BUTTON (radio)->active)
return;
- {
- GtkWidget *child = GTK_BIN (ee->recur_content)->child;
-
- if (child){
- gtk_widget_ref (child);
- gtk_container_remove (GTK_CONTAINER (ee->recur_content), child);
- }
- }
- printf ("Aņadiendo\n");
for (which = 0; list; list = list->next, which++){
if (list->data == radio){
- GtkWidget *w;
-
- switch (which){
- case 3:
- w = ee->recur_content_daily;
- break;
- case 2:
- w = ee->recur_content_weekly;
- break;
- case 1:
- w = ee->recur_content_monthly;
- break;
- default:
- return;
- }
- printf ("Aņadiendo\n");
- gtk_widget_show_all (w);
- gtk_container_add (GTK_CONTAINER (ee->recur_content), w);
+ gtk_notebook_set_page (GTK_NOTEBOOK (ee->recur_content), 3-which);
+ return;
}
}
}
static GtkWidget *
-small_entry (void)
+small_entry (int v)
{
GtkWidget *entry = gtk_entry_new ();
-
+ char buffer [40];
+
+ sprintf (buffer, "%d", v);
gtk_widget_set_usize (GTK_WIDGET (entry), gdk_string_width (entry->style->font, "WWW"), 0);
+ gtk_entry_set_text (GTK_ENTRY (entry), buffer);
+ gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
return entry;
}
@@ -636,45 +615,72 @@ ee_rp_init_frequency (EventEditor *ee)
{
char *day_names [] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *content, *week_hbox, *week_day, *w;
+ GtkWidget *daily, *weekly, *monthly, *yearly;
+ GtkNotebook *notebook;
GSList *group;
- int i;
+ int i, page, day_period, week_period, month_period, year_period;
f = gtk_frame_new (_("Frequency"));
vbox = gtk_vbox_new (0, 0);
hbox = gtk_hbox_new (0, 0);
- ee->recur_content = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
+ ee->recur_content = gtk_notebook_new ();
+ notebook = (GtkNotebook *) ee->recur_content;
+
gtk_container_add (GTK_CONTAINER (f), hbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), gtk_vseparator_new (), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), ee->recur_content, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), ee->recur_content, TRUE, TRUE, 10);
+
+ day_period = 1;
+ week_period = 1;
+ month_period = 1;
+ year_period = 1;
+
+ /* Determine which should be the default selection */
+ if (ee->ical->recur){
+ enum RecurType type = ee->ical->recur->type;
+ int freq = ee->ical->recur->frequency;
+
+ switch (type){
+ case RECUR_DAILY: page = 0; day_period = freq; break;
+ case RECUR_WEEKLY: page = 1; week_period = freq; break;
+ case RECUR_MONTHLY_BY_POS: page = 2; month_period = freq; break;
+ case RECUR_MONTHLY_BY_DAY: page = 2; month_period = freq; break;
+ case RECUR_YEARLY_BY_MONTH: page = 3; year_period = freq; break;
+ case RECUR_YEARLY_BY_DAY: page = 4; year_period = freq; break;
+ }
+ } else {
+ page = 0;
+ }
/* The recureency selector */
for (i = 0, group = NULL; recurrence_types [i].name; i++){
r = gtk_radio_button_new_with_label (group, _(recurrence_types [i].name));
group = gtk_radio_button_group (GTK_RADIO_BUTTON (r));
- gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == 0);
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r), i == page);
gtk_signal_connect (GTK_OBJECT (r), "toggled", GTK_SIGNAL_FUNC (recurrence_toggled), ee);
gtk_box_pack_start_defaults (GTK_BOX (vbox), r);
}
ee->recur_group = group;
/* 1. The daily recurrence */
- ee->recur_content_daily = gtk_hbox_new (0, 0);
- ee->recur_day_period = small_entry ();
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), gtk_label_new (_("Every")), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), ee->recur_day_period, 0, 0, 5);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_daily), gtk_label_new (_("day(s)")), 0, 0, 0);
+ daily = gtk_hbox_new (0, 0);
+ ee->recur_day_period = small_entry (day_period);
+ gtk_box_pack_start (GTK_BOX (daily), gtk_label_new (_("Every")), 0, 0, 0);
+ gtk_box_pack_start (GTK_BOX (daily), ee->recur_day_period, 0, 0, 5);
+ gtk_box_pack_start (GTK_BOX (daily), gtk_label_new (_("day(s)")), 0, 0, 0);
/* 2. The weekly recurrence */
- ee->recur_content_weekly = gtk_vbox_new (0, 0);
+ weekly = gtk_vbox_new (0, 0);
week_hbox = gtk_hbox_new (0, 0);
/* 2.1 The week period selector */
- ee->recur_week_period = small_entry ();
+ ee->recur_week_period = small_entry (week_period);
gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new _("Every"), 0, 0, 0);
gtk_box_pack_start (GTK_BOX (week_hbox), ee->recur_week_period, 0, 0, 5);
gtk_box_pack_start (GTK_BOX (week_hbox), gtk_label_new (_("week(s)")), 0, 0, 0);
- gtk_box_pack_start (GTK_BOX (ee->recur_content_weekly), week_hbox, 1, 1, 0);
+ gtk_box_pack_start (GTK_BOX (weekly), week_hbox, 1, 1, 0);
/* 2.2 The week day selector */
week_day = gtk_hbox_new (0, 0);
@@ -682,48 +688,63 @@ ee_rp_init_frequency (EventEditor *ee)
ee->recur_week_days [i] = gtk_check_button_new_with_label (_(day_names [i]));
gtk_box_pack_start (GTK_BOX (week_day), ee->recur_week_days [i], 1, 1, 5);
}
- gtk_box_pack_start (GTK_BOX (ee->recur_content_weekly), week_day, 1, 1, 0);
+ gtk_box_pack_start (GTK_BOX (weekly), week_day, 1, 1, 0);
/* 3. The monthly recurrence */
- ee->recur_content_monthly = gtk_table_new (0, 0, 0);
+ monthly = gtk_table_new (0, 0, 0);
re = gtk_radio_button_new_with_label (NULL, _("Recur on the"));
ee->recur_month_date = make_day_list_widget (numeral_day_names);
w = gtk_label_new (_("day"));
- gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), re,
+ gtk_table_attach (GTK_TABLE (monthly), re,
0, 1, 0, 1, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_date,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_date,
1, 2, 0, 1, 0, 0, 5, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), w,
+ gtk_table_attach (GTK_TABLE (monthly), w,
2, 3, 0, 1, 0, 0, 0, 0);
gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee);
r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (r)), _("Recur on the"));
ee->recur_month_day = make_day_list_widget (numeral_day_names);
ee->recur_month_weekday = make_day_list_widget (weekday_names);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), r1,
+ gtk_table_attach (GTK_TABLE (monthly), r1,
0, 1, 1, 2, 0, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_day,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_day,
1, 2, 1, 2, 0, 0, 5, 0);
- gtk_table_attach (GTK_TABLE (ee->recur_content_monthly), ee->recur_month_weekday,
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_weekday,
2, 3, 1, 2, 0, 0, 5, 0);
- month_sensitize (ee, 0);
-
-/* recurrence_toggled (GTK_RADIO_BUTTON (r), ee); */
- gtk_container_add (GTK_CONTAINER (ee->recur_content), gtk_label_new ("hola!"));
- gtk_widget_show_all (ee->recur_content);
+ gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("Every")),
+ 3, 4, 0, 2, 0, 0, 0, 0);
+ ee->recur_month_period = small_entry (month_period);
+ gtk_table_attach (GTK_TABLE (monthly), ee->recur_month_period,
+ 4, 5, 0, 2, 0, 0, 5, 0);
+ gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")),
+ 5, 6, 0, 2, 0, 0, 0, 0);
+ /* 4. The yearly recurrence */
+ yearly = gtk_hbox_new (0, 0);
+ ee->recur_year_period = small_entry (year_period);
+ gtk_box_pack_start (GTK_BOX (yearly), gtk_label_new (_("Every")), 0, 0, 0);
+ gtk_box_pack_start (GTK_BOX (yearly), ee->recur_year_period, 0, 0, 5);
+ gtk_box_pack_start (GTK_BOX (yearly), gtk_label_new (_("year(s)")), 0, 0, 0);
+
+ /* Finish setting this up */
+ gtk_notebook_append_page (notebook, daily, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, weekly, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, monthly, gtk_label_new (""));
+ gtk_notebook_append_page (notebook, yearly, gtk_label_new (""));
+ gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_border (notebook, FALSE);
+
+ gtk_notebook_set_page (notebook, page);
/* Attach to the main table */
- gtk_table_attach (GTK_TABLE (ee->recur_table), f,
- 0, 1, 0, 1,
- GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
-}
+ gtk_box_pack_start (GTK_BOX (ee->recur_table), f, 1, 0, 0);
+};
static void
ee_init_recurrent_page (EventEditor *ee)
{
- ee->recur_table = gtk_table_new (1, 1, 0);
+ ee->recur_table = gtk_vbox_new (0, 0);
gtk_notebook_append_page (GTK_NOTEBOOK (ee->notebook), GTK_WIDGET (ee->recur_table),
gtk_label_new (_("Repeating")));
ee_rp_init_frequency (ee);
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
index c2d5d1123f..6de4d09256 100644
--- a/calendar/gui/eventedit.h
+++ b/calendar/gui/eventedit.h
@@ -38,17 +38,17 @@ typedef struct {
GSList *recur_group;
GtkWidget *recur_content;
- GtkWidget *recur_content_daily;
GtkWidget *recur_day_period; /* GtkEntry */
- GtkWidget *recur_content_weekly;
GtkWidget *recur_week_period; /* GtkEntry */
GtkWidget *recur_week_days [7];
- GtkWidget *recur_content_monthly;
GtkWidget *recur_month_date;
GtkWidget *recur_month_day;
GtkWidget *recur_month_weekday;
+ GtkWidget *recur_month_period; /* GtkEntry */
+
+ GtkWidget *recur_year_period; /* GtkEntry */
/* The associated ical object */
iCalObject *ical;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 873ee3f908..18409e3318 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -41,44 +41,32 @@ static void
setup_widgets (GnomeCalendar *gcal)
{
time_t now;
- GtkWidget *sw;
now = time (NULL);
gcal->notebook = gtk_notebook_new ();
- gcal->day_view = day_view_create (gcal);
gcal->week_view = gncal_week_view_new (gcal, now);
gcal->year_view = year_view_create (gcal);
gcal->task_view = tasks_create (gcal);
if (1)
{
- struct tm tm;
time_t a, b;
- tm = *localtime (&now);
-/* tm.tm_mday = 2; */
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
-
- a = mktime (&tm);
-
- tm.tm_mday++;
-
- b = mktime (&tm);
-
+ a = time_start_of_day (now);
+ b = time_end_of_day (now);
+
gcal->day_view = gncal_full_day_new (gcal, a, b);
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+ gcal->day_view_container = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gcal->day_view_container),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
- gtk_container_add (GTK_CONTAINER (sw), gcal->day_view);
+ gtk_container_add (GTK_CONTAINER (gcal->day_view_container), gcal->day_view);
gtk_widget_show (gcal->day_view);
}
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), sw, gtk_label_new (_("Day View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view_container, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo")));
@@ -114,9 +102,11 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
if (current == gcal->week_view)
gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- else if (current == gcal->day_view)
- printf ("updating day view\n");
- else if (current == gcal->year_view)
+ else if (current == gcal->day_view_container){
+ gncal_full_day_set_bounds (GNCAL_FULL_DAY (gcal->day_view),
+ time_start_of_day (new_time),
+ time_end_of_day (new_time));
+ } else if (current == gcal->year_view)
printf ("updating year view\n");
else
printf ("My penguin is gone!\n");
@@ -131,7 +121,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
if (cp == gcal->week_view)
new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->day_view)
+ else if (cp == gcal->day_view_container)
new_time = time_add_day (gcal->current_display, 1 * direction);
else if (cp == gcal->year_view)
new_time = time_add_year (gcal->current_display, 1 * direction);
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 2a91237f81..dcb4b2ffa1 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -25,6 +25,7 @@ typedef struct {
GtkWidget *notebook;
GtkWidget *week_view;
GtkWidget *day_view;
+ GtkWidget *day_view_container;
GtkWidget *year_view;
GtkWidget *task_view;
void *event_editor;
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 8504d7a95b..a5832e469d 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -103,7 +103,7 @@ ical_object_destroy (iCalObject *ico)
g_free (ico);
}
-GList *
+static GList *
set_list (char *str, char *sc)
{
GList *list = 0;
@@ -115,6 +115,12 @@ set_list (char *str, char *sc)
return list;
}
+static void
+load_recurrence (iCalObject *o, char *str)
+{
+
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -246,13 +252,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
if (has (o, VCMAlarmProp))
;
- /* FIXME: rdate */
- if (has (o, VCRDateProp))
- ;
-
/* FIXME: rrule */
if (has (o, VCRRuleProp))
- ;
+ load_recurrence (ical, str_val (vo));
return ical;
}
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
index 0fe85c6ca3..560c4ca99e 100644
--- a/calendar/pcs/calobj.h
+++ b/calendar/pcs/calobj.h
@@ -70,6 +70,21 @@ typedef enum {
typedef char NotYet;
+enum RecurType {
+ RECUR_DAILY,
+ RECUR_WEEKLY,
+ RECUR_MONTHLY_BY_POS,
+ RECUR_MONTHLY_BY_DAY,
+ RECUR_YEARLY_BY_MONTH,
+ RECUR_YEARLY_BY_DAY,
+};
+
+typedef struct {
+ enum RecurType type;
+
+ int frequency;
+} Recurrence;
+
/*
* This describes an iCalendar object, note that we never store durations, instead we
* always compute the end time computed from the start + duration.
@@ -114,6 +129,8 @@ typedef struct {
CalendarAlarm aalarm;
CalendarAlarm palarm;
CalendarAlarm malarm;
+
+ Recurrence *recur;
} iCalObject;
iCalObject *ical_new (char *comment, char *organizer, char *summary);
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index acd2b33ee7..c19b394be9 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -117,3 +117,51 @@ time_add_year (time_t time, int years)
}
return new_time;
}
+
+time_t
+time_day_hour (time_t t, int hour)
+{
+ struct tm tm;
+ time_t retval;
+
+ tm = *localtime (&t);
+ tm.tm_hour = hour;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ retval = mktime (&tm);
+ return retval;
+}
+
+
+time_t
+time_start_of_day (time_t t)
+{
+ struct tm tm;
+ time_t retval;
+
+ tm = *localtime (&t);
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+
+ retval = mktime (&tm);
+ return retval;
+}
+
+time_t
+time_end_of_day (time_t t)
+{
+ struct tm tm;
+ time_t retval;
+
+ tm = *localtime (&t);
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ tm.tm_mday++;
+
+ retval = mktime (&tm);
+ return retval;
+}
+
diff --git a/calendar/timeutil.h b/calendar/timeutil.h
index 8f9157351c..fa0b865e76 100644
--- a/calendar/timeutil.h
+++ b/calendar/timeutil.h
@@ -28,5 +28,9 @@ time_t time_add_year (time_t time, int years);
*/
char *format_simple_hour (int hour, int use_am_pm);
+time_t time_start_of_day (time_t t);
+time_t time_end_of_day (time_t t);
+time_t time_day_hour (time_t t, int hour);
+
#endif