[ease/iconview] more stuff



commit 81ec5ae2c9936fca51dd2ee0904812d5f5287ff3
Author: Nate Stedman <natesm gmail com>
Date:   Thu Aug 26 19:50:33 2010 -0400

     more stuff

 ease-core/ease-icon-view.vala        |  117 +++++++++++++++++++++++++--------
 ease-core/ease-scrollable-embed.vala |    6 +-
 2 files changed, 91 insertions(+), 32 deletions(-)
---
diff --git a/ease-core/ease-icon-view.vala b/ease-core/ease-icon-view.vala
index d6ce669..10ffb2a 100644
--- a/ease-core/ease-icon-view.vala
+++ b/ease-core/ease-icon-view.vala
@@ -85,42 +85,20 @@ public class Ease.IconView : ScrollableEmbed
 			actors.clear();
 			
 			// add new actors for each of the model's rows
-			Gdk.Pixbuf pixbuf = null;
-			string text = null;
-			
 			model.foreach((model, path, iter) => {
 				// create a new actor
 				var actor = new IconActor();
 				
-				// set the actor's pixbuf (if possible)
-				if (pixbuf_column != -1)
-				{
-					model.get(iter, pixbuf_column, out pixbuf);
-					if (pixbuf != null) actor.set_pixbuf(pixbuf);
-				}
-				
-				// set the actor's markup (if possible)
-				bool text_set = false;
-				if (markup_column != -1)
-				{
-					model.get(iter, markup_column, out text);
-					if (text != null)
-					{
-						actor.set_markup(text);
-						text_set = true;
-					}
-				}
-				
-				// set the actor's text (if necessary & possible)
-				if (!text_set && text_column != -1)
-				{
-					model.get(iter, text_column, out text);
-					if (text != null) actor.set_text(text);
-				}
+				// set up the actor
+				set_actor(actor, iter, path);
 				
 				// add the actor
 				actors.offer_tail(actor);
 				
+				// actually add the actor
+				contents.add_actor(actor);
+				actor.show();
+				
 				// continue iterating
 				return false;
 			});
@@ -283,6 +261,7 @@ public class Ease.IconView : ScrollableEmbed
 	{
 		// initialize the ScrollableEmbed
 		base(false, false);
+		get_stage().color = {150, 150, 150, 255};
 	}
 	
 	public IconView.with_model(Gtk.TreeModel model)
