Skip to content

Commit

Permalink
fix review concerns (#218)
Browse files Browse the repository at this point in the history
* fix review concerns

* bump version
  • Loading branch information
kenohassler authored May 17, 2024
1 parent 52d7d45 commit 79bc68e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
8 changes: 4 additions & 4 deletions src/nvidiautil@ethanwharris/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ class MainMenu extends PanelMenu.Button {
accessible_name: 'Open Preferences',
style_class: 'button',
child: new St.Icon({
icon_name: GIcons.Icon.Wrench.name,
gicon: GIcons.Icon.Wrench.get(),
icon_name: GIcons.Icon.Wrench,
gicon: GIcons.get(GIcons.Icon.Wrench),
}),
});
this.wrench.connect('clicked', () => {
Expand All @@ -368,8 +368,8 @@ class MainMenu extends PanelMenu.Button {
accessible_name: 'Open Nvidia Settings',
style_class: 'button',
child: new St.Icon({
icon_name: GIcons.Icon.Cog.name,
gicon: GIcons.Icon.Cog.get(),
icon_name: GIcons.Icon.Cog,
gicon: GIcons.get(GIcons.Icon.Cog),
}),
});
this.cog.connect('clicked', () => this.provider.openSettings());
Expand Down
33 changes: 17 additions & 16 deletions src/nvidiautil@ethanwharris/gIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
import Gio from 'gi://Gio';
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';

export class Icon {
static Card = new this('card-symbolic');
static Temp = new this('temp-symbolic');
static RAM = new this('ram-symbolic');
static Fan = new this('fan-symbolic');
static Power = new this('power-symbolic');
static Wrench = new this('wrench-symbolic');
static Cog = new this('cog-symbolic');
export const Icon = {
Card: 'card-symbolic',
Temp: 'temp-symbolic',
RAM: 'ram-symbolic',
Fan: 'fan-symbolic',
Power: 'power-symbolic',
Wrench: 'wrench-symbolic',
Cog: 'cog-symbolic',
};

constructor(name) {
this.name = name;
}

get() {
let extensionObject = Extension.lookupByURL(import.meta.url);
return Gio.icon_new_for_string(`${extensionObject.path}/icons/${this.name}.svg`);
}
/**
* get an icon from the extension directory
* @param {string} name file name of the icon
* @returns {Gio.Icon} new gicon
*/
export function get(name) {
let extensionObject = Extension.lookupByURL(import.meta.url);
return Gio.icon_new_for_string(`${extensionObject.path}/icons/${name}.svg`);
}
2 changes: 1 addition & 1 deletion src/nvidiautil@ethanwharris/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"settings-schema": "org.gnome.shell.extensions.nvidiautil",
"uuid": "nvidiautil@ethanwharris",
"url": "https://github.com/ethanwharris/gnome-nvidia-extension",
"version": 11
"version": 14
}
3 changes: 0 additions & 3 deletions src/nvidiautil@ethanwharris/settingsAndSmiProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

'use strict';

import * as SettingsProperties from './settingsProperties.js';
import * as SmiProperties from './smiProperties.js';
import * as Processor from './processor.js';
import * as SettingsProvider from './settingsProvider.js';
import * as SmiProvider from './smiProvider.js';

Expand Down
8 changes: 4 additions & 4 deletions src/nvidiautil@ethanwharris/settingsProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as GIcons from './gIcons.js';

export class UtilisationProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Utilisation', '-q GPUUtilization ', GIcons.Icon.Card.get(),
super(processor, 'Utilisation', '-q GPUUtilization ', GIcons.get(GIcons.Icon.Card),
new Formatter.PercentFormatter('UtilisationFormatter'), gpuCount);
}

Expand All @@ -24,7 +24,7 @@ export class UtilisationProperty extends Property {

export class TemperatureProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Temperature', '-q [GPU]/GPUCoreTemp ', GIcons.Icon.Temp.get(),
super(processor, 'Temperature', '-q [GPU]/GPUCoreTemp ', GIcons.get(GIcons.Icon.Temp),
new Formatter.TempFormatter(Formatter.CENTIGRADE), gpuCount);
}

Expand All @@ -35,7 +35,7 @@ export class TemperatureProperty extends Property {

export class MemoryProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Memory Usage', '-q UsedDedicatedGPUMemory -q TotalDedicatedGPUMemory ', GIcons.Icon.RAM.get(),
super(processor, 'Memory Usage', '-q UsedDedicatedGPUMemory -q TotalDedicatedGPUMemory ', GIcons.get(GIcons.Icon.RAM),
new Formatter.MemoryFormatter(), gpuCount);
}

Expand All @@ -59,7 +59,7 @@ export class MemoryProperty extends Property {

export class FanProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Fan Speed', '-q GPUCurrentFanSpeed ', GIcons.Icon.Fan.get(),
super(processor, 'Fan Speed', '-q GPUCurrentFanSpeed ', GIcons.get(GIcons.Icon.Fan),
new Formatter.PercentFormatter('FanFormatter'), gpuCount);
}
}
10 changes: 5 additions & 5 deletions src/nvidiautil@ethanwharris/smiProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ import * as GIcons from './gIcons.js';

export class UtilisationProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Utilisation', 'utilization.gpu,', GIcons.Icon.Card.get(),
super(processor, 'Utilisation', 'utilization.gpu,', GIcons.get(GIcons.Icon.Card),
new Formatter.PercentFormatter('UtilisationFormatter'), gpuCount);
}
}

export class PowerProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Power Usage (W)', 'power.draw,', GIcons.Icon.Power.get(),
super(processor, 'Power Usage (W)', 'power.draw,', GIcons.get(GIcons.Icon.Power),
new Formatter.PowerFormatter(), gpuCount);
}
}

export class TemperatureProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Temperature', 'temperature.gpu,', GIcons.Icon.Temp.get(),
super(processor, 'Temperature', 'temperature.gpu,', GIcons.get(GIcons.Icon.Temp),
new Formatter.TempFormatter(Formatter.CENTIGRADE), gpuCount);
}

Expand All @@ -34,7 +34,7 @@ export class TemperatureProperty extends Property {

export class MemoryProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Memory Usage', 'memory.used,memory.total,', GIcons.Icon.RAM.get(),
super(processor, 'Memory Usage', 'memory.used,memory.total,', GIcons.get(GIcons.Icon.RAM),
new Formatter.MemoryFormatter('MemoryFormatter'), gpuCount);
}

Expand All @@ -58,7 +58,7 @@ export class MemoryProperty extends Property {

export class FanProperty extends Property {
constructor(gpuCount, processor) {
super(processor, 'Fan Speed', 'fan.speed,', GIcons.Icon.Fan.get(),
super(processor, 'Fan Speed', 'fan.speed,', GIcons.get(GIcons.Icon.Fan),
new Formatter.PercentFormatter('FanFormatter'), gpuCount);
}
}

0 comments on commit 79bc68e

Please sign in to comment.