[baobab/wip/new-design] Layout improvements to the Location widget



commit 3d448a8baa7080333cac79e7e1395cf180d9bda6
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Tue Apr 3 16:02:07 2012 +0200

    Layout improvements to the Location widget

 src/baobab-volume-list.vala |   56 +++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 15 deletions(-)
---
diff --git a/src/baobab-volume-list.vala b/src/baobab-volume-list.vala
index 7abeff8..6f198da 100644
--- a/src/baobab-volume-list.vala
+++ b/src/baobab-volume-list.vala
@@ -147,48 +147,74 @@ namespace Baobab {
 	}
 
 	public class LocationWidget : Gtk.Grid {
+		private static Gtk.SizeGroup name_size_group = null;
+		private static Gtk.SizeGroup mount_point_size_group = null;
+		private static Gtk.SizeGroup size_size_group = null;
+		private static Gtk.SizeGroup used_size_group = null;
+		private static Gtk.SizeGroup button_size_group = null;
+
 		public delegate void ActionOnClick (Location location);
 
+		void ensure_size_groups () {
+			if (name_size_group == null)
+				name_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+
+			if (mount_point_size_group == null)
+				mount_point_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+
+			if (size_size_group == null)
+				size_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+
+			if (used_size_group == null)
+				used_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+
+			if (button_size_group == null)
+				button_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+		}
+
 		public LocationWidget (Location location, ActionOnClick action) {
 			orientation = Gtk.Orientation.HORIZONTAL;
 			column_spacing = 10;
 			margin = 6;
 
+			ensure_size_groups ();
+
 			var image = new Gtk.Image.from_gicon (location.icon, Gtk.IconSize.DIALOG);
 			add (image);
 
-			var label_grid = new Gtk.Grid ();
-			label_grid.orientation = Gtk.Orientation.VERTICAL;
 			var label = new Gtk.Label (location.name);
+			label.xalign = 0;
+			name_size_group.add_widget (label);
+			add (label);
+
+			label = new Gtk.Label (location.mount_point != null ? location.mount_point : "");
 			label.hexpand = true;
-			label.halign = Gtk.Align.START;
-			label_grid.add (label);
-			if (location.mount_point != null) {
-				label = new Gtk.Label (location.mount_point);
-				label.halign = Gtk.Align.START;
-				label.get_style_context ().add_class ("dim-label");
-				label_grid.add (label);
-			}
-			add (label_grid);
+			label.halign = Gtk.Align.CENTER;
+			label.xalign = 0;
+			label.get_style_context ().add_class ("dim-label");
+			mount_point_size_group.add_widget (label);
+			add (label);
 
-			if (location.size != null) {
-				label = new Gtk.Label (format_size (location.size));
-				add (label);
-			}
+			label = new Gtk.Label (location.size != null ? format_size (location.size) : "");
+			size_size_group.add_widget (label);
+			add (label);
 
 			if (location.used != null) {
 				var progress = new Gtk.ProgressBar ();
 				progress.valign = Gtk.Align.CENTER;
 				progress.set_fraction ((double) location.used / location.size);
+				used_size_group.add_widget (progress);
 				add (progress);
 			} else {
 				label = new Gtk.Label (_("Usage unknown"));
+				used_size_group.add_widget (label);
 				add (label);
 			}
 
 			string button_label = location.mount_point != null ? _("Scan") : _("Mount and scan");
 			var button = new Gtk.Button.with_label (button_label);
 			button.valign = Gtk.Align.CENTER;
+			button_size_group.add_widget (button);
 			add (button);
 
 			button.clicked.connect(() => { action (location); });



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