Author: sh-sh-sh Date: Fri Apr 11 17:43:36 2008 New Revision: 46439 URL: http://svn.opensuse.org/viewcvs/yast?rev=46439&view=rev Log: use wizard docking Modified: branches/tmp/sh/docked-sub-wizards/yast2/library/wizard/src/Wizard.ycp Modified: branches/tmp/sh/docked-sub-wizards/yast2/library/wizard/src/Wizard.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/docked-sub-wizards/yast2/library/wizard/src/Wizard.ycp?rev=46439&r1=46438&r2=46439&view=diff ============================================================================== --- branches/tmp/sh/docked-sub-wizards/yast2/library/wizard/src/Wizard.ycp (original) +++ branches/tmp/sh/docked-sub-wizards/yast2/library/wizard/src/Wizard.ycp Fri Apr 11 17:43:36 2008 @@ -55,7 +55,8 @@ * Returns a button box with buttons "Back", "Abort", "Next" * @return a widget tree **/ - global term BackAbortNextButtonBox() { + global term BackAbortNextButtonBox() + { return `HBox( `HWeight(1, `ReplacePoint(`id(`rep_help ), `PushButton(`id(`help ), `opt (`key_F1,`helpButton), Label::HelpButton() ) ) ), `HStretch(), @@ -90,7 +91,8 @@ * Returns a button box with buttons "Back", "Next" * @return a widget tree **/ - global term BackNextButtonBox() { + global term BackNextButtonBox() + { return `HBox( `HWeight(1, `ReplacePoint(`id(`rep_back ), `PushButton(`id(`back ), `opt (`key_F8), Label::BackButton() ) ) ), `HStretch(), @@ -103,7 +105,8 @@ * Returns a button box with buttons "Cancel", "Accept" * @return a widget tree **/ - global term CancelAcceptButtonBox() { + global term CancelAcceptButtonBox() + { return `HBox( `HWeight(1, `Empty() ), // Layout trick to make sure the center button is centered `HStretch(), @@ -118,7 +121,8 @@ * Returns a button box with buttons "Abort", "Accept" * @return a widget tree **/ - global term AbortAcceptButtonBox() { + global term AbortAcceptButtonBox() + { return `HBox( `HWeight(1, `ReplacePoint (`id (`back_rep), `Empty())), // Layout trick to make sure the center button is centered `HStretch(), @@ -133,7 +137,8 @@ * Returns a button box with buttons "Abort Installation", "Accept" * @return a widget tree **/ - global term AbortInstallationAcceptButtonBox() { + global term AbortInstallationAcceptButtonBox() + { return `HBox( `HWeight(1, `Empty() ), // Layout trick to make sure the center button is centered `HStretch(), @@ -172,7 +177,8 @@ * @param button_box term that contains a `HBox() with buttons in it * @return term term describing the dialog. **/ - global term GenericDialog( term button_box ) { + global term GenericDialog( term button_box ) + { return `VBox( `id(`WizardDialog), `ReplacePoint( `id(`topmenu ), `Empty() ), `HBox( @@ -208,7 +214,8 @@ * * @return boolean True if topmost dialog is a wizard dialog, false otherwise **/ - global boolean IsWizardDialog() { + global boolean IsWizardDialog() + { return UI::WidgetExists(`id(`WizardDialog) ) == true || UI::WidgetExists(`wizard) == true; @@ -222,7 +229,8 @@ * * @param help_text the text to display **/ - global void ShowHelp( string help_text ) { + global void ShowHelp( string help_text ) + { Popup::LongText( // Heading for help popup window _("Help"), @@ -238,7 +246,8 @@ * * @return term describing the dialog. **/ - global term NextBackDialog() { + global term NextBackDialog() + { return GenericDialog( BackAbortNextButtonBox() ); } @@ -250,7 +259,8 @@ * * @return term describing the dialog. **/ - global term AcceptDialog() { + global term AcceptDialog() + { return GenericDialog( CancelAcceptButtonBox() ); } @@ -262,7 +272,8 @@ * * @param dialog a wizard dialog, e.g. Wizard::GenericDialog() **/ - global void OpenDialog( term dialog ) { + global void OpenDialog( term dialog ) + { UI::OpenDialog( `opt(`defaultsize), dialog ); } @@ -275,10 +286,16 @@ { if ( haveFancyUI() ) { - UI::OpenDialog(`opt(`defaultsize ), - `Wizard(`back, Label::BackButton(), - `abort, Label::AbortButton(), - `next, Label::NextButton() ) ); + if ( UI::WizardCommand(`DockSubWizard(`back, Label::BackButton(), + `abort, Label::AbortButton(), + `next, Label::NextButton() ) + != true ) ) + { + UI::OpenDialog(`opt(`defaultsize ), + `Wizard(`back, Label::BackButton(), + `abort, Label::AbortButton(), + `next, Label::NextButton() ) ); + } } else { @@ -296,10 +313,16 @@ { if ( haveFancyUI() ) { - UI::OpenDialog(`opt(`defaultsize ), - `Wizard(`no_back_button, "", - `cancel, Label::CancelButton(), - `accept, Label::AcceptButton() ) ); + if ( UI::WizardCommand(`DockSubWizard( `no_back_button, "", + `cancel, Label::CancelButton(), + `accept, Label::AcceptButton() ) ) + != true ) + { + UI::OpenDialog(`opt(`defaultsize ), + `Wizard(`no_back_button, "", + `cancel, Label::CancelButton(), + `accept, Label::AcceptButton() ) ); + } // Don't let sloppy calls to Wizard::SetContents() disable this button by accident UI::WizardCommand(`ProtectNextButton( true ) ); @@ -320,10 +343,16 @@ { if ( haveFancyUI() ) { - UI::OpenDialog(`opt(`defaultsize ), - `Wizard(`apply, _( "&Apply" ), - `abort, Label::AbortButton(), - `finish, Label::FinishButton() ) ); + if ( UI::WizardCommand(`DockSubWizard(`apply, _( "&Apply" ), + `abort, Label::AbortButton(), + `finish, Label::FinishButton() ) ) + != true ) + { + UI::OpenDialog(`opt(`defaultsize ), + `Wizard(`apply, _( "&Apply" ), + `abort, Label::AbortButton(), + `finish, Label::FinishButton() ) ); + } } else { @@ -340,6 +369,9 @@ { if ( haveFancyUI() ) { + // Don't try DockSubWizard() with this one: + // It would end up with two steps panels side by side + UI::OpenDialog(`opt(`defaultsize ), `Wizard(`opt(`stepsEnabled), `no_back_button, "", @@ -364,12 +396,15 @@ { if ( haveFancyUI() ) { + // Don't try DockSubWizard() with this one: + // It would end up with two steps panels side by side + UI::OpenDialog(`opt(`defaultsize ), `Wizard(`opt(`stepsEnabled), `no_back_button, "", `abort, Label::AbortButton(), `accept, Label::AcceptButton() ) ); - + // Don't let sloppy calls to Wizard::SetContents() disable this button by accident UI::WizardCommand(`ProtectNextButton( true ) ); } @@ -387,6 +422,9 @@ { if ( haveFancyUI() ) { + // Don't try DockSubWizard() with this one: + // It would end up with two steps panels side by side + UI::OpenDialog(`opt(`defaultsize ), `Wizard(`opt(`stepsEnabled), `back, Label::BackButton(), @@ -455,10 +493,12 @@ * * @stable **/ - global void CloseDialog() { + global void CloseDialog() + { if ( IsWizardDialog() ) { - UI::CloseDialog(); + if ( UI::WizardCommand(`DeleteSubWizard() != true ) ) + UI::CloseDialog(); } else { @@ -479,7 +519,8 @@ * * @return (maybe normalized) widget ID **/ - global any UserInput() { + global any UserInput() + { any input = UI::UserInput(); if ( input == `accept ) return `next; @@ -494,7 +535,7 @@ * * Analogical to Wizard::UserInput. **/ - global any TimeoutUserInput(integer timeout_millisec) + global any TimeoutUserInput(integer timeout_millisec) { any input = UI::TimeoutUserInput(timeout_millisec); @@ -510,7 +551,7 @@ * * Analogical to Wizard::UserInput. **/ - global map WaitForEvent(integer timeout_millisec) + global map WaitForEvent(integer timeout_millisec) { map input = UI::WaitForEvent(timeout_millisec); @@ -550,8 +591,8 @@ * @param set_focus Should the focus be set to Next button? **/ global void SetContentsFocus(string title, term contents, string help_text, - boolean has_back, boolean has_next, boolean set_focus) { - + boolean has_back, boolean has_next, boolean set_focus) + { if ( UI::WizardCommand(`SetDialogHeading( title ) ) == true ) { UI::WizardCommand(`SetHelpText( help_text ) ); @@ -597,9 +638,12 @@ * @screenshot screenshots/wizard1.png **/ global void SetContents(string title, term contents, string help_text, - boolean has_back, boolean has_next) { + boolean has_back, boolean has_next) + { SetContentsFocus (title, contents, help_text, has_back, has_next, true); } + + /** * Clear the wizard contents. * @@ -611,7 +655,8 @@ * * @stable **/ - global void ClearContents() { + global void ClearContents() + { Wizard::SetContents("", `Empty(), "", false, false); } @@ -663,7 +708,8 @@ * @deprecated * @param contents Replace Help with contents **/ - global void ReplaceHelp(term contents) { + global void ReplaceHelp(term contents) + { if ( UI::WidgetExists( `id(`helpSpace ) ) ) { y2warning( "Wizard::ReplaceHelp() is deprecated!" ); @@ -722,7 +768,7 @@ if ( UI::WidgetExists(`id(`rep_next ) ) ) { UI::ReplaceWidget(`id(`rep_next ), - `PushButton( `id( id ), `opt (`key_F10, `default), label ) + `PushButton( `id( id ), `opt (`key_F10, `default), label ) ); } } @@ -780,6 +826,8 @@ } } } + + /** * Hide the Wizard's "Next" button. * Restore it later with RestoreNextButton(): @@ -796,6 +844,7 @@ } } + /** * Hide the Wizard's "Back" button. * Restore it later with RestoreBackButton(): @@ -860,12 +909,12 @@ * @see HideAbortButton * @stable **/ - global void RestoreAbortButton() { + global void RestoreAbortButton() + { Wizard::SetAbortButton( `abort, Label::AbortButton() ); } - /** * Replace the wizard 'next' button with a custom widget. * THIS FUNCTION IS DEPRECATED! @@ -874,7 +923,8 @@ * @see SetNextButton * @param contents a term describing the new contents **/ - global void ReplaceNextButton(term contents) { + global void ReplaceNextButton(term contents) + { if ( UI::WidgetExists(`id(`rep_next ) ) ) UI::ReplaceWidget(`id(`rep_next), contents); @@ -889,7 +939,8 @@ * @see SetBackButton * @param contents a term describing the new contents **/ - global void ReplaceBackButton(term contents) { + global void ReplaceBackButton(term contents) + { if ( UI::WidgetExists(`id(`rep_back ) ) ) UI::ReplaceWidget(`id(`rep_back), contents); @@ -905,7 +956,8 @@ * @deprecated * @param contents a term describing the new contents **/ - global void ReplaceAbortButton(term contents) { + global void ReplaceAbortButton(term contents) + { if ( UI::WidgetExists(`id(`rep_abort ) ) ) UI::ReplaceWidget(`id(`rep_abort), contents); @@ -913,7 +965,6 @@ } - /** * Set the wizard 'title' icon * @@ -981,7 +1032,7 @@ string icon = (string) SCR::Read(filepath); y2debug("icon: %1 (%2)", icon, filepath); - if (icon == nil) + if (icon == nil) return false; SetTitleIcon(icon); @@ -990,6 +1041,7 @@ return true; } + /** * PRIVATE - Replace the entire Wizard button box with a new one. * @param button_box Button Box term @@ -1001,7 +1053,6 @@ } - /** * Enable the wizard's "Abort" button. * @@ -1122,8 +1173,10 @@ * @see bnc #367213. * @return boolean available */ - boolean HasWidgetWizard () { - if (! UI::HasSpecialWidget(`Wizard)) { + boolean HasWidgetWizard () + { + if (! UI::HasSpecialWidget(`Wizard)) + { y2milestone ("no Wizard available"); return false; } @@ -1186,7 +1239,7 @@ else // Qt wizard { UI::WizardCommand(`RetranslateInternalButtons() ); - + if ( UI::WidgetExists(`accept) ) { UI::WizardCommand(`SetBackButtonLabel ( "" ) ); @@ -1230,9 +1283,8 @@ } - - - /* ------------------------------------------------------------ */ + // ------------------------------------------------------------ + /* * screenshot functions */ @@ -1281,7 +1333,9 @@ } } - /* ------------------------------------------------------------ */ + + // ------------------------------------------------------------ + /* * Tree & Menu Wizard functions */ @@ -1328,7 +1382,8 @@ * @param id Item ID * @return list<map> Updated Tree Data **/ - global list<map> AddTreeItem(list<map> Tree, string parent , string title, string id) { + global list<map> AddTreeItem(list<map> Tree, string parent , string title, string id) + { if ( haveFancyUI() ) { UI::WizardCommand(`AddTreeItem( parent, title , id ) ); @@ -1347,19 +1402,20 @@ * @param parent Parent of current Item * @return list Tree Items **/ - list CreateTreeInternal(list<map> Tree, string parent) { + list CreateTreeInternal(list<map> Tree, string parent) + { list<map> m = filter(map c, Tree, ``((c["parent"]:"" == parent ))); map ccbak = nil; // #38596, broken recursion for iterators list mm = maplist(map cc, m, ``{ - string TreeEntry = cc["id"]:""; - ccbak = cc; - list items = CreateTreeInternal(Tree, TreeEntry); - cc = ccbak; - if (size(items)>0) - return(`item(`id(cc["id"]:""), cc["title"]:"", items)); - else - return(`item(`id(cc["id"]:""), cc["title"]:"")); - }); + string TreeEntry = cc["id"]:""; + ccbak = cc; + list items = CreateTreeInternal(Tree, TreeEntry); + cc = ccbak; + if (size(items)>0) + return(`item(`id(cc["id"]:""), cc["title"]:"", items)); + else + return(`item(`id(cc["id"]:""), cc["title"]:"")); + }); y2debug("items: %1", mm ); return mm; } @@ -1369,7 +1425,8 @@ * Query Tree Item * @return Tree Item */ - global string QueryTreeItem() { + global string QueryTreeItem() + { if (haveFancyUI() ) { @@ -1386,7 +1443,8 @@ * @param Tree Tree data * @param title Tree title **/ - global void CreateTree(list<map> Tree, string title) { + global void CreateTree(list<map> Tree, string title) + { if ( !haveFancyUI() ) { list items = []; @@ -1417,7 +1475,8 @@ * Select Tree item * @param tree_item tree item */ - global void SelectTreeItem(string tree_item) { + global void SelectTreeItem(string tree_item) + { if ( haveFancyUI() ) { UI::WizardCommand(`SelectTreeItem( tree_item ) ); @@ -1427,6 +1486,7 @@ UI::ChangeWidget(`id(`wizardTree), `CurrentItem, tree_item); } } + /** * Delete Tree items */ @@ -1444,7 +1504,8 @@ /** * Delete Menu items */ - global void DeleteMenus() { + global void DeleteMenus() + { if ( haveFancyUI() ) { UI::WizardCommand(`DeleteMenus() ); @@ -1454,6 +1515,7 @@ UI::ReplaceWidget(`id(`topmenu), `Empty()); } } + /** * Add Menu * @param Menu Menu data @@ -1461,7 +1523,8 @@ * @param id Menu ID * @return list<map> Updated Menu Data **/ - global list<map> AddMenu(list<map> Menu, string title, string id) { + global list<map> AddMenu(list<map> Menu, string title, string id) + { if ( haveFancyUI() ) { UI::WizardCommand(`AddMenu( title, id ) ); @@ -1481,7 +1544,8 @@ * @param id Menu ID * @return list<map> Updated Menu Data **/ - global list<map> AddSubMenu(list<map> Menu, string parent_id, string title, string id) { + global list<map> AddSubMenu(list<map> Menu, string parent_id, string title, string id) + { if ( haveFancyUI() ) { UI::WizardCommand(`AddSubMenu( parent_id, title, id ) ); @@ -1501,7 +1565,8 @@ * @param id Menu ID * @return list<map> Updated Menu Data **/ - global list<map> AddMenuEntry(list<map> Menu, string parent_id, string title, string id) { + global list<map> AddMenuEntry(list<map> Menu, string parent_id, string title, string id) + { if ( haveFancyUI() ) { UI::WizardCommand(`AddMenuEntry( parent_id, title, id ) ); @@ -1519,22 +1584,23 @@ * @param parent Menu Parent * @return list Menu Items **/ - list CreateMenuInternal(list<map> Menu, string parent) { + list CreateMenuInternal(list<map> Menu, string parent) + { list<map> m = filter(map c, Menu, ``((c["parent"]:"" == parent ))); list mm = maplist(map cc, m, ``{ - if(cc["type"]:"" == "MenuEntry") - { - string MenuEntry = cc["id"]:""; - return(`item(`id(MenuEntry), cc["title"]:"")); - } - else if (cc["type"]:"" == "SubMenu") - { - string SubMenu = cc["id"]:""; - return(`menu( cc["title"]:"", CreateMenuInternal(Menu, - SubMenu))); - } - }); + if(cc["type"]:"" == "MenuEntry") + { + string MenuEntry = cc["id"]:""; + return(`item(`id(MenuEntry), cc["title"]:"")); + } + else if (cc["type"]:"" == "SubMenu") + { + string SubMenu = cc["id"]:""; + return(`menu( cc["title"]:"", CreateMenuInternal(Menu, + SubMenu))); + } + }); y2debug("items: %1", mm ); return mm; } @@ -1544,19 +1610,20 @@ * @param Menu Menu data * @return void **/ - global void CreateMenu(list<map> Menu) { + global void CreateMenu(list<map> Menu) + { if (!haveFancyUI() ) { term menu_term = `HBox(); foreach(map m, Menu, ``{ - if (m["type"]:"" == "Menu") - { - list menu_items = CreateMenuInternal(Menu, m["id"]:""); - y2debug("menu_items: %1", menu_items ); - menu_term=add(menu_term, `MenuButton( m["title"]:"", - menu_items)); - } - }); + if (m["type"]:"" == "Menu") + { + list menu_items = CreateMenuInternal(Menu, m["id"]:""); + y2debug("menu_items: %1", menu_items ); + menu_term=add(menu_term, `MenuButton( m["title"]:"", + menu_items)); + } + }); y2milestone("menu: %1", menu_term ); UI::ReplaceWidget(`id(`topmenu), `Left(menu_term)); } @@ -1569,11 +1636,10 @@ * @param name the product name * @return void **/ - global void SetProductName (string name) { + global void SetProductName (string name) + { y2milestone ("Setting product name to '%1'", name); product_name = name; } - -/* EOF */ } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org