Name

SimplePatchSelector — Simplified approach to patch selection

Synopsis

SimplePatchSelector (void); 
 

Description

This is a stripped-down version of the PackageSelector widget in "online update" ("patches") mode. It provides a very simplistic view on patches. It does not give access to handling packages by itself, but it contains a "Details..." button that lets the application open a full-fledged PackageSelector (in "online update" / "patches" mode).

Be advised that only this widget alone without access to the full PackageSelector might easily lead the user to a dead end: If dependency problems arise that cannot easily be solved from within the dependency problems dialog or by deselecting one or several patches, it might be necessary for the user to solve the problem on the package level. If he cannot do that, he might be unable to continue his update task.

This widget is similar in many ways to the PatternSelector widget: It gives a higher-level, more abstract access to package management at the cost of omitting details and fine control that more advanced users will want or need. The SimplePatchSelector should be used in ways similarl to the PatternSelector widget.

Usage

 	if ( UI::HasSpecialWidget( `SimplePatchSelector) {...
 	`SimplePatchSelector()...
 	UI::RunPkgSelection();
 

Examples

          // Simple example for SimplePatchSelector
{
    if ( ! UI::HasSpecialWidget(`SimplePatchSelector ) )
    {
        UI::OpenDialog(
		   `VBox( 
			 `Label("Error: This UI doesn't support the SimplePatchSelector widget!"),
			 `PushButton(`opt(`default), "&OK")
			 )
		   );
        UI::UserInput();
        UI::CloseDialog();
	
	return;
    }
    

    UI::OpenDialog(`opt(`defaultsize), `SimplePatchSelector(`id(`selector) ) );
    any input = UI::RunPkgSelection(`id(`selector) );
    UI::CloseDialog();

    y2milestone( "Input: %1", input );
}

        
          // Full-fledged simple patch selection
{
    textdomain "bogus";

    // Initialize RPM DB as pkg src
    Pkg::TargetInit( "/",		// installed system
		     false ); 	// don't create a new RPM database
    
    // Pkg::SourceCreate( "file:/mounts/dist/install/stable-x86/", "" );
    Pkg::SourceCreate( "ftp://ftp.gwdg.de/pub/suse/update/10.2", "" );
    
    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 ),
						 `opt(`youMode),
						 "/dev/fd0" )
			  );
		
	symbol input = (symbol) UI::RunPkgSelection(`id(`packages ) );
	y2milestone( "Package selector returned  %1", input );
	UI::CloseDialog();
	    
    }


    
    if ( ! UI::HasSpecialWidget(`SimplePatchSelector ) )
    {
	detailedSelection();	// Fallback: Do detailed selection right away
	return;
    }

    
    UI::OpenDialog(`opt(`defaultsize), `SimplePatchSelector(`id(`selector) ) );
    
    symbol button = nil;

    repeat
	{
	    button = (symbol) UI::RunPkgSelection(`id(`selector) );
	    y2milestone( "SimplePatchSelector selector returned %1", button );

	    if ( button == `details )
		detailedSelection();
	    
	} until ( button == `cancel || button == `accept );
    
    UI::CloseDialog();
}