diff options
author | Miguel de Icaza <miguel@nuclecu.unam.mx> | 1998-04-02 15:57:58 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-02 15:57:58 +0800 |
commit | f865d886f5aae9279d44f726a0b8093316a40e09 (patch) | |
tree | f397fa0ffb407d2ae4c15c61335bac25cb68d2a0 /calendar/gui | |
parent | 33b0ab0d0f19c405445315446fd584748538a1ed (diff) | |
download | gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.gz gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.tar.zst gsoc2013-evolution-f865d886f5aae9279d44f726a0b8093316a40e09.zip |
New main program that uses our new datatypes and objects.
1998-04-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* main.c: New main program that uses our new datatypes and
objects.
* calendar.c (calendar_load_from_vobject, calendar_load):
Implement loading of vCalendar objects and vCalendar files.
* calobj.c (ical_object_create_from_vobject): Implement loading of
vCalendar event and todo objects.
* timeutil.c (isodate_from_time_t): New function.
* gnome-cal.c, gnome-cal.h: Implement a toplevel widget, derived
from GnomeApp. It holds all of the day views and arbitrates the
display.
svn path=/trunk/; revision=93
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/Makefile.am | 18 | ||||
-rw-r--r-- | calendar/gui/calendar.c | 55 | ||||
-rw-r--r-- | calendar/gui/calendar.h | 1 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 11 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 2 | ||||
-rw-r--r-- | calendar/gui/main.c | 24 |
6 files changed, 99 insertions, 12 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 5ab3511b11..6ab68ffb7d 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -9,15 +9,23 @@ INCLUDES = \ bin_PROGRAMS = gnomecal gnomecal_SOURCES = \ - main.c \ - gnome-cal.c \ - gnome-cal.h \ - views.c \ calendar.c \ calendar.h \ calobj.c \ calobj.h \ - views.h + gncal-week-view.c \ + gncal-week-view.h \ + gncal-day-view.c \ + gncal-day-view.h \ + gnome-cal.c \ + gnome-cal.h \ + main.c \ + timeutil.c \ + timeutil.h \ + view-utils.h \ + view-utils.c \ + views.h \ + views.c #gncal_SOURCES = \ diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index e077279461..5d7cb1dd8a 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -13,6 +13,7 @@ */ #include "calendar.h" +#include "versit/vcc.h" Calendar * calendar_new (char *title) @@ -28,6 +29,7 @@ calendar_new (char *title) void calendar_add_object (Calendar *cal, iCalObject *obj) { + printf ("Adding object\n"); switch (obj->type){ case ICAL_EVENT: cal->events = g_list_prepend (cal->events, obj); @@ -133,3 +135,56 @@ calendar_compare_by_dtstart (gpointer a, gpointer b) return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; } + +#define str_val(obj) (char *) vObjectUStringZValue (obj) + +/* Loads our calendar contents from a vObject */ +void +calendar_load_from_vobject (Calendar *cal, VObject *vcal) +{ + VObjectIterator i;; + + initPropIterator (&i, vcal); + + while (moreIteration (&i)){ + VObject *this = nextVObject (&i); + iCalObject *ical; + const char *object_name = vObjectName (this); + + if (strcmp (object_name, VCDCreatedProp) == 0){ + cal->created = time_from_isodate (str_val (this)); + continue; + } + + if (strcmp (object_name, VCLocationProp) == 0) + continue; /* FIXME: imlement */ + + if (strcmp (object_name, VCProdIdProp) == 0) + continue; /* FIXME: implement */ + + if (strcmp (object_name, VCVersionProp) == 0) + continue; /* FIXME: implement */ + + ical = ical_object_create_from_vobject (this, object_name); + + if (ical) + calendar_add_object (cal, ical); + } +} + +/* Loads a calendar from a file */ +void +calendar_load (Calendar *cal, char *fname) +{ + VObject *vcal; + + if (cal->filename){ + g_warning ("Calendar load called again\n"); + return; + } + + cal->filename = g_strdup (fname); + vcal = Parse_MIME_FromFileName (fname); + calendar_load_from_vobject (cal, vcal); + cleanVObject (vcal); +} diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h index 09242d9b76..805076d949 100644 --- a/calendar/gui/calendar.h +++ b/calendar/gui/calendar.h @@ -12,6 +12,7 @@ typedef struct { GList *todo; GList *journal; + time_t created; int modified; } Calendar; diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 333931a5a2..0b22a1a684 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -39,10 +39,13 @@ setup_widgets (GnomeCalendar *gcal) { GtkWidget *notebook; GtkWidget *day_view, *week_view, *year_view, *task_view; - + time_t now; + + now = time (NULL); + notebook = gtk_notebook_new (); day_view = day_view_create (gcal); - week_view = week_view_create (gcal); + week_view = gncal_week_view_new (gcal->cal, now); year_view = year_view_create (gcal); task_view = tasks_create (gcal); @@ -86,7 +89,7 @@ gnome_calendar_new (char *title) } void -gnome_calendar_load (char *file) +gnome_calendar_load (GnomeCalendar *gcal, char *file) { - + calendar_load (gcal->cal, file); } diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 840ccf5122..2b30bf1f7c 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -28,7 +28,7 @@ typedef struct { guint gnome_calendar_get_type (void); GtkWidget *gnome_calendar_new (char *title); -void gnome_calendar_load (char *file); +void gnome_calendar_load (GnomeCalendar *gcal, char *file); END_GNOME_DECLS diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 941efe1c2b..be54ba2d81 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -173,10 +173,25 @@ GnomeUIInfo gnome_cal_menu [] = { GNOMEUIINFO_END }; +GnomeUIInfo gnome_toolbar [] = { + { GNOME_APP_UI_ITEM, N_("Prev"), N_("Previous"), /*previous_clicked*/0, 0, 0, + GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, + + { GNOME_APP_UI_ITEM, N_("Today"), N_("Today"), /*previous_clicked*/0, 0, 0, + GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, + + { GNOME_APP_UI_ITEM, N_("Next"), N_("Next"), /*previous_clicked*/0, 0, 0, + GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD }, + + GNOMEUIINFO_END +}; + static void setup_menu (GtkWidget *gcal) { gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal); + gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal); + } static void @@ -191,8 +206,13 @@ new_calendar (char *full_name, char *calendar_file) setup_menu (toplevel); gtk_widget_show (toplevel); - if (g_file_exists (calendar_file)) - gnome_calendar_load (calendar_file); + if (g_file_exists (calendar_file)){ + printf ("Trying to load %s\n", calendar_file); + gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); + } else { + printf ("tring: ./test.vcf\n"); + gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); + } active_calendars++; } |