Class: Yast::SlideShowClass

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

Instance Method Summary collapse

Instance Method Details

#add_relnotes_for_product(product, relnotes, tabs) ⇒ Object



515
516
517
518
519
520
# File 'library/packages/src/modules/SlideShow.rb', line 515

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

#AppendMessageToInstLog(_msg) ⇒ Object

Append message to the installation log.

Parameters:

  • msg (String)

    message to be added, without trailing eoln



324
325
326
# File 'library/packages/src/modules/SlideShow.rb', line 324

def AppendMessageToInstLog(_msg)
  nil
end

#ChangeSlideIfNecessaryObject

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

FIXME: Obsolete



378
379
380
# File 'library/packages/src/modules/SlideShow.rb', line 378

def ChangeSlideIfNecessary
  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.

FIXME: Obsolete



338
339
340
# File 'library/packages/src/modules/SlideShow.rb', line 338

def CheckForSlides
  nil
end

#CloseDialogObject

Close the slide show dialog.



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

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



257
258
259
# File 'library/packages/src/modules/SlideShow.rb', line 257

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

#DetailsPageWidgetsObject

Construct widgets for the "details" page

Returns:

  • A term describing the widgets



448
# File 'library/packages/src/modules/SlideShow.rb', line 448

def DetailsPageWidgets; end

#DetailsTableWidgetObject



442
# File 'library/packages/src/modules/SlideShow.rb', line 442

def DetailsTableWidget; end

#GenericHandleInputObject

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



605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# File 'library/packages/src/modules/SlideShow.rb', line 605

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()


791
792
793
# File 'library/packages/src/modules/SlideShow.rb', line 791

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)



150
151
152
# File 'library/packages/src/modules/SlideShow.rb', line 150

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.

FIXME: Obsolete published method

Parameters:

  • text (String)

    new label for the global progress



224
225
226
# File 'library/packages/src/modules/SlideShow.rb', line 224

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

#HandleInput(button) ⇒ Object

Process (slide show) input (button press).



595
596
597
598
599
600
# File 'library/packages/src/modules/SlideShow.rb', line 595

def HandleInput(button)
  SwitchToReleaseNotesView(button) if @_rn_tabs.key?(button) && !ShowingRelNotes(button)
  # 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.



330
331
332
# File 'library/packages/src/modules/SlideShow.rb', line 330

def HaveSlideWidget
  UI.WidgetExists(:dumbTab)
end

#HelpTextObject

Help text for the dialog



499
500
501
502
503
504
505
# File 'library/packages/src/modules/SlideShow.rb', line 499

def HelpText
  # Help text while software packages are being installed (displayed only in rare cases)
  _("<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>"
    )
end

#HideTableObject



661
662
663
# File 'library/packages/src/modules/SlideShow.rb', line 661

def HideTable
  nil
end

#LoadSlide(_slide_no) ⇒ Object

Load a slide image + text. FIXME: Obsolete

Parameters:

  • slide_no (Fixnum)

    number of slide to load



370
371
372
# File 'library/packages/src/modules/SlideShow.rb', line 370

def LoadSlide(_slide_no)
  nil
end

#mainObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'library/packages/src/modules/SlideShow.rb', line 108

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"

  @language = "en"
  @widgets_created = false
  @opened_own_wizard = false
  @user_abort = false

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

  @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



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

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.



637
638
639
640
641
642
643
644
# File 'library/packages/src/modules/SlideShow.rb', line 637

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

  OpenSlideShowBaseDialog()

  nil
end

#OpenSlideShowBaseDialogObject

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



559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'library/packages/src/modules/SlideShow.rb', line 559

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(true)

  # reset abort status
  SetUserAbort(false)

  nil
end

#product_nameString?

Name of the base product that is or will be installed

Returns:

  • (String, nil)

    Display name of the base product



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'library/packages/src/modules/SlideShow.rb', line 418

def product_name
  # Avoid expensive operation in the installed system where this will
  # always return 'nil' anyway.
  return nil if Mode.normal

  # lazy load product spec as it lives in packager and maybe is not available
  require "y2packager/product_spec"
  product = Y2Packager::ProductSpec.selected_base
  return nil if product.nil?

  product.display_name
rescue LoadError
  log.info "product spec not available. Probably yast2-packager is missing"

  nil
end

#product_name_widgetsObject

Widgets for the product name

Returns:

  • A term describing the widgets



404
405
406
407
408
409
410
411
412
413
414
# File 'library/packages/src/modules/SlideShow.rb', line 404

def product_name_widgets
  text = product_name
  return Empty() if text.nil? || text.empty?

  MarginBox(
    0, 1, # hor/vert
    Left(
      Label(Id(:productName), text)
    )
  )
end

#ProductRelNotesID(product) ⇒ Object



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

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

#progress_widgetsObject

Widgets for the progress bar tab

Returns:

  • A term describing the widgets



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'library/packages/src/modules/SlideShow.rb', line 385

