PatternSelector — High-level widget to select software patterns (selections)
PatternSelector
( | void) ; |
This widget is similar to the PackageSelector in its semantics: It is a very high-level widget that lets the user select software, but unlike the PackageSelector it works on software patterns (selections).
if ( UI::HasSpecialWidget( `PatternSelector) {... `PatternSelector()... UI::RunPkgSelection();
// Simple example for PatternSelector { if ( ! UI::HasSpecialWidget(`PatternSelector ) ) { UI::OpenDialog( `VBox( `Label("Error: This UI doesn't support the PatternSelector widget!"), `PushButton(`opt(`default), "&OK") ) ); UI::UserInput(); UI::CloseDialog(); return; } Pkg::TargetInit( "/", // installed system false ); // don't create a new RPM database UI::OpenDialog(`opt(`defaultsize), `PatternSelector(`id(`selector) ) ); any input = UI::RunPkgSelection(`id(`selector) ); UI::CloseDialog(); y2milestone( "Input: %1", input ); }
// Full-fledged pattern selection { textdomain "bogus"; // Pkg::SourceCreate( "http://dist.suse.de/install/SLP/SUSE-10.1-Beta3/i386/CD1/", "" ); Pkg::SourceCreate( "file:/srv/sles-10-i386/CD1/", "" ); void detailedSelection() { // Open empty dialog for instant feedback UI::OpenDialog(`opt(`defaultsize), `ReplacePoint(`id( `rep), `Label( "Reading package database..." ) ) ); // This will take a while: Detailed package data are retrieved // while the package manager is initialized UI::ReplaceWidget(`rep, `PackageSelector(`id(`packages ), "/dev/fd0" ) ); symbol input = (symbol) UI::RunPkgSelection(`id(`packages ) ); y2milestone( "Package selector returned %1", input ); UI::CloseDialog(); } if ( ! UI::HasSpecialWidget(`PatternSelector ) ) { detailedSelection(); // Fallback: Do detailed selection right away return; } UI::OpenDialog(`opt(`defaultsize ), `Wizard(`back, "", `cancel, "&Cancel", `ok, "&OK" ) ); string help_text = _( "<p>" "The available software for this system is shown by category in the left " "column. To view a description for an item, select it in the list." "</p>" ) + _( "<p>" "Change the status of items by clicking on their status icon " "or right-click on any icon for a context menu. " "With the context menu you can also change the status of all items." "</p>" ) + _( "<p>" "<b>Details</b> opens the detailed software package selection " "where you can view and select individual software packages." "</p>" ) + _( "<p>" "The <b>disk usage</b> display in the lower right corner shows the remaining disk space " "after all requested changes will have been performed. " "Please notice that hard disk partitions that are full or nearly full can degrade " "system performance and in some cases even cause serious problems. " "The system needs some available disk space to run properly." "</p>" ); UI::WizardCommand(`SetDialogIcon( "/usr/share/YaST2/theme/current/icons/22x22/apps/YaST.png" ) ); UI::WizardCommand(`SetDialogHeading( "Software Selection" ) ); UI::WizardCommand(`SetHelpText( help_text ) ); Pkg::TargetInit( "/", // installed system false ); // don't create a new RPM database UI::ReplaceWidget(`id(`contents), `PatternSelector(`id(`patterns ) ) ); symbol button = nil; repeat { button = (symbol) UI::RunPkgSelection(`id(`patterns ) ); y2milestone( "Pattern selector returned %1", button ); if ( button == `details ) detailedSelection(); } until ( button == `cancel || button == `accept ); UI::CloseDialog(); }