Author: aschnell Date: Tue Apr 15 12:22:50 2008 New Revision: 46656 URL: http://svn.opensuse.org/viewcvs/yast?rev=46656&view=rev Log: - work on partition type selection 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 Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-dialogs.ycp Tue Apr 15 12:22:50 2008 @@ -12,7 +12,12 @@ // TODO: y2milestones at begin and end of MiniWorkflowSteps as decorators // or in MiniWorkflow (Sequencer) module? - + /** + * read data["flavour"] + * read data["slots"] + * read data["type"] + * read data["cyl_size"] + */ symbol MiniWorkflowStepSize(map &data) { y2milestone("MiniWorkflowStepSize data:%1", data); @@ -25,13 +30,16 @@ term frames = `VStackFrames(); + map slot = data["slots", data["type"]:`unknown]:$[]; + integer max_size = slot["cyl_size"]:0 * data["cyl_size"]:0; + string tmp = String::FormatSizeWithPrecision(max_size, 2, false); + frames = add(frames, `Frame(_("Size"), `RadioButtonGroup(`id(`size), `VBox( `LeftRadioButton(`id(`max_size), `opt(`notify), - sformat(_("Maximum Size (%1)"), - String::FormatSizeWithPrecision(data["max_size"]:0, 2, false))), + sformat(_("Maximum Size (%1)"), tmp)), `LeftRadioButtonWithAttachment(`id(`manual_size), `opt(`notify), _("Manual Size"), `VBox(`id(`manual_size_attachment), `MinWidth(15, `InputField(`id(`size), `opt(`shrinkable), _("Size"))), @@ -57,6 +65,8 @@ MiniWorkflow::SetContents(Greasemonkey::Transform(contents), "help"); MiniWorkflow::SetLastStep(false); + if (flavour == `part && data["type"]:`unknown == `extended) + MiniWorkflow::SetLastStep(true); symbol widget = nil; 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/sto... ============================================================================== --- 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 Tue Apr 15 12:22:50 2008 @@ -9,29 +9,33 @@ textdomain "storage"; + /** + * read data["slots"] + * read/write data["type"] + */ symbol MiniWorkflowStepPartitionType(map &data) { y2milestone("MiniWorkflowStepPartitionType data:%1", data); - map possibilities = data["possibilities"]:$[]; + map slots = data["slots"]:$[]; term tmp = `VBox(); - if (possibilities[`primary, `possible]:false) + if (haskey(slots, `primary)) // radio button text tmp = add(tmp, `Left(`RadioButton(`id(`primary), _("&Primary Partition"), data["type"]:`unknown == `primary))); - if (possibilities[`logical, `possible]:false) - // radio button text - tmp = add(tmp, `Left(`RadioButton(`id(`logical), _("&Logical Partition"), - data["type"]:`unknown == `logical))); - - if (possibilities[`extended, `possible]:false) + if (haskey(slots, `extended)) // radio button text tmp = add(tmp, `Left(`RadioButton(`id(`extended), _("&Extended Partition"), data["type"]:`unknown == `extended))); + if (haskey(slots, `logical)) + // radio button text + tmp = add(tmp, `Left(`RadioButton(`id(`logical), _("&Logical Partition"), + data["type"]:`unknown == `logical))); + // heading for a frame in a dialog term contents = `HVSquash(`Frame(_("Partition Type"), `RadioButtonGroup(`id(`partition_type), tmp))); @@ -68,6 +72,8 @@ boolean DlgCreatePartition(map &data) { + data["flavour"] = `part; + map<string, any> aliases = $[ "Type" : ``(MiniWorkflowStepPartitionType(data)), "Size" : ``(MiniWorkflowStepSize(data)), @@ -84,7 +90,18 @@ "Password" : $[ `finish : `finish ] ]; - symbol widget = MiniWorkflow::Run(_("Add Partition"), aliases, sequence, "Type"); + map slots = data["slots"]:$[]; + + if (haskey(slots, `primary)) + data["type"] = `primary; + else if (haskey(slots, `extended)) + data["type"] = `extended; + else if (haskey(slots, `logical)) + data["type"] = `logical; + + string start = size(slots) == 1 ? "Size" : "Type"; + + symbol widget = MiniWorkflow::Run(_("Add Partition"), aliases, sequence, start); return widget == `finish; } 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/sto... ============================================================================== --- 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 Tue Apr 15 12:22:50 2008 @@ -6,80 +6,40 @@ * */ { - map GetPossiblePartitions(map tg, map disk, string disk_device) + map GetPossibleSlots(map tg, map disk, string disk_device) { - list possibilities = CheckCreatePossibilities(disk_device, disk); - y2milestone("possibilities %1", possibilities); + list<map> slots = []; + Storage::GetUnusedPartitionSlots(disk_device, slots); + y2milestone("slots %1", slots); + + // find biggest primary, extended and logical slot + + map ret = $[]; + list<map> tmp = []; + + tmp = filter(map slot, slots, { return slot["primary_possible"]:false; }); + tmp = sort(map a, map b, tmp, { return a["cyl_size"]:0 > b["cyl_size"]:0; }); + if (size(tmp) > 0) + ret[`primary] = tmp[0]:$[]; + + tmp = filter(map slot, slots, { return slot["extended_possible"]:false; }); + tmp = sort(map a, map b, tmp, { return a["cyl_size"]:0 > b["cyl_size"]:0; }); + if (size(tmp) > 0) + ret[`extended] = tmp[0]:$[]; + + tmp = filter(map slot, slots, { return slot["logical_possible"]:false; }); + tmp = sort(map a, map b, tmp, { return a["cyl_size"]:0 > b["cyl_size"]:0; }); + if (size(tmp) > 0) + ret[`logical] = tmp[0]:$[]; - boolean primary_is_possible = possibilities[0]:false; - boolean extended_is_possible = possibilities[1]:false; - boolean logical_is_possible = possibilities[2]:false; - - symbol no_primary_cause = possibilities[3]:`no_space; - symbol no_extended_cause = possibilities[4]:`no_space; - symbol no_logical_cause = possibilities[5]:`no_space; - - list p_e_slot = GetSlot(disk_device, disk); - y2milestone("p_e_slot %1", p_e_slot); - list l_slot = GetLogicalSlot(disk_device, disk); - y2milestone("l_slot %1", l_slot); - - if ((p_e_slot == nil) && primary_is_possible) { - primary_is_possible = false; - no_primary_cause = `no_space; - } - - if ((p_e_slot == nil) && extended_is_possible) { - extended_is_possible = false; - no_extended_cause = `no_space; - } - - if ((l_slot == nil) && logical_is_possible) { - logical_is_possible = false; - no_logical_cause = `no_space; - } - - if (!primary_is_possible && !extended_is_possible && !logical_is_possible) + if (size(ret) == 0) { - string text = ""; - - if (disk["label"]:"msdos" != "msdos") - { - // popup text , %1 is replaced by a disk name e.g. /dev/hda - text = sformat(_("It is not possible to create a partition on %1."), disk_device); - } - else - { - // popup text , %1 is replaced by a disk name e.g. /dev/hda - // %2 is replaced by an explanation - text = sformat(_("It is not possible to create a partition on %1. - -%2 -"), disk_device, - FormatYouCannotCause(primary_is_possible, - extended_is_possible, - logical_is_possible, - no_primary_cause, - no_extended_cause, - no_logical_cause)); - } + // TODO: give detailed reasons esp. for msdos partition table + string text = sformat(_("It is not possible to create a partition on %1."), disk_device); Popup::Warning(text); - return nil; } - map ret = $[ `primary : $[ `possible : primary_is_possible, `slot : p_e_slot ], - `extended : $[ `possible : extended_is_possible, `slot : p_e_slot ], - `logical : $[ `possible : logical_is_possible, `slot : l_slot ] ]; - - if (primary_is_possible) - ret[`primary, `default] = true; - else if (extended_is_possible) - ret[`extended, `default] = true; - else if (logical_is_possible) - ret[`logical, `default] = true; - y2milestone("ret %1", ret); - return ret; } @@ -92,14 +52,17 @@ map<string, map> tg = Storage::GetTargetMap(); map disk = tg[disk_device]:$[]; - map possibilities = GetPossiblePartitions(tg, disk, disk_device); - - map data = $[ "possibilities" : possibilities, - "cyl_size" : disk["cyl_size"]:0 ]; + map slots = GetPossibleSlots(tg, disk, disk_device); - if (DlgCreatePartition(data)) + if (size(slots) > 0) { - y2milestone("create partition with %1", data); + map data = $[ "slots" : slots, + "cyl_size" : disk["cyl_size"]:0 ]; + + if (DlgCreatePartition(data)) + { + y2milestone("create partition with %1", data); + } } return false; @@ -109,7 +72,7 @@ boolean EpEditPartition(string device) { DlgEditPartition(device); - + return false; } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org