Skip to content

Commit ecdf62f

Browse files
authored
Merge pull request #10 from derenv/adwaita
Adwaita
2 parents da6e35c + 25fc005 commit ecdf62f

File tree

23 files changed

+2015
-386
lines changed

23 files changed

+2015
-386
lines changed

Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

44
[package]
5-
name = "gnome-nvidia-extension-rust"
5+
name = "gtk4-nvidia-monitor-rust"
66
version = "0.1.0"
77
edition = "2021"
88

99
[dependencies]
10-
#adwaita = { version = "^0.1.1", package = "libadwaita"}
10+
adwaita = { version = "^0.1.1", package = "libadwaita" }
1111
gtk = { version = "^0.4.8", package = "gtk4" }
12-
#glib = { version = "^0.15.12", package = "glib" }
12+
gdk = { version = "^0.4.8", package = "gdk4" }
1313

14+
#shell = { version = "^0.4.4", package = "gtk-layer-shell" } #may not need
15+
#serde = { version = "1.0", features = ["derive"] }
16+
#serde_json = "1.0"
1417
#gobject = { version = "^0.15.10", package = "gobject-sys" }
15-
libappindicator = { version = "^0.7.1", package = "libappindicator" }
18+
#libappindicator = { version = "^0.7.1", package = "libappindicator" }
19+
20+
[build-dependencies]
21+
adwaita = { version = "^0.1.1", package = "libadwaita" }

build.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-FileCopyrightText: 2022 Deren Vural
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
/*
5+
* Name:
6+
* build.rs
7+
*
8+
* Description:
9+
* Build script for Nvidia Gnome Extension (Rust)
10+
*
11+
* Made:
12+
* 09/10/2022
13+
*
14+
* Made by:
15+
* Deren Vural
16+
*
17+
* Notes:
18+
* imports must be added as a dependancy for build scripts via:
19+
* `cargo add gtk4 --rename gtk --build`
20+
* which updates Cargo.toml with:
21+
* [build-dependencies]
22+
* gtk = { version = "^0.4.8", package = "gtk4" }
23+
*/
24+
25+
// Imports
26+
use adwaita::gio::compile_resources;
27+
28+
/*
29+
* Name:
30+
* main
31+
*
32+
* Description:
33+
* Runs pre-build
34+
*
35+
* Made:
36+
* 09/10/2022
37+
*
38+
* Made by:
39+
* Deren Vural
40+
*
41+
* Notes:
42+
*
43+
*/
44+
fn main() {
45+
// UI
46+
println!("..Compiling UI resources into `.gresource` file");
47+
compile_resources(
48+
"src/resources",
49+
"src/resources/resources.gresource.xml",
50+
"nvidiamonitorrust.gresource",
51+
);
52+
}

