Author: kmachalkova
Date: Fri Jul 25 18:17:07 2008
New Revision: 49424
URL: http://svn.opensuse.org/viewcvs/yast?rev=49424&view=rev
Log:
- Pass real partition size data to resize partition
dialog
- Adjust bar graph labels acc. to type of partition
(todo: adjust units, special cases for window partitions
etc.)
Modified:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-dialogs.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp?rev=49424&r1=49423&r2=49424&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp Fri Jul 25 18:17:07 2008
@@ -307,35 +307,100 @@
return widget;
}
-
- map DlgResize(map &data , symbol flavour)
+ //data i.e. partition
+ map DlgResize(map &data , map disk, symbol flavour)
{
+ integer cyl_size = disk["cyl_size"]:1;
+ integer free_cyl_after = Storage::FreeCylAfter( disk, data);
+ integer av_space = cyl_size * free_cyl_after;
+ integer fsid = data["fsid"]:0;
string device = data["device"]:"error";
- integer lv_used = 3500;
+ symbol used_fs = data["used_fs"]:`none;
+
+ /*integer lv_used = 3500;
integer lv_free = 7000;
integer lv_min_free = 10;
integer vg_free = 80000;
- integer vg_min_free = 0;
+ integer vg_min_free = 0;*/
- integer total_free = lv_free + vg_free;
- integer total = lv_used + total_free;
+ integer used = 0;
+ integer free = 0;
+ integer total = 0;
+ //leave this 5 for now, will be different for Windows
+ integer min_free = 5;
// Unit for partition resizing - currently Megabytes
string unit = _("MB");
+ integer factor = 1024*1024;
string heading = "";
- string bargraph_label_lv_used = "";
- string bargraph_label_lv_free = "";
- string bargraph_label_vg_free = "";
- string field_label_lv_free = "";
+ string field_label_free = "";
string field_label_vg_free = "";
+ map AdjustSwapPartitionDf ( map size_data)
+ {
+ map ret = size_data;
+ ret["used"] = 0;
+ ret["df_free"] = data["region",1]:0 * cyl_size;
+
+ return ret;
+ }
+
+ list <string> BarGraphLabels()
+ {
+ string used = "";
+ string free = "";
+ string available = "";
+
+ if (flavour == `part)
+ {
+ //FIXME: add special case for Windows part.
+ used = _("Space\nUsed\n%1 ") + unit;
+
+ if ( Partitions::IsSwapPartition( fsid ) )
+ free = _("Swap\nSpace\n%1 ") + unit;
+ else
+ free = _("Space\nFree\n%1 ") + unit;
+
+ available = _("Unused\nDisk\n%1 ") + unit;
+ }
+ if (flavour == `lv)
+ {
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ used = _("LV\nUsed\n%1") + unit;
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ free = _("LV\nFree\n%1") + unit;
+ // Labels for bar graph. "%1" will be replace with a numeric value.
+ available = _("VG\nFree\n%1") + unit;
+ }
+
+ return [ used, free, available ];
+ }
+
if (flavour == `part)
{
+
// Heading for dialog
heading = sformat(_("Resize Partition %1"), device);
+ map size_data = Storage::GetFreeSpace( device, 0, used_fs, true);
+ y2internal("zirafa %1 %2", size_data["used"]:0, size_data["df_free"]:0);
+
+ if( size_data["df_free"]:0 > 15*1024*factor )
+ {
+ factor = factor * 1024;
+ unit = _("GB");
+ }
+
+ if ( Partitions::IsSwapPartition( fsid ) )
+ size_data = AdjustSwapPartitionDf( size_data );
+
+ used = size_data["used"]:0 / factor;
+ free = size_data["df_free"]:0 / factor;
+ av_space = av_space / factor;
+ total = used + free + av_space;
+
// TODO: see texts in inst_custom_part.ycp
}
else if (flavour == `lv)
@@ -343,15 +408,8 @@
// Heading for dialog
heading = sformat(_("Resize Logical Volume %1"), device);
- // Labels for bar graph. "%1" will be replace with a numeric value.
- bargraph_label_lv_used = _("LV\nUsed\n%1") + unit;
- // Labels for bar graph. "%1" will be replace with a numeric value.
- bargraph_label_lv_free = _("LV\nFree\n%1") + unit;
- // Labels for bar graph. "%1" will be replace with a numeric value.
- bargraph_label_vg_free = _("VG\nFree\n%1") + unit;
-
// Labels for input fields. "%1" will be replaced with the current unit (MB).
- field_label_lv_free = sformat(_("LV Free (%1)"), unit);
+ field_label_free = sformat(_("LV Free (%1)"), unit);
// Labels for input fields. "%1" will be replaced with the current unit (MB).
field_label_vg_free = sformat(_("VG Free (%1)"), unit);
}
@@ -362,17 +420,19 @@
UI::HasSpecialWidget(`Slider))
{
content = `VBox(
- `BarGraph(`id(`graph), `opt(`vstretch), [lv_used, total_free] ),
- `Slider(`id(`new_size), `opt(`notify), sformat(_("New Size (in %1)"), unit), vg_min_free,
- (lv_used + total_free - lv_min_free), lv_used )
+ `BarGraph(`id(`graph), `opt(`vstretch), [used, free, av_space], BarGraphLabels() ),
+ //`Slider(`id(`new_size), `opt(`notify), sformat(_("New Size (in %1)"), unit), vg_min_free,
+ // (lv_used + free - lv_min_free), lv_used )
+ `Slider(`id(`new_size), `opt(`notify), sformat(_("New Size (in %1)"), unit), used+min_free,
+ used + free + av_space, used+free)
);
}
else
{
content = `Frame("",
`IntField(`id(`new_size), `opt(`notify), sformat(_("New Size (in %1)"), unit),
- lv_used + lv_min_free, lv_used + lv_free + vg_free,
- lv_used + lv_free)
+ used + min_free, used + free + av_space,
+ used + free)
);
}
@@ -381,13 +441,13 @@
`Left(`Heading(heading)),
`HSpacing(60),
content,
- `Left(`Label( `id(`free), sformat(_("Free Space Remaining: %1 MB"), total_free ))),
+ `Left(`Label( `id(`free), sformat(_("Free Space Remaining: %1 MB"), free ))),
`VSpacing(1.0),
- `Left(`Label( sformat(_("Minimum Partition Size: %1 MB"), lv_min_free ))),
+ `Left(`Label( sformat(_("Minimum Partition Size: %1 MB"), used + min_free ))),
`Left(`Label( sformat(_("Maximum Partition Size: %1 MB"), total ))),
- //`PartitionSplitter(lv_used, total_free, vg_free, vg_min_free, lv_min_free,
- // bargraph_label_lv_used, bargraph_label_lv_free,
- // bargraph_label_vg_free, field_label_lv_free,
+ //`PartitionSplitter(lv_used, free, vg_free, vg_min_free, lv_min_free,
+ // bargraph_label_used, bargraph_label_free,
+ // bargraph_label_vg_free, field_label_free,
// field_label_vg_free),
`HBox(
`HStretch(),
@@ -404,9 +464,9 @@
if (widget == `new_size)
{
integer new_size = (integer) UI::QueryWidget(`id(`new_size), `Value);
- integer new_free = total - new_size;
- UI::ChangeWidget(`id(`graph), `Values, [ new_size, new_free ]);
- UI::ChangeWidget(`id(`free), `Value, sformat(_("Free Space Remaining: %1 MB"), (new_free)));
+ integer new_free = new_size - used ;
+ UI::ChangeWidget(`id(`graph), `Values, [ used, new_free, total - (new_free + used) ]);
+ UI::ChangeWidget(`id(`free), `Value, sformat(_("Free Space Remaining: %1 MB"), new_free));
}
} while ( widget != `cancel && widget != `ok);
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-dialogs.ycp?rev=49424&r1=49423&r2=49424&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-dialogs.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-dialogs.ycp Fri Jul 25 18:17:07 2008
@@ -245,8 +245,8 @@
}
- void DlgResizePartition( map data )
+ void DlgResizePartition( map data, map disk )
{
- DlgResize(data, `part);
+ DlgResize(data, disk, `part);
}
}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp?rev=49424&r1=49423&r2=49424&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp Fri Jul 25 18:17:07 2008
@@ -209,7 +209,8 @@
return;
}
- DlgResizePartition(data);
+ //Need to pass data on the whole disk, to determine free/available space
+ DlgResizePartition(data, disk);
}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp?rev=49424&r1=49423&r2=49424&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp Fri Jul 25 18:17:07 2008
@@ -541,6 +541,9 @@
void DlgResizeLogicalVolumeNew(map &data)
{
- DlgResize(data, `lv);
+ //the empty map is here because data on whole disk need to be passed
+ //to resize dialog for partitions (to get available space etc.)
+ //for LVMs we probably don't need it)
+ DlgResize(data, $[], `lv);
}
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org