[gitg/vala] Can't use GLib.SList as property type



commit 03f8446283eebb58d5c2fbba1bbc1f05b5fc8e31
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Wed Apr 25 00:01:27 2012 +0200

    Can't use GLib.SList as property type

 libgitg-gtk/gitg-gtk-cell-renderer-lanes.vala |   35 +++++++++++++-----------
 libgitg-gtk/gitg-gtk-commit-model.vala        |    1 +
 libgitg/gitg-commit.vala                      |   22 +++++++++++----
 libgitg/gitg-lanes.vala                       |   12 +++-----
 4 files changed, 41 insertions(+), 29 deletions(-)
---
diff --git a/libgitg-gtk/gitg-gtk-cell-renderer-lanes.vala b/libgitg-gtk/gitg-gtk-cell-renderer-lanes.vala
index c2b080a..440ef35 100644
--- a/libgitg-gtk/gitg-gtk-cell-renderer-lanes.vala
+++ b/libgitg-gtk/gitg-gtk-cell-renderer-lanes.vala
@@ -12,7 +12,7 @@ namespace GitgGtk
 
 		private uint num_lanes
 		{
-			get { return commit.lanes.length(); }
+			get { return commit.get_lanes().length(); }
 		}
 
 		private uint total_width(Gtk.Widget widget)
@@ -61,7 +61,7 @@ namespace GitgGtk
 		{
 			uint to = 0;
 
-			foreach (Gitg.Lane lane in commit.lanes)
+			foreach (var lane in commit.get_lanes())
 			{
 				var color = lane.color;
 				context.set_source_rgb(color.r, color.g, color.b);
@@ -93,7 +93,7 @@ namespace GitgGtk
 			double cw = lane_width;
 			double ch = area.height / 2.0;
 
-			foreach (var lane in commit.lanes)
+			foreach (var lane in commit.get_lanes())
 			{
 				var color = lane.color;
 				context.set_source_rgb(color.r, color.g, color.b);
@@ -185,26 +185,29 @@ namespace GitgGtk
 		                            Gdk.Rectangle         cell_area,
 		                            Gtk.CellRendererState flags)
 		{
-			d_last_height = area.height;
+			var ncell_area = cell_area;
+			var narea = area;
 
-			context.save();
+			d_last_height = area.height;
 
-			Gdk.cairo_rectangle(context, area);
-			context.clip();
+			if (commit != null)
+			{
+				context.save();
 
-			draw_paths(context, area);
-			draw_indicator(context, area);
-			draw_labels(context, area, widget);
+				Gdk.cairo_rectangle(context, area);
+				context.clip();
 
-			var narea = area;
-			var ncell_area = cell_area;
+				draw_paths(context, area);
+				draw_indicator(context, area);
+				draw_labels(context, area, widget);
 
-			var tw = total_width(widget);
+				var tw = total_width(widget);
 
-			narea.x += (int)tw;
-			ncell_area.x += (int)tw;
+				narea.x += (int)tw;
+				ncell_area.x += (int)tw;
 
-			context.restore();
+				context.restore();
+			}
 
 			base.render(context, widget, narea, ncell_area, flags);
 		}
diff --git a/libgitg-gtk/gitg-gtk-commit-model.vala b/libgitg-gtk/gitg-gtk-commit-model.vala
index a9ef278..c141e66 100644
--- a/libgitg-gtk/gitg-gtk-commit-model.vala
+++ b/libgitg-gtk/gitg-gtk-commit-model.vala
@@ -213,6 +213,7 @@ namespace GitgGtk
 			return_val_if_fail(iter.stamp == d_stamp, null);
 
 			uint idx = (uint)(ulong)iter.user_data;
+
 			return base[idx];
 		}
 
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 905d43b..65c0266 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -6,8 +6,12 @@ public class Commit : Ggit.Commit
 	public LaneTag tag { get; set; }
 
 	private uint d_mylane;
+	private SList<Lane> d_lanes;
 
-	public unowned SList<Lane> lanes { get; set; }
+	public unowned SList<Lane> get_lanes()
+	{
+		return d_lanes;
+	}
 
 	public uint mylane
 	{
@@ -21,18 +25,24 @@ public class Commit : Ggit.Commit
 
 	public Lane lane
 	{
-		get { return lanes.nth_data(d_mylane); }
+		get { return d_lanes.nth_data(d_mylane); }
+	}
+
+	public unowned SList<Lane> insert_lane(Lane lane, int idx)
+	{
+		d_lanes.insert(lane, idx);
+		return d_lanes;
 	}
 
 	public unowned SList<Lane> remove_lane(Lane lane)
 	{
-		lanes.remove(lane);
-		return lanes;
+		d_lanes.remove(lane);
+		return d_lanes;
 	}
 
 	private void update_lane_tag()
 	{
-		unowned Lane? lane = lanes.nth_data(d_mylane);
+		unowned Lane? lane = d_lanes.nth_data(d_mylane);
 
 		if (lane == null)
 		{
@@ -46,7 +56,7 @@ public class Commit : Ggit.Commit
 
 	public void update_lanes(owned SList<Lane> lanes, int mylane)
 	{
-		lanes = (owned)lanes;
+		d_lanes = (owned)lanes;
 
 		if (mylane >= 0)
 		{
diff --git a/libgitg/gitg-lanes.vala b/libgitg/gitg-lanes.vala
index 78a9672..ef670a8 100644
--- a/libgitg/gitg-lanes.vala
+++ b/libgitg/gitg-lanes.vala
@@ -208,9 +208,8 @@ public class Lanes : Object
 		while (item != null)
 		{
 			var commit = item.data;
-			unowned SList<Lane> lns = commit.lanes;
-			unowned SList<Lane> lstlane = lns.nth(index);
-			unowned Lane lane = lstlane.data;
+			unowned SList<Lane> lns = commit.get_lanes();
+			unowned Lane lane = lns.nth_data(index);
 
 			if (item.next != null)
 			{
@@ -270,7 +269,7 @@ public class Lanes : Object
 	private int ensure_correct_index(Commit commit,
 	                                 int    index)
 	{
-		var len = commit.lanes.length();
+		var len = commit.get_lanes().length();
 
 		if (index > len)
 		{
@@ -357,7 +356,7 @@ public class Lanes : Object
 
 			// Insert new lane at the index
 			Lane copy = ln.copy();
-			unowned SList<Lane> lns = commit.lanes;
+			unowned SList<Lane> lns = commit.get_lanes();
 
 			if (ptr.next == null || cnt + 1 == inactive_collapse)
 			{
@@ -372,8 +371,7 @@ public class Lanes : Object
 				update_merge_indices(lns, (int)index, 1);
 			}
 
-			commit.lanes.insert((owned)copy, (int)index);
-			lns = commit.lanes;
+			commit.insert_lane(copy, (int)index);
 
 			var mylane = commit.mylane;
 



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