Class: Yast::SlideShowClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
library/packages/src/modules/SlideShow.rb

Defined Under Namespace

Modules: UI_ID

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#user_switched_toObject

Returns the value of attribute user_switched_to


113
114
115
# File 'library/packages/src/modules/SlideShow.rb', line 113

def user_switched_to
  @user_switched_to
end

Instance Method Details

#add_relnotes_for_product(product, relnotes, tabs) ⇒ Object


650
651
652
653
654
655
# File 'library/packages/src/modules/SlideShow.rb', line 650

def add_relnotes_for_product(product, relnotes, tabs)
  id = ProductRelNotesID product
  # Translators: Tab name, keep short, %s is product name, e.g. SLES
  tabs << Item(Id(id), _("%s Release Notes") % product)
  @_rn_tabs[id] = relnotes
end

#AddProgressWidgets(page_id, page_contents) ⇒ Object

Add widgets for progress bar etc. around a slide show page

Parameters:

  • page_id (Symbol)

    ID to use for this page (for checking with UI::WidgetExists() )

  • page_contents (Yast::Term)

    The inner widgets (the page contents)

Returns:

  • A term describing the widgets


479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'library/packages/src/modules/SlideShow.rb', line 479

def AddProgressWidgets(page_id, page_contents)
  page_contents = deep_copy(page_contents)
  widgets = HBox(
    Id(page_id),
    HSpacing(1),
    VBox(
      VWeight(
        1, # lower layout priority
        page_contents
      ), # intentionally omitting `Label(`nextMedia) -
      # too much flicker upon update (UI::RecalcLayout() ) on NCurses
      # Progress bar for overall progress of software package installation
      ProgressBar(
        Id(UI_ID::TOTAL_PROGRESS),
        @total_progress_label,
        100,
        @total_progress_value
      )
    ),
    HSpacing(0.5)
  )

  Builtins.y2debug("widget term: \n%1", widgets)
  deep_copy(widgets)
end

#AppendMessageToInstLog(msg) ⇒ Object

Append message to the installation log.

Parameters:

  • msg (String)

    message to be added, without trailing eoln


388
389
390
391
392
393
394
395
396
# File 'library/packages/src/modules/SlideShow.rb', line 388

def AppendMessageToInstLog(msg)
  log_line = "#{msg}\n"

  @inst_log << log_line

  UI.ChangeWidget(:instLog, :LastLine, log_line) if ShowingDetails() && UI.WidgetExists(:instLog)

  nil
end

#ChangeSlideIfNecessaryObject

Check if the current slide needs to be changed and do that if necessary.


468
469
470
471
472
# File 'library/packages/src/modules/SlideShow.rb', line 468

def ChangeSlideIfNecessary
  LoadSlide(@current_slide_no + 1) if Yast2::SystemTime.uptime > (@slide_start_time + @slide_interval)

  nil
end

#CheckForSlidesObject

Check if the slide show is available. This must be called before trying to access any slides; some late initialization is done here.


407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'library/packages/src/modules/SlideShow.rb', line 407

def CheckForSlides
  Slides.CheckBasePath

  if Stage.initial || Stage.cont
    if Slides.HaveSlideSupport
      Builtins.y2milestone("Display OK for slide show, loading")
      Slides.LoadSlides(@language)
    else
      Builtins.y2warning(
        "Disabling slide show - insufficient display capabilities"
      )
    end
  end

  nil
end

#CloseDialogObject

Close the slide show dialog.


888
889
890
891
892
893
894
895
# File 'library/packages/src/modules/SlideShow.rb', line 888

def CloseDialog
  Wizard.CloseDialog if @opened_own_wizard

  # call SlideShowCallbacks::RemoveSlideShowCallbacks()
  WFM.call("wrapper_slideshow_callbacks", ["RemoveSlideShowCallbacks"])

  nil
end

#CurrentStageDescriptionString

Return the description for the current stage.

Returns:

  • (String)

    localized string description


321
322
323
# File 'library/packages/src/modules/SlideShow.rb', line 321

def CurrentStageDescription
  Ops.get_locale(@_current_stage, "description", _("Installing..."))
