Changeset 1361cd4


Ignore:
Timestamp:
Aug 8, 2013 9:04:31 AM (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
4f9718b, e897460
Parents:
94a335c
Message:

Setup the "activate" button in pc-bootconfig to properly set the default BE to startup on reboot. Also make sure that we cannot rename a running BE.

Location:
src-qt4/pc-bootconfig
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-bootconfig/mainUI.cpp

    rde1ea77 r1361cd4  
    2020    proc->setProcessChannelMode(QProcess::MergedChannels); 
    2121   
     22  //Load the GRUB defaults file into memory 
     23  G_goodLoad = loadGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE); 
    2224  //Update the list of available boot environments 
    2325  updateBEList(); 
     
    8789//Boot Environment Management Functions 
    8890void mainUI::beadmActivate(QString name){  
     91        //GRUB OVERRIDES THIS TYPE OF ACTIVATION!!! DO NOT USE! 
    8992        qDebug() << "Activate BE:" << name; 
    9093        QString cmd = "beadm activate "+name; 
     
    151154 
    152155//GRUB Configuration Management Functions 
    153 bool mainUI::loadGRUBdefaults(QString &themefile, QString &fontfile, int &countdown, bool &showcountdown){ 
     156bool mainUI::loadGRUBdefaults(QString &themefile, QString &fontfile, int &countdown, bool &showcountdown, int &defaultBE){ 
    154157  qDebug() << "Load GRUB defaults:" << file_GRUBdefaults; 
    155158  QFile file(file_GRUBdefaults); 
     
    161164  countdown = 0; //initialization 
    162165  showcountdown = false; 
     166  defaultBE = 0; 
    163167  while( !in.atEnd() ){ 
    164168    QString line = in.readLine(); 
     
    170174    else if(var == "GRUB_TIMEOUT"){ countdown = val.toInt(); } 
    171175    else if(var == "GRUB_HIDDEN_TIMEOUT_QUIET"){ showcountdown = (val != "true"); } 
     176    else if(var == "GRUB_DEFAULT"){ defaultBE = val.toInt(); } 
    172177  } 
    173178  file.close(); 
     
    178183} 
    179184 
    180 bool mainUI::saveGRUBdefaults(QString themefile, QString fontfile, int countdown, bool showcountdown){ 
     185bool mainUI::saveGRUBdefaults(QString themefile, QString fontfile, int countdown, bool showcountdown, int defaultBE){ 
    181186  qDebug() << "Save GRUB defaults:" << file_GRUBdefaults; 
    182187  QFile file(file_GRUBdefaults+".new"); 
     
    193198    out << "GRUB_HIDDEN_TIMEOUT="+ QString::number(countdown)+"\n"; 
    194199  } 
     200  if(defaultBE >= 0){ out << "GRUB_DEFAULT="+QString::number(defaultBE)+"\n"; } 
    195201  file.close(); 
    196202  QString cmd="mv "+file_GRUBdefaults+".new "+file_GRUBdefaults; 
     
    240246      cols << blist[i].section("::",0,0); // [0] name 
    241247      cols << blist[i].section("::",1,1); // [1] is running 
    242       cols << blist[i].section("::",2,2); // [2] is activated for next boot 
     248      // [2] is default for next boot 
     249      if(G_defaultBE == i){ cols << "Yes"; } 
     250      else{ cols << "No"; } 
    243251      cols << blist[i].section("::",5,6); // [3] date 
    244252      cols << blist[i].section("::",3,3); // [4] mountpoints 
     
    256264 
    257265void mainUI::updateGRUBdefaults(){ 
    258   QString themefile, fontfile; 
    259   int timeout; 
    260   bool showcountdown; 
    261   if( loadGRUBdefaults(themefile, fontfile, timeout, showcountdown) ){ 
     266  if( G_goodLoad ){ 
    262267    //Load the info into the UI 
    263     ui->line_GRUBthemefile->setText(themefile); 
    264     ui->line_GRUBfontfile->setText(fontfile); 
    265     ui->spin_GRUBtimer->setValue(timeout); 
    266     ui->check_GRUBshowcountdown->setChecked(showcountdown); 
     268    ui->line_GRUBthemefile->setText(G_themeFile); 
     269    ui->line_GRUBfontfile->setText(G_fontFile); 
     270    ui->spin_GRUBtimer->setValue(G_timer); 
     271    ui->check_GRUBshowcountdown->setChecked(G_showMenu); 
    267272    ui->group_GRUBsettings->setEnabled(true); 
    268273  }else{ 
     
    314319  int index = getSelectedBE(); 
    315320  if(index != -1){ 
    316     QString name = ui->tree_BE->topLevelItem(index)->text(0); 
    317     beadmActivate(name); 
     321    //Save the new defaults 
     322    G_defaultBE = index; 
     323    bool ok = saveGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE); 
     324    //Update GRUB config 
     325    if(ok){ on_action_rebuildGRUBmenu_triggered(); } 
     326    //Update GUI 
    318327    updateBEList(); 
    319328  } 
     
    342351  int index = getSelectedBE(); 
    343352  if(index != -1){ 
     353    if(ui->tree_BE->topLevelItem(index)->text(1).toLower() == "yes"){ 
     354      QMessageBox::warning(this,tr("Running Boot Environment"), tr("You cannot rename a boot environment that you are currently running!") ); 
     355      return; 
     356    } 
    344357    QString name = ui->tree_BE->topLevelItem(index)->text(0); 
    345358    //Get the new name from the user 
     
    383396void mainUI::on_tool_GRUBsavedefaults_clicked(){ 
    384397  //Get all the values 
    385   QString themefile = ui->line_GRUBthemefile->text(); 
    386   QString fontfile = ui->line_GRUBfontfile->text(); 
    387   int countdown = ui->spin_GRUBtimer->value(); 
    388   bool showcountdown = ui->check_GRUBshowcountdown->isChecked(); 
     398  G_themeFile = ui->line_GRUBthemefile->text(); 
     399  G_fontFile = ui->line_GRUBfontfile->text(); 
     400  G_timer = ui->spin_GRUBtimer->value(); 
     401  G_showMenu = ui->check_GRUBshowcountdown->isChecked(); 
    389402  //always show the countdown if more than one BE 
    390   if( ui->tree_BE->topLevelItemCount() > 1 ){ showcountdown=true; } 
     403  if( ui->tree_BE->topLevelItemCount() > 1 ){ G_showMenu=true; } 
    391404         
    392405  //Save the values to the file 
    393   bool ok = saveGRUBdefaults(themefile,fontfile,countdown,showcountdown); 
     406  bool ok = saveGRUBdefaults(G_themeFile,G_fontFile,G_timer,G_showMenu, G_defaultBE); 
    394407  if(!ok){ 
    395408    qDebug() << "Unable to save the GRUB defaults to file:" << file_GRUBdefaults+".new"; 
     409    G_goodLoad = loadGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE); //reset values 
    396410  }else{ 
     411    on_action_rebuildGRUBmenu_triggered(); 
    397412    ui->tool_GRUBsavedefaults->setEnabled(false); 
    398413    ui->tool_GRUBresetdefaults->setEnabled(false);     
     
    401416 
    402417void mainUI::on_tool_GRUBresetdefaults_clicked(){ 
     418  G_goodLoad = loadGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE); 
    403419  updateGRUBdefaults(); 
    404420} 
  • src-qt4/pc-bootconfig/mainUI.h

    rb3cb948 r1361cd4  
    3232        QString file_GRUBdefaults, file_GRUBentries; 
    3333        QString dir_GRUBthemes, dir_GRUBfonts; 
    34  
     34        //GRUB default values 
     35        QString G_fontFile, G_themeFile; 
     36        int G_timer, G_defaultBE; 
     37        bool G_showMenu, G_goodLoad; 
    3538        //Random usage functions 
    3639        int getSelectedBE(); //get the currently selected Boot Environment index 
     
    4952 
    5053        //GRUB Configuration Management Functions 
    51         bool loadGRUBdefaults(QString&, QString&, int&, bool&); 
    52         bool saveGRUBdefaults(QString, QString, int, bool); 
     54        bool loadGRUBdefaults(QString&, QString&, int&, bool&, int&); 
     55        bool saveGRUBdefaults(QString, QString, int, bool, int defaultBE=0); 
    5356        bool loadGRUBcustomentries(QStringList&); 
    5457        bool saveGRUBcustomentries(QStringList); 
  • src-qt4/pc-bootconfig/mainUI.ui

    rb3cb948 r1361cd4  
    102102             <widget class="QToolButton" name="tool_BEactivate"> 
    103103              <property name="statusTip"> 
    104                <string>Activate the selected boot environment to be used with next reboot</string> 
     104               <string>Activate the selected boot environment to be used as the default during bootup</string> 
    105105              </property> 
    106106              <property name="text"> 
     
    135135            <column> 
    136136             <property name="text"> 
    137               <string>Bootup</string> 
     137              <string>Default</string> 
    138138             </property> 
    139139            </column> 
Note: See TracChangeset for help on using the changeset viewer.