def progress_widgets
  MarginBox(
    4, 1, # hor/vert
    VBox(
      product_name_widgets,
      VCenter(
        ProgressBar(
          Id(:progressTotal),
          @total_progress_label,
          100,
          @total_progress_value
        )
      )
    )
  )
end

#RebuildDetailsViewObject

Rebuild the details page. FIXME: Obsolete



473
474
475
# File 'library/packages/src/modules/SlideShow.rb', line 473

def RebuildDetailsView
  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)

    release notes tab will be shown.



525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'library/packages/src/modules/SlideShow.rb', line 525

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

  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

  nil
end

#RedrawObject

Redrawing the complete slide show if needed.



552
553
554
# File 'library/packages/src/modules/SlideShow.rb', line 552

def Redraw
  nil
end

#RelNotesPageWidgets(id) ⇒ Object

Construct widgets for the "release notes" page

Returns:

  • A term describing the widgets



454
# File 'library/packages/src/modules/SlideShow.rb', line 454

def RelNotesPageWidgets(id); end

#ResetObject

Initialize generic data to default values



589
590
591
# File 'library/packages/src/modules/SlideShow.rb', line 589

def Reset
  nil
end

#ResetTimerObject

Reset the internal (global) timer.

FIXME: Obsolete published method



164
165
166
# File 'library/packages/src/modules/SlideShow.rb', line 164

def ResetTimer
  nil
end

#SetGlobalProgressLabel(text) ⇒ Object

Sets the current global progress label.

Parameters:



316
317
318
319
320
# File 'library/packages/src/modules/SlideShow.rb', line 316

def SetGlobalProgressLabel(text)
  UpdateGlobalProgress(nil, text)

  nil
end

#SetLanguage(new_language) ⇒ Object

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



352
353
354
355
356
357
# File 'library/packages/src/modules/SlideShow.rb', line 352

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



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

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

#SetSlideText(_text) ⇒ Object

Set the slide show text. FIXME: Obsolete

Parameters:



346
347
348
# File 'library/packages/src/modules/SlideShow.rb', line 346

def SetSlideText(_text)
  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 ], ]



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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
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
# File 'library/packages/src/modules/SlideShow.rb', line 688

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)



142
143
144
145
146
# File 'library/packages/src/modules/SlideShow.rb', line 142

def SetUserAbort(abort)
  @user_abort = abort

  nil
end

#ShowingDetailsObject

Check if currently the "Details" page is shown

Returns:

  • true if showing details, false otherwise



178
179
180
# File 'library/packages/src/modules/SlideShow.rb', line 178

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



193
194
195
# File 'library/packages/src/modules/SlideShow.rb', line 193

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

#ShowingSlideObject

Check if currently the "Slide Show" page is shown FIXME: Obsolete published method

Returns:

  • true if showing details, false otherwise



186
187
188
# File 'library/packages/src/modules/SlideShow.rb', line 186

def ShowingSlide
  false
end

#ShowTableObject



657
658
659
# File 'library/packages/src/modules/SlideShow.rb', line 657

def ShowTable
  nil
end

#SlidePageWidgetsObject

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

Returns:

  • A term describing the widgets



440
# File 'library/packages/src/modules/SlideShow.rb', line 440

def SlidePageWidgets; 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



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'library/packages/src/modules/SlideShow.rb', line 293

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.

FIXME: Obsolete published method



157
158
159
# File 'library/packages/src/modules/SlideShow.rb', line 157

def StartTimer
  nil
end

#StopTimerObject

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

FIXME: Obsolete published method



171
172
173
# File 'library/packages/src/modules/SlideShow.rb', line 171

def StopTimer
  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.

FIXME: Obsolete published method

Parameters:

  • value (Fixnum)

    new value for the subprogress

  • label (String)

    new label for the subprogress



216
# File 'library/packages/src/modules/SlideShow.rb', line 216

def SubProgress(value, label); end

#SubProgressStart(text) ⇒ Object

Restart the subprogress of the slideshow. This means the label will be set to given text, value to 0. FIXME: Obsolete published method

Parameters:

  • text (String)

    new label for the subprogress



206
# File 'library/packages/src/modules/SlideShow.rb', line 206

def SubProgressStart(text); end

#SwitchToDetailsViewObject

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

FIXME: Obsolete



480
481
482
# File 'library/packages/src/modules/SlideShow.rb', line 480

def SwitchToDetailsView
  nil
end

#SwitchToReleaseNotesView(id) ⇒ Object

Switch to the 'release notes' view.



486
487
488
489
490
491
492
493
494
495
496
# File 'library/packages/src/modules/SlideShow.rb', line 486

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.

FIXME: Obsolete



459
460
461
462
463
464
465
466
467
468
469
# File 'library/packages/src/modules/SlideShow.rb', line 459

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

FIXME: Obsolete published method



362
363
364
# File 'library/packages/src/modules/SlideShow.rb', line 362

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



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'library/packages/src/modules/SlideShow.rb', line 234

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

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

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

  nil
end

#UpdateTable(_items) ⇒ Object



665
666
667
# File 'library/packages/src/modules/SlideShow.rb', line 665

def UpdateTable(_items)
  nil
end