Class: Yast::DoNotShowAgainEditorClient

Inherits:
Client
  • Object
show all
Defined in:
src/clients/do_not_show_again_editor.rb

Overview

Editor for “Do Not Show This Dialog Again” store

Instance Method Summary collapse

Instance Method Details

#DeleteItemObject


100
101
102
103
104
105
106
107
108
109
# File 'src/clients/do_not_show_again_editor.rb', line 100

def DeleteItem
  delete_item = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem))
  if Confirm.DeleteSelected
    delete_params = Ops.get(@table_index, delete_item)
    DontShowAgain.RemoveShowQuestionAgain(delete_params)
    InitTable()
  end

  nil
end

#HandleDialogObject


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'src/clients/do_not_show_again_editor.rb', line 111

def HandleDialog
  ret = nil

  loop do
    ret = UI.UserInput

    break if ret == :abort || ret == :cancel || ret == :accept || ret == :next

    if ret == :delete
      DeleteItem()
    else
      Builtins.y2error("Undefined return %1", ret)
    end
  end

  deep_copy(ret)
end

#InitTableObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'src/clients/do_not_show_again_editor.rb', line 26

def InitTable
  @table_index = {}

  current_configuration = DontShowAgain.GetCurrentConfigurationMap

  table_items = []
  index_counter = 0

  Builtins.foreach(current_configuration) do |dont_show_type, records|
    # DontShowAgain cannot handle other types, there's no functionality for that
    next if dont_show_type != "inst-source"
    Builtins.foreach(records) do |popup_type, one_record|
      Builtins.foreach(one_record) do |url, record_options|
        # nil records are skipped
        next if record_options.nil?
        index_counter = Ops.add(index_counter, 1)
        table_items = Builtins.add(
          table_items,
          Item(Id(index_counter), dont_show_type, popup_type, url)
        )
        table_index_item = {}
        Ops.set(table_index_item, "q_type", dont_show_type)
        Ops.set(table_index_item, "q_ident", popup_type)
        Ops.set(table_index_item, "q_url", url)
        Ops.set(@table_index, index_counter, table_index_item)
      end
    end
  end

  UI.ChangeWidget(Id(:table), :Items, table_items)

  nil
end

#mainObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'src/clients/do_not_show_again_editor.rb', line 5

def main
  Yast.import "UI"
  Yast.import "DontShowAgain"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Confirm"

  textdomain "packager"

  @table_index = {}

  # -----------------------------------
  Wizard.CreateDialog
  SetDialogContents()
  @ret = HandleDialog()
  UI.CloseDialog
  # -----------------------------------

  deep_copy(@ret)
end

#SetDialogContentsObject


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
# File 'src/clients/do_not_show_again_editor.rb', line 60

def SetDialogContents
  # dialog caption
  caption = _("Editor for 'Do Not Show Again'")

  # help text
  helptext = _(
    "<p>Remove entries by selecting them in the table and clicking the \n" \
      "<b>Delete</b> button. The entries will be removed immediately from \n" \
      "the current configuration.</p>\n"
  )

  contents = VBox(
    Table(
      Id(:table),
      Header(_("Type"), _("Popup Ident."), _("Additional Info")),
      []
    ),
    HBox(
      # FIXME: Add filter
      # `PushButton(`id(`filter), _("&Filter...")),
      # `HSpacing(2),
      PushButton(Id(:delete), _("&Delete"))
    )
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    helptext,
    Label.BackButton,
    Label.CloseButton
  )
  Wizard.DisableBackButton
  Wizard.DisableAbortButton

  InitTable()

  nil
end