aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/gui/calendar-commands.c17
-rw-r--r--calendar/gui/gnome-cal.c102
-rw-r--r--calendar/gui/gnome-cal.h13
-rw-r--r--calendar/pcs/cal-backend.c2
5 files changed, 92 insertions, 52 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index cb6314bdb4..516f5c393f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,15 @@
2000-04-19 Seth Alves <alves@hungry.com>
+ * gui/calendar-commands.c (calendar_set_uri): calls gnome_calendar_open
+ instead of checking on disk and calling load or create.
+
+ * gui/gnome-cal.c (gnome_calendar_object_changed): fixed to use
+ cal_client_update_object -- editing and dragging events works again
+ (gnome_calendar_open): collapsed gnome_calendar_load and
+ gnome_calendar_create into this function. added new type
+ GnomeCalendarOpenMode which has the value CALENDAR_OPEN or
+ CALENDAR_OPEN_OR_CREATE.
+
* gui/evolution-calendar-control.c (calendar_properties_init): create
a property bag for this control
(set_prop): callback for property sets
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index 850b5d95d9..a052b8ebf7 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -617,17 +617,14 @@ void calendar_set_uri (GnomeCalendar *gcal, char *calendar_file)
{
gboolean success;
- printf ("calendar_set_uri: calendar_file is '%s'\n",
- calendar_file ? calendar_file : "NULL");
+ g_return_if_fail (gcal);
+ g_return_if_fail (calendar_file);
- if (calendar_file && g_file_exists (calendar_file)) {
- printf ("loading calendar\n");
- success = gnome_calendar_load (gcal, calendar_file);
- }
- else {
- printf ("creating calendar\n");
- success = gnome_calendar_create (gcal, calendar_file);
- }
+ printf ("calendar_set_uri: calendar_file is '%s'\n", calendar_file);
+
+ success = gnome_calendar_open (gcal,
+ calendar_file,
+ CALENDAR_OPEN_OR_CREATE);
printf (" load or create returned %d\n", success);
}
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 30123d053e..bb50e1c1c4 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -230,24 +230,13 @@ 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_strconcat ("/", app->name, "/", NULL);
- */
-
- /*
- gtk_window_set_title (GTK_WINDOW (gtk_widget_get_toplevel (retval)),
- title);
- */
+ gcal = GNOME_CALENDAR (retval);
gcal->current_display = time_day_begin (time (NULL));
gcal->client = cal_client_new ();
+
setup_widgets (gcal);
return retval;
@@ -265,25 +254,78 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
}
+typedef struct
+{
+ GnomeCalendar *gcal;
+ char *uri;
+ GnomeCalendarOpenMode gcom;
+ guint signal_handle;
+} load_or_create_data;
+
+
static void
gnome_calendar_load_cb (GtkWidget *cal_client,
- gpointer something,
- GnomeCalendar *gcal)
+ /*gpointer something,*/
+ CalClientLoadStatus success,
+ load_or_create_data *locd)
{
- gnome_calendar_update_all (gcal, NULL, 0);
-}
+ g_return_if_fail (locd);
+ g_return_if_fail (GNOME_IS_CALENDAR (locd->gcal));
+
+ switch (success) {
+ case CAL_CLIENT_LOAD_SUCCESS:
+ gnome_calendar_update_all (locd->gcal, NULL, 0);
+ printf ("gnome_calendar_load_cb: success\n");
+ break;
+ case CAL_CLIENT_LOAD_ERROR:
+ printf ("gnome_calendar_load_cb: load error.\n");
+ if (locd->gcom == CALENDAR_OPEN_OR_CREATE) {
+ printf ("gnome_calendar_load_cb: trying create...\n");
+ /* FIXME: connect to the cal_loaded signal of the
+ * CalClient and get theasynchronous notification
+ * properly! */
+ /*gtk_signal_connect (GTK_OBJECT (gcal->client),
+ "cal_loaded",
+ gnome_calendar_create_cb, gcal);*/
+
+ gtk_signal_disconnect (GTK_OBJECT (locd->gcal->client),
+ locd->signal_handle);
+
+ cal_client_create_calendar (locd->gcal->client,
+ locd->uri);
+ gnome_calendar_update_all (locd->gcal, NULL, 0);
+ }
+ break;
+ case CAL_CLIENT_LOAD_IN_USE:
+ printf ("gnome_calendar_load_cb: in use\n");
+ break;
+ }
+ g_free (locd->uri);
+ g_free (locd);
+}
int
-gnome_calendar_load (GnomeCalendar *gcal, char *file)
+gnome_calendar_open (GnomeCalendar *gcal,
+ char *file,
+ GnomeCalendarOpenMode gcom)
{
+ load_or_create_data *locd;
+
g_return_val_if_fail (gcal != NULL, 0);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
g_return_val_if_fail (file != NULL, 0);
- gtk_signal_connect (GTK_OBJECT (gcal->client), "cal_loaded",
- gnome_calendar_load_cb, gcal);
+ locd = g_new0 (load_or_create_data, 1);
+ locd->gcal = gcal;
+ locd->uri = g_strdup (file);
+ locd->gcom = gcom;
+
+ locd->signal_handle = gtk_signal_connect (GTK_OBJECT (gcal->client),
+ "cal_loaded",
+ gnome_calendar_load_cb,
+ locd);
if (cal_client_load_calendar (gcal->client, file) == FALSE){
printf ("Error loading calendar: %s\n", file);
@@ -293,26 +335,6 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
return 1;
}
-int
-gnome_calendar_create (GnomeCalendar *gcal, char *file)
-{
- g_return_val_if_fail (gcal != NULL, 0);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
- g_return_val_if_fail (file != NULL, 0);
-
- /* FIXME: connect to the cal_loaded signal fo the CalClient and get the
- * asynchronous notification properly!
- */
-
- /* if ((r = calendar_load (gcal->cal, file)) != NULL){ DELETE */
- if (cal_client_create_calendar (gcal->client, file) == FALSE){
- printf ("Error creating calendar: %s\n", file);
- return 0;
- }
- gnome_calendar_update_all (gcal, NULL, 0);
- return 1;
-}
-
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 6437977d6b..75406e1c71 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -45,12 +45,21 @@ typedef struct {
GnomeAppClass parent_class;
} GnomeCalendarClass;
+
+typedef enum {
+ CALENDAR_OPEN,
+ CALENDAR_OPEN_OR_CREATE
+} GnomeCalendarOpenMode;
+
guint gnome_calendar_get_type (void);
GtkWidget *gnome_calendar_new (char *title);
-int gnome_calendar_load (GnomeCalendar *gcal,
- char *file);
+int gnome_calendar_open (GnomeCalendar *gcal,
+ char *file,
+ GnomeCalendarOpenMode gcom);
+/*
int gnome_calendar_create (GnomeCalendar *gcal,
char *file);
+*/
void gnome_calendar_add_object (GnomeCalendar *gcal,
iCalObject *obj);
void gnome_calendar_remove_object (GnomeCalendar *gcal,
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 8c4d4d02be..b9198c54d1 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -205,6 +205,8 @@ save (CalBackend *backend)
/* FIX ME log */
break;
}
+
+ printf ("cal-backend: '%s' saved\n", str_uri);
}