install_schemas.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: 2022 Deren Vural
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
6+
#####
7+
# Name:
8+
# install_schemas.sh
9+
#
10+
# Description:
11+
# Installs gtk schema to system
12+
#
13+
# Made:
14+
# 13/10/2022
15+
#
16+
# Made by:
17+
# Deren Vural
18+
#
19+
# Notes:
20+
#
21+
#####
22+
23+
# Variables
24+
SCHEMA_DIR="$HOME/.local/share/glib-2.0/schemas"
25+
SCHEMA_FILE="com.gtk_d.NvidiaMonitorRust.gschema.xml"
26+
27+
# Create schema directory if it doesn't exist
28+
if [[ -d "$SCHEMA_DIR" ]]; then
29+
echo "$SCHEMA_DIR already exists.."
30+
else
31+
echo "$SCHEMA_DIR needs created.."
32+
mkdir -p "$SCHEMA_DIR"
33+
fi
34+
35+
# Copy schema file across
36+
if [[ -f "$SCHEMA_DIR/$SCHEMA_FILE" ]]; then
37+
echo "$SCHEMA_FILE already exists, overwriting.."
38+
cp "./src/$SCHEMA_FILE" "$SCHEMA_DIR/"
39+
else
40+
echo "$SCHEMA_FILE needs copied to $SCHEMA_DIR.."
41+
cp "./src/$SCHEMA_FILE" "$SCHEMA_DIR/"
42+
fi
43+
44+
# Compile schemas
45+
echo "Compiling schemas.."
46+
glib-compile-schemas "$SCHEMA_DIR/"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
SPDX-FileCopyrightText: 2022 Deren Vural
4+
SPDX-License-Identifier: GPL-3.0-or-later
5+
-->
6+
<schemalist>
7+
<schema id="com.gtk_d.NvidiaMonitorRust" path="/com/gtk_d/NvidiaMonitorRust/">
8+
<key name="nvidia-settings-open" type="b">
9+
<default>false</default>
10+
<summary>Nvidia settings state</summary>
11+
<description>
12+
Nvidia settings open/closed
13+
</description>
14+
</key>
15+
<key name="app-settings-open" type="b">
16+
<default>false</default>
17+
<summary>App settings state</summary>
18+
<description>
19+
App settings window open/closed
20+
</description>
21+
</key>
22+
23+
<key name="refreshrate" type="i">
24+
<default>5</default>
25+
<summary>Refresh Interval (s)</summary>
26+
<description>
27+
The time between refreshes in seconds
28+
</description>
29+
</key>
30+
<key name="tempformat" type="i">
31+
<default>0</default>
32+
<summary>Temperature Unit</summary>
33+
<description>
34+
Set the temperature unit to be displayed in either Celcius (0) or Fahrenheit (1)
35+
</description>
36+
</key>
37+
<key name="provider" type="i">
38+
<default>0</default>
39+
<summary>Properties Provider</summary>
40+
<description>
41+
Select the properties provider to use, Nvidia Settings and Nvidia SMI (0), Nvidia Settings only (1), Nvidia SMI only (2), or Optimus (3)
42+
</description>
43+
</key>
44+
45+
<!-- Not entirely sure what these are for..-->
46+
<key name="settingsconfig" type="as">
47+
<default>[]</default>
48+
</key>
49+
<key name="smiconfig" type="as">
50+
<default>[]</default>
51+
</key>
52+
<key name="settingsandsmiconfig" type="as">
53+
<default>[]</default>
54+
</key>
55+
<key name="optimusconfig" type="as">
56+
<default>[]</default>
57+
</key>
58+
</schema>
59+
</schemalist>

src/custom_button/imp.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
*/
2020

2121
// Imports
22-
use gtk::glib;
23-
use gtk::subclass::prelude::*;
22+
use gtk::{glib, subclass::prelude::*};
2423

2524
// Object holding the state
2625
#[derive(Default)]
@@ -30,7 +29,7 @@ pub struct CustomButton;
3029
#[glib::object_subclass]
3130
impl ObjectSubclass for CustomButton {
3231
//Crate+Obj to avoid collisions
33-
const NAME: &'static str = "NvidiaExtensionRustCustomButton";
32+
const NAME: &'static str = "NvidiaMonitorRustCustomButton";
3433
// the actual GObject that will be created
3534
type Type = super::CustomButton;
3635
// Parent GObject we inherit from

src/formatter/imp.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
*/
2020

2121
// Imports
22-
use gtk::glib::once_cell::sync::Lazy;
23-
use gtk::glib::{self, ParamSpec, Value};
24-
use gtk::subclass::prelude::*;
22+
use glib::{once_cell::sync::Lazy, ParamSpec, Value};
23+
use gtk::{glib, subclass::prelude::*};
2524

2625
// Modules
2726
//
@@ -34,7 +33,7 @@ pub struct Formatter;
3433
#[glib::object_subclass]
3534
impl ObjectSubclass for Formatter {
3635
//Crate+Obj to avoid collisions
37-
const NAME: &'static str = "NvidiaExtensionRustFormatter";
36+
const NAME: &'static str = "NvidiaMonitorRustFormatter";
3837
// the actual GObject that will be created
3938
type Type = super::Formatter;
4039
// Parent GObject we inherit from

0 commit comments

Comments
 (0)