[evolution] Fix GnomeCalendar lifecycle; not being a widget meant we didn't get a gtk_widget_destroy inv



commit f767cb847bebc3b9935137076d7e43f44f029029
Author: Michael Meeks <michael meeks novell com>
Date:   Sat Mar 13 19:48:21 2010 +0000

        Fix GnomeCalendar lifecycle; not being a widget meant we didn't
        get a gtk_widget_destroy invocation, which meant we left some
        callbacks registered, long after our child 'views' were destroyed
        causing sudden death in update_marcus_bains_line_cb, manipulating
        views.

 calendar/gui/gnome-cal.c               |   20 +++++++++++---------
 calendar/gui/gnome-cal.h               |    5 +++--
 modules/calendar/e-cal-shell-content.c |    4 +---
 3 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 8c48b8e..a8afeff 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -151,7 +151,7 @@ enum {
 
 static guint signals[LAST_SIGNAL];
 
-static void gnome_calendar_destroy (GtkObject *object);
+static void gnome_calendar_do_dispose (GObject *object);
 static void gnome_calendar_goto_date (GnomeCalendar *gcal,
 				      GnomeCalendarGotoDateType goto_date);
 
@@ -195,7 +195,7 @@ message_push (Message *msg)
 	g_thread_pool_push ((GThreadPool *) once.retval, msg, NULL);
 }
 
-G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, GTK_TYPE_VBOX)
+G_DEFINE_TYPE (GnomeCalendar, gnome_calendar, G_TYPE_OBJECT)
 
 static void
 gcal_update_status_message (GnomeCalendar *gcal, const gchar *message, gdouble percent)
@@ -482,16 +482,13 @@ static void
 gnome_calendar_class_init (GnomeCalendarClass *class)
 {
 	GObjectClass *object_class;
-	GtkObjectClass *gtk_object_class;
 	GtkBindingSet *binding_set;
 
 	object_class = G_OBJECT_CLASS (class);
 	object_class->set_property = gnome_calendar_set_property;
 	object_class->get_property = gnome_calendar_get_property;
 	object_class->constructed = gnome_calendar_constructed;
-
-	gtk_object_class = GTK_OBJECT_CLASS (class);
-	gtk_object_class->destroy = gnome_calendar_destroy;
+	object_class->dispose = gnome_calendar_do_dispose;
 
 	class->dates_shown_changed = NULL;
 	class->calendar_selection_changed = NULL;
@@ -1384,7 +1381,7 @@ gnome_calendar_init (GnomeCalendar *gcal)
 }
 
 static void
-gnome_calendar_destroy (GtkObject *object)
+gnome_calendar_do_dispose (GObject *object)
 {
 	GnomeCalendar *gcal;
 	GnomeCalendarPrivate *priv;
@@ -1454,8 +1451,13 @@ gnome_calendar_destroy (GtkObject *object)
 		gcal->priv = NULL;
 	}
 
-	if (GTK_OBJECT_CLASS (gnome_calendar_parent_class)->destroy)
-		(* GTK_OBJECT_CLASS (gnome_calendar_parent_class)->destroy) (object);
+	G_OBJECT_CLASS (gnome_calendar_parent_class)->dispose (object);
+}
+
+void
+gnome_calendar_dispose (GnomeCalendar *gcal)
+{
+	g_object_run_dispose (G_OBJECT (gcal));
 }
 
 static void
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 91d80f0..b24648e 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -85,12 +85,12 @@ typedef enum {
 } GnomeCalendarGotoDateType;
 
 struct _GnomeCalendar {
-	GtkVBox vbox;
+	GObject parent;
 	GnomeCalendarPrivate *priv;
 };
 
 struct _GnomeCalendarClass {
-	GtkVBoxClass parent_class;
+	GObjectClass parent_class;
 
 	/* Notification signals */
 	void	(*dates_shown_changed)		(GnomeCalendar *gcal);
@@ -114,6 +114,7 @@ struct _GnomeCalendarClass {
 
 GType		gnome_calendar_get_type		(void);
 GtkWidget *	gnome_calendar_new		(EShellSettings *shell_settings);
+void		gnome_calendar_dispose          (GnomeCalendar *gcal);
 EShellSettings *gnome_calendar_get_shell_settings
 						(GnomeCalendar *gcal);
 ECalendar *	gnome_calendar_get_date_navigator
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 67081ce..bffa39a 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -204,6 +204,7 @@ cal_shell_content_dispose (GObject *object)
 	}
 
 	if (priv->calendar != NULL) {
+		gnome_calendar_dispose (priv->calendar);
 		g_object_unref (priv->calendar);
 		priv->calendar = NULL;
 	}
@@ -324,10 +325,7 @@ cal_shell_content_constructed (GObject *object)
 	/* Add views in the order defined by GnomeCalendarViewType, such
 	 * that the notebook page number corresponds to the view type. */
 
-	/* XXX GnomeCalendar is a widget, but we don't pack it.
-	 *     Maybe it should just be a GObject instead? */
 	priv->calendar = gnome_calendar_new (shell_settings);
-	g_object_ref_sink (priv->calendar);
 	calendar = GNOME_CALENDAR (priv->calendar);
 
 	for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]