aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-04-20 00:55:59 +0800
committerSeth Alves <alves@src.gnome.org>2000-04-20 00:55:59 +0800
commitd8e30fdcb380d2a715a915c8278a024c07c12815 (patch)
tree02b3d0230362f550ed5197663922e65e6d67879a /calendar/gui
parentd3a3dd69a846a5642d7b66294410fb671a498ec0 (diff)
downloadgsoc2013-evolution-d8e30fdcb380d2a715a915c8278a024c07c12815.tar.gz
gsoc2013-evolution-d8e30fdcb380d2a715a915c8278a024c07c12815.tar.zst
gsoc2013-evolution-d8e30fdcb380d2a715a915c8278a024c07c12815.zip
calls gnome_calendar_open instead of checking on disk and calling load or
* 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_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. svn path=/trunk/; revision=2506
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar-commands.c17
-rw-r--r--calendar/gui/gnome-cal.c102
-rw-r--r--calendar/gui/gnome-cal.h13
3 files changed, 80 insertions, 52 deletions
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,