end

#DetailsPageWidgetsObject

Construct widgets for the "details" page

Returns:

  • A term describing the widgets


541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'library/packages/src/modules/SlideShow.rb', line 541

def DetailsPageWidgets
  widgets = AddProgressWidgets(
    :detailsPage,
    VBox(
      @_show_table ? DetailsTableWidget() : Empty(),
      VWeight(1, LogView(Id(:instLog), _("Actions performed:"), 6, 0)),
      ProgressBar(
        Id(UI_ID::CURRENT_PACKAGE),
        @sub_progress_label,
        100,
        @sub_progress_value
      )
    )
  )

  Builtins.y2debug("widget term: \n%1", widgets)
  deep_copy(widgets)
end

#DetailsTableWidgetObject


516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'library/packages/src/modules/SlideShow.rb', line 516

def DetailsTableWidget
  VWeight(
    1,
    Table(
      Id(:cdStatisticsTable),
      Opt(:keepSorting),
      Header(
        # Table headings for CD statistics during installation
        _("Media"),
        # Table headings for CD statistics during installation - keep as short as possible!
        Right(_("Remaining")),
        # Table headings for CD statistics during installation
        Right(_("Packages")),
        # Table headings for CD statistics during installation
        Right(_("Time"))
      ),
      @table_items
    )
  )
end

#GenericHandleInputObject

Check for user button presses and handle them. Generic handling to be used in the progress handlers.


836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# File 'library/packages/src/modules/SlideShow.rb', line 836

def GenericHandleInput
  button = UI.PollInput

  # in case of cancel ask user if he really wants to quit installation
  if [:abort, :cancel].include?(button)
    if Mode.normal
      SetUserAbort(
        Popup.AnyQuestion(
          Popup.NoHeadline,
          # popup yes-no
          _("Do you really want\nto quit the installation?"),
          Label.YesButton,
          Label.NoButton,
          :focus_no
        )
      )
    elsif Stage.initial
      SetUserAbort(Popup.ConfirmAbort(:unusable)) # Mode::update (), Stage::cont ()
    else
      SetUserAbort(Popup.ConfirmAbort(:incomplete))
    end

    AppendMessageToInstLog(_("Aborted")) if GetUserAbort()
  else
    HandleInput(button)
  end

  nil
end

#GetSetupHash <String, Hash{String => Object>}

Returns the current setup defined by Setup().

Structure:

$[ stage_name : $[ stage_setup ], ... ]

Returns:

See Also:

  • #Setup()

1047
1048
1049
# File 'library/packages/src/modules/SlideShow.rb', line 1047

def GetSetup
  deep_copy(@_stages)
end

#GetUserAbortBoolean

Get the status of the flag that user requested abort of the installation

Returns:

  • (Boolean)

    state of the abort requested flag (true = abort requested)


182
183
184
# File 'library/packages/src/modules/SlideShow.rb', line 182

def GetUserAbort
  @user_abort
end

#GlobalProgressStart(text) ⇒ Object

Restart the global progress of the slideshow. This means the label will be set to given text, value to 0.

Parameters:

  • text (String)

    new label for the global progress


285
286
287
# File 'library/packages/src/modules/SlideShow.rb', line 285

def GlobalProgressStart(text)
  UpdateGlobalProgress(0, text)
end

#HandleInput(button) ⇒ Object

Process (slide show) input (button press).


801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
# File 'library/packages/src/modules/SlideShow.rb', line 801

def HandleInput(button)
  button = deep_copy(button)
  if button == :showDetails && !ShowingDetails()
    Builtins.y2milestone("User asks to switch to details")
    @user_switched_to = :details
    SwitchToDetailsView()
  elsif button == :showSlide && !ShowingSlide()
    if Slides.HaveSlides
      if @user_switched_to == :release_notes
        # The user is currently in the release notes tab.
        # In order to not disturb him while reading the release notes
        # we are not updating the tabs although the slide show has been
        # changed in the background.
        # Now the user is switching from release notes to slide show
        # and we are updating the slide show now.
        RebuildDialog(true) # true: showing the release tab
      end
      SwitchToSlideView()
      LoadSlide(@current_slide_no)
    else
      UI.ChangeWidget(:dumbTab, :CurrentItem, :showDetails)
    end
    @user_switched_to = :slides
  elsif @_rn_tabs.key?(button) && !ShowingRelNotes(button)
    @user_switched_to = :release_notes
    SwitchToReleaseNotesView(button)
  end
  # note: `abort is handled in SlideShowCallbacks::HandleInput()

  nil
