[yast-devel] How to stay in a tab in DialogTree after clicking Next
Hello, short story: in yast2-printer I use a DialogTree and in one of its tabs (which is not its initial tab) I like to stay in the tab after the user clicked Next when an error happened while writing the settings to the system so that the user can change the settings in the tab until it works or he can click [Cancel] to enforce leaving the dialog. Details: in yast2-printer I have in src/dialogs.ycp -------------------------------------------------------------------------- widgets_handling = ... "NETWORKPRINTING" : $[ "widget" : `custom, "custom_widget" : widgetNetworkPrinting, "init" : initNetworkPrinting, "handle" : handleNetworkPrinting, "help" : HELPS["printing_via_network_dialog"]:"" ], . . . tabs_description = ... "network" : $[ "header" : _("Print via Network"), "tree_item_label" : _("Print via Network"), "caption" : _("Print via Network"), "contents" : `VBox( "NETWORKPRINTING" ), "widget_names" : ["NETWORKPRINTING"] ], . . . DialogTree::ShowAndRun ( $[ "ids_order" : [ "overview", "network", ... ], "initial_screen" : "overview", -------------------------------------------------------------------------- I like to stay in the "NETWORKPRINTING" tab when writing its settings fails. In src/printingvianetwork.ycp I have currently in the handleNetworkPrinting() function: ---------------------------------------------------------------------------- if( `next == event["ID"]:nil ) { if( ! ApplyNetworkPrintingSettings() ) { Popup::Error( // Popup::Error message: _("Failed to apply the settings to the system.") ); // In case of an error stay on the "Print via Network" dialog // so that the user can either change his settings until it works // or he can use the [Cancel] button to return to the Overview dialog: return nil; } ---------------------------------------------------------------------------- but this does not work. Instead the whole YaST module is exiting with `next regardless that I explicitely "return nil" and in y2log there is: ------------------------------------------------------------------------------ 2009-11-06 11:06:28 <1> nelson(6379) [liby2] Y2ProgramComponent.cc(result):159 Sending result: `result (nil) 2009-11-06 11:06:28 <1> nelson(6379) [liby2] genericfrontend.cc(main):777 Finished YaST2 component 'y2base' 2009-11-06 11:06:28 <1> nelson(6379) [liby2] genericfrontend.cc(main):782 Exiting with client return value '`next' ------------------------------------------------------------------------------ Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hi! I think you should use "validate" instead of "handle" for deciding whether to leave the dialog or not. In case of "handle", the return value means to leave the dialog with specified ret val, however, nil does not prevent leaving the dialog. Failing validation does. Hope that helps, Jiri Dne pátek 06 Listopad 2009 11:11:25 Johannes Meixner napsal(a):
Hello,
short story: in yast2-printer I use a DialogTree and in one of its tabs (which is not its initial tab) I like to stay in the tab after the user clicked Next when an error happened while writing the settings to the system so that the user can change the settings in the tab until it works or he can click [Cancel] to enforce leaving the dialog.
Details: in yast2-printer I have in src/dialogs.ycp -------------------------------------------------------------------------- widgets_handling = ... "NETWORKPRINTING" : $[ "widget" : `custom, "custom_widget" : widgetNetworkPrinting, "init" : initNetworkPrinting, "handle" : handleNetworkPrinting, "help" : HELPS["printing_via_network_dialog"]:"" ], . . . tabs_description = ... "network" : $[ "header" : _("Print via Network"), "tree_item_label" : _("Print via Network"), "caption" : _("Print via Network"), "contents" : `VBox( "NETWORKPRINTING" ), "widget_names" : ["NETWORKPRINTING"] ], . . . DialogTree::ShowAndRun ( $[ "ids_order" : [ "overview", "network", ... ], "initial_screen" : "overview", --------------------------------------------------------------------------
I like to stay in the "NETWORKPRINTING" tab when writing its settings fails.
In src/printingvianetwork.ycp I have currently in the handleNetworkPrinting() function: --------------------------------------------------------------------------- - if( `next == event["ID"]:nil ) { if( ! ApplyNetworkPrintingSettings() ) { Popup::Error( // Popup::Error message: _("Failed to apply the settings to the system.") ); // In case of an error stay on the "Print via Network" dialog // so that the user can either change his settings until it works // or he can use the [Cancel] button to return to the Overview dialog: return nil; } --------------------------------------------------------------------------- - but this does not work.
Instead the whole YaST module is exiting with `next regardless that I explicitely "return nil" and in y2log there is: --------------------------------------------------------------------------- --- 2009-11-06 11:06:28 <1> nelson(6379) [liby2] Y2ProgramComponent.cc(result):159 Sending result: `result (nil) 2009-11-06 11:06:28 <1> nelson(6379) [liby2] genericfrontend.cc(main):777 Finished YaST2 component 'y2base' 2009-11-06 11:06:28 <1> nelson(6379) [liby2] genericfrontend.cc(main):782 Exiting with client return value '`next' --------------------------------------------------------------------------- ---
Kind Regards Johannes Meixner
-- Regards, Jiri Srain YaST Team Leader --------------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: jsrain@suse.cz Lihovarska 1060/12 tel: +420 284 028 959 190 00 Praha 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hello, On Nov 6 12:15 Jiri Srain wrote (shortened):
I think you should use "validate" instead of "handle" for deciding whether to leave the dialog or not. In case of "handle", the return value means to leave the dialog with specified ret val, however, nil does not prevent leaving the dialog. Failing validation does.
Regarding DialogTree I know currently only about the information at http://forgeftp.novell.com/yast/doc/SL11.1/modules/DialogTree.html which does not help to understand what "validate" instead of "handle" means. The code in yast2-printer in src/dialogs.ycp was initially written by Michal Zugec and I do not understand very much about what there goes on internally. If I used "validate", it would have to leave the dialog when everything is o.k. but not leave it only when there is an error. Is this possible? Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Friday 06 November 2009 12:54:47 Johannes Meixner wrote:
Hello,
On Nov 6 12:15 Jiri Srain wrote (shortened):
I think you should use "validate" instead of "handle" for deciding whether to leave the dialog or not. In case of "handle", the return value means to leave the dialog with specified ret val, however, nil does not prevent leaving the dialog. Failing validation does.
Regarding DialogTree I know currently only about the information at http://forgeftp.novell.com/yast/doc/SL11.1/modules/DialogTree.html which does not help to understand what "validate" instead of "handle" means.
Usually CWM widget functions look like this: init : InitMyCoolDialog handle: HandleMyCoolDialog store: StoreMyCoolDialog 'handle' describes immediate responses to user actions, for example something happens once user (de)selects a check box, or pushes a button 'store' is called as soon as the dialog is left - e.g. when user clicks on Next/OK button, or switches to different tab or tree branch To the above, you may want to add those: validate_type : `function, validate_function: ValidateMyCoolDialog where ValidateMyCoolDialog will be a function returning boolean - true if the validation passes, false otherwise. 'validate' is called prior to 'store' (described above) and only if it returns true, data are really stored. Otherwise, when the validation does not pass, the control is returned to the dialog and user is not allowed to leave it unless the errors are corrected. hB. -- \\\\\ Katarina Machalkova \\\\\\\__o YaST developer __\\\\\\\'/_ & hedgehog painter -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Dne pátek 06 Listopad 2009 12:54:47 Johannes Meixner napsal(a):
Hello,
On Nov 6 12:15 Jiri Srain wrote (shortened):
I think you should use "validate" instead of "handle" for deciding whether to leave the dialog or not. In case of "handle", the return value means to leave the dialog with specified ret val, however, nil does not prevent leaving the dialog. Failing validation does.
Regarding DialogTree I know currently only about the information at http://forgeftp.novell.com/yast/doc/SL11.1/modules/DialogTree.html which does not help to understand what "validate" instead of "handle" means.
Refer to documentation in svn: /yast2/library/cwm/doc (it is a docbook, you can read advanced.xml), or find some examples in the sources, there are a lot (grep for '"validate_type"').
The code in yast2-printer in src/dialogs.ycp was initially written by Michal Zugec and I do not understand very much about what there goes on internally.
If I used "validate", it would have to leave the dialog when everything is o.k. but not leave it only when there is an error. Is this possible?
That's exactly what validation does. If it fails, it does not allow to leave the dialog. If you use validation via function, you can also define other actios to do (display specified message, change active widget, etc). Jiri -- Regards, Jiri Srain YaST Team Leader --------------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: jsrain@suse.cz Lihovarska 1060/12 tel: +420 284 028 959 190 00 Praha 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (3)
-
Jiri Srain
-
Johannes Meixner
-
Katarina Machalkova