[glide] Implement finalize for slide buttons



commit ffcc1f0d590863c256173ba708ac95e69dcdb7b4
Author: Robert Carr <racarr Valentine localdomain>
Date:   Thu Apr 29 05:28:34 2010 -0400

    Implement finalize for slide buttons

 src/glide-slide-button-priv.h |    4 ++++
 src/glide-slide-button.c      |   21 +++++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/glide-slide-button-priv.h b/src/glide-slide-button-priv.h
index 19a6261..fce26ba 100644
--- a/src/glide-slide-button-priv.h
+++ b/src/glide-slide-button-priv.h
@@ -29,6 +29,10 @@ struct _GlideSlideButtonPrivate
   GlideSlide *slide;
   
   GtkWidget *drawing_area;
+  
+  guint position_changed_id;
+  
+  GlideUndoManager *manager;
 };
 
 G_END_DECLS
diff --git a/src/glide-slide-button.c b/src/glide-slide-button.c
index 1b22083..f859de3 100644
--- a/src/glide-slide-button.c
+++ b/src/glide-slide-button.c
@@ -98,7 +98,17 @@ glide_slide_button_set_property (GObject *object,
 static void
 glide_slide_button_finalize (GObject *object)
 {
+  GlideSlideButton *button = (GlideSlideButton *)object;
+  gtk_widget_destroy (button->priv->drawing_area);
   
+  if (button->priv->manager)
+    {
+      if (button->priv->position_changed_id)
+	{
+	  g_signal_handler_disconnect (button->priv->manager, button->priv->position_changed_id);
+	}
+      g_object_unref (G_OBJECT (button->priv->manager));
+    }
 }
 
 static void
@@ -166,11 +176,14 @@ void
 glide_slide_button_set_slide (GlideSlideButton *button,
 			      GlideSlide *slide)
 {
-  GlideUndoManager *manager = 
-    glide_stage_manager_get_undo_manager (glide_actor_get_stage_manager (GLIDE_ACTOR (slide)));
+  button->priv->manager = 
+    (GlideUndoManager *)g_object_ref 
+    (G_OBJECT (glide_stage_manager_get_undo_manager 
+	       (glide_actor_get_stage_manager 
+		(GLIDE_ACTOR (slide)))));
   button->priv->slide = slide;
   g_object_notify (G_OBJECT (button), "slide");
   
-  g_signal_connect (manager, "position-changed",
-		    G_CALLBACK (glide_slide_button_undo_position_changed), button);
+  button->priv->position_changed_id = g_signal_connect (button->priv->manager, "position-changed",
+							G_CALLBACK (glide_slide_button_undo_position_changed), button);
 }



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