ACC SHELL
/**
* File: clients/do_not_show_again_editor.ycp
* Authors: Lukas Ocilka <locilka@suse.cz>
* Summary: Editor for "Do Not Show This Dialog Again" store
*
* $Id: DontShowAgain.ycp 11111 2006-05-30 12:27:15Z locilka $
*/
{
import "DontShowAgain";
import "Wizard";
import "Label";
import "Confirm";
textdomain "packager";
map <integer, map <string, string> > table_index = $[];
void InitTable () {
table_index = $[];
map <string, map <string, map <string, any> > > current_configuration =
DontShowAgain::GetCurrentConfigurationMap();
list <term> table_items = [];
integer index_counter = 0;
foreach (string dont_show_type, map <string, map <string, any> > records, current_configuration, {
// DontShowAgain cannot handle other types, there's no functionality for that
if (dont_show_type != "inst-source")
continue;
foreach (string popup_type, map <string, any> one_record, records, {
foreach (string url, any record_options, one_record, {
// nil records are skipped
if (record_options == nil)
continue;
index_counter = index_counter + 1;
table_items = add(table_items,
`item(`id(index_counter),
dont_show_type,
popup_type,
url
)
);
map <string, string> table_index_item = $[];
table_index_item["q_type"] = dont_show_type;
table_index_item["q_ident"] = popup_type;
table_index_item["q_url"] = url;
table_index[index_counter] = table_index_item;
});
});
});
UI::ChangeWidget(`id(`table), `Items, table_items);
}
void SetDialogContents () {
// dialog caption
string caption = _("Editor for 'Do Not Show Again'");
// help text
string helptext = _("<p>You can remove entries by selecting them
in the table and clicking the <b>Delete</b> button.
The entry will be removed immediately from the current configuration.</p>");
term 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();
}
void DeleteItem () {
integer delete_item = (integer) UI::QueryWidget(`id(`table), `CurrentItem);
if (Confirm::DeleteSelected()) {
map <string, string> delete_params = table_index[delete_item]:nil;
DontShowAgain::RemoveShowQuestionAgain(delete_params);
InitTable();
}
}
any HandleDialog () {
any ret = nil;
while (true) {
ret = UI::UserInput();
if (ret == `abort || ret == `cancel || ret == `accept || ret == `next) {
break;
} else if (ret == `delete) {
DeleteItem();
continue;
} else {
y2error("Undefined return %1", ret);
continue;
}
}
return ret;
}
/* ----------------------------------- */
Wizard::CreateDialog();
SetDialogContents();
any ret = HandleDialog();
UI::CloseDialog();
/* ----------------------------------- */
return ret;
}
ACC SHELL 2018