mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
ProcessManager: Add a process-specific tab view below the process table.
To start out, add a "Stacks" view where we see what the selected process is currently doing (via /proc/PID/stack) :^)
This commit is contained in:
parent
c452528952
commit
9b7e1eb287
4 changed files with 73 additions and 1 deletions
|
@ -5,6 +5,7 @@ OBJS = \
|
||||||
ProcessTableView.o \
|
ProcessTableView.o \
|
||||||
MemoryStatsWidget.o \
|
MemoryStatsWidget.o \
|
||||||
GraphWidget.o \
|
GraphWidget.o \
|
||||||
|
ProcessStacksWidget.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
APP = ProcessManager
|
APP = ProcessManager
|
||||||
|
|
38
Applications/ProcessManager/ProcessStacksWidget.cpp
Normal file
38
Applications/ProcessManager/ProcessStacksWidget.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#include "ProcessStacksWidget.h"
|
||||||
|
#include <LibCore/CFile.h>
|
||||||
|
#include <LibCore/CTimer.h>
|
||||||
|
#include <LibGUI/GBoxLayout.h>
|
||||||
|
|
||||||
|
ProcessStacksWidget::ProcessStacksWidget(GWidget* parent)
|
||||||
|
: GWidget(parent)
|
||||||
|
{
|
||||||
|
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||||
|
layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
m_stacks_editor = new GTextEditor(GTextEditor::Type::MultiLine, this);
|
||||||
|
m_stacks_editor->set_readonly(true);
|
||||||
|
|
||||||
|
m_timer = new CTimer(1000, [this] { refresh(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessStacksWidget::~ProcessStacksWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessStacksWidget::set_pid(pid_t pid)
|
||||||
|
{
|
||||||
|
if (m_pid == pid)
|
||||||
|
return;
|
||||||
|
m_pid = pid;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessStacksWidget::refresh()
|
||||||
|
{
|
||||||
|
CFile file(String::format("/proc/%d/stack", m_pid));
|
||||||
|
if (!file.open(CIODevice::ReadOnly)) {
|
||||||
|
m_stacks_editor->set_text(String::format("Unable to open %s", file.filename().characters()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_stacks_editor->set_text(file.read_all());
|
||||||
|
}
|
21
Applications/ProcessManager/ProcessStacksWidget.h
Normal file
21
Applications/ProcessManager/ProcessStacksWidget.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/GTextEditor.h>
|
||||||
|
#include <LibGUI/GWidget.h>
|
||||||
|
|
||||||
|
class CTimer;
|
||||||
|
|
||||||
|
class ProcessStacksWidget final : public GWidget {
|
||||||
|
C_OBJECT(ProcessStacksWidget)
|
||||||
|
public:
|
||||||
|
explicit ProcessStacksWidget(GWidget* parent);
|
||||||
|
virtual ~ProcessStacksWidget() override;
|
||||||
|
|
||||||
|
void set_pid(pid_t);
|
||||||
|
void refresh();
|
||||||
|
|
||||||
|
private:
|
||||||
|
pid_t m_pid { -1 };
|
||||||
|
GTextEditor* m_stacks_editor { nullptr };
|
||||||
|
CTimer* m_timer { nullptr };
|
||||||
|
};
|
|
@ -1,5 +1,6 @@
|
||||||
#include "GraphWidget.h"
|
#include "GraphWidget.h"
|
||||||
#include "MemoryStatsWidget.h"
|
#include "MemoryStatsWidget.h"
|
||||||
|
#include "ProcessStacksWidget.h"
|
||||||
#include "ProcessTableView.h"
|
#include "ProcessTableView.h"
|
||||||
#include <LibCore/CTimer.h>
|
#include <LibCore/CTimer.h>
|
||||||
#include <LibGUI/GAction.h>
|
#include <LibGUI/GAction.h>
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
#include <LibGUI/GGroupBox.h>
|
#include <LibGUI/GGroupBox.h>
|
||||||
#include <LibGUI/GLabel.h>
|
#include <LibGUI/GLabel.h>
|
||||||
#include <LibGUI/GMenuBar.h>
|
#include <LibGUI/GMenuBar.h>
|
||||||
|
#include <LibGUI/GSplitter.h>
|
||||||
#include <LibGUI/GTabWidget.h>
|
#include <LibGUI/GTabWidget.h>
|
||||||
#include <LibGUI/GToolBar.h>
|
#include <LibGUI/GToolBar.h>
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
|
@ -26,7 +28,9 @@ int main(int argc, char** argv)
|
||||||
keeper->set_background_color(Color::WarmGray);
|
keeper->set_background_color(Color::WarmGray);
|
||||||
keeper->layout()->set_margins({ 4, 4, 4, 4 });
|
keeper->layout()->set_margins({ 4, 4, 4, 4 });
|
||||||
|
|
||||||
auto* tabwidget = new GTabWidget(keeper);
|
auto* splitter = new GSplitter(Orientation::Vertical, keeper);
|
||||||
|
|
||||||
|
auto* tabwidget = new GTabWidget(splitter);
|
||||||
|
|
||||||
auto* process_table_container = new GWidget(nullptr);
|
auto* process_table_container = new GWidget(nullptr);
|
||||||
tabwidget->add_widget("Processes", process_table_container);
|
tabwidget->add_widget("Processes", process_table_container);
|
||||||
|
@ -149,6 +153,14 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
|
auto* process_tab_widget = new GTabWidget(splitter);
|
||||||
|
auto* stacks_widget = new ProcessStacksWidget(nullptr);
|
||||||
|
process_tab_widget->add_widget("Stacks", stacks_widget);
|
||||||
|
|
||||||
|
process_table_view->on_process_selected = [&](pid_t pid) {
|
||||||
|
stacks_widget->set_pid(pid);
|
||||||
|
};
|
||||||
|
|
||||||
auto* window = new GWindow;
|
auto* window = new GWindow;
|
||||||
window->set_title("Process Manager");
|
window->set_title("Process Manager");
|
||||||
window->set_rect(20, 200, 680, 400);
|
window->set_rect(20, 200, 680, 400);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue