Skip to content

Commit 8c33dbe

Browse files
authored
Merge pull request #1 from derenv/README
Readme
2 parents 44c5c42 + 49c93b4 commit 8c33dbe

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2022 Deren Vural
3+
SPDX-License-Identifier: GPL-3.0-or-later
4+
-->
5+
6+
# Description
7+
8+
This project is a rewrite of gnome-nvidia-extension in Rust - intended as a practise Rust project.
9+
10+
# Usage
11+
12+
Use the following to compile the project:
13+
14+
```bash
15+
cargo clean; cargo run
16+
```
17+
18+
# Resources
19+
20+
## Original Extension
21+
22+
[Original version, written in GTK-JS](https://github.com/ethanwharris/gnome-nvidia-extension)
23+
24+
## Documentation
25+
26+
- [GTK-RS Project website](https://gtk-rs.org/)
27+
- [GTK-RS Book](https://gtk-rs.org/gtk4-rs/stable/latest/book/introduction.html)
28+
- [GTK-RS Documentation](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/)
29+
- [GLib Documentation](https://docs.gtk.org/glib/index.html)
30+
- [GObject Documentation](https://docs.gtk.org/gobject/index.html)
31+
32+
## GitHub
33+
34+
- [GTK-RS Organisation on GitHub](https://github.com/gtk-rs)
35+
- [GTK-RS Core](https://github.com/gtk-rs/gtk-rs-core)
36+
- [GTK3-RS](https://github.com/gtk-rs/gtk3-rs)
37+
- [GTK4-RS](https://github.com/gtk-rs/gtk4-rs)
38+
39+
## Crates
40+
41+
### GTK libraries
42+
43+
- [GTK4](https://crates.io/crates/gtk4)
44+
- [GLib](https://crates.io/crates/glib/0.15.12)
45+
- [Gio](https://crates.io/crates/gio/0.15.12)
46+
47+
### System Tray Library
48+
49+
[libappindicator](https://crates.io/crates/libappindicator/0.7.1)
50+
51+
There are other ways of doing this - libappindicator seems broken..
52+
53+
## Examples
54+
55+
- [GObject Subclassing (GTK3)](https://github.com/gtk-rs/gtk3-rs/tree/master/examples/basic_subclass)
56+
- [GObject Subclassing (GTK4)](https://github.com/gtk-rs/gtk4-rs/tree/8b0c4cbd35912b9f8685d40f796b0806c52119ab/book/listings/todo/1)
57+
- [System Tray (libappindicator)](https://github.com/tauri-apps/libappindicator-rs/blob/main/examples/hello.rs)
58+
59+
## System Tray Discussion
60+
61+
[Reddit Post](https://www.reddit.com/r/gnome/comments/7x7qc6/by_what_logic_was_system_tray_removed/)
62+
63+
The post above has possible alternatives to libappindicator in the comments
64+
65+
# License
66+
67+
[![License: GPL v3.0+](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)

src/property/imp.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-FileCopyrightText: 2022 Deren Vural
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
/*
5+
* Name:
6+
* imp.rs
7+
*
8+
* Description:
9+
* Implementation of our custom GObject class (Property)
10+
*
11+
* Made:
12+
* 13/09/2022
13+
*
14+
* Made by:
15+
* Deren Vural
16+
*
17+
* Notes:
18+
*
19+
*/
20+
21+
// Imports
22+
use gtk::glib;
23+
use gtk::subclass::prelude::*;
24+
25+
// Object holding the state
26+
#[derive(Default)]
27+
pub struct Property {
28+
processor: str,
29+
name: str,
30+
callExtension: str,
31+
icon: str,
32+
formatter: str,
33+
gpuCount: i32,
34+
}
35+
36+
// The central trait for subclassing a GObject
37+
#[glib::object_subclass]
38+
impl ObjectSubclass for Property {
39+
//Crate+Obj to avoid collisions
40+
const NAME: &'static str = "NvidiaExtensionRustProperty";
41+
// the actual GObject that will be created
42+
type Type = super::Property;
43+
// Parent GObject we inherit from
44+
type ParentType = glib::Object;
45+
}
46+
47+
// Trait shared by all GObjects
48+
impl ObjectImpl for Property {}

src/property/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// SPDX-FileCopyrightText: 2022 Deren Vural
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
/*
5+
* Name:
6+
* mod.rs
7+
*
8+
* Description:
9+
* Public-facing interface/wrapper for our custom GObject (Property)
10+
*
11+
* Made:
12+
* 13/09/2022
13+
*
14+
* Made by:
15+
* Deren Vural
16+
*
17+
* Notes:
18+
*
19+
*/
20+
21+
// Custom GObjects
22+
mod imp;
23+
24+
// Imports
25+
use glib::Object;
26+
use gtk::glib;
27+
28+
glib::wrapper! {
29+
pub struct Property(ObjectSubclass<imp::Property>)
30+
@extends Object;/*,
31+
@implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;*/
32+
}
33+
34+
impl Property {
35+
pub fn new() -> Self {
36+
Object::new(&[]).expect("Failed to create `Property`.")
37+
}
38+
/*
39+
pub fn with_label(label: &str) -> Self {
40+
Object::new(&[("label", &label)]).expect("Failed to create `Property`.")
41+
}
42+
*/
43+
}

0 commit comments

Comments
 (0)