This shows unpartitioned space, not reclaimable space on filesystems.
---
pyanaconda/ui/gui/spokes/storage.py | 3 ++
widgets/python/AnacondaWidgets.py | 3 +-
widgets/src/DiskOverview.c | 69 +++++++++++++++++++++++++++++--------
3 files changed, 59 insertions(+), 16 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 24d8818..0cb6b30 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -580,9 +580,12 @@ class StorageSpoke(NormalSpoke, StorageChecker):
else:
description = disk.description
+ free = self.storage.getFreeSpace(disks=[disk])[disk.name][1]
+
overview = AnacondaWidgets.DiskOverview(description,
kind,
size,
+ _("%s free") % size_str(free),
disk.name,
popup=popup_info)
box.pack_start(overview, False, False, 0)
diff --git a/widgets/python/AnacondaWidgets.py b/widgets/python/AnacondaWidgets.py
index edb9f35..e2899a8 100644
--- a/widgets/python/AnacondaWidgets.py
+++ b/widgets/python/AnacondaWidgets.py
@@ -63,10 +63,11 @@ SpokeSelector = override(SpokeSelector)
__all__.append('SpokeSelector')
class DiskOverview(Anaconda.DiskOverview):
- def __init__(self, description, kind, capacity, name, popup=None):
+ def __init__(self, description, kind, capacity, free, name, popup=None):
Anaconda.DiskOverview.__init__(self)
self.set_property("description", description)
self.set_property("kind", kind)
+ self.set_property("free", free)
self.set_property("capacity", capacity)
self.set_property("name", name)
diff --git a/widgets/src/DiskOverview.c b/widgets/src/DiskOverview.c
index 2dcade1..7685f52 100644
--- a/widgets/src/DiskOverview.c
+++ b/widgets/src/DiskOverview.c
@@ -42,6 +42,7 @@
enum {
PROP_DESCRIPTION = 1,
PROP_KIND,
+ PROP_FREE,
PROP_CAPACITY,
PROP_NAME,
PROP_POPUP_INFO
@@ -51,16 +52,17 @@ enum {
#define DEFAULT_DESCRIPTION N_("New Device")
#define DEFAULT_KIND "drive-harddisk"
#define DEFAULT_CAPACITY N_("0 MB")
+#define DEFAULT_FREE N_("0 MB")
#define DEFAULT_NAME ""
#define DEFAULT_POPUP_INFO ""
#define ICON_SIZE 128
struct _AnacondaDiskOverviewPrivate {
- GtkWidget *vbox;
+ GtkWidget *grid;
GtkWidget *kind_icon;
GtkWidget *description_label;
- GtkWidget *capacity_label;
+ GtkWidget *capacity_label, *free_label;
GtkWidget *name_label;
GtkWidget *tooltip;
@@ -138,6 +140,22 @@ static void anaconda_disk_overview_class_init(AnacondaDiskOverviewClass *klass)
G_PARAM_READWRITE));
/**
+ * AnacondaDiskOverview:free:
+ *
+ * The :free string is the amount of free, unpartitioned space on the disk,
+ * plus units.
+ *
+ * Since: 1.0
+ */
+ g_object_class_install_property(object_class,
+ PROP_FREE,
+ g_param_spec_string("free",
+ P_("Free space"),
+ P_("The drive's unpartitioned free space (including units)"),
+ DEFAULT_FREE,
+ G_PARAM_READWRITE));
+
+ /**
* AnacondaDiskOverview:name:
*
* The :name string provides this device's node name (like 'sda'). Note
@@ -254,9 +272,11 @@ static void anaconda_disk_overview_init(AnacondaDiskOverview *widget) {
/* Set some properties. */
widget->priv->chosen = FALSE;
- /* Create the vbox. */
- widget->priv->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_set_border_width(GTK_CONTAINER(widget->priv->vbox), 6);
+ /* Create the grid. */
+ widget->priv->grid = gtk_grid_new();
+ gtk_grid_set_row_spacing(GTK_GRID(widget->priv->grid), 6);
+ gtk_grid_set_column_spacing(GTK_GRID(widget->priv->grid), 6);
+ gtk_container_set_border_width(GTK_CONTAINER(widget->priv->grid), 6);
/* Create the capacity label. */
widget->priv->capacity_label = gtk_label_new(NULL);
@@ -275,14 +295,24 @@ static void anaconda_disk_overview_init(AnacondaDiskOverview *widget) {
/* Create the name label. */
widget->priv->name_label = gtk_label_new(NULL);
+ gtk_widget_set_halign(widget->priv->name_label, GTK_ALIGN_END);
+
+ /* Create the free space label. */
+ widget->priv->free_label = gtk_label_new(NULL);
+ gtk_widget_set_halign(widget->priv->free_label, GTK_ALIGN_START);
+ markup = g_markup_printf_escaped("<span size='large'>%s</span>", _(DEFAULT_FREE));
+ gtk_label_set_markup(GTK_LABEL(widget->priv->capacity_label), markup);
+ g_free(markup);
- /* Add everything to the vbox, add the vbox to the widget. */
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->capacity_label);
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->kind_icon);
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->description_label);
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->name_label);
+ /* Add everything to the grid, add the grid to the widget. */
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->capacity_label, 0, 0, 3, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->kind_icon, 0, 1, 3, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->description_label, 0, 2, 3, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->name_label, 0, 3, 1, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), gtk_label_new("/"), 1, 3, 1, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->free_label, 2, 3, 1, 1);
- gtk_container_add(GTK_CONTAINER(widget), widget->priv->vbox);
+ gtk_container_add(GTK_CONTAINER(widget), widget->priv->grid);
/* We need to handle button-press-event in order to change the background color. */
g_signal_connect(widget, "button-press-event", G_CALLBACK(anaconda_disk_overview_clicked), NULL);
@@ -315,8 +345,7 @@ static void anaconda_disk_overview_toggle_background(AnacondaDiskOverview *widge
gtk_widget_unset_state_flags(GTK_WIDGET(widget), GTK_STATE_FLAG_SELECTED);
set_icon(widget, widget->priv->kind);
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->kind_icon);
- gtk_box_reorder_child(GTK_BOX(widget->priv->vbox), widget->priv->kind_icon, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->kind_icon, 0, 1, 3, 1);
gtk_widget_show(widget->priv->kind_icon);
}
@@ -343,6 +372,10 @@ static void anaconda_disk_overview_get_property(GObject *object, guint prop_id,
g_value_set_object (value, (GObject *)priv->kind_icon);
break;
+ case PROP_FREE:
+ g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->free_label)));
+ break;
+
case PROP_CAPACITY:
g_value_set_string (value, gtk_label_get_text(GTK_LABEL(priv->capacity_label)));
break;
@@ -375,10 +408,16 @@ static void anaconda_disk_overview_set_property(GObject *object, guint prop_id,
widget->priv->kind = g_strdup(g_value_get_string(value));
set_icon(widget, widget->priv->kind);
- gtk_container_add(GTK_CONTAINER(widget->priv->vbox), widget->priv->kind_icon);
- gtk_box_reorder_child(GTK_BOX(widget->priv->vbox), widget->priv->kind_icon, 1);
+ gtk_grid_attach(GTK_GRID(widget->priv->grid), widget->priv->kind_icon, 0, 1, 3, 1);
break;
+ case PROP_FREE: {
+ char *markup = g_markup_printf_escaped("<span size='large'>%s</span>", g_value_get_string(value));
+ gtk_label_set_markup(GTK_LABEL(priv->free_label), markup);
+ g_free(markup);
+ break;
+ }
+
case PROP_CAPACITY: {
char *markup = g_markup_printf_escaped("<span size='large'>%s</span>", g_value_get_string(value));
gtk_label_set_markup(GTK_LABEL(priv->capacity_label), markup);
--
1.8.1.2