end

#HaveSlideWidgetObject

Check if the dialog is currently set up so the user could switch to the slide page.


400
401
402
# File 'library/packages/src/modules/SlideShow.rb', line 400

def HaveSlideWidget
  UI.WidgetExists(:dumbTab)
end

#HelpTextObject

Help text for the dialog


632
633
634
635
636
637
638
639
640
# File 'library/packages/src/modules/SlideShow.rb', line 632

def HelpText
  # Help text while software packages are being installed (displayed only in rare cases)
  help_text = _("<p>Packages are being installed.</p>") +
    _(
      "<P><B>Aborting Installation</B> Package installation can be aborted using the <B>Abort</B> button. However, the system then can be in an inconsistent or unusable state or it may not boot if the basic system component is not installed.</P>"
    )

  help_text
end

#HideTableObject


907
908
909
910
911
912
913
914
915
# File 'library/packages/src/modules/SlideShow.rb', line 907

def HideTable
  if ShowingDetails() && @_show_table
    @_show_table = false
    RebuildDetailsView()
  end
  @_show_table = false

  nil
end

#LoadSlide(slide_no) ⇒ Object

Load a slide image + text.

Parameters:

  • slide_no (Fixnum)

    number of slide to load


451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'library/packages/src/modules/SlideShow.rb', line 451

def LoadSlide(slide_no)
  slide_no = 0 if slide_no >= Slides.slides.size
  log.info "load slide #{slide_no}"

  @current_slide_no = slide_no

  slide_name = Ops.get(Slides.slides, slide_no, "")
  @slide_start_time = Yast2::SystemTime.uptime

  SetSlideText(Slides.LoadSlideFile(slide_name))

  nil
end

#mainObject


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'library/packages/src/modules/SlideShow.rb', line 120

def main
  Yast.import "UI"

  textdomain "base"

  Yast.import "Label"
  Yast.import "Stage"
  Yast.import "Wizard"
  Yast.import "Mode"
  Yast.import "Popup"
  Yast.import "Slides"

  @total_time_elapsed = 0
  @start_time = -1
  @initial_recalc_delay = 60 # const - seconds before initially calculating remaining times
  @recalc_interval = 30 # const - seconds between "remaining time" recalculations
  @next_recalc_time = Yast2::SystemTime.uptime

  @current_slide_no = 0
  @slide_start_time = 0
  @slide_interval = 30 # FIXME: constant
  @language = "en"
  @widgets_created = false
  @user_switched_to = :none
  @opened_own_wizard = false
  @inst_log = ""
  @user_abort = false

  # we need to remember the values for tab switching
  # these are the initial values
  @total_progress_label = _("Installing...")
  @sub_progress_label = _("Installing...")
  @total_progress_value = 0
  @sub_progress_value = 0
  @table_items = []

  @_show_table = false

  # properties of the current UI
  @textmode = false
  @display_width = 80

  @relnotes = nil # forward declaration

  @_stages = {} # list of the configured stages
  @_current_stage = nil # current stage

  @_rn_tabs = {} # tabs with release notes
  @_relnotes = {} # texts with release notes, product -> text
  @_base_product = "" # base product for release notes ordering
end

#MoveToStage(stage_name) ⇒ Object

Move the global progress to the beginning of the given stage.

Parameters:

  • stage_name (String)

    id of the stage to move to


327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'library/packages/src/modules/SlideShow.rb', line 327

