home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / share / YaST2 / clients / packages_proposal.ycp < prev    next >
Text File  |  2006-11-29  |  4KB  |  150 lines

  1. /**
  2.  * Module:    packages_proposal.ycp
  3.  *
  4.  * Author:    Arvin Schnell <arvin@suse.de>
  5.  *
  6.  * Purpose:    Let user choose packages during update.
  7.  *
  8.  * $Id: packages_proposal.ycp 33392 2006-10-13 11:39:53Z locilka $
  9.  */
  10. {
  11.     textdomain "update";
  12.  
  13.     import "HTML";
  14.     import "Packages";
  15.     import "SpaceCalculation";
  16.  
  17.     import "Update";
  18.  
  19.  
  20.     string func  = (string) WFM::Args(0);
  21.     map    param = (map) WFM::Args(1);
  22.     map    ret   = $[];
  23.  
  24.  
  25.     define symbol call_packageselector ()
  26.     {
  27.     if (Update::unknown_packages > 0) // FIXME
  28.     {
  29.         UI::OpenDialog (`opt(`defaultsize), `PackageSelector (`id(`selector),
  30.                                   `opt(`updateMode)));
  31.     }
  32.     else
  33.     {
  34.         UI::OpenDialog (`opt(`defaultsize), `PackageSelector (`id(`selector)));
  35.     }
  36.  
  37.     Pkg::SaveState();
  38.  
  39.     symbol ret = (symbol) UI::RunPkgSelection (`id(`selector));
  40.     if (ret == `accept)
  41.     {
  42.         Pkg::ClearSaveState();
  43.  
  44.         // FIXME: IT'S A MESS
  45.         Update::solve_errors = 0;
  46.         Update::unknown_packages = 0;
  47.         Packages::base_selection_modified = true;
  48.     }
  49.     else
  50.     {
  51.         Pkg::RestoreState(true);
  52.     }
  53.  
  54.     UI::CloseDialog();
  55.  
  56.     return ret;
  57.     }
  58.  
  59.  
  60.     if ( func == "MakeProposal" )
  61.     {
  62.     boolean force_reset      = param["force_reset"     ]:false;
  63.     boolean language_changed = param["language_changed"]:false;
  64.  
  65.     // call some function that makes a proposal here:
  66.     //
  67.     // DummyMod::MakeProposal( force_reset );
  68.  
  69.     // Fill return map
  70.  
  71. //    SpaceCalculation::ShowPartitionWarning ();
  72.     list<string> warning = SpaceCalculation::GetPartitionWarning ();
  73.  
  74.     list<string> tmp = [];
  75.  
  76.     // proposal for packages during update, %1 is count of packages
  77.     tmp = add (tmp, sformat (_("Packages to Update: %1"),
  78.         Update::packages_to_update));
  79.     // proposal for packages during update, %1 is count of packages
  80.     tmp = add (tmp, sformat (_("New Packages to Install: %1"),
  81.         Update::packages_to_install));
  82.     // proposal for packages during update, %1 is count of packages
  83.     tmp = add (tmp, sformat (_("Packages to Remove: %1"),
  84.         Update::packages_to_remove));
  85.     // part of summary, %1 is size of packages (in MB or GB)
  86.     tmp = add (tmp, sformat (_("Total Size of Packages to Update: %1"),
  87.         Packages::CountSizeToBeInstalled ()));
  88.  
  89.     if (Update::solve_errors > 0)
  90.     {
  91.          // the proposal for the packages requires manual invervention
  92.         ret = $[ "preformatted_proposal" : HTML::List (tmp),
  93.             /* warning text */
  94.              "warning" : _("Cannot solve all conflicts. Manual intervention is required."),
  95.              "warning_level" : `blocker ];
  96.     }
  97.     else if (size (warning) > 0)
  98.     {
  99.          // the proposal for the packages requires manual intervention
  100.         ret = $[ "preformatted_proposal" : HTML::List (tmp),
  101.              "warning" : mergestring (warning, "<br>"),
  102.              "warning_level" : `warning ];
  103.     }
  104.     else
  105.     {
  106.         ret = $[ "preformatted_proposal" : HTML::List (tmp) ];
  107.     }
  108.     }
  109.     else if ( func == "AskUser" )
  110.     {
  111.     boolean has_next = param["has_next"]:false;
  112.  
  113.     // call some function that displays a user dialog
  114.     // or a sequence of dialogs here:
  115.     //
  116.     // sequence = DummyMod::AskUser( has_next );
  117.  
  118.     symbol result = call_packageselector ();
  119.  
  120.     // FIXME: IT'S A MESS
  121.     /*
  122.     if (Pkg::PkgSolve (!Update::onlyUpdateInstalled))
  123.         Update::solve_errors = 0;
  124.     else
  125.         Update::solve_errors = Pkg::PkgSolveErrors ();
  126.     */
  127.  
  128.     // Fill return map
  129.  
  130.     ret = $[ "workflow_sequence" : result ];
  131.     }
  132.     else if ( func == "Description" )
  133.     {
  134.     // Fill return map.
  135.     //
  136.     // Static values do just nicely here, no need to call a function.
  137.  
  138.     ret =
  139.         $[
  140.           // this is a heading
  141.           "rich_text_title"    :    _("Packages"),
  142.           // this is a menu entry
  143.           "menu_title"    :    _("&Packages"),
  144.           "id"        :    "packages_stuff"
  145.         ];
  146.     }
  147.  
  148.     return ret;
  149. }
  150.