Skip to content

Commit

Permalink
Merge pull request nokyan#191 from nokyan/gnome-46
Browse files Browse the repository at this point in the history
Gnome 46
  • Loading branch information
nokyan authored Apr 5, 2024
2 parents 3ed6c27 + b5fe299 commit 4214fe2
Show file tree
Hide file tree
Showing 33 changed files with 882 additions and 471 deletions.
702 changes: 583 additions & 119 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,27 @@ anyhow = "1.0.75"
log = "0.4.20"
pretty_env_logger = "0.5"
gettext-rs = { version = "0.7", features = ["gettext-system"] }
gtk = { version = "0.7.3", features = ["v4_10"], package = "gtk4" }
adw = { version = "0.5.3", features = ["v1_4"], package = "libadwaita" }
gtk = { version = "0.8.1", features = ["v4_10"], package = "gtk4" }
adw = { version = "0.6.0", features = ["v1_5"], package = "libadwaita" }
regex = "1.10.2"
sysconf = "0.3.4"
nvml-wrapper = "0.9.0"
nvml-wrapper = "0.10.0"
unescape = "0.1.0"
nix = { version = "0.27.1", features = ["signal"] }
nix = { version = "0.28", features = ["signal"] }
uzers = "0.11.3"
plotters = { version = "0.3.5", default_features = false, features = [
"area_series",
] }
plotters-cairo = "0.5.0"
plotters-cairo = "0.6.0"
serde = { version = "1.0.193", features = ["serde_derive"] }
rmp-serde = "1.1.2"
rust-ini = "0.20.0"
rust-ini = "0.21.0"
gtk-macros = "0.3.0"
strum = "0.25.0"
strum_macros = "0.25.3"
strum = "0.26.2"
strum_macros = "0.26.2"
once_cell = "1.19.0"
hashbrown = "0.14.3"
expanduser = "1.2.2"
paste = "1.0.14"
num_cpus = "1.16.0"
async-std = { version = "1.12.0", features = ["async-channel"] }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ninja -C build install
Or, even better, use the Flatpak CLI to build:

```sh
flatpak install org.gnome.Sdk//45 org.freedesktop.Sdk.Extension.rust-stable//23.08 org.gnome.Platform//45 org.freedesktop.Sdk.Extension.llvm16//23.08
flatpak install org.gnome.Sdk//46 org.freedesktop.Sdk.Extension.rust-stable//23.08 org.gnome.Platform//46 org.freedesktop.Sdk.Extension.llvm16//23.08
flatpak-builder --user flatpak_app build-aux/net.nokyan.Resources.Devel.json
```

