aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gnome-cal.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gnome-cal.c')
-rw-r--r--calendar/gnome-cal.c127
1 files changed, 25 insertions, 102 deletions
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index bc26be5c92..a71e7fb343 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -11,15 +11,13 @@
#include <sys/wait.h>
#include "calendar.h"
#include "gnome-cal.h"
-#include "gncal-full-day.h"
-#include "gncal-year-view.h"
+#include "gncal-day-panel.h"
#include "gncal-week-view.h"
+#include "gncal-year-view.h"
#include "timeutil.h"
#include "views.h"
#include "main.h"
-static void gnome_calendar_init (GnomeCalendar *gcal);
-
GnomeApp *parent_class;
guint
@@ -32,7 +30,7 @@ gnome_calendar_get_type (void)
sizeof(GnomeCalendar),
sizeof(GnomeCalendarClass),
(GtkClassInitFunc) NULL,
- (GtkObjectInitFunc) gnome_calendar_init,
+ (GtkObjectInitFunc) NULL,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
};
@@ -43,70 +41,6 @@ gnome_calendar_get_type (void)
}
static void
-day_view_range_activated (GncalFullDay *fullday, GnomeCalendar *gcal)
-{
- iCalObject *ical;
-
- ical = ical_new ("", user_name, "");
- ical->new = 1;
-
- gncal_full_day_selection_range (fullday, &ical->dtstart, &ical->dtend);
-
- gnome_calendar_add_object (gcal, ical);
- gncal_full_day_focus_child (fullday, ical);
-}
-
-static void
-set_day_view_label (GnomeCalendar *gcal, time_t t)
-{
- static char buf[256];
-
- strftime (buf, sizeof (buf), "%a %b %d %Y", localtime (&t));
- gtk_label_set (GTK_LABEL (gcal->day_view_label), buf);
-}
-
-static void
-setup_day_view (GnomeCalendar *gcal, time_t now)
-{
- GtkTable *t;
- GtkWidget *sw;
-
- time_t a, b;
-
- a = time_start_of_day (now);
- b = time_end_of_day (now);
-
- gcal->day_view = gncal_full_day_new (gcal, a, b);
- gtk_signal_connect (GTK_OBJECT (gcal->day_view), "range_activated",
- (GtkSignalFunc) day_view_range_activated,
- gcal);
-
- t = (GtkTable *) gcal->day_view_container = gtk_table_new (0, 0, 0);
- gtk_container_border_width (GTK_CONTAINER (t), 4);
- gtk_table_set_row_spacings (t, 4);
- gtk_table_set_col_spacings (t, 4);
-
- gcal->day_view_label = gtk_label_new ("");
- set_day_view_label (gcal, now);
- gtk_table_attach (t, gcal->day_view_label, 0, 1, 0, 1,
- GTK_FILL | GTK_SHRINK,
- GTK_FILL | GTK_SHRINK,
- 0, 0);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_table_attach (t, sw, 0, 1, 1, 2,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK,
- GTK_FILL | GTK_EXPAND | GTK_SHRINK,
- 0, 0);
- gtk_container_add (GTK_CONTAINER (sw), gcal->day_view);
-
- gtk_widget_show_all (GTK_WIDGET (t));
-}
-
-static void
setup_widgets (GnomeCalendar *gcal)
{
time_t now;
@@ -114,13 +48,12 @@ setup_widgets (GnomeCalendar *gcal)
now = time (NULL);
gcal->notebook = gtk_notebook_new ();
+ gcal->day_view = gncal_day_panel_new (gcal, now);
gcal->week_view = gncal_week_view_new (gcal, now);
gcal->year_view = gncal_year_view_new (gcal, now);
gcal->task_view = tasks_create (gcal);
- setup_day_view (gcal, now);
-
- 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->day_view, 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"))); */
@@ -131,16 +64,6 @@ setup_widgets (GnomeCalendar *gcal)
}
-static void
-gnome_calendar_init(GnomeCalendar *gcal)
-{
- gcal->cal = 0;
- gcal->day_view = 0;
- gcal->week_view = 0;
- gcal->year_view = 0;
- gcal->event_editor = 0;
-}
-
static GtkWidget *
get_current_page (GnomeCalendar *gcal)
{
@@ -153,17 +76,17 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
GtkWidget *current = get_current_page (gcal);
g_assert (new_time != -1);
- if (current == gcal->week_view)
+ if (current == gcal->day_view)
+ gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time);
+ else if (current == gcal->week_view)
gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time);
- 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));
- set_day_view_label (gcal, new_time);
- } else if (current == gcal->year_view)
+ else if (current == gcal->year_view)
gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time);
- else
- printf ("My penguin is gone!\n");
+ else {
+ g_warning ("My penguin is gone!");
+ g_assert_not_reached ();
+ }
+
gcal->current_display = new_time;
}
@@ -173,22 +96,24 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction)
GtkWidget *cp = get_current_page (gcal);
time_t new_time;
- if (cp == gcal->week_view)
- new_time = time_add_day (gcal->current_display, 7 * direction);
- else if (cp == gcal->day_view_container)
+ if (cp == gcal->day_view)
new_time = time_add_day (gcal->current_display, 1 * direction);
+ else if (cp == gcal->week_view)
+ new_time = time_add_day (gcal->current_display, 7 * direction);
else if (cp == gcal->year_view)
new_time = time_add_year (gcal->current_display, 1 * direction);
- else
+ else {
g_warning ("Weee! Where did the penguin go?");
-
+ g_assert_not_reached ();
+ }
+
gnome_calendar_goto (gcal, new_time);
}
void
gnome_calendar_next (GnomeCalendar *gcal)
{
-gnome_calendar_direction (gcal, 1);
+ gnome_calendar_direction (gcal, 1);
}
void
@@ -229,7 +154,7 @@ gnome_calendar_new (char *title)
static void
gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
{
- gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, flags);
+ gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags);
gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags);
gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
}
@@ -358,14 +283,14 @@ calendar_notify (time_t time, void *data)
if (ico->malarm.enabled && ico->malarm.trigger == time){
char *command;
time_t app = ico->malarm.trigger + ico->malarm.offset;
-
+
command = g_copy_strings ("mail -s '",
_("Reminder of your appointment at "),
ctime (&app), "' '",
ico->malarm.data, "' ",
NULL);
execute (command, 1);
-
+
g_free (command);
return;
}
@@ -383,5 +308,3 @@ calendar_notify (time_t time, void *data)
return;
}
}
-
-