@@ -304,15 +283,39 @@ public class Ease.IconView : ScrollableEmbed
 	private void on_model_row_changed(Gtk.TreeModel model, Gtk.TreePath path,
 	                                  Gtk.TreeIter iter)
 	{
+		foreach (var actor in actors)
+		{
+			if (actor.tree_path == path)
+			{
+				set_actor(actor, iter, path);
+				break;
+			}
+		}
 	}
 	
 	private void on_model_row_deleted(Gtk.TreeModel model, Gtk.TreePath path)
 	{
+		foreach (var actor in actors)
+		{
+			if (actor.tree_path == path)
+			{
+				contents.remove_actor(actor);
+				debug("Removed Actor");
+				break;
+			}
+		}
 	}
 	
 	private void on_model_row_inserted(Gtk.TreeModel model, Gtk.TreePath path,
 	                                   Gtk.TreeIter iter)
 	{
+		var actor = new IconActor();
+		set_actor(actor, iter, path);
+		actors.offer_tail(actor);
+		contents.add_actor(actor);
+		actor.show();
+		get_stage().show_all();
+		debug("Added Actor");
 	}
 	
 	private void on_model_rows_reordered(Gtk.TreeModel model, Gtk.TreePath path,
@@ -320,6 +323,42 @@ public class Ease.IconView : ScrollableEmbed
 	{
 	}
 	
+	private void set_actor(IconActor actor, Gtk.TreeIter iter,
+	                       Gtk.TreePath tree_path)
+	{
+		Gdk.Pixbuf pixbuf = null;
+		string text = null;
+			
+		// set the actor's pixbuf (if possible)
+		if (pixbuf_column != -1)
+		{
+			model.get(iter, pixbuf_column, out pixbuf);
+			if (pixbuf != null) actor.set_pixbuf(pixbuf);
+		}
+		
+		// set the actor's markup (if possible)
+		bool text_set = false;
+		if (markup_column != -1)
+		{
+			model.get(iter, markup_column, out text);
+			if (text != null)
+			{
+				actor.set_markup(text);
+				text_set = true;
+			}
+		}
+		
+		// set the actor's text (if necessary & possible)
+		if (!text_set && text_column != -1)
+		{
+			model.get(iter, text_column, out text);
+			if (text != null) actor.set_text(text);
+		}
+		
+		// set the actor's tree path
+		actor.tree_path = tree_path;
+	}
+	
 	/**
 	 * An embedded ClutterGroup that forms the basis of each icon/title tile.
 	 */
@@ -339,6 +378,11 @@ public class Ease.IconView : ScrollableEmbed
 		public Clutter.Texture texture;
 		
 		/**
+		 * A reference to the the pixbuf object.
+		 */
+		public Gdk.Pixbuf pixbuf;
+		
+		/**
 		 * A background that is automatically placed behind defocused icons.
 		 * This prevents these widgets from being transparent when they
 		 * overlap during reshuffling. This is automatically synced with the
@@ -346,6 +390,11 @@ public class Ease.IconView : ScrollableEmbed
 		 */
 		public Clutter.Rectangle background;
 		
+		/**
+		 * The TreePath to the data that this icon is displaying.
+		 */
+		public Gtk.TreePath tree_path;
+		
 		public IconActor()
 		{
 			text = new Clutter.Text();
@@ -353,6 +402,10 @@ public class Ease.IconView : ScrollableEmbed
 			text.font_name = "Sans 12";
 			
 			texture = new Clutter.Texture();
+			
+			background = new Clutter.Rectangle.with_color({255, 0, 0, 255});
+			background.set_size(200, 200);
+			background.show();
 		}
 		
 		/**
@@ -360,15 +413,19 @@ public class Ease.IconView : ScrollableEmbed
 		 */
 		public void set_pixbuf(Gdk.Pixbuf pixbuf)
 		{
+			if (this.pixbuf == pixbuf) return;
+			
+			this.pixbuf = pixbuf;
 			try
 			{
 				GtkClutter.texture_set_from_pixbuf(texture, pixbuf);
-				
+				texture.show();
 				height = width * (texture.height / texture.width) +
 				         2 * TEXT_PADDING + TEXT_HEIGHT;
 			}
 			catch (Error e)
 			{
+				texture.hide();
 				critical(e.message);
 			}                         
 		}
@@ -380,6 +437,7 @@ public class Ease.IconView : ScrollableEmbed
 		{
 			text.use_markup = true;
 			text.text = markup;
+			text.show();
 		}
 		
 		/**
@@ -389,6 +447,7 @@ public class Ease.IconView : ScrollableEmbed
 		{
 			this.text.use_markup = false;
 			this.text.text = text;
+			this.text.show();
 		}
 	}
 }
diff --git a/ease-core/ease-scrollable-embed.vala b/ease-core/ease-scrollable-embed.vala
index e1e4ff1..e1d72c9 100644
--- a/ease-core/ease-scrollable-embed.vala
+++ b/ease-core/ease-scrollable-embed.vala
@@ -76,9 +76,9 @@ public class Ease.ScrollableEmbed : Gtk.HBox
 
 		// set up clutter actors
 		viewport = new GtkClutter.Viewport(h_adjust, v_adjust, z_adjust);
-		contents = new Clutter.Group();
+		contents = new Flutter.Group();
 		
-		stage = (Clutter.Stage)(embed.get_stage());
+		stage = get_stage();
 		stage.add_actor(viewport);
 		viewport.child = contents;
 
@@ -175,7 +175,7 @@ public class Ease.ScrollableEmbed : Gtk.HBox
 	 */
 	public Clutter.Stage get_stage()
 	{
-		return (Clutter.Stage)(embed.get_stage());
+		return embed.get_stage() as Clutter.Stage;
 	}
 	
 	/**



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