Skip to content

Commit

Permalink
Merge pull request #24 from MoAlyousef/main
Browse files Browse the repository at this point in the history
0.1.12
  • Loading branch information
MoAlyousef committed May 25, 2022
2 parents efa6198 + d3e699f commit 756020f
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sysinfo-gui"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
repository = "https://github.com/MoAlyousef/sysinfo-gui"
keywords = ["cross-platform", "monitoring", "gui"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ If you would like to use the bundled version of fltk-rs (for supported platforms
`cargo build --features=fltk/fltk-bundled --release`

## TODO
- The codebase needs some refactoring.
- Support more things in the right click popup menu in the processes view.
- Map uid to User and display a user name in the processes view.
- Add downloand and upload speed.
- Use better colors for the cpus.
- Add more setting tweaks.
9 changes: 8 additions & 1 deletion src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ impl App {
app::set_frame_type2(FrameType::UpBox, FrameType::FlatBox);
let (r, g, b) = SEL_BLUE.to_rgb();
app::set_selection_color(r, g, b);
misc::Tooltip::set_color(Color::from_rgb(0xFF, 0xFF, 0xF0));
app::set_font_size(18);
misc::Tooltip::set_color(Color::from_rgb(0xFF, 0xFF, 0xF0));
misc::Tooltip::set_font_size(app::font_size() - 4);
let temp = std::env::temp_dir().join("Roboto-Medium.ttf");
if !temp.exists() {
let bytes = include_bytes!("../../assets/Roboto-Medium.ttf");
Expand Down Expand Up @@ -82,6 +83,9 @@ impl App {
SvgButton::new(WRENCH)
.with_tooltip("Settings")
.emit(s, Message::Settings);
SvgButton::new(ABOUT)
.with_tooltip("About")
.emit(s, Message::Info);
col.end();
grp.end();
let mut grp = group::Group::new(60, 0, 800 - 50, 50, "\tSysinfo")
Expand All @@ -95,6 +99,7 @@ impl App {
scroll.set_color(win.color());
scroll.set_scrollbar_size(-1);
let mut scrollbar = scroll.scrollbar();
// To work around Card resizing on macos
scrollbar.set_callback({
let mut old_cb = scrollbar.callback();
move |s| {
Expand All @@ -106,6 +111,8 @@ impl App {
});
scroll.end();
win.end();
win.resizable(&scroll);
win.size_range(800, 600, 0, 0);
win.show();
win.set_callback(|w| {
if app::event() == Event::Close {
Expand Down
1 change: 1 addition & 0 deletions src/gui/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pub enum Message {
Procs,
Net,
Settings,
Info,
}
5 changes: 5 additions & 0 deletions src/gui/styles/svgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ pub const ASC: &str = r#"<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="ht
<path d="M74.244,262.736H10c-5.523,0-10,4.477-10,10v10c0,5.523,4.477,10,10,10h64.244c5.522,0,10-4.477,10-10v-10 C84.244,267.213,79.767,262.736,74.244,262.736z"/>
<path d="M298.29,216.877l-7.071-7.071c-1.875-1.875-4.419-2.929-7.071-2.929c-2.652,0-5.196,1.054-7.072,2.929l-34.393,34.393 V18.736c0-5.523-4.477-10-10-10h-10c-5.523,0-10,4.477-10,10v225.462l-34.393-34.393c-1.876-1.875-4.419-2.929-7.071-2.929 c-2.652,0-5.196,1.054-7.071,2.929l-7.072,7.071c-3.904,3.905-3.904,10.237,0,14.142l63.536,63.536 c1.953,1.953,4.512,2.929,7.071,2.929c2.559,0,5.119-0.976,7.071-2.929l63.536-63.536 C302.195,227.113,302.195,220.781,298.29,216.877z"/>
</g></svg>"#;

pub const ABOUT: &str = r#"<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="white" class="bi bi-info-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>
</svg>"#;
3 changes: 3 additions & 0 deletions src/gui/widgets/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ impl Card {
grp.end();
Self { grp }
}
pub fn default_fill() -> Card {
Card::default().size_of_parent().center_of_parent()
}
}

fltk::widget_extends!(Card, group::Group, grp);
26 changes: 26 additions & 0 deletions src/view/info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::view::MyView;
use fltk::{enums::*, prelude::*, *};

const INFO: &str = r#"Sysinfo-gui is a lightweight cross-platform system-monitoring
<a href="https://github.com/fltk-rs/fltk-rs">fltk</a> gui application based on
<a href="https://github.com/GuillaumeGomez/sysinfo">sysinfo</a>.
<br>
Sysinfo-gui is MIT licensed.
"#;

pub fn info(_view: &MyView) -> Option<Box<dyn FnMut() + Send>> {
let mut grp = group::Pack::default()
.with_size(600, 400)
.center_of_parent();
grp.set_spacing(40);
let mut frame = misc::HelpView::default()
.with_size(500, 300)
.center_of_parent();
frame.set_frame(FrameType::FlatBox);
frame.set_color(frame.parent().unwrap().color());
frame.set_value(INFO);
frame.set_text_size(16);
frame.set_text_font(Font::Helvetica);
grp.end();
None
}
5 changes: 5 additions & 0 deletions src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod mem;
pub mod net;
pub mod procs;
pub mod settings;
pub mod info;

use crate::gui::{message::Message, styles::colors::GRAY, View};
use fltk::app;
Expand Down Expand Up @@ -74,6 +75,7 @@ impl View for MyView {
Message::Procs => self.procs(),
Message::Net => self.network(),
Message::Settings => self.settings(),
Message::Info => self.info(),
}
}
fn sleep_duration(&self) -> u64 {
Expand Down Expand Up @@ -106,4 +108,7 @@ impl MyView {
pub fn procs(&self) -> Option<Box<dyn FnMut() + Send>> {
procs::procs(self)
}
pub fn info(&self) -> Option<Box<dyn FnMut() + Send>> {
info::info(self)
}
}
7 changes: 5 additions & 2 deletions src/view/procs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ pub fn procs(view: &MyView) -> Option<Box<dyn FnMut() + Send>> {
}
}
});
ProcToggle::new("virt", view.ordering.clone()).handle({
let mut b = ProcToggle::new("virt", view.ordering.clone());
b.handle({
let ord = view.ordering.clone();
move |_, e| {
if e == Event::Push {
Expand All @@ -153,6 +154,7 @@ pub fn procs(view: &MyView) -> Option<Box<dyn FnMut() + Send>> {
}
}
});
b.set_tooltip("Virtual memory in Kb");
ProcToggle::new("cpu%", view.ordering.clone()).handle({
let ord = view.ordering.clone();
move |_, e| {
Expand Down Expand Up @@ -188,7 +190,7 @@ pub fn procs(view: &MyView) -> Option<Box<dyn FnMut() + Send>> {
hpack.end();
let mut b = browser::HoldBrowser::default().with_size(0, 500 - 30);
b.clear_visible_focus();
b.set_text_size(14);
b.set_text_size(app::font_size() - 2);
b.set_color(Color::color_average(b.color(), Color::Background, 0.1));
b.set_selection_color(SEL_BLUE);
b.set_scrollbar_size(5);
Expand All @@ -211,6 +213,7 @@ pub fn procs(view: &MyView) -> Option<Box<dyn FnMut() + Send>> {
}
let mut menu = menu::MenuButton::default().with_type(menu::MenuButtonType::Popup3);
menu.set_frame(FrameType::FlatBox);
menu.set_text_size(app::font_size() - 2);
menu.set_color(Color::color_average(menu.color(), Color::Background, 0.9));
drop(sys);
menu.add("End Task\t\t", Shortcut::None, menu::MenuFlag::Normal, {
Expand Down

0 comments on commit 756020f

Please sign in to comment.