[ease] [editor] Fix thumbnails not redrawing.



commit 174be960a39c7d69a872b7df09b8e5e88b6ea8fc
Author: Nate Stedman <natesm gmail com>
Date:   Mon Jul 26 20:33:06 2010 -0400

    [editor] Fix thumbnails not redrawing.

 src/ease-slide-button-panel.vala |   45 +++++++++++++++++++++++++------------
 1 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/src/ease-slide-button-panel.vala b/src/ease-slide-button-panel.vala
index 3bb2349..1a50e69 100644
--- a/src/ease-slide-button-panel.vala
+++ b/src/ease-slide-button-panel.vala
@@ -89,32 +89,30 @@ public class Ease.SlideButtonPanel : Gtk.ScrolledWindow
 		add(viewport);
 		
 		// render pixbufs for all current slides
+		Slide s;
 		foreach (var itr in document.slides)
 		{
 			slide_redraw(itr);
+			document.slides.get(itr, Document.COL_SLIDE, out s);
+			s.changed.connect(on_slide_changed);
 		}
 		
 		// switch slides when the selection changes
 		slides.get_selection().changed.connect((sender) => {
 			slides.get_selection().selected_foreach((m, p, itr) => {
-				Slide s = new Slide();
-				m.get(itr, Document.COL_SLIDE, ref s);
-				owner.set_slide(document.index_of(s));
+				Slide sl;
+				m.get(itr, Document.COL_SLIDE, out sl);
+				owner.set_slide(document.index_of(sl));
 			});
 		});
 		
 		document.slide_added.connect((slide, index) => {
-			Slide s;
-			foreach (var itr in document.slides)
-			{
-				document.slides.get(itr, Document.COL_SLIDE, out s);
-				if (s == slide)
-				{
-					slide_redraw(itr);
-					return;
-				}
-			}
-			debug("new slide");
+			on_slide_changed(slide);
+			slide.changed.connect(on_slide_changed);
+		});
+		
+		document.slide_deleted.connect((slide, index) => {
+			slide.changed.disconnect(on_slide_changed);
 		});
 		
 		// redraw all slides when the size allocation changes
@@ -174,7 +172,7 @@ public class Ease.SlideButtonPanel : Gtk.ScrolledWindow
 	 *
 	 * @param slide The slide to create a pixbuf of.
 	 */
-	private Gdk.Pixbuf? pixbuf(Slide slide, int width)
+	private static Gdk.Pixbuf? pixbuf(Slide slide, int width)
 	{
 		var height = (int)((float)width * slide.parent.height /
 		                                  slide.parent.width);
@@ -214,5 +212,22 @@ public class Ease.SlideButtonPanel : Gtk.ScrolledWindow
 		}
 		catch (GLib.Error e) { error(e.message); return null; }
 	}
+	
+	/**
+	 * Handles { link Slide.changed}
+	 */
+	private void on_slide_changed(Slide slide)
+	{
+		Slide s;
+		foreach (var itr in document.slides)
+		{
+			document.slides.get(itr, Document.COL_SLIDE, out s);
+			if (s == slide)
+			{
+				slide_redraw(itr);
+				return;
+			}
+		}
+	}
 }
 



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