def MoveToStage(stage_name)
  if !Builtins.haskey(@_stages, stage_name)
    Builtins.y2error("Unknown progress stage \"%1\"", stage_name)
    return
  end

  @_current_stage = Ops.get(@_stages, stage_name)

  Builtins.y2milestone(
    "Moving to stage %1 (%2)",
    stage_name,
    Ops.get_integer(@_stages, [stage_name, "start"], 0)
  )
  # translators: default global progress bar label
  UpdateGlobalProgress(
    Ops.get_integer(@_stages, [stage_name, "start"], 0),
    Ops.get_locale(@_current_stage, "description", _("Installing..."))
  )

  nil
end

#OpenDialogObject

Open the slide show dialog.


868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
# File 'library/packages/src/modules/SlideShow.rb', line 868

def OpenDialog
  # call SlideShowCallbacks::InstallSlideShowCallbacks()
  WFM.call("wrapper_slideshow_callbacks", ["InstallSlideShowCallbacks"])

  # check for slides first, otherwise dialogs will be built without them
  CheckForSlides()

  OpenSlideShowBaseDialog()

  if Slides.HaveSlides
    LoadSlide(0)
  else
    SwitchToDetailsView()
  end

  nil
end

#OpenSlideShowBaseDialogObject

Open the slide show base dialog with empty work area (placeholder for the image) and CD statistics.


756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'library/packages/src/modules/SlideShow.rb', line 756

def OpenSlideShowBaseDialog
  if !Wizard.IsWizardDialog # If there is no Wizard dialog open already, open one
    Wizard.OpenNextBackDialog
    @opened_own_wizard = true
  end

  UI.WizardCommand(term(:ProtectNextButton, false))
  Wizard.RestoreBackButton
  Wizard.RestoreAbortButton
  Wizard.EnableAbortButton
  Wizard.RestoreNextButton

  Wizard.SetContents(
    # Dialog heading while software packages are being installed
    _("Package Installation"),
    Empty(), # Wait until InitPkgData() is called from outside
    HelpText(),
    false,
    false
  ) # has_back, has_next

  RebuildDialog()

  # reset abort status
  SetUserAbort(false)

  nil
end

#ProductRelNotesID(product) ⇒ Object


245
246
247
# File 'library/packages/src/modules/SlideShow.rb', line 245

def ProductRelNotesID(product)
  ("rn_" + product).to_sym
end

#RebuildDetailsViewObject

Rebuild the details page.


593
594
595
596
597
598
599
600
601
602
603
# File 'library/packages/src/modules/SlideShow.rb', line 593

def RebuildDetailsView
  if UI.WidgetExists(:tabContents)
    UI.ChangeWidget(:dumbTab, :CurrentItem, :showDetails) if UI.WidgetExists(:dumbTab)
    UI.ReplaceWidget(:tabContents, DetailsPageWidgets())
    Builtins.y2milestone("Contents set to details")
  end

  UI.ChangeWidget(:instLog, :Value, @inst_log) if UI.WidgetExists(:instLog) && @inst_log != ""

  nil
end

#RebuildDialog(show_release_notes = false) ⇒ Object

Rebuild the dialog. Useful if slides become available post-creating the dialog.

Parameters:

  • show_release_notes (Boolean) (defaults to: false)

    release notes tab will be shown.


660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
# File 'library/packages/src/modules/SlideShow.rb', line 660

def RebuildDialog(show_release_notes = false)
  log.info "Rebuilding partitioning/RPM_installation progress"
  contents = Empty()

  show_slides = Slides.HaveSlideSupport && Slides.HaveSlides
  if UI.HasSpecialWidget(:DumbTab) && (show_slides || !@_relnotes.empty?)
    tabs = [
      # tab
      Item(Id(:showDetails), _("&Details"))
    ]
    if show_slides
      # tab
      tabs.unshift(Item(Id(:showSlide), _("Slide Sho&w")))
    end

    if show_release_notes
      @_rn_tabs = {}
      add_relnotes_for_product @_base_product, @_relnotes[@_base_product], tabs if @_relnotes.key?(@_base_product)
      @_relnotes.each do |product, relnotes|
        add_relnotes_for_product product, relnotes, tabs if @_base_product != product
      end
    end

    contents = DumbTab(
      Id(:dumbTab),
      tabs,
      VBox(
        VSpacing(0.4),
        VWeight(
          1, # lower layout priority
          HBox(
            HSpacing(1),
            ReplacePoint(Id(:tabContents), SlidePageWidgets()),
            HSpacing(0.5)
          )
        ),
        VSpacing(0.4)
      )
    )
  else
    # no tabs, but we need to modify hide cd statistics table, so add replace point
    contents = ReplacePoint(Id(:tabContents), DetailsPageWidgets())
  end

  Builtins.y2milestone("SlideShow contents: %1", contents)

  Wizard.SetContents(
    if Mode.update
      # Dialog heading - software packages are being upgraded
      _("Performing Upgrade")
    else
      # Dialog heading - software packages are being installed
      _("Performing Installation")
    end,
    contents,
    HelpText(),
    false, # no back button
    false  # no next button
  )

  @widgets_created = true

  # if no tabs, update the log
  RebuildDetailsView() if ShowingDetails()

  SwitchToDetailsView() if !Slides.HaveSlides && ShowingSlide()

  nil
