Author: jreidinger Date: Thu Feb 19 15:28:36 2009 New Revision: 55612 URL: http://svn.opensuse.org/viewcvs/yast?rev=55612&view=rev Log: convert disks order dialog to CWM, missing handler for add button. Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/widgets_i386.ycp Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIref... ============================================================================== --- branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp (original) +++ branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/dialogs_i386.ycp Thu Feb 19 15:28:36 2009 @@ -30,199 +30,27 @@ include "bootloader/routines/widgets_i386.ycp"; + + /** * Run dialog to adjust installation on i386 and AMD64 * @return symbol for wizard sequencer */ symbol i386InstallDetailsDialog () { - term contents = `HBox (`HStretch (), `VBox ( - `VStretch (), - // frame - `Frame (_("Disk Order"), - `HBox (`HSpacing (2), `VBox ( - `VSpacing (1), - `SelectionBox (`id (`disks), - `opt (`notify, `immediate), - // selectionn box label - _("D&isks"), []), - Mode::config () - ? `HBox ( - `HStretch (), - `PushButton (`id (`add), `opt (`key_F3), Label::AddButton ()), - `PushButton (`id (`delete), `opt(`key_F5), Label::DeleteButton ()), - `HStretch () - ) - : `HBox (), - `VSpacing (1) - ), - `HSquash ( - `VBox ( - `VStretch (), - `PushButton (`id (`up), `opt (`hstretch), _("&Up")), - `PushButton (`id (`down), `opt (`hstretch), _("&Down")), - `VStretch () - ) - ), - `HSpacing (2) - ) - ), - `VStretch (), - // frame - `Frame (_("Disk System Area Update"), `HBox (`HSpacing (2), `VBox ( - `VSpacing (1), - `Left (`CheckBox (`id (`repl_mbr), - // check box - _("R&eplace MBR with Generic Code"))), - `Left (`CheckBox (`id (`activate), - // check box - _("&Activate Boot Loader Partition"))), - BootCommon::getLoaderType (false) == "grub" - && BootCommon::allowEmbed15 () - ? `Left (`CheckBox (`id (`embed), - // check box - _("U&se Dedicated Boot Loader Area"))) - : `VBox (), - `VSpacing (1) - ), `HSpacing (2))), - `VStretch () - ), `HStretch ()); - - Wizard::SetContentsButtons ( - // dialog caption - _("Boot Loader Installation Details"), - contents, - i386InstallDetailsHelp (), - Label::BackButton (), - Label::OKButton ()); - - list<string> disks_order = BootCommon::DisksOrder (); - - UI::ChangeWidget (`id (`disks), `Items, disks_order); - UI::ChangeWidget (`id (`disks), `CurrentItem, disks_order[0]:""); - UI::ChangeWidget (`id (`repl_mbr), `Value, BootCommon::repl_mbr); - UI::ChangeWidget (`id (`activate), `Value, BootCommon::activate); - if (UI::WidgetExists (`id (`embed))) - UI::ChangeWidget (`id (`embed), `Value, BootCommon::embed_stage15); - boolean save_embed = BootCommon::embed_stage15; - - any ret = nil; - while (ret == nil) - { - string current = (string)UI::QueryWidget (`id (`disks), `CurrentItem); - integer pos = 0; - while (pos < size (disks_order) && disks_order[pos]:"" != current) - pos = pos + 1; - UI::ChangeWidget (`id (`up), `Enabled, - pos > 0 && pos < size (disks_order)); - UI::ChangeWidget (`id (`down), `Enabled, pos < size (disks_order) - 1); - - ret = UI::UserInput (); - boolean order_changed = false; - - if (ret == `add) - { - term popup = `VBox (`VSpacing (1), - // textentry header - `InputField (`id (`devname), `opt (`hstretch), _("&Device")), - `VSpacing (1), - `HBox (`HStretch (), - `PushButton (`id (`ok), `opt (`key_F10, `default), - Label::OKButton ()), - `HStretch (), - `PushButton (`id (`cancel), `opt (`key_F8), - Label::CancelButton ()), - `HStretch () - ), - `VSpacing (1) - ); - UI::OpenDialog (popup); - symbol pushed = (symbol)UI::UserInput (); - string new_dev = (string) - UI::QueryWidget (`id (`devname), `Value); - UI::CloseDialog (); - if (pushed == `ok) - { - disks_order = add (disks_order, new_dev); - order_changed = true; - current = new_dev; - } - } - else if (ret == `delete) - { - disks_order = filter (string d, disks_order, { - return d != current; - }); - order_changed = true; - current = disks_order[0]:nil; - } - else if (ret == `up) - { - disks_order = (list<string>) - BootCommon::swapItems (disks_order, pos, pos - 1); - order_changed = true; - } - else if (ret == `down) - { - disks_order = (list<string>) - BootCommon::swapItems (disks_order, pos, pos + 1); - order_changed = true; - } - - if (ret == `cancel) - ret = `abort; - if (ret != `next && ret != `abort && ret != `back) - { - if (order_changed) - { - UI::ChangeWidget (`id (`disks), `Items, disks_order); - UI::ChangeWidget (`id (`disks), `CurrentItem, current); - } - ret = nil; - } - } - if (ret == `next) - { - integer index = 0; - BootCommon::device_mapping = filter (string k, string v, - BootCommon::device_mapping, - { - return substring (v, 0, 2) != "hd"; - }); - BootCommon::mbrDisk = disks_order[0]:""; - BootCommon::device_mapping = (map<string,string>)union ( - BootCommon::device_mapping, - listmap (string d, disks_order, { - string hex_index = substring (tohexstring (index), 2); - index = index + 1; - return $[ d : sformat ("hd%1", hex_index) ]; - }) - ); - BootCommon::repl_mbr = (boolean) - UI::QueryWidget (`id (`repl_mbr), `Value); - if (BootCommon::activate != (boolean) - UI::QueryWidget (`id (`activate), `Value)) - { - BootCommon::activate_changed = true; - } - BootCommon::activate = (boolean) - UI::QueryWidget (`id (`activate), `Value); - if (UI::WidgetExists (`id (`embed))) - { - BootCommon::embed_stage15 = (boolean) - UI::QueryWidget (`id (`embed), `Value); - } - if (BootCommon::repl_mbr) - { - if (Stage::initial ()) - Pkg::PkgInstall ("master-boot-code"); - BootCommon::location_changed = true; - } - if (BootCommon::activate || BootCommon::embed_stage15 != save_embed) - { - BootCommon::location_changed = true; - } - } - return (symbol)ret; + term contents = `HBox (`HStretch (), `VBox ( + `Frame (_("Disk Order"),"disks_order"), + `VStretch()), + `HStretch()); + + return CWM::ShowAndRun ($[ + "widget_descr": $[ "disks_order": DisksOrderWidget()], + "widget_names": ["disks_order"], + "contents": contents, + "caption" : _("Disk order settings"), + "back_button" : Label::BackButton (), + "abort_button" : Label::AbortButton (), + "next_button" : Label::OKButton () + ]); } /** Modified: branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/widgets_i386.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/juhliarik/bootloader-UIref... ============================================================================== --- branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/widgets_i386.ycp (original) +++ branches/tmp/juhliarik/bootloader-UIrefactor/src/routines/widgets_i386.ycp Thu Feb 19 15:28:36 2009 @@ -228,6 +228,108 @@ ]; } +void InitDiskOrder(string widget) { + list<string> disksOrder = BootCommon::DisksOrder (); + + UI::ChangeWidget ( `id(`disks), `Items, disksOrder); + UI::ChangeWidget (`id (`disks), `CurrentItem, disksOrder[0]:""); +} + +string GetItemID(term t){ + return argsof((term)argsof(t)[0]:`id(""))[0]:""; +} + +void StoreDiskOrder(string widget, map event) { + list<term> disksOrder = (list<term>)UI::QueryWidget(`id(`disks), `Items); + list<string> result = (list<string>) maplist(term t, disksOrder, { + return GetItemID(t); + }); + BootCommon::mbrDisk = result[0]:""; + integer index = 0; + BootCommon::device_mapping = listmap (string d, result, { + string indexs = tostring(index); + index = index + 1; + return $[ d : sformat ("hd%1", indexs)]; + }); +} + +symbol HandleDiskOrder( string widget, map event ){ + any action = event["ID"]:nil; + boolean changed = false; + list<term> disksOrder = (list<term>)UI::QueryWidget(`id(`disks), `Items); + string current = (string)UI::QueryWidget (`id (`disks), `CurrentItem); + integer pos = 0; + while (pos < size (disksOrder) + && GetItemID(disksOrder[pos]:`Item(`id(""))) != current) + pos = pos + 1; + + //disabling & enabling up/down + UI::ChangeWidget (`id (`up), `Enabled, pos > 0 && pos < size (disksOrder)); + UI::ChangeWidget (`id (`down), `Enabled, pos < size (disksOrder) - 1); + + if (action == `up){ + changed= true; + disksOrder = + (list<term>) BootCommon::swapItems (disksOrder, pos, pos - 1); + } else if (action == `down){ + changed= true; + disksOrder = + (list<term>) BootCommon::swapItems (disksOrder, pos, pos + 1); + } else if (action == `delete){ + changed = true; + disksOrder = remove(disksOrder,pos); + UI::ChangeWidget (`id (`disks), `CurrentItem, + (pos > 0) ? GetItemID(disksOrder[(pos-1)]:`Item(`id(""))) + : GetItemID(disksOrder[0]:`Item(`id("")))); + } else if (action == `add) { + //TODO + } + + if (changed){ + UI::ChangeWidget (`id (`disks), `Items, disksOrder); + } +} + +map<string,any> DisksOrderWidget(){ + term contents = `HBox (`HSpacing (2), `VBox ( + `VSpacing (1), + `SelectionBox (`id (`disks), + `opt (`notify, `immediate),_("D&isks"), []), + (Mode::config () || Mode::installation()) + ? `HBox ( + `HStretch (), + `PushButton (`id (`add), + `opt (`key_F3), Label::AddButton ()), + `PushButton (`id (`delete), + `opt(`key_F5), Label::DeleteButton ()), + `HStretch () + ) + : `HBox (), + `VSpacing (1) + ), + `HSquash ( + `VBox ( + `VStretch (), + `PushButton (`id (`up), + `opt (`hstretch), _("&Up")), + `PushButton (`id (`down), + `opt (`hstretch), _("&Down")), + `VStretch () + ) + ), + `HSpacing (2) + ); + return $[ + "widget" : `custom, + "custom_widget" : contents, + "init" : InitDiskOrder, + "handle" : HandleDiskOrder, +// "handle_events" : [`up, `down, `add, `delete], + "store" : StoreDiskOrder, + "help" : i386InstallDetailsHelp () + ]; +} + /** * Cache for i386Widgets function */ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org