Expand Down
2 changes: 1 addition & 1 deletion build-aux/net.nokyan.Resources.Devel.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "net.nokyan.Resources.Devel",
"runtime": "org.gnome.Platform",
"runtime-version": "45",
"runtime-version": "46",
"sdk": "org.gnome.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable",
Expand Down
6 changes: 2 additions & 4 deletions data/resources/ui/dialogs/app_dialog.ui
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ResAppDialog" parent="AdwWindow">
<template class="ResAppDialog" parent="AdwDialog">
<property name="width_request">360</property>
<property name="default_width">480</property>
<property name="height_request">600</property>
<property name="default_height">600</property>
<property name="modal">true</property>
<property name="content_width">480</property>
<property name="title" translatable="yes">Application Information</property>
<child>
<object class="GtkBox">
Expand Down
6 changes: 2 additions & 4 deletions data/resources/ui/dialogs/process_dialog.ui
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ResProcessDialog" parent="AdwWindow">
<template class="ResProcessDialog" parent="AdwDialog">
<property name="width_request">360</property>
<property name="default_width">480</property>
<property name="height_request">600</property>
<property name="default_height">600</property>
<property name="modal">true</property>
<property name="content_width">480</property>
<property name="title" translatable="yes">Process Information</property>
<child>
<object class="GtkBox">
Expand Down
5 changes: 1 addition & 4 deletions data/resources/ui/dialogs/settings_dialog.ui
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="ResSettingsDialog" parent="AdwPreferencesWindow">
<property name="default-width">550</property>
<property name="default-height">570</property>
<property name="can-navigate-back">True</property>
<template class="ResSettingsDialog" parent="AdwPreferencesDialog">
<child>
<object class="AdwPreferencesPage">
<property name="icon-name">generic-settings-symbolic</property>
Expand Down
14 changes: 4 additions & 10 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,13 @@ impl Application {
fn show_settings_dialog(&self) {
let settings = ResSettingsDialog::new();

settings.set_transient_for(Some(&self.main_window()));
settings.set_modal(true);

settings.init();

settings.present();
settings.present(&self.main_window());
}

fn show_about_dialog(&self) {
let about = adw::AboutWindow::builder()
let about = adw::AboutDialog::builder()
.application_name(i18n("Resources"))
.application_icon(config::APP_ID)
.developer_name(i18n("The Nalux Team"))
Expand All @@ -210,10 +207,7 @@ impl Application {
about.set_translator_credits(&i18n("translator-credits"));
about.add_credit_section(Some(&i18n("Icon by")), &["Avhiren"]);

about.set_transient_for(Some(&self.main_window()));
about.set_modal(true);

about.present();
about.present(&self.main_window());
}

pub fn run(&self) {
Expand All @@ -224,7 +218,7 @@ impl Application {
if PROFILE == "Devel" {
info!(
"You are running a development version of Resources, things may be slow or break!"
)
);
}

ApplicationExtManual::run(self);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/resources-processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ fn main() -> Result<()> {

handle.write_all(&encoded)?;

handle.flush()?
handle.flush()?;
}
}
8 changes: 3 additions & 5 deletions src/ui/dialogs/app_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use process_data::Containerization;

use crate::config::PROFILE;
use crate::i18n::i18n;
use crate::ui::window::MainWindow;
use crate::utils::app::AppItem;
use crate::utils::units::{convert_speed, convert_storage};

Expand Down Expand Up @@ -57,7 +56,7 @@ mod imp {
impl ObjectSubclass for ResAppDialog {
const NAME: &'static str = "ResAppDialog";
type Type = super::ResAppDialog;
type ParentType = adw::Window;
type ParentType = adw::Dialog;

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Expand All @@ -83,12 +82,12 @@ mod imp {

impl WidgetImpl for ResAppDialog {}
impl WindowImpl for ResAppDialog {}
impl AdwWindowImpl for ResAppDialog {}
impl AdwDialogImpl for ResAppDialog {}
}

glib::wrapper! {
pub struct ResAppDialog(ObjectSubclass<imp::ResAppDialog>)
@extends gtk::Widget, gtk::Window, adw::Window;
@extends gtk::Widget, adw::Dialog;
}

impl ResAppDialog {
Expand All @@ -97,7 +96,6 @@ impl ResAppDialog {
}

pub fn init(&self, app: &AppItem) {
self.set_transient_for(Some(&MainWindow::default()));
self.setup_widgets(app);
}

Expand Down
8 changes: 3 additions & 5 deletions src/ui/dialogs/process_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use process_data::Containerization;

use crate::config::PROFILE;
use crate::i18n::i18n;
use crate::ui::window::MainWindow;
use crate::utils::boot_time;
use crate::utils::process::ProcessItem;
use crate::utils::units::{convert_speed, convert_storage};
Expand Down Expand Up @@ -59,7 +58,7 @@ mod imp {
impl ObjectSubclass for ResProcessDialog {
const NAME: &'static str = "ResProcessDialog";
type Type = super::ResProcessDialog;
type ParentType = adw::Window;
type ParentType = adw::Dialog;

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Expand All @@ -85,12 +84,12 @@ mod imp {

impl WidgetImpl for ResProcessDialog {}
impl WindowImpl for ResProcessDialog {}
impl AdwWindowImpl for ResProcessDialog {}
impl AdwDialogImpl for ResProcessDialog {}
}

glib::wrapper! {
pub struct ResProcessDialog(ObjectSubclass<imp::ResProcessDialog>)
@extends gtk::Widget, gtk::Window, adw::Window;
@extends gtk::Widget, adw::Dialog;
}

impl ResProcessDialog {
Expand All @@ -99,7 +98,6 @@ impl ResProcessDialog {
}

pub fn init<S: AsRef<str>>(&self, process: &ProcessItem, user: S) {
self.set_transient_for(Some(&MainWindow::default()));
self.setup_widgets(process, user.as_ref());
}

Expand Down
8 changes: 4 additions & 4 deletions src/ui/dialogs/settings_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod imp {
impl ObjectSubclass for ResSettingsDialog {
const NAME: &'static str = "ResSettingsDialog";
type Type = super::ResSettingsDialog;
type ParentType = adw::PreferencesWindow;
type ParentType = adw::PreferencesDialog;

fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
Expand Down Expand Up @@ -121,14 +121,14 @@ mod imp {

impl WindowImpl for ResSettingsDialog {}

impl AdwWindowImpl for ResSettingsDialog {}
impl AdwDialogImpl for ResSettingsDialog {}

impl PreferencesWindowImpl for ResSettingsDialog {}
impl PreferencesDialogImpl for ResSettingsDialog {}
}

glib::wrapper! {
pub struct ResSettingsDialog(ObjectSubclass<imp::ResSettingsDialog>)
@extends adw::PreferencesWindow, gtk::Window, gtk::Widget, adw::Window;
@extends adw::PreferencesDialog, gtk::Widget, adw::Dialog;
}

impl ResSettingsDialog {
Expand Down
54 changes: 26 additions & 28 deletions src/ui/pages/applications/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use std::collections::HashSet;

use adw::ResponseAppearance;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib::{self, clone, closure, Object, Sender};
use async_std::channel::Sender;
use gtk::glib::{self, clone, closure, MainContext, Object};
use gtk::{
gio, ColumnView, ColumnViewColumn, FilterChange, NumericSorter, SortType, StringSorter, Widget,
};
use gtk_macros::send;

use log::error;

use crate::config::PROFILE;
use crate::i18n::{i18n, i18n_f};
Expand All @@ -37,7 +35,7 @@ mod imp {

use gtk::{
gio::{Icon, ThemedIcon},
glib::{ParamSpec, Properties, Sender, Value},
glib::{ParamSpec, Properties, Value},
ColumnViewColumn, CompositeTemplate,
};

Expand Down Expand Up @@ -371,7 +369,7 @@ impl ResApplications {
column_view.sort_by_column(
columns
.get(SETTINGS.apps_sort_by() as usize)
.or_else(|| columns.get(0)),
.or_else(|| columns.first()),
SETTINGS.apps_sort_by_ascending(),
);

Expand Down Expand Up @@ -451,7 +449,7 @@ impl ResApplications {
if let Some(sorter) = sorter.downcast_ref::<gtk::ColumnViewSorter>() {
let current_column = sorter.primary_sort_column().map(|column| column.as_ptr() as usize).unwrap_or_default();

let current_column_number = this.imp().columns.borrow().iter().enumerate().find(|(_, column)| column.as_ptr() as usize == current_column).map(|(i, _)| i as u32).unwrap_or(0); // 0 corresponds to the name column
let current_column_number = this.imp().columns.borrow().iter().enumerate().find(|(_, column)| column.as_ptr() as usize == current_column).map_or(0, |(i, _)| i as u32); // 0 corresponds to the name column

if SETTINGS.apps_sort_by() != current_column_number {
let _ = SETTINGS.set_apps_sort_by(current_column_number);
Expand All @@ -469,7 +467,7 @@ impl ResApplications {
let imp = self.imp();
let app_dialog = ResAppDialog::new();
app_dialog.init(app_item);
app_dialog.set_visible(true);
app_dialog.present(&MainWindow::default());
*imp.open_dialog.borrow_mut() =
Some((app_item.id.as_ref().map(|gs| gs.to_string()), app_dialog));
}
Expand All @@ -482,8 +480,7 @@ impl ResApplications {
|| item.name().to_lowercase().contains(&search_string)
|| item
.id()
.map(|id| id.to_lowercase().contains(&search_string))
.unwrap_or_default()
.is_some_and(|id| id.to_lowercase().contains(&search_string))
|| item
.description()
.unwrap_or_default()
Expand Down Expand Up @@ -560,7 +557,7 @@ impl ResApplications {
store.extend_from_slice(&items);

if let Some(sorter) = imp.column_view.borrow().sorter() {
sorter.changed(gtk::SorterChange::Different)
sorter.changed(gtk::SorterChange::Different);
}

// -1 because we don't want to count System Processes
Expand All @@ -574,21 +571,20 @@ impl ResApplications {
}

pub fn execute_process_action_dialog(&self, app: AppItem, action: ProcessAction) {
let imp = self.imp();

// Nothing too bad can happen on Continue so dont show the dialog
if action == ProcessAction::CONT {
send!(
imp.sender.get().unwrap(),
Action::ManipulateApp(action, app.id.unwrap(), self.imp().toast_overlay.get())
);
let main_context = MainContext::default();
main_context.spawn_local(clone!(@strong self as this => async move {
let imp = this.imp();
let _ = imp.sender.get().unwrap().send(
Action::ManipulateApp(action, app.id.unwrap(), imp.toast_overlay.get())
).await;
}));
return;
}

// Confirmation dialog & warning
let dialog = adw::MessageDialog::builder()
.transient_for(&MainWindow::default())
.modal(true)
let dialog = adw::AlertDialog::builder()
.heading(get_action_name(action, &[&app.display_name]))
.body(get_app_action_warning(action))
.build();
Expand All @@ -603,18 +599,20 @@ impl ResApplications {
// Called when "yes" or "no" were clicked
dialog.connect_response(
None,
clone!(@strong self as this, @strong app => move |_, response| {
clone!(@strong self as this => move |_, response| {
if response == "yes" {
let imp = this.imp();
send!(
imp.sender.get().unwrap(),
Action::ManipulateApp(action, app.id.clone().unwrap(), imp.toast_overlay.get())
);
let main_context = MainContext::default();
main_context.spawn_local(clone!(@strong this, @strong app => async move {
let imp = this.imp();
let _ = imp.sender.get().unwrap().send(
Action::ManipulateApp(action, app.id.clone().unwrap(), imp.toast_overlay.get())
).await;
}));
}
}),
);

dialog.set_visible(true);
dialog.present(&MainWindow::default());
}

fn add_name_column(&self, column_view: &ColumnView) -> ColumnViewColumn {
Expand Down Expand Up @@ -894,7 +892,7 @@ impl ResApplications {

SETTINGS.connect_apps_show_drive_write_speed(
clone!(@strong write_speed_col => move |visible| {
write_speed_col.set_visible(visible)
write_speed_col.set_visible(visible);
}),
);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/pages/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ impl ResCPU {
&convert_frequency(frequency as f64)
));
} else {
curr_threadbox.set_title_label(&i18n_f("CPU {}", &[&(i + 1).to_string()]))
curr_threadbox.set_title_label(&i18n_f("CPU {}", &[&(i + 1).to_string()]));
}
*old_thread_usage = new_thread_usage;
}
Expand Down
Loading

0 comments on commit 4214fe2

Please sign in to comment.