end

#RedrawObject

Redrawing the complete slide show if needed.


732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# File 'library/packages/src/modules/SlideShow.rb', line 732

def Redraw
  CheckForSlides()

  # do not rebuild if the user reads the release notes
  return if @user_switched_to == :release_notes

  if Slides.HaveSlides && Slides.HaveSlideSupport
    if !SlideShow.HaveSlideWidget
      # (true) : Showing release tab if needed
      RebuildDialog(true)
      SwitchToDetailsView() if @user_switched_to == :details
    end

    # Don't override explicit user request!
    SwitchToSlideView() if @user_switched_to != :details
  elsif !ShowingDetails()
    # (true) : Showing release tab if needed
    RebuildDialog(true)
  end
end

#RelNotesPageWidgets(id) ⇒ Object

Construct widgets for the "release notes" page

Returns:

  • A term describing the widgets


564
565
566
567
568
569
570
571
572
573
574
575
576
# File 'library/packages/src/modules/SlideShow.rb', line 564

def RelNotesPageWidgets(id)
  # Release notes in plain text need to be escaped to be shown properly (bsc#1028721)
  rel_notes =
    if @_rn_tabs[id] =~ /<\/.*>/
      @_rn_tabs[id]
    else
      "<pre>#{String.EscapeTags(@_rn_tabs[id])}</pre>"
    end

  widgets = AddProgressWidgets(:relNotesPage, RichText(rel_notes))
  Builtins.y2debug("widget term: \n%1", widgets)
  deep_copy(widgets)
end

#ResetObject

Initialize generic data to default values


786
787
788
789
790
791
792
793
794
795
796
797
# File 'library/packages/src/modules/SlideShow.rb', line 786

def Reset
  @current_slide_no = -1
  @slide_start_time = 0
  @total_time_elapsed = 0
  @start_time = -1
  @next_recalc_time = -1

  @textmode = Ops.get_boolean(UI.GetDisplayInfo, "TextMode", false)
  @display_width = Ops.get_integer(UI.GetDisplayInfo, "Width", 0)

  nil
end

#ResetTimerObject

Reset the internal (global) timer.


196
197
198
199
200
# File 'library/packages/src/modules/SlideShow.rb', line 196

def ResetTimer
  @start_time = Yast2::SystemTime.uptime

  nil
end

#SetGlobalProgressLabel(text) ⇒ Object

Sets the current global progress label.

Parameters:


380
381
382
383
384
# File 'library/packages/src/modules/SlideShow.rb', line 380

def SetGlobalProgressLabel(text)
  UpdateGlobalProgress(nil, text)

  nil
end

#SetLanguage(new_language) ⇒ Object

Set the curent language. Must be called once during initialization.


435
436
437
438
439
440
# File 'library/packages/src/modules/SlideShow.rb', line 435

def SetLanguage(new_language)
  @language = new_language
  Builtins.y2milestone("New SlideShow language: %1", @language)

  nil
end

#SetReleaseNotes(relnotes, base_product) ⇒ Object

set the release notes for slide show

Parameters:

  • map (map<string,string>)

    product name -> release notes text

  • base (string)

    product name


645
646
647
648
# File 'library/packages/src/modules/SlideShow.rb', line 645

