Author: kmachalkova Date: Thu Apr 23 12:59:35 2009 New Revision: 56932 URL: http://svn.opensuse.org/viewcvs/yast?rev=56932&view=rev Log: Function buttons for HDs (finally they do something useful) Modified: trunk/storage/storage/src/include/ep-hd.ycp Modified: trunk/storage/storage/src/include/ep-hd.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/storage/src/include/ep-hd.ycp?rev=56932&r1=56931&r2=56932&view=diff ============================================================================== --- trunk/storage/storage/src/include/ep-hd.ycp (original) +++ trunk/storage/storage/src/include/ep-hd.ycp Thu Apr 23 12:59:35 2009 @@ -8,6 +8,7 @@ textdomain "storage"; import "Arch"; + import "TreePanel"; import "Region"; import "Mode"; import "Stage"; @@ -68,6 +69,42 @@ ); } + void HandleHdButtons( string device, map event ) + { + map dev = Storage::GetDiskPartition( device ); + string disk = (string) dev["disk"]:nil; + // FIXME: is this necessary & sufficient condition? + boolean is_disk = (dev["nr"]:"" == ""); + + switch (Event::IsWidgetActivated(event)) + { + case `add: + EpCreatePartition( disk ); + break; + case `edit: + if ( is_disk ) + TreePanel::SwitchToNew( disk ); + else + EpEditPartition( device ); + break; + + case `resize: + if ( is_disk ) + Popup::Error(_("Hard disks, BIOS RAIDs and multipath +devices cannot be resized.")); + else + EpResizePartition ( device ); + break; + + case `delete: + if ( is_disk ) + EpDeleteDisk( device ); + else + EpDeletePartition ( device, UI::WidgetExists(`id(`table)) ? `table : `overview ); + break; + } + } + void CreateHdMainPanel(any user_data) { symbol Predicate(map disk, map partition) @@ -113,10 +150,13 @@ void HandleHdMainPanel(any user_data, map event) { + string device = (string) UI::QueryWidget(`id(`table), `CurrentItem); + + HandleHdButtons( device, event ); + switch (Event::IsWidgetContextMenuActivated(event)) { case `table: - string device = (string) UI::QueryWidget(`id(`table), `CurrentItem); EpContextMenuDevice(device); break; } @@ -272,24 +312,7 @@ string disk_device = (string) user_data; string part_device = (string) UI::QueryWidget(`id(`table), `CurrentItem); - switch (Event::IsWidgetActivated(event)) - { - case `add: - EpCreatePartition(disk_device); - break; - - case `edit: - EpEditPartition(part_device); - break; - - case `resize: - EpResizePartition(part_device); - break; - - case `delete: - EpDeletePartition(part_device, `table); - break; - } + HandleHdButtons( part_device, event ); switch (Event::IsMenu(event)) { @@ -427,21 +450,7 @@ { string part_device = (string) user_data; - switch (Event::IsWidgetActivated(event)) - { - case `edit: - EpEditPartition(part_device); - break; - - case `resize: - EpResizePartition(part_device); - break; - - case `delete: - EpDeletePartition(part_device, `overview); - break; - } - + HandleHdButtons( part_device, event); UI::SetFocus(`id(`text)); } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org