Author: aschnell
Date: Mon Feb 25 18:30:37 2008
New Revision: 45005
URL: http://svn.opensuse.org/viewcvs/yast?rev=45005&view=rev
Log:
- ui stuff (backup checkin)
Added:
branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp
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.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp
branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.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=45005&r1=45004&r2=45005&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 Mon Feb 25 18:30:37 2008
@@ -9,6 +9,69 @@
textdomain "storage";
+ term FrameSize(symbol flavour)
+ {
+ return `Frame(_("Size"),
+ `HBox(`InputField(`id(`size), "Size:"),
+ `HStretch(),
+ `PushButton(`id(`max_size), "Max Size"))
+ );
+ }
+
+
+ term FrameFormat(symbol flavour)
+ {
+ term tmp = `VBox(
+ `RadioButton(`id(`do_not_format),
+ _("Do not format the partition")));
+
+ if (flavour == `part)
+ tmp = add(tmp, FsidComboBox($[], FileSystems::GetAllFileSystems(true, true)));
+
+ return `Frame(_("Format"),
+ `VBox(
+ `RadioButtonGroup(`id(`format),
+ `VBox(
+ tmp,
+ `VBox(
+ `RadioButton(`id(`do_format),
+ _("Format the partition")),
+ FileSystemsComboBox($[], FileSystems::GetAllFileSystems(true, true)))
+ ))
+ )
+ );
+ }
+
+
+ term FrameMount(symbol flavour)
+ {
+ map new_val = $[];
+ list mountpoints = nil;
+
+ if (mountpoints == nil)
+ mountpoints = [ "/", "/usr", Partitions::BootMount(), "/var", "/home",
+ "/opt" , "" ];
+
+ if (!contains(mountpoints, "") && new_val["enc_type"]:`none==`none)
+ mountpoints = add(mountpoints, "");
+
+ string mount = new_val["mount"]:"";
+ if (!contains(mountpoints, mount))
+ mountpoints = union([mount], mountpoints);
+
+ return `Frame(_("Mount"),
+ `HBox(
+ `ComboBox(`id(`mount_point), `opt(`editable, `hstretch, `notify),
+ _("Mount the partition at"), mountpoints),
+ `HStretch(),
+ `PushButton(`id(`fstab_options),
+ // button text
+ _("Fs&tab Options..."))
+ )
+ );
+ }
+
+
map DlgResize(symbol flavour)
{
integer lv_used = 3500;
@@ -21,7 +84,7 @@
// Unit for partition resizing - currently Megabytes
string unit = _("MB");
-
+
string heading = "";
string bargraph_label_lv_used = "";
string bargraph_label_lv_free = "";
@@ -40,14 +103,14 @@
{
// Heading for dialog
heading = _("Resize Volume Group");
-
+
// 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);
// Labels for input fields. "%1" will be replaced with the current unit (MB).
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=45005&r1=45004&r2=45005&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 Mon Feb 25 18:30:37 2008
@@ -9,6 +9,89 @@
textdomain "storage";
+ term FramePartitionType(map possibilities)
+ {
+ term tmp = `VBox();
+
+ if (possibilities[`primary, `possible]:false)
+ // radio button text
+ tmp = add(tmp, `Left(`RadioButton(`id(`primary), _("&Primary Partition"),
+ possibilities[`primary, `default]:false)));
+
+ if (possibilities[`logical, `possible]:false)
+ // radio button text
+ tmp = add(tmp, `Left(`RadioButton(`id(`logical), _("&Logical Partition"),
+ possibilities[`logical, `default]:false)));
+
+ if (possibilities[`extended, `possible]:false)
+ // radio button text
+ tmp = add(tmp, `Left(`RadioButton(`id(`extended), _("&Extended Partition"),
+ possibilities[`extended, `default]:false)));
+
+ // heading for a frame in a dialog
+ return `Frame(_("Partition Type"),
+ `RadioButtonGroup(`id(`partition_type), tmp));
+ }
+
+
+ boolean DlgCreatePartition(map possibilities)
+ {
+ UI::OpenDialog(`opt(`decorated),
+ // heading in a popup dialog
+ `VBox(`Left(`Heading(_("Add Partition"))),
+ SpaceFrames([ FramePartitionType(possibilities),
+ FrameSize(`part),
+ FrameFormat(`part),
+ FrameMount(`part) ]),
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton())
+ )
+ )
+ );
+
+ symbol widget = nil;
+
+ repeat
+ {
+ widget = (symbol) UI::UserInput();
+ }
+ until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+
+ return false;
+ }
+
+
+ boolean DlgEditPartition(string device)
+ {
+ UI::OpenDialog(`opt(`decorated),
+ // heading in a popup dialog
+ `VBox(`Left(`Heading(_("Edit Partition"))),
+ SpaceFrames([ FrameFormat(`part),
+ FrameMount(`part) ]),
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton())
+ )
+ )
+ );
+
+ symbol widget = nil;
+
+ repeat
+ {
+ widget = (symbol) UI::UserInput();
+ }
+ until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+
+ return false;
+ }
+
+
void DlgResizePartition(string device)
{
DlgResize(`lv);
Added: 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=45005&view=auto
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp (added)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd-lib.ycp Mon Feb 25 18:30:37 2008
@@ -0,0 +1,109 @@
+/**
+ * File: ep-lib-hd.ycp
+ * Package: yast2-storage
+ * Summary: Expert Partitioner
+ * Authors: Arvin Schnell
+ *
+ */
+{
+ map GetPossiblePartitions(map tg, map disk, string disk_device)
+ {
+ list possibilities = CheckCreatePossibilities(disk_device, disk);
+ y2milestone("possibilities %1", possibilities);
+
+ 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)
+ {
+ 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));
+ }
+ 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;
+ }
+
+
+ /**
+ * argument is device of hard disk
+ */
+ boolean EpCreatePartition(string disk_device)
+ {
+ map tg = Storage::GetTargetMap();
+ map disk = tg[disk_device]:$[];
+
+ map possibilities = GetPossiblePartitions(tg, disk, disk_device);
+
+ DlgCreatePartition(possibilities);
+
+ return false;
+ }
+
+
+ boolean EpEditPartition(string device)
+ {
+ DlgEditPartition(device);
+
+ return false;
+ }
+}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp?rev=45005&r1=45004&r2=45005&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-hd.ycp Mon Feb 25 18:30:37 2008
@@ -10,6 +10,7 @@
include "partitioning/ep-hd-dialogs.ycp";
+ include "partitioning/ep-hd-lib.ycp";
void CreateHdPanel(any user_data)
@@ -121,9 +122,16 @@
void HandleHdDiskPartitionsTab(any user_data, any widget)
{
+ string disk_device = (string) user_data;
+ string part_device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
+
if (widget == `add)
{
- Popup::YesNo(tostring(user_data));
+ EpCreatePartition(disk_device);
+ }
+ else if (widget == `edit)
+ {
+ EpEditPartition(part_device);
}
else if (widget == `resize)
{
@@ -131,8 +139,7 @@
}
else if (widget == `delete)
{
- string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
- if (EpDeleteDevice(device))
+ if (EpDeleteDevice(part_device))
{
// TODO: update tree and tab (with focus)
UpdateNavigationTree(nil);
@@ -200,14 +207,19 @@
void HandleHdPartitionPanel(any user_data, any widget)
{
- if (widget == `resize)
+ string part_device = (string) user_data;
+
+ if (widget == `edit)
+ {
+ EpEditPartition(part_device);
+ }
+ else if (widget == `resize)
{
DlgResize(`part);
}
else if (widget == `delete)
{
- string device = (string) user_data;
- if (EpDeleteDevice(device))
+ if (EpDeleteDevice(part_device))
{
// TODO: update tree (with focus)
UpdateNavigationTree(nil);
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=45005&r1=45004&r2=45005&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 Mon Feb 25 18:30:37 2008
@@ -88,7 +88,98 @@
}
- void DlgResizeLogicalVolumeGroupNew(string device)
+ term FrameVgNameNew()
+ {
+ return `Frame("Name",
+ `VBox(
+ `Left(`ComboBox("Volume Group:", ["system", "data"])),
+ `Left(`InputField("Logical Volume:"))));
+ }
+
+
+ term FrameVgName()
+ {
+ return `Frame("Name",
+ `VBox(
+ `Left(`Label("Volume Group: system")),
+ `Left(`Label("Logical Volume: test"))));
+ }
+
+
+ term FrameStripes()
+ {
+ return `Frame("Stripes",
+ `HBox(
+ `Left(`ComboBox("Stripes:", ["1", "2", "3", "4"])),
+ `Left(`ComboBox("Stripe Size:", ["4 KB", "8 KB", "16 KB", "32 KB"])),
+ `HStretch())
+ );
+ }
+
+
+ boolean DlgCreateLogicalVolume()
+ {
+ UI::OpenDialog(`opt(`decorated),
+ // heading in a popup dialog
+ `VBox(`Left(`Heading(_("Add Logical Volume"))),
+ SpaceFrames([ FrameVgNameNew(),
+ FrameSize(`lv),
+ FrameStripes(),
+ FrameFormat(`lv),
+ FrameMount(`lv) ]),
+ `HBox(
+ `HStretch(),
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton())
+ )
+ )
+ );
+
+ symbol widget = nil;
+
+ repeat
+ {
+ widget = (symbol) UI::UserInput();
+ }
+ until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+
+ return false;
+ }
+
+
+ boolean DlgEditLogicalVolume(string device)
+ {
+ // TODO: include stripes if newly create
+ UI::OpenDialog(`opt(`decorated),
+ // heading in a popup dialog
+ `VBox(`Left(`Heading(_("Edit Logical Volume"))),
+ SpaceFrames([ FrameVgName(),
+ FrameFormat(`lv),
+ FrameMount(`lv) ]),
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), `opt(`default), Label::OKButton())
+ )
+ )
+ );
+
+ symbol widget = nil;
+
+ repeat
+ {
+ widget = (symbol) UI::UserInput();
+ }
+ until (widget == `cancel || widget == `ok);
+
+ UI::CloseDialog();
+
+ return false;
+ }
+
+
+ void DlgResizeLogicalVolumeNew(string device)
{
DlgResize(`lv);
}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp?rev=45005&r1=45004&r2=45005&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm.ycp Mon Feb 25 18:30:37 2008
@@ -41,6 +41,10 @@
UpdateNavigationTree("/dev/" + vgname);
}
}
+ else if (widget == `create_lv)
+ {
+ DlgCreateLogicalVolume();
+ }
}
@@ -110,7 +114,7 @@
UI::ReplaceWidget(`tab_panel,
`VBox(
- `Table(`opt(`keepSorting),
+ `Table(`id(`table), `opt(`keepSorting),
header, table_list
),
`HBox(
@@ -127,11 +131,24 @@
void HandleLvmVgLvsTab(any user_data, any widget)
{
- string device = (string) user_data;
+ string vg_device = (string) user_data;
+ string lv_device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
- if (widget == `resize)
+ if (widget == `add)
+ {
+ DlgCreateLogicalVolume();
+ }
+ else if (widget == `edit)
+ {
+ DlgEditLogicalVolume(lv_device);
+ }
+ else if (widget == `resize)
{
- DlgResizeLogicalVolumeGroupNew(device);
+ DlgResizeLogicalVolumeNew(lv_device);
+ }
+ else if (widget == `delete)
+ {
+ EpDeleteDevice(lv_device);
}
}
@@ -221,9 +238,10 @@
`Left(`Heading("Logical Volume: " + device)),
`Left(`Label("Mount Point: " + partition["mount"]:"")),
`Left(`Label("Size: " + ByteToHumanString(partition["size_k"]:0*1024))),
+ `Left(`Label("Stripes: " + partition["stripes"]:1)),
`VStretch(),
`HBox(
- `PushButton(`id(`delete), "Edit..."),
+ `PushButton(`id(`edit), "Edit..."),
`PushButton(`id(`resize), "Resize..."),
`PushButton(`id(`delete), "Delete..."),
`HStretch()
@@ -237,9 +255,17 @@
{
string device = (string) user_data;
- if (widget == `resize)
+ if (widget == `edit)
+ {
+ DlgEditLogicalVolume(device);
+ }
+ else if (widget == `resize)
+ {
+ DlgResizeLogicalVolumeNew(device);
+ }
+ else if (widget == `delete)
{
- DlgResizeLogicalVolumeGroupNew(device);
+ EpDeleteDevice(device);
}
}
}
Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp?rev=45005&r1=45004&r2=45005&view=diff
==============================================================================
--- branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp (original)
+++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-main.ycp Mon Feb 25 18:30:37 2008
@@ -15,12 +15,25 @@
// useful for e.g. ComboBox, SelectionBox and DumbTab
+ // terms must be of form: `item(`id(any), any, ...)
list<term> SelectOne(list<term> items, any id)
{
return maplist(term item, items, { return `item(item[0]:nil, item[1]:nil, item[0]:nil == id); });
}
+ term SpaceFrames(list<term> contents)
+ {
+ term tmp = `VBox();
+ foreach(term content, contents, {
+ if (size(tmp) != 0)
+ tmp = add(tmp, `VSpacing(0.5));
+ tmp = add(tmp, content);
+ });
+ return `MarginBox(1, 0.5, tmp);
+ }
+
+
list<symbol> FilterColumns(list<symbol> columns)
{
if (Arch::ppc())
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org