2020-01-21 00:32:44 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-21 00:32:44 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ProcessUnveiledPathsWidget.h"
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
#include <LibGUI/JsonArrayModel.h>
|
2020-09-22 01:40:57 +03:00
|
|
|
#include <LibGUI/SortingProxyModel.h>
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/TableView.h>
|
2020-01-21 00:32:44 +03:00
|
|
|
|
2020-02-23 14:07:13 +03:00
|
|
|
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget()
|
2020-01-21 00:32:44 +03:00
|
|
|
{
|
2020-03-04 11:43:54 +03:00
|
|
|
set_layout<GUI::VerticalBoxLayout>();
|
Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:
- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
the top margin, the second argument to the left and right margins,
and the third argument to the bottom margin.
2021-08-17 03:11:38 +03:00
|
|
|
layout()->set_margins(4);
|
2020-02-23 14:07:13 +03:00
|
|
|
m_table_view = add<GUI::TableView>();
|
2020-01-21 00:32:44 +03:00
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
|
2020-02-06 13:56:38 +03:00
|
|
|
pid_unveil_fields.empend("path", "Path", Gfx::TextAlignment::CenterLeft);
|
|
|
|
pid_unveil_fields.empend("permissions", "Permissions", Gfx::TextAlignment::CenterLeft);
|
2020-09-22 01:40:57 +03:00
|
|
|
|
|
|
|
m_model = GUI::JsonArrayModel::create({}, move(pid_unveil_fields));
|
2021-12-24 15:12:04 +03:00
|
|
|
m_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_model)));
|
2020-01-21 00:32:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessUnveiledPathsWidget::~ProcessUnveiledPathsWidget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessUnveiledPathsWidget::set_pid(pid_t pid)
|
|
|
|
{
|
|
|
|
if (m_pid == pid)
|
|
|
|
return;
|
|
|
|
m_pid = pid;
|
2020-10-06 19:04:36 +03:00
|
|
|
m_model->set_json_path(String::formatted("/proc/{}/unveil", m_pid));
|
2020-01-21 00:32:44 +03:00
|
|
|
}
|