[yast-commit] r52641 - in /trunk/storage/storage/src: include/ep-hd-dialogs.ycp include/ep-main.ycp modules/Makefile.am modules/Region.ycp
Author: aschnell Date: Tue Oct 28 19:45:18 2008 New Revision: 52641 URL: http://svn.opensuse.org/viewcvs/yast?rev=52641&view=rev Log: - validate manual region Added: trunk/storage/storage/src/modules/Region.ycp Modified: trunk/storage/storage/src/include/ep-hd-dialogs.ycp trunk/storage/storage/src/include/ep-main.ycp trunk/storage/storage/src/modules/Makefile.am Modified: trunk/storage/storage/src/include/ep-hd-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd-dialogs.ycp?rev=52641&r1=52640&r2=52641&view=diff ============================================================================== --- trunk/storage/storage/src/include/ep-hd-dialogs.ycp (original) +++ trunk/storage/storage/src/include/ep-hd-dialogs.ycp Tue Oct 28 19:45:18 2008 @@ -96,7 +96,7 @@ y2milestone("MiniWorkflowStepPartitionSize data:%1", data); integer cyl_size = data["cyl_size"]:0; - list slots = data["slots", data["type"]:`unknown]:[]; + list< list<integer> > slots = data["slots", data["type"]:`unknown]:[]; list<integer> slot = slots[0]:[]; list<integer> region = data["region"]:slot; @@ -193,17 +193,20 @@ case `manual_region: { - integer tmp1 = (integer) UI::QueryWidget(`id(`start_cyl), `Value); - integer tmp2 = (integer) UI::QueryWidget(`id(`num_cyls), `Value); + region = [ (integer) UI::QueryWidget(`id(`start_cyl), `Value), + (integer) UI::QueryWidget(`id(`num_cyls), `Value) ]; - if (false) // TODO + boolean valid = find(list<integer> slot, slots, { + return Region::Inside(slot, region); + }) != nil; + + if (!valid) { + // error popup Popup::Error(_("The region is invalid.")); widget = `again; } - region = [ tmp1, tmp2 ]; - break; } } Modified: trunk/storage/storage/src/include/ep-main.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-main.ycp?rev=52641&r1=52640&r2=52641&view=diff ============================================================================== --- trunk/storage/storage/src/include/ep-main.ycp (original) +++ trunk/storage/storage/src/include/ep-main.ycp Tue Oct 28 19:45:18 2008 @@ -26,6 +26,7 @@ import "DevicesSelectionBox"; import "Integer"; import "String"; + import "Region"; include "partitioning/lvm_ui_dialogs.ycp"; Modified: trunk/storage/storage/src/modules/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Makefile.am?rev=52641&r1=52640&r2=52641&view=diff ============================================================================== --- trunk/storage/storage/src/modules/Makefile.am (original) +++ trunk/storage/storage/src/modules/Makefile.am Tue Oct 28 19:45:18 2008 @@ -21,7 +21,8 @@ MiniWorkflow.ycp \ Greasemonkey.ycp \ DevicesSelectionBox.ycp \ - DualMultiSelectionBox.ycp + DualMultiSelectionBox.ycp \ + Region.ycp EXTRA_DIST = $(module_DATA) Added: trunk/storage/storage/src/modules/Region.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/modules/Region.ycp?rev=52641&view=auto ============================================================================== --- trunk/storage/storage/src/modules/Region.ycp (added) +++ trunk/storage/storage/src/modules/Region.ycp Tue Oct 28 19:45:18 2008 @@ -0,0 +1,39 @@ +/** + * File: Region.ycp + * Package: yast2-storage + * Summary: Expert Partitioner + * Authors: Arvin Schnell <aschnell@suse.de> + * + * A region is a list of two integers, the first being the start and the + * second the length. + */ +{ + module "Region"; + + + integer Start(list<integer> a) + { + return a[0]:0; + } + + + integer Length(list<integer> a) + { + return a[1]:0; + } + + + integer End(list<integer> a) + { + return a[0]:0 + a[1]:0 - 1; + } + + + /** + * Checks whether region b lies within region a. + */ + global boolean Inside(list<integer> a, list<integer> b) + { + return Start(b) >= Start(a) && End(b) <= End(a); + } +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org