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 / language_proposal.ycp < prev    next >
Text File  |  2006-11-29  |  3KB  |  112 lines

  1. /**
  2.  * File:        language_proposal.ycp
  3.  *
  4.  * $Id: language_proposal.ycp 26747 2006-01-03 17:32:59Z jsuchome $
  5.  *
  6.  * Author:        Klaus Kaempf <kkaempf@suse.de>
  7.  *
  8.  * Purpose:        Proposal function dispatcher - language.
  9.  *
  10.  *            See also file proposal-API.txt for details.
  11.  */
  12. {
  13.     textdomain "country";
  14.  
  15.     import "Language";
  16.     import "Wizard";
  17.     import "Encoding";
  18.  
  19.     string func  = (string) WFM::Args(0);
  20.     map    param = (map) WFM::Args(1);
  21.     map    ret   = $[];
  22.  
  23.     // Memorize current language to be able to detect a change.
  24.     //
  25.     string language_on_entry = Language::language;
  26.     y2milestone("language_on_entry - 1: %1", language_on_entry );
  27.  
  28.     if ( func == "MakeProposal" )
  29.     {
  30.     boolean force_reset      = param["force_reset"     ]:false;
  31.     boolean language_changed = param["language_changed"]:false;
  32.  
  33.     import "Installation";
  34.     import "Misc";
  35.     import "Mode";
  36.  
  37.     if (Mode::update () &&
  38.         (Language::languages == "" || Language::languages == language_on_entry) &&
  39.         !force_reset && !Language::Modified ())
  40.     {
  41.         Language::languages = Misc::CustomSysconfigRead ("INSTALLED_LANGUAGES", "",
  42.         Installation::destdir + "/etc/sysconfig/language");
  43.         y2milestone ("languages got from target system: %1", Language::languages);
  44.     }
  45.  
  46.     // Make proposal and fill return map
  47.     list<string> prop =
  48.         Language::MakeProposal (force_reset, language_changed);
  49.  
  50.     y2milestone ("language_on_entry:%1 lang:%2, languages: %3",
  51.         language_on_entry, Language::language, Language::languages);
  52.  
  53.     if (force_reset && language_on_entry != Language::language)
  54.     {
  55.         // Set it in YaST2
  56.         Language::WfmSetLanguage();
  57.     }
  58.  
  59.     ret = $[
  60.           "raw_proposal"    : prop,
  61.           "language_changed": (language_on_entry != Language::language )
  62.     ];
  63.     }
  64.     else if ( func == "AskUser" )
  65.     {
  66.  
  67.     Wizard::OpenAcceptDialog();
  68.     map args = $[
  69.         "enable_back"    : true,
  70.         "enable_next"    : param["has_next"]:false,
  71.     ];
  72.     symbol result    = (symbol)WFM::CallFunction ("select_language", [args]);
  73.  
  74.     Wizard::CloseDialog();
  75.  
  76.     if ( result == `back )
  77.     {
  78.         y2milestone("back to language_on_entry: %1", language_on_entry );
  79.  
  80.         Language::Set( language_on_entry );
  81.     }
  82.  
  83.     // Fill return map
  84.  
  85.     ret =
  86.         $[
  87.           "workflow_sequence" : result,
  88.           "language_changed": (language_on_entry != Language::language)
  89.         ];
  90.  
  91.     y2debug( "Returning from proposal_language::AskUser() with: %1", ret );
  92.  
  93.     }
  94.     else if ( func == "Description" )
  95.     {
  96.     // Fill return map.
  97.     //
  98.     // Static values do just nicely here, no need to call a function.
  99.  
  100.     ret =
  101.         $[
  102.           // label text
  103.           "rich_text_title"    :    _( "Language"  ),
  104.           // menue label text
  105.           "menu_title"    :    _( "&Language" ),
  106.           "id"        :    "language_stuff"
  107.         ];
  108.     }
  109.  
  110.     return ret;
  111. }
  112.