def SetReleaseNotes(relnotes, base_product)
  @_relnotes = relnotes
  @_base_product = base_product
end

#SetSlideText(text) ⇒ Object

Set the slide show text.

Parameters:


427
428
429
430
431
# File 'library/packages/src/modules/SlideShow.rb', line 427

def SetSlideText(text)
  UI.ChangeWidget(:slideText, :Value, text) if UI.WidgetExists(:slideText)

  nil
end

#Setup(stages) ⇒ Object

Prepare the stages for the global progressbar. Will compute the total estimate of time and partition the global 100% to given stages based on their estimates. Can compute out of time and size to download.

The stages description list example: [ $[ "name" : "disk", "description" : "Prepare disk...", "value" : 85, // disk speed can be guessed by the storage, thus passing time "units" : sec ], $[ "name" : "images"; "description" : "Deploying images...", "value" : 204800, // amount of kb to be downloaded/installed "units" :kb ], ]


944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
# File 'library/packages/src/modules/SlideShow.rb', line 944

def Setup(stages)
  stages = deep_copy(stages)
  log.info "SlideShow stages: #{stages}"
  # initiliaze the generic counters
  Reset()

  # gather total amount of time need
  total_time = 0

  Builtins.foreach(stages) do |stage|
    total_time = if Ops.get_symbol(stage, "units", :sec) == :sec
      Ops.add(total_time, Ops.get_integer(stage, "value", 0)) # assume kilobytes
    else
      # assume 15 minutes for installation of openSUSE 11.0, giving 3495 as the constant for kb/s
      Ops.add(
        total_time,
        Ops.divide(Ops.get_integer(stage, "value", 0), 3495)
      )
    end
  end

  # avoid division by zero, set at least 1 second
  total_time = 1 if total_time == 0

  Builtins.y2milestone("Total estimated time: %1", total_time)

  start = 0 # value where the current stage starts

  @_stages = {} # prepare a new stages description

  total_size = 0
  # distribute the total time to stages as per cents
  Builtins.foreach(stages) do |stage|
    if Ops.get_symbol(stage, "units", :sec) == :sec
      Ops.set(
        stage,
        "size",
        Ops.divide(
          Ops.multiply(Ops.get_integer(stage, "value", 0), 100),
          total_time
        )
      )
      Ops.set(stage, "start", start)
    else
      # assume 15 minutes for installation of openSUSE 11.0, giving 3495 as the constant
      Ops.set(
        stage,
        "size",
        Ops.divide(
          Ops.divide(
            Ops.multiply(Ops.get_integer(stage, "value", 0), 100),
            3495
          ),
          total_time
        )
      )
      Ops.set(stage, "start", start)
      if Ops.greater_than(
        Ops.add(Ops.get_integer(stage, "size", 0), start),
        100
      )
        Ops.set(stage, "size", Ops.subtract(100, start))
      end
    end

    start = Ops.add(start, Ops.get_integer(stage, "size", 0))
    total_size += stage["size"]
    Ops.set(@_stages, Ops.get_string(stage, "name", ""), stage)
    # setup first stage
    @_current_stage = deep_copy(stage) if @_current_stage.nil?
  end

  # Because of using integers in the calculation above the sum of the sizes
  # might not be 100% due to rounding. Update the last stage so the
  # total installation progress is 100%.
  if total_size != 100
    log.info "Total global progress: #{total_size}%, adjusting to 100%..."

    # find the last stage and adjust it
    updated_stage_name = stages.last["name"]
    updated_stage = @_stages[updated_stage_name]

    new_size = 100 - total_size + updated_stage["size"]
    log.info "Updating '#{updated_stage_name}' stage size from " \
      "#{updated_stage["size"]}% to #{new_size}%"

    updated_stage["size"] = new_size
    @_stages[updated_stage_name] = updated_stage
  end

  Builtins.y2milestone("Global progress bar: %1", @_stages)

  nil
end

#SetUserAbort(abort) ⇒ Object

Set the flag that user requested abort of the installation

Parameters:

  • abort (Boolean)

    new state of the abort requested flag (true = abort requested)


174
175
176
177
178
# File 'library/packages/src/modules/SlideShow.rb', line 174

def SetUserAbort(abort)
  @user_abort = abort

  nil
end

#ShowingDetailsObject

Check if currently the "Details" page is shown

Returns:

  • true if showing details, false otherwise


227
228
229
# File 'library/packages/src/modules/SlideShow.rb', line 227

def ShowingDetails
  @widgets_created && UI.WidgetExists(:detailsPage)
end

#ShowingRelNotes(id) ⇒ Object

Check if currently the "Release Notes" page is shown

Returns:

  • true if showing details, false otherwise


241
242
243
# File 'library/packages/src/modules/SlideShow.rb', line 241

def ShowingRelNotes(id)
  @widgets_created && UI.WidgetExists(id)
end

#ShowingSlideObject

Check if currently the "Slide Show" page is shown

Returns:

  • true if showing details, false otherwise


234
235
236
# File 'library/packages/src/modules/SlideShow.rb', line 234

def ShowingSlide
  @widgets_created && UI.WidgetExists(:slideShowPage)
end

#ShowTableObject


897
898
899
900
901
902
903
904
905
# File 'library/packages/src/modules/SlideShow.rb', line 897

def ShowTable
  if ShowingDetails() && !@_show_table
    @_show_table = true
    RebuildDetailsView()
  end
  @_show_table = true

  nil
end

#SlidePageWidgetsObject

Construct widgets describing a page with the real slide show (the RichText / HTML page)

Returns:

  • A term describing the widgets


510
511
512
513
514
# File 'library/packages/src/modules/SlideShow.rb', line 510

def SlidePageWidgets
  widgets = AddProgressWidgets(:slideShowPage, RichText(Id(:slideText), ""))
  Builtins.y2debug("widget term: \n%1", widgets)
  deep_copy(widgets)
end

#StageProgress(value, text) ⇒ Object

Update the global progress according to the progress in the current stage. The new value will be set to the per cent of the current stage according to \param value.The value must be lower that 100 (or it's corrected to 100). If the \text is not nil, the label will be updated to this text as well. Otherwise label will not change.

Parameters:

  • value (Fixnum)

    new value for the stage progress in per cents

  • text (String)

    new label for the global progress


357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'library/packages/src/modules/SlideShow.rb', line 357

def StageProgress(value, text)
  if Ops.greater_than(value, 100)
    Builtins.y2error("Stage progress value larger than expected: %1", value)
    value = 100
  end

  UpdateGlobalProgress(
    Ops.add(
      Ops.get_integer(@_current_stage, "start", 0),
      Ops.divide(
        Ops.multiply(value, Ops.get_integer(@_current_stage, "size", 1)),
        100
      )
    ),
    text
  )

  nil
end

#StartTimerObject

Start the internal (global) timer.


188
189
190
191
192
# File 'library/packages/src/modules/SlideShow.rb', line 188

def StartTimer
  @start_time = Yast2::SystemTime.uptime

  nil
end

#StopTimerObject

Stop the internal (global) timer and account elapsed time.


204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'library/packages/src/modules/SlideShow.rb', line 204

def StopTimer
  if Ops.less_than(@start_time, 0)
    Builtins.y2error("StopTimer(): No timer running.")
    return
  end

  elapsed = Ops.subtract(Yast2::SystemTime.uptime, @start_time)
  @start_time = -1
  @total_time_elapsed = Ops.add(@total_time_elapsed, elapsed)
  Builtins.y2debug(
    "StopTimer(): Elapsed this time: %1 sec; total: %2 sec (%3:%4)",
    elapsed,
    @total_time_elapsed,
    Ops.divide(@total_time_elapsed, 60),
    Ops.modulo(@total_time_elapsed, 60) # min
  ) # sec

  nil
end

#SubProgress(value, label) ⇒ Object

Updates status of the sub-progress in slide show. The new value and label will be set to values given as parametes. If a given parameter contains nil, respective value/label will not be updated.

Parameters:

  • value (Fixnum)

    new value for the subprogress

  • label (String)

    new label for the subprogress


262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'library/packages/src/modules/SlideShow.rb', line 262

def SubProgress(value, label)
  value ||= @sub_progress_value
  label ||= @sub_progress_label

  if UI.WidgetExists(UI_ID::CURRENT_PACKAGE)
    if @sub_progress_value != value
      @sub_progress_value = value
      UI.ChangeWidget(UI_ID::CURRENT_PACKAGE, :Value, value)
    end

    if @sub_progress_label != label
      @sub_progress_label = label
      UI.ChangeWidget(UI_ID::CURRENT_PACKAGE, :Label, label)
    end
  end

  nil
end

#SubProgressStart(text) ⇒ Object

Restart the subprogress of the slideshow. This means the label will be set to given text, value to 0.

Parameters:

  • text (String)

    new label for the subprogress


252
253
254
# File 'library/packages/src/modules/SlideShow.rb', line 252

def SubProgressStart(text)
  SubProgress(0, text)
end

#SwitchToDetailsViewObject

Switch from the 'slide show' view to the 'details' view.


607
608
609
610
611
612
613
614
615
# File 'library/packages/src/modules/SlideShow.rb', line 607

def SwitchToDetailsView
  if ShowingDetails()
    Builtins.y2milestone("Already showing details")
    return
  end
  RebuildDetailsView()

  nil
end

#SwitchToReleaseNotesView(id) ⇒ Object

Switch to the 'release notes' view.


619
620
621
622
623
624
625
626
627
628
629
# File 'library/packages/src/modules/SlideShow.rb', line 619

def SwitchToReleaseNotesView(id)
  return if ShowingRelNotes(id)

  if UI.WidgetExists(:tabContents)
    UI.ChangeWidget(:dumbTab, :CurrentItem, id)
    UI.ReplaceWidget(:tabContents, RelNotesPageWidgets(id))
    # UpdateTotalProgress(false);
  end

  nil
end

#SwitchToSlideViewObject

Switch from the 'details' view to the 'slide show' view.


580
581
582
583
584
585
586
587
588
589
590
# File 'library/packages/src/modules/SlideShow.rb', line 580

def SwitchToSlideView
  return if ShowingSlide()

  if UI.WidgetExists(:tabContents)
    UI.ChangeWidget(:dumbTab, :CurrentItem, :showSlide)
    UI.ReplaceWidget(:tabContents, SlidePageWidgets())
    # UpdateTotalProgress(false);    // FIXME: this breaks other stages!
  end

  nil
end

#TableItem(id, col1, col2, col3, col4) ⇒ Object

Create one single item for the CD statistics table


444
445
446
# File 'library/packages/src/modules/SlideShow.rb', line 444

def TableItem(id, col1, col2, col3, col4)
  Item(Id(id), col1, col2, col3, col4)
end

#UpdateGlobalProgress(value, label) ⇒ Object

Updates status of the global progress in slide show. The new value and label will be set to values given as parametes. If a given parameter contains nil, respective value/label will not be updated.

Parameters:

  • value (Fixnum)

    new value for the global progress

  • label (String)

    new label for the global progress


295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'library/packages/src/modules/SlideShow.rb', line 295

def UpdateGlobalProgress(value, label)
  value ||= @total_progress_value
  label ||= @total_progress_label

  if UI.WidgetExists(UI_ID::TOTAL_PROGRESS)
    if @total_progress_value != value
      @total_progress_value = value
      UI.ChangeWidget(UI_ID::TOTAL_PROGRESS, :Value, value)
    end

    if @total_progress_label != label
      @total_progress_label = label
      UI.ChangeWidget(UI_ID::TOTAL_PROGRESS, :Label, label)
    end
  else
    log.warn "progressTotal widget missing"
  end

  # update slide
  ChangeSlideIfNecessary() if ShowingSlide()

  nil
end

#UpdateTable(items) ⇒ Object


917
918
919
920
921
922
923
# File 'library/packages/src/modules/SlideShow.rb', line 917

def UpdateTable(items)
  items = deep_copy(items)
  @table_items = deep_copy(items)
  UI.ChangeWidget(Id(:cdStatisticsTable), :Items, items) if ShowingDetails() && @_show_table

  nil
end