Skip to content

Commit 47c850f

Browse files
author
Deren Vural
committed
Updated crate for documentation
- Added missing function comment headers in main.rs - Added <> brackets around hyperlinks - Cleaned up some imports (removed super::xxx style also) - Moved subprocess functions into a module - Fixed weird "process()" header in property class Signed-off-by: Deren Vural <[email protected]>
1 parent 90c5e91 commit 47c850f

File tree

10 files changed

+168
-106
lines changed

10 files changed

+168
-106
lines changed

src/formatter/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl ObjectImpl for Formatter {
7171
* Deren Vural
7272
*
7373
* Notes:
74-
* beware that you need to use kebab-case (https://en.wikipedia.org/wiki/Letter_case#Kebab_case)
74+
* beware that you need to use kebab-case (<https://en.wikipedia.org/wiki/Letter_case#Kebab_case>)
7575
*
7676
* ParamSpec Examples:
7777
* glib::ParamSpecString::builder("icon").build(),

src/main.rs

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
/**
55
* Name:
6-
* main.rs
6+
* gtk4-nvidia-monitor-rust
77
*
88
* Description:
9-
* Rust Implementation of Nvidia Gnome Extension
9+
* GTK-rs app for monitoring Nvidia GPU statistics
1010
*
1111
* Made:
1212
* 12/09/2022
@@ -17,7 +17,6 @@
1717
* Notes:
1818
*
1919
*/
20-
2120
// Modules
2221
mod formatter;
2322
mod mainwindow;
@@ -30,16 +29,30 @@ mod custom_button;
3029
mod settingswindow;
3130

3231
// Imports
33-
use adwaita::prelude::*;
34-
use adwaita::{gio, Application};
32+
use adwaita::{gio, prelude::*, Application};
3533
use gdk::Display;
3634
use gio::resources_register_include;
3735
use gtk::{CssProvider, StyleContext};
3836

3937
// Constants
4038
const APP_ID: &str = "com.gtk_d.NvidiaMonitorRust";
4139

42-
// Main Function
40+
/**
41+
* Name:
42+
* main
43+
*
44+
* Description:
45+
* Load resources, initialise GTK, create application and connect signals
46+
*
47+
* Made:
48+
* 13/09/2022
49+
*
50+
* Made by:
51+
* Deren Vural
52+
*
53+
* Notes:
54+
*
55+
*/
4356
fn main() {
4457
// Resources
4558
resources_register_include!("nvidiamonitorrust.gresource")
@@ -60,17 +73,48 @@ fn main() {
6073
println!("{}", app.run());
6174
}
6275

76+
/**
77+
* Name:
78+
* setup_shortcuts
79+
*
80+
* Description:
81+
* Add keyboard shortcuts to the program
82+
*
83+
* Made:
84+
* 09/10/2022
85+
*
86+
* Made by:
87+
* Deren Vural
88+
*
89+
* Notes:
90+
* <https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/todo/5/main.rs>
91+
* <https://gtk-rs.org/gtk4-rs/stable/latest/book/todo_3.html>
92+
*
93+
*/
6394
/*
64-
//https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/todo/5/main.rs
65-
//https://gtk-rs.org/gtk4-rs/stable/latest/book/todo_3.html
6695
fn setup_shortcuts(app: &Application) {
6796
app.set_accels_for_action("win.filter('All')", &["<Ctrl>a"]);
6897
app.set_accels_for_action("win.filter('Open')", &["<Ctrl>o"]);
6998
app.set_accels_for_action("win.filter('Done')", &["<Ctrl>d"]);
7099
}
71100
*/
72101

73-
// Load CSS styles
102+
/**
103+
* Name:
104+
* load_css
105+
*
106+
* Description:
107+
* Load css from file and add as style provider
108+
*
109+
* Made:
110+
* 23/10/2022
111+
*
112+
* Made by:
113+
* Deren Vural
114+
*
115+
* Notes:
116+
*
117+
*/
74118
fn load_css() {
75119
// Load the CSS file and add it to the provider
76120
let provider = CssProvider::new();
@@ -84,10 +128,27 @@ fn load_css() {
84128
);
85129
}
86130

87-
// Build Function
131+
/**
132+
* Name:
133+
* build_ui
134+
*
135+
* Description:
136+
* Build the main window (given the application object) and run
137+
*
138+
* Made:
139+
* 13/09/2022
140+
*
141+
* Made by:
142+
* Deren Vural
143+
*
144+
* Notes:
145+
*
146+
*/
88147
fn build_ui(app: &Application) {
89148
// Create a new custom window and show it
90149
let window: MainWindow = MainWindow::new(app);
150+
151+
// Present window
91152
window.show();
92153

93154
/*

src/mainwindow/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl ObjectImpl for MainWindow {
658658
* Deren Vural
659659
*
660660
* Notes:
661-
* beware that you need to use kebab-case (https://en.wikipedia.org/wiki/Letter_case#Kebab_case)
661+
* beware that you need to use kebab-case (<https://en.wikipedia.org/wiki/Letter_case#Kebab_case>)
662662
*
663663
* ParamSpec Examples:
664664
* glib::ParamSpecString::builder("icon").build(),

src/processor/imp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* Deren Vural
1616
*
1717
* Notes:
18-
* https://github.com/gtk-rs/gtk4-rs/blob/master/book/src/g_object_properties.md
19-
* https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_properties/4/custom_button/imp.rs
20-
* https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_properties/4/custom_button/mod.rs
18+
* <https://github.com/gtk-rs/gtk4-rs/blob/master/book/src/g_object_properties.md>
19+
* <https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_properties/4/custom_button/imp.rs>
20+
* <https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/g_object_properties/4/custom_button/mod.rs>
2121
*/
2222

2323
// Imports
@@ -77,7 +77,7 @@ impl ObjectImpl for Processor {
7777
* Deren Vural
7878
*
7979
* Notes:
80-
* beware that you need to use kebab-case (https://en.wikipedia.org/wiki/Letter_case#Kebab_case)
80+
* beware that you need to use kebab-case (<https://en.wikipedia.org/wiki/Letter_case#Kebab_case>)
8181
*
8282
* ParamSpec Examples:
8383
* glib::ParamSpecString::builder("icon").build(),

src/processor/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
mod imp;
2424

2525
// Imports
26-
use super::subprocess;
2726
use glib::Object;
2827
use gtk::{gio, glib, prelude::ObjectExt};
2928
use std::ffi::OsStr;
3029

30+
// Crates
31+
use crate::{subprocess::subprocess::exec_communicate};
32+
3133
// GObject wrapper for Processor
3234
glib::wrapper! {
3335
pub struct Processor(ObjectSubclass<imp::Processor>)
@@ -151,7 +153,7 @@ impl Processor {
151153
];
152154

153155
// Run process, get output
154-
match subprocess::exec_communicate(&argv, None::<&gio::Cancellable>) {
156+
match exec_communicate(&argv, None::<&gio::Cancellable>) {
155157
Ok(return_val) => match return_val {
156158
// ACTUAL
157159
(None, None) => return Ok(None),
@@ -189,7 +191,7 @@ impl Processor {
189191
];
190192

191193
// Run process, get output
192-
match subprocess::exec_communicate(&argv, None::<&gio::Cancellable>) {
194+
match exec_communicate(&argv, None::<&gio::Cancellable>) {
193195
Ok(return_val) => match return_val {
194196
// ACTUAL
195197
(None, None) => return Ok(None),
@@ -226,7 +228,7 @@ impl Processor {
226228
];
227229

228230
// Run process, get output
229-
match subprocess::exec_communicate(&argv, None::<&gio::Cancellable>) {
231+
match exec_communicate(&argv, None::<&gio::Cancellable>) {
230232
Ok(return_val) => match return_val {
231233
// ACTUAL
232234
(None, None) => return Ok(None),
@@ -258,7 +260,7 @@ impl Processor {
258260
let argv: [&OsStr; 2] = [call_stack_items[0], call_stack_items[1]];
259261

260262
// Run process, get output
261-
match subprocess::exec_communicate(&argv, None::<&gio::Cancellable>) {
263+
match exec_communicate(&argv, None::<&gio::Cancellable>) {
262264
Ok(return_val) => match return_val {
263265
// ACTUAL
264266
(None, None) => return Ok(None),

src/property/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl ObjectImpl for Property {
7979
* Deren Vural
8080
*
8181
* Notes:
82-
* beware that you need to use kebab-case (https://en.wikipedia.org/wiki/Letter_case#Kebab_case)
82+
* beware that you need to use kebab-case (<https://en.wikipedia.org/wiki/Letter_case#Kebab_case>)
8383
*/
8484
fn properties() -> &'static [ParamSpec] {
8585
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {

src/property/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,10 @@ impl Property {
106106
* Deren Vural
107107
*
108108
* Notes:
109-
*
109+
* <https://doc.rust-lang.org/std/primitive.array.html>
110+
* <https://www.tutorialspoint.com/rust/rust_array.htm>
111+
* <https://doc.rust-lang.org/std/vec/struct.Vec.html>
110112
*/
111-
// Parsing
112-
//https://doc.rust-lang.org/std/primitive.array.html
113-
//https://www.tutorialspoint.com/rust/rust_array.htm
114-
//https://doc.rust-lang.org/std/vec/struct.Vec.html
115113
pub fn parse(
116114
self,
117115
values: Vec<Vec<String>>,

src/provider/imp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl ObjectImpl for Provider {
7979
* Deren Vural
8080
*
8181
* Notes:
82-
* beware that you need to use kebab-case (https://en.wikipedia.org/wiki/Letter_case#Kebab_case)
82+
* beware that you need to use kebab-case (<https://en.wikipedia.org/wiki/Letter_case#Kebab_case>)
8383
*
8484
* ParamSpec Examples:
8585
* glib::ParamSpecString::builder("icon").build(),

src/provider/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use gtk::prelude::*;
2828
use std::ffi::OsStr;
2929

3030
// Crates
31-
use crate::{processor::Processor, property::Property, subprocess};
31+
use crate::{processor::Processor, property::Property, subprocess::subprocess::exec_check};
3232

3333
// GObject wrapper for Provider
3434
glib::wrapper! {
@@ -277,7 +277,7 @@ impl Provider {
277277
match self.property::<i32>("provider-type") {
278278
// Open Nvidia Settings
279279
0 => {
280-
match subprocess::exec_check(
280+
match exec_check(
281281
&[OsStr::new("nvidia-settings")],
282282
None::<&gio::Cancellable>,
283283
) {
@@ -286,7 +286,7 @@ impl Provider {
286286
};
287287
}
288288
1 => {
289-
match subprocess::exec_check(
289+
match exec_check(
290290
&[OsStr::new("nvidia-settings")],
291291
None::<&gio::Cancellable>,
292292
) {

0 commit comments

Comments
 (0)