aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-02 10:18:42 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-02 10:18:42 +0800
commit4750b90ad18f4f59fa19b839550d6397f5dffbfd (patch)
treea2d62941f88d3aedb6509b4883e08c82e13ed1cc /calendar
parent9bc7db5333a2319828768142c527d3fb64afd999 (diff)
downloadgsoc2013-evolution-4750b90ad18f4f59fa19b839550d6397f5dffbfd.tar.gz
gsoc2013-evolution-4750b90ad18f4f59fa19b839550d6397f5dffbfd.tar.zst
gsoc2013-evolution-4750b90ad18f4f59fa19b839550d6397f5dffbfd.zip
GnomeCalendar toplevel GnomeApp; versit code -mig
svn path=/trunk/; revision=89
Diffstat (limited to 'calendar')
-rw-r--r--calendar/Makefile.am52
-rw-r--r--calendar/calendar.h4
-rw-r--r--calendar/gnome-cal.c92
-rw-r--r--calendar/gnome-cal.h35
-rw-r--r--calendar/gui/Makefile.am52
-rw-r--r--calendar/gui/calendar.h4
-rw-r--r--calendar/gui/gnome-cal.c92
-rw-r--r--calendar/gui/gnome-cal.h35
-rw-r--r--calendar/gui/main.c218
-rw-r--r--calendar/main.c218
-rw-r--r--calendar/views.c33
-rw-r--r--calendar/views.h4
12 files changed, 801 insertions, 38 deletions
diff --git a/calendar/Makefile.am b/calendar/Makefile.am
index 883c5322ae..5ab3511b11 100644
--- a/calendar/Makefile.am
+++ b/calendar/Makefile.am
@@ -1,33 +1,51 @@
+SUBDIRS = versit
+
INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
+ -I$(includedir) \
+ $(GNOME_INCLUDEDIR) \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I../../gcalendar
-bin_PROGRAMS = gncal objedit
+bin_PROGRAMS = gnomecal
-gncal_SOURCES = \
- gncal.c \
- gncal.h \
- calcs.c \
- calcs.h \
- clist.c \
- clist.h \
+gnomecal_SOURCES = \
+ main.c \
+ gnome-cal.c \
+ gnome-cal.h \
+ views.c \
calendar.c \
calendar.h \
calobj.c \
calobj.h \
- gncal-day-view.c \
- gncal-day-view.h \
- timeutil.c \
- timeutil.h
+ views.h
+
+
+#gncal_SOURCES = \
+# gncal.c \
+# gncal.h \
+# calcs.c \
+# calcs.h \
+# clist.c \
+# clist.h \
+# calendar.c \
+# calendar.h \
+# calobj.c \
+# calobj.h \
+# gncal-day-view.c \
+# gncal-day-view.h \
+# timeutil.c \
+# timeutil.h
LINK_FLAGS = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
- $(INTLLIBS)
+ $(INTLLIBS) versit/libversit.a
+
+
+#gncal_LDADD = $(LINK_FLAGS)
+#objedit_LDADD = $(LINK_FLAGS)
-gncal_LDADD = $(LINK_FLAGS)
-objedit_LDADD = $(LINK_FLAGS)
+gnomecal_LDADD = $(LINK_FLAGS)
EXTRA_DIST = \
gncal.desktop
diff --git a/calendar/calendar.h b/calendar/calendar.h
index bfbee92df8..09242d9b76 100644
--- a/calendar/calendar.h
+++ b/calendar/calendar.h
@@ -11,17 +11,17 @@ typedef struct {
GList *events;
GList *todo;
GList *journal;
+
+ int modified;
} Calendar;
Calendar *calendar_new (char *title);
void calendar_add_object (Calendar *cal, iCalObject *obj);
void calendar_remove_object (Calendar *cal, iCalObject *obj);
void calendar_destroy (Calendar *cal);
-
GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-
gint calendar_compare_by_dtstart (gpointer a, gpointer b);
END_GNOME_DECLS
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
new file mode 100644
index 0000000000..333931a5a2
--- /dev/null
+++ b/calendar/gnome-cal.c
@@ -0,0 +1,92 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#include <gnome.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+#include "views.h"
+
+static void gnome_calendar_init (GnomeCalendar *gcal);
+
+GnomeApp *parent_class;
+
+guint
+gnome_calendar_get_type (void)
+{
+ static guint gnome_calendar_type = 0;
+ if(!gnome_calendar_type) {
+ GtkTypeInfo gnome_calendar_info = {
+ "GnomeCalendar",
+ sizeof(GnomeCalendar),
+ sizeof(GnomeCalendarClass),
+ (GtkClassInitFunc) NULL,
+ (GtkObjectInitFunc) gnome_calendar_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL,
+ };
+ gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info);
+ parent_class = gtk_type_class (gnome_app_get_type());
+ }
+ return gnome_calendar_type;
+}
+
+static void
+setup_widgets (GnomeCalendar *gcal)
+{
+ GtkWidget *notebook;
+ GtkWidget *day_view, *week_view, *year_view, *task_view;
+
+ notebook = gtk_notebook_new ();
+ day_view = day_view_create (gcal);
+ week_view = week_view_create (gcal);
+ year_view = year_view_create (gcal);
+ task_view = tasks_create (gcal);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), day_view, gtk_label_new (_("Day View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), week_view, gtk_label_new (_("Week View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), year_view, gtk_label_new (_("Year View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), task_view, gtk_label_new (_("Tasks")));
+
+ gtk_widget_show_all (notebook);
+
+ gnome_app_set_contents (GNOME_APP (gcal), notebook);
+
+}
+
+static void
+gnome_calendar_init(GnomeCalendar *gcal)
+{
+ gcal->cal = 0;
+
+ setup_widgets (gcal);
+}
+
+GtkWidget *
+gnome_calendar_new (char *title)
+{
+ GtkWidget *retval;
+ GnomeCalendar *gcal;
+ GnomeApp *app;
+
+ retval = gtk_type_new (gnome_calendar_get_type ());
+ app = GNOME_APP (retval);
+ gcal = GNOME_CALENDAR (retval);
+
+ app->name = g_strdup ("calendar");
+ app->prefix = g_copy_strings ("/", app->name, "/", NULL);
+
+ gtk_window_set_title(GTK_WINDOW(retval), title);
+
+ gcal->cal = calendar_new (title);
+ return retval;
+}
+
+void
+gnome_calendar_load (char *file)
+{
+
+}
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
new file mode 100644
index 0000000000..840ccf5122
--- /dev/null
+++ b/calendar/gnome-cal.h
@@ -0,0 +1,35 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#ifndef GNOME_CALENDAR_APP_H
+#define GNOME_CALENDAR_APP_H
+
+#include <libgnome/gnome-defs.h>
+#include <libgnomeui/gnome-app.h>
+
+BEGIN_GNOME_DECLS
+
+#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar)
+#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass)
+#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
+
+typedef struct {
+ GnomeApp gnome_app;
+ Calendar *cal;
+} GnomeCalendar;
+
+typedef struct {
+ GnomeAppClass parent_class;
+} GnomeCalendarClass;
+
+guint gnome_calendar_get_type (void);
+GtkWidget *gnome_calendar_new (char *title);
+void gnome_calendar_load (char *file);
+
+END_GNOME_DECLS
+
+#endif
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 883c5322ae..5ab3511b11 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -1,33 +1,51 @@
+SUBDIRS = versit
+
INCLUDES = \
- -I$(includedir) \
- $(GNOME_INCLUDEDIR) \
+ -I$(includedir) \
+ $(GNOME_INCLUDEDIR) \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I../../gcalendar
-bin_PROGRAMS = gncal objedit
+bin_PROGRAMS = gnomecal
-gncal_SOURCES = \
- gncal.c \
- gncal.h \
- calcs.c \
- calcs.h \
- clist.c \
- clist.h \
+gnomecal_SOURCES = \
+ main.c \
+ gnome-cal.c \
+ gnome-cal.h \
+ views.c \
calendar.c \
calendar.h \
calobj.c \
calobj.h \
- gncal-day-view.c \
- gncal-day-view.h \
- timeutil.c \
- timeutil.h
+ views.h
+
+
+#gncal_SOURCES = \
+# gncal.c \
+# gncal.h \
+# calcs.c \
+# calcs.h \
+# clist.c \
+# clist.h \
+# calendar.c \
+# calendar.h \
+# calobj.c \
+# calobj.h \
+# gncal-day-view.c \
+# gncal-day-view.h \
+# timeutil.c \
+# timeutil.h
LINK_FLAGS = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
- $(INTLLIBS)
+ $(INTLLIBS) versit/libversit.a
+
+
+#gncal_LDADD = $(LINK_FLAGS)
+#objedit_LDADD = $(LINK_FLAGS)
-gncal_LDADD = $(LINK_FLAGS)
-objedit_LDADD = $(LINK_FLAGS)
+gnomecal_LDADD = $(LINK_FLAGS)
EXTRA_DIST = \
gncal.desktop
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index bfbee92df8..09242d9b76 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -11,17 +11,17 @@ typedef struct {
GList *events;
GList *todo;
GList *journal;
+
+ int modified;
} Calendar;
Calendar *calendar_new (char *title);
void calendar_add_object (Calendar *cal, iCalObject *obj);
void calendar_remove_object (Calendar *cal, iCalObject *obj);
void calendar_destroy (Calendar *cal);
-
GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func);
-
gint calendar_compare_by_dtstart (gpointer a, gpointer b);
END_GNOME_DECLS
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
new file mode 100644
index 0000000000..333931a5a2
--- /dev/null
+++ b/calendar/gui/gnome-cal.c
@@ -0,0 +1,92 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#include <gnome.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+#include "views.h"
+
+static void gnome_calendar_init (GnomeCalendar *gcal);
+
+GnomeApp *parent_class;
+
+guint
+gnome_calendar_get_type (void)
+{
+ static guint gnome_calendar_type = 0;
+ if(!gnome_calendar_type) {
+ GtkTypeInfo gnome_calendar_info = {
+ "GnomeCalendar",
+ sizeof(GnomeCalendar),
+ sizeof(GnomeCalendarClass),
+ (GtkClassInitFunc) NULL,
+ (GtkObjectInitFunc) gnome_calendar_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL,
+ };
+ gnome_calendar_type = gtk_type_unique(gnome_app_get_type(), &gnome_calendar_info);
+ parent_class = gtk_type_class (gnome_app_get_type());
+ }
+ return gnome_calendar_type;
+}
+
+static void
+setup_widgets (GnomeCalendar *gcal)
+{
+ GtkWidget *notebook;
+ GtkWidget *day_view, *week_view, *year_view, *task_view;
+
+ notebook = gtk_notebook_new ();
+ day_view = day_view_create (gcal);
+ week_view = week_view_create (gcal);
+ year_view = year_view_create (gcal);
+ task_view = tasks_create (gcal);
+
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), day_view, gtk_label_new (_("Day View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), week_view, gtk_label_new (_("Week View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), year_view, gtk_label_new (_("Year View")));
+ gtk_notebook_append_page (GTK_NOTEBOOK (notebook), task_view, gtk_label_new (_("Tasks")));
+
+ gtk_widget_show_all (notebook);
+
+ gnome_app_set_contents (GNOME_APP (gcal), notebook);
+
+}
+
+static void
+gnome_calendar_init(GnomeCalendar *gcal)
+{
+ gcal->cal = 0;
+
+ setup_widgets (gcal);
+}
+
+GtkWidget *
+gnome_calendar_new (char *title)
+{
+ GtkWidget *retval;
+ GnomeCalendar *gcal;
+ GnomeApp *app;
+
+ retval = gtk_type_new (gnome_calendar_get_type ());
+ app = GNOME_APP (retval);
+ gcal = GNOME_CALENDAR (retval);
+
+ app->name = g_strdup ("calendar");
+ app->prefix = g_copy_strings ("/", app->name, "/", NULL);
+
+ gtk_window_set_title(GTK_WINDOW(retval), title);
+
+ gcal->cal = calendar_new (title);
+ return retval;
+}
+
+void
+gnome_calendar_load (char *file)
+{
+
+}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
new file mode 100644
index 0000000000..840ccf5122
--- /dev/null
+++ b/calendar/gui/gnome-cal.h
@@ -0,0 +1,35 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+
+#ifndef GNOME_CALENDAR_APP_H
+#define GNOME_CALENDAR_APP_H
+
+#include <libgnome/gnome-defs.h>
+#include <libgnomeui/gnome-app.h>
+
+BEGIN_GNOME_DECLS
+
+#define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar)
+#define GNOME_CALENDAR_CLASS(class) GTK_CHECK_CAST_CLASS(class, gnome_calendar_get_type(), GnomeCalendarClass)
+#define GNOME_IS_CALENDAR(obj) GTK_CHECK_TYPE(obj, gnome_calendar_get_type())
+
+typedef struct {
+ GnomeApp gnome_app;
+ Calendar *cal;
+} GnomeCalendar;
+
+typedef struct {
+ GnomeAppClass parent_class;
+} GnomeCalendarClass;
+
+guint gnome_calendar_get_type (void);
+GtkWidget *gnome_calendar_new (char *title);
+void gnome_calendar_load (char *file);
+
+END_GNOME_DECLS
+
+#endif
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
new file mode 100644
index 0000000000..941efe1c2b
--- /dev/null
+++ b/calendar/gui/main.c
@@ -0,0 +1,218 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ */
+#include <config.h>
+#include <gnome.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+
+/* The username, used to set the `owner' field of the event */
+char *user_name;
+
+/* The full user name from the Gecos field */
+char *full_name;
+
+/* The user's default calendar file */
+char *user_calendar_file;
+
+/* a gnome-config string prefix that can be used to access the calendar config info */
+char *calendar_settings;
+
+/* Day begin, day end parameters */
+int day_begin, day_end;
+
+/* Number of calendars active */
+int active_calendars = 0;
+
+void
+init_username (void)
+{
+ char *p;
+ struct passwd *passwd;
+
+ passwd = getpwuid (getuid ());
+ if ((p = passwd->pw_name)){
+ user_name = g_strdup (p);
+ full_name = g_strdup (passwd->pw_gecos);
+ } else {
+ if ((p = getenv ("USER"))){
+ user_name = g_strdup (p);
+ full_name = g_strdup (p);
+ return;
+ } else {
+ user_name = g_strdup ("unknown");
+ full_name = g_strdup ("unknown");
+ }
+ }
+ endpwent ();
+}
+
+int
+range_check_hour (int hour)
+{
+ if (hour < 0)
+ hour = 0;
+ if (hour > 24)
+ hour = 23;
+ return hour;
+}
+
+/*
+ * Initializes the calendar internal variables, loads defaults
+ */
+void
+init_calendar (void)
+{
+ init_username ();
+ user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
+ calendar_settings = g_copy_strings ("=", gnome_util_user_home (), ".gnome/calendar=", NULL);
+
+ gnome_config_push_prefix (calendar_settings);
+ day_begin = range_check_hour (gnome_config_get_int ("/Calendar/Day start=8"));
+ day_end = range_check_hour (gnome_config_get_int ("/Calendar/Day end=17"));
+
+ if (day_end < day_begin){
+ day_begin = 8;
+ day_end = 17;
+ }
+ gnome_config_pop_prefix ();
+}
+
+void
+new_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+open_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+save_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+about_calendar_cmd (GtkWidget *widget, void *data)
+{
+
+ GtkWidget *about;
+ gchar *authors[] = {
+ "Miguel de Icaza (miguel@kernel.org)",
+ "Federico Mena (federico@gimp.org)",
+ NULL
+ };
+
+ about = gnome_about_new (_("Gnome Calendar"), VERSION,
+ "(C) 1998 the Free Software Fundation",
+ authors,
+ _("The GNOME personal calendar and schedule manager."),
+ NULL);
+ gtk_widget_show (about);
+}
+
+void
+quit_cmd (GtkWidget *widget, GnomeCalendar *gcal)
+{
+ /* FIXME: check all of the calendars for their state (modified) */
+
+ gtk_main_quit ();
+}
+
+void
+close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
+{
+ if (gcal->cal->modified){
+ gnome_message_box_new (_("The calendar has unsaved changes, Save them?"),
+ GNOME_MESSAGE_BOX_WARNING,
+ "Yes", "No");
+ }
+ gtk_widget_destroy (widget);
+ active_calendars--;
+
+ if (active_calendars == 0)
+ gtk_main_quit ();
+}
+
+GnomeUIInfo gnome_cal_file_menu [] = {
+ { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd },
+
+ { GNOME_APP_UI_ITEM, N_("Open calendar"), NULL, open_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN },
+
+ { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
+
+ { GNOME_APP_UI_SEPARATOR },
+ { GNOME_APP_UI_ITEM, N_("Close"), NULL, close_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+
+ { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+
+ GNOMEUIINFO_END
+};
+
+GnomeUIInfo gnome_cal_about_menu [] = {
+ { GNOME_APP_UI_ITEM, N_("About"), NULL, about_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT },
+ GNOMEUIINFO_HELP ("midnight-commander"),
+ GNOMEUIINFO_END
+};
+
+GnomeUIInfo gnome_cal_menu [] = {
+ { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
+ { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
+ GNOMEUIINFO_END
+};
+
+static void
+setup_menu (GtkWidget *gcal)
+{
+ gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
+}
+
+static void
+new_calendar (char *full_name, char *calendar_file)
+{
+ GtkWidget *toplevel;
+ char *title;
+
+ title = g_copy_strings (full_name, "'s calendar", NULL);
+
+ toplevel = gnome_calendar_new (title);
+ setup_menu (toplevel);
+ gtk_widget_show (toplevel);
+
+ if (g_file_exists (calendar_file))
+ gnome_calendar_load (calendar_file);
+ active_calendars++;
+}
+
+int
+main(int argc, char *argv[])
+{
+ GnomeClient *client;
+
+ argp_program_version = VERSION;
+
+ /* Initialise the i18n stuff */
+ bindtextdomain(PACKAGE, GNOMELOCALEDIR);
+ textdomain(PACKAGE);
+
+ gnome_init ("gncal", NULL, argc, argv, 0, NULL);
+
+ init_calendar ();
+
+ new_calendar (full_name, user_calendar_file);
+ gtk_main ();
+}
+
+
diff --git a/calendar/main.c b/calendar/main.c
new file mode 100644
index 0000000000..941efe1c2b
--- /dev/null
+++ b/calendar/main.c
@@ -0,0 +1,218 @@
+/*
+ * GnomeCalendar widget
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Authors:
+ * Miguel de Icaza (miguel@kernel.org)
+ */
+#include <config.h>
+#include <gnome.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+
+/* The username, used to set the `owner' field of the event */
+char *user_name;
+
+/* The full user name from the Gecos field */
+char *full_name;
+
+/* The user's default calendar file */
+char *user_calendar_file;
+
+/* a gnome-config string prefix that can be used to access the calendar config info */
+char *calendar_settings;
+
+/* Day begin, day end parameters */
+int day_begin, day_end;
+
+/* Number of calendars active */
+int active_calendars = 0;
+
+void
+init_username (void)
+{
+ char *p;
+ struct passwd *passwd;
+
+ passwd = getpwuid (getuid ());
+ if ((p = passwd->pw_name)){
+ user_name = g_strdup (p);
+ full_name = g_strdup (passwd->pw_gecos);
+ } else {
+ if ((p = getenv ("USER"))){
+ user_name = g_strdup (p);
+ full_name = g_strdup (p);
+ return;
+ } else {
+ user_name = g_strdup ("unknown");
+ full_name = g_strdup ("unknown");
+ }
+ }
+ endpwent ();
+}
+
+int
+range_check_hour (int hour)
+{
+ if (hour < 0)
+ hour = 0;
+ if (hour > 24)
+ hour = 23;
+ return hour;
+}
+
+/*
+ * Initializes the calendar internal variables, loads defaults
+ */
+void
+init_calendar (void)
+{
+ init_username ();
+ user_calendar_file = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/user-cal.vcf");
+ calendar_settings = g_copy_strings ("=", gnome_util_user_home (), ".gnome/calendar=", NULL);
+
+ gnome_config_push_prefix (calendar_settings);
+ day_begin = range_check_hour (gnome_config_get_int ("/Calendar/Day start=8"));
+ day_end = range_check_hour (gnome_config_get_int ("/Calendar/Day end=17"));
+
+ if (day_end < day_begin){
+ day_begin = 8;
+ day_end = 17;
+ }
+ gnome_config_pop_prefix ();
+}
+
+void
+new_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+open_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+save_calendar_cmd (GtkWidget *widget, void *data)
+{
+}
+
+void
+about_calendar_cmd (GtkWidget *widget, void *data)
+{
+
+ GtkWidget *about;
+ gchar *authors[] = {
+ "Miguel de Icaza (miguel@kernel.org)",
+ "Federico Mena (federico@gimp.org)",
+ NULL
+ };
+
+ about = gnome_about_new (_("Gnome Calendar"), VERSION,
+ "(C) 1998 the Free Software Fundation",
+ authors,
+ _("The GNOME personal calendar and schedule manager."),
+ NULL);
+ gtk_widget_show (about);
+}
+
+void
+quit_cmd (GtkWidget *widget, GnomeCalendar *gcal)
+{
+ /* FIXME: check all of the calendars for their state (modified) */
+
+ gtk_main_quit ();
+}
+
+void
+close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
+{
+ if (gcal->cal->modified){
+ gnome_message_box_new (_("The calendar has unsaved changes, Save them?"),
+ GNOME_MESSAGE_BOX_WARNING,
+ "Yes", "No");
+ }
+ gtk_widget_destroy (widget);
+ active_calendars--;
+
+ if (active_calendars == 0)
+ gtk_main_quit ();
+}
+
+GnomeUIInfo gnome_cal_file_menu [] = {
+ { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd },
+
+ { GNOME_APP_UI_ITEM, N_("Open calendar"), NULL, open_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN },
+
+ { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
+
+ { GNOME_APP_UI_SEPARATOR },
+ { GNOME_APP_UI_ITEM, N_("Close"), NULL, close_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+
+ { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
+
+ GNOMEUIINFO_END
+};
+
+GnomeUIInfo gnome_cal_about_menu [] = {
+ { GNOME_APP_UI_ITEM, N_("About"), NULL, about_calendar_cmd, NULL, NULL,
+ GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT },
+ GNOMEUIINFO_HELP ("midnight-commander"),
+ GNOMEUIINFO_END
+};
+
+GnomeUIInfo gnome_cal_menu [] = {
+ { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu },
+ { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu },
+ GNOMEUIINFO_END
+};
+
+static void
+setup_menu (GtkWidget *gcal)
+{
+ gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal);
+}
+
+static void
+new_calendar (char *full_name, char *calendar_file)
+{
+ GtkWidget *toplevel;
+ char *title;
+
+ title = g_copy_strings (full_name, "'s calendar", NULL);
+
+ toplevel = gnome_calendar_new (title);
+ setup_menu (toplevel);
+ gtk_widget_show (toplevel);
+
+ if (g_file_exists (calendar_file))
+ gnome_calendar_load (calendar_file);
+ active_calendars++;
+}
+
+int
+main(int argc, char *argv[])
+{
+ GnomeClient *client;
+
+ argp_program_version = VERSION;
+
+ /* Initialise the i18n stuff */
+ bindtextdomain(PACKAGE, GNOMELOCALEDIR);
+ textdomain(PACKAGE);
+
+ gnome_init ("gncal", NULL, argc, argv, 0, NULL);
+
+ init_calendar ();
+
+ new_calendar (full_name, user_calendar_file);
+ gtk_main ();
+}
+
+
diff --git a/calendar/views.c b/calendar/views.c
new file mode 100644
index 0000000000..a066d789e8
--- /dev/null
+++ b/calendar/views.c
@@ -0,0 +1,33 @@
+/*
+ * Calendar views.
+ * Copyright (C) 1998 the Free Software Foundation
+ *
+ * Author: Miguel de Icaza (miguel@kernel.org)
+ */
+#include <gnome.h>
+#include "calendar.h"
+#include "gnome-cal.h"
+
+GtkWidget *
+day_view_create (GnomeCalendar *gcal)
+{
+ return gtk_button_new_with_label ("This is supposed to be the Day View");
+}
+
+GtkWidget *
+week_view_create (GnomeCalendar *gcal)
+{
+ return gtk_button_new_with_label ("This is supposed to be the Week View");
+}
+
+GtkWidget *
+year_view_create (GnomeCalendar *gcal)
+{
+ return gtk_button_new_with_label ("This is supposed to be the Year View");
+}
+
+GtkWidget *
+tasks_create (GnomeCalendar *gcal)
+{
+ return gtk_button_new_with_label ("This is supposed to be the Tasks View");
+}
diff --git a/calendar/views.h b/calendar/views.h
new file mode 100644
index 0000000000..d7162cfcbd
--- /dev/null
+++ b/calendar/views.h
@@ -0,0 +1,4 @@
+GtkWidget *day_view_create (GnomeCalendar *gcal);
+GtkWidget *week_view_create (GnomeCalendar *gcal);
+GtkWidget *year_view_create (GnomeCalendar *gcal);
+GtkWidget *tasks_create (GnomeCalendar *gcal);