Class: Yast::ViewAnymsgClient

Inherits:
Client
  • Object
show all
Defined in:
library/system/src/lib/yast2/clients/view_anymsg.rb

Overview

Reads a \n separated list of filenames from /var/lib/YaST2/filenames Lines starting with "#" are ignored (comments) A line starting with "" is taken as the default filename, the "" is stripped

All files are listed in an editable combo box, where the user can easily switch between files and even add a new file

At finish, the list of filenames is written back to /var/lib/YaST2/filenames adapting the default line (starting with "*") accordingly.

The default is either given as WFM::Args(0) or is the file last viewed.

Constant Summary collapse

DEFAULT_FILENAMES =

[String] Default list of log files

[
  "/var/log/boot.log",
  "/var/log/messages",
  "/var/log/YaST2/y2log"
].freeze

Instance Method Summary collapse

Instance Method Details

#mainObject


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'library/system/src/lib/yast2/clients/view_anymsg.rb', line 60

def main
  textdomain "base"

  # the command line description map
  return CommandLine.Run("id" => "view_anymsg") if WFM.Args.first == "help"

  # set up dialogue
  UI.OpenDialog(
    Opt(:decorated, :defaultsize),
    dialog_content
  )

  # wait until user clicks "OK"
  # check if ComboBox selected and change view accordingly
  res = nil

  loop do
    # Fill the LogView with file content
    UI.ChangeWidget(Id(:log), :Value, file_content(selected_filename))

    heading = Builtins.sformat(_("System Log (%1)"), selected_filename)
    UI.ChangeWidget(Id(:log), :Label, heading)

    if start_journal?
      res = :journal
      break
    end

    # wait for user input
    res = UI.UserInput

    case res
    when :ok, :cancel then break
    when :custom_file      # adapt to combo box settings

      new_file = UI.QueryWidget(Id(:custom_file), :Value)
      self.selected_filename = new_file if !new_file.nil?
    else
      Builtins.y2milestone("bad UserInput (%1)", res)
    end
  end

  write_new_filenames if res == :ok
  UI.CloseDialog

  Yast::WFM.CallFunction("journal") if res == :journal

  true
end