aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gncal-day-view.c4
-rw-r--r--calendar/gnome-cal.c8
-rw-r--r--calendar/gnome-cal.h2
-rw-r--r--calendar/gui/gncal-day-view.c4
-rw-r--r--calendar/gui/gnome-cal.c8
-rw-r--r--calendar/gui/gnome-cal.h2
-rw-r--r--calendar/gui/main.c21
-rw-r--r--calendar/main.c21
8 files changed, 44 insertions, 26 deletions
diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c
index 2172810c52..e62d6ba2e6 100644
--- a/calendar/gncal-day-view.c
+++ b/calendar/gncal-day-view.c
@@ -291,10 +291,8 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
g_return_if_fail (dview != NULL);
g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
+ g_return_if_fail (dview->calendar->cal);
- if (!dview->calendar->cal)
- return;
-
if (dview->day_str)
g_free (dview->day_str);
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index b851b65d44..434af707bc 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -137,8 +137,6 @@ gnome_calendar_init(GnomeCalendar *gcal)
gcal->week_view = 0;
gcal->year_view = 0;
gcal->event_editor = 0;
-
- setup_widgets (gcal);
}
static GtkWidget *
@@ -222,6 +220,7 @@ gnome_calendar_new (char *title)
gcal->current_display = time (NULL);
gcal->cal = calendar_new (title);
+ setup_widgets (gcal);
return retval;
}
@@ -233,16 +232,17 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
}
-void
+int
gnome_calendar_load (GnomeCalendar *gcal, char *file)
{
char *r;
if ((r = calendar_load (gcal->cal, file)) != NULL){
printf ("Error loading calendar: %s\n", r);
- return;
+ return 0;
}
gnome_calendar_update_all (gcal, NULL, 0);
+ return 1;
}
void
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
index 002aed07ae..88e5fc5b6d 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/gnome-cal.h
@@ -40,7 +40,7 @@ typedef struct {
guint gnome_calendar_get_type (void);
GtkWidget *gnome_calendar_new (char *title);
-void gnome_calendar_load (GnomeCalendar *gcal, char *file);
+int gnome_calendar_load (GnomeCalendar *gcal, char *file);
void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_next (GnomeCalendar *gcal);
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
index 2172810c52..e62d6ba2e6 100644
--- a/calendar/gui/gncal-day-view.c
+++ b/calendar/gui/gncal-day-view.c
@@ -291,10 +291,8 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
g_return_if_fail (dview != NULL);
g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
+ g_return_if_fail (dview->calendar->cal);
- if (!dview->calendar->cal)
- return;
-
if (dview->day_str)
g_free (dview->day_str);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index b851b65d44..434af707bc 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -137,8 +137,6 @@ gnome_calendar_init(GnomeCalendar *gcal)
gcal->week_view = 0;
gcal->year_view = 0;
gcal->event_editor = 0;
-
- setup_widgets (gcal);
}
static GtkWidget *
@@ -222,6 +220,7 @@ gnome_calendar_new (char *title)
gcal->current_display = time (NULL);
gcal->cal = calendar_new (title);
+ setup_widgets (gcal);
return retval;
}
@@ -233,16 +232,17 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags);
}
-void
+int
gnome_calendar_load (GnomeCalendar *gcal, char *file)
{
char *r;
if ((r = calendar_load (gcal->cal, file)) != NULL){
printf ("Error loading calendar: %s\n", r);
- return;
+ return 0;
}
gnome_calendar_update_all (gcal, NULL, 0);
+ return 1;
}
void
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 002aed07ae..88e5fc5b6d 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -40,7 +40,7 @@ typedef struct {
guint gnome_calendar_get_type (void);
GtkWidget *gnome_calendar_new (char *title);
-void gnome_calendar_load (GnomeCalendar *gcal, char *file);
+int gnome_calendar_load (GnomeCalendar *gcal, char *file);
void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_next (GnomeCalendar *gcal);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index ff4fc370a9..e4dfdf77b9 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -130,6 +130,7 @@ display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
void
close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
+ all_calendars = g_list_remove (all_calendars, gcal);
if (gcal->cal->modified){
if (!gcal->cal->filename)
save_calendar_cmd (widget, gcal);
@@ -137,9 +138,8 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
calendar_save (gcal->cal, gcal->cal->filename);
}
- gtk_widget_destroy (GTK_WIDGET (gcal));
+/* gtk_widget_destroy (GTK_WIDGET (gcal)); */
active_calendars--;
- all_calendars = g_list_remove (all_calendars, gcal);
if (active_calendars == 0)
gtk_main_quit ();
@@ -218,7 +218,14 @@ save_ok (GtkWidget *widget, GtkFileSelection *fs)
gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
calendar_save (gcal->cal, gcal->cal->filename);
- gtk_widget_destroy (GTK_WIDGET (fs));
+ gtk_main_quit ();
+}
+
+static gint
+close_save (GtkWidget *w)
+{
+ gtk_main_quit ();
+ return TRUE;
}
void
@@ -233,11 +240,15 @@ save_calendar_cmd (GtkWidget *widget, void *data)
(GtkSignalFunc) save_ok,
fs);
gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) gtk_widget_destroy,
+ (GtkSignalFunc) close_save,
+ GTK_OBJECT (fs));
+ gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event",
+ GTK_SIGNAL_FUNC (close_save),
GTK_OBJECT (fs));
-
gtk_widget_show (GTK_WIDGET (fs));
gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */
+ gtk_main ();
+ gtk_widget_destroy (GTK_WIDGET (fs));
}
GnomeUIInfo gnome_cal_file_menu [] = {
diff --git a/calendar/main.c b/calendar/main.c
index ff4fc370a9..e4dfdf77b9 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -130,6 +130,7 @@ display_objedit (GtkWidget *widget, GnomeCalendar *gcal)
void
close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
+ all_calendars = g_list_remove (all_calendars, gcal);
if (gcal->cal->modified){
if (!gcal->cal->filename)
save_calendar_cmd (widget, gcal);
@@ -137,9 +138,8 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
calendar_save (gcal->cal, gcal->cal->filename);
}
- gtk_widget_destroy (GTK_WIDGET (gcal));
+/* gtk_widget_destroy (GTK_WIDGET (gcal)); */
active_calendars--;
- all_calendars = g_list_remove (all_calendars, gcal);
if (active_calendars == 0)
gtk_main_quit ();
@@ -218,7 +218,14 @@ save_ok (GtkWidget *widget, GtkFileSelection *fs)
gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs));
calendar_save (gcal->cal, gcal->cal->filename);
- gtk_widget_destroy (GTK_WIDGET (fs));
+ gtk_main_quit ();
+}
+
+static gint
+close_save (GtkWidget *w)
+{
+ gtk_main_quit ();
+ return TRUE;
}
void
@@ -233,11 +240,15 @@ save_calendar_cmd (GtkWidget *widget, void *data)
(GtkSignalFunc) save_ok,
fs);
gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked",
- (GtkSignalFunc) gtk_widget_destroy,
+ (GtkSignalFunc) close_save,
+ GTK_OBJECT (fs));
+ gtk_signal_connect_object (GTK_OBJECT (fs), "delete_event",
+ GTK_SIGNAL_FUNC (close_save),
GTK_OBJECT (fs));
-
gtk_widget_show (GTK_WIDGET (fs));
gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */
+ gtk_main ();
+ gtk_widget_destroy (GTK_WIDGET (fs));
}
GnomeUIInfo gnome_cal_file_menu [] = {