mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 16:34:21 +09:00
Added icons into the extension.
This commit is contained in:
@@ -14,6 +14,7 @@ sensors.shell-extension.zip: all
|
||||
$(AM_V_at)cp -r "$(builddir)/.build$(datadir)/gnome-shell/extensions/$(uuid)" "$(builddir)/.build"
|
||||
$(AM_V_at)cp -r "$(builddir)/.build$(datadir)/locale" "$(builddir)/.build/$(uuid)"
|
||||
$(AM_V_at)cp -r "$(builddir)/.build$(datadir)/glib-2.0/schemas" "$(builddir)/.build/$(uuid)"
|
||||
$(AM_V_at)cp -r "$(builddir)/.build$(datadir)/icons" "$(builddir)/.build/$(uuid)"
|
||||
$(AM_V_at)glib-compile-schemas "$(builddir)/.build/$(uuid)/schemas"
|
||||
$(AM_V_at)(cd "$(builddir)/.build/$(uuid)/"; zip -qr "$(abs_builddir)/sensors.shell-extension.zip" .)
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ metadata.json: metadata.json.in $(top_builddir)/config.status
|
||||
|
||||
CLEANFILES = metadata.json
|
||||
|
||||
icondir = $(datadir)/icons/hicolor/scalable/status
|
||||
|
||||
icon_DATA = \
|
||||
sensors-fan-symbolic.svg \
|
||||
sensors-temperature-symbolic.svg \
|
||||
sensors-voltage-symbolic.svg
|
||||
|
||||
gschemas_in = org.gnome.shell.extensions.sensors.gschema.xml.in
|
||||
|
||||
@INTLTOOL_XML_NOMERGE_RULE@
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const Gettext = imports.gettext;
|
||||
const Gio = imports.gi.Gio;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
@@ -29,6 +30,20 @@ function initTranslations(domain) {
|
||||
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* initIcons:
|
||||
*
|
||||
* Initialize Gtk to load icons from extensionsdir/icons.
|
||||
*/
|
||||
function initIcons() {
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
let theme = Gtk.IconTheme.get_default();
|
||||
let iconDir = extension.dir.get_child('icons');
|
||||
if(iconDir.query_exists(null))
|
||||
theme.append_search_path(iconDir.get_path());
|
||||
}
|
||||
|
||||
/**
|
||||
* getSettings:
|
||||
* @schema: (optional): the GSettings schema id
|
||||
|
||||
@@ -19,7 +19,7 @@ const SensorsItem = new Lang.Class({
|
||||
Name: 'SensorsItem',
|
||||
Extends: PopupMenu.PopupBaseMenuItem,
|
||||
|
||||
_init: function(label, value) {
|
||||
_init: function(type, label, value) {
|
||||
this.parent();
|
||||
this.connect('activate', function () {
|
||||
settings.set_string('main-sensor', label);
|
||||
@@ -27,6 +27,7 @@ const SensorsItem = new Lang.Class({
|
||||
this._label = label;
|
||||
this._value = value;
|
||||
|
||||
this.addActor(new St.Icon({ style_class: 'system-status-icon', icon_name: 'sensors-'+type+'-symbolic' }));
|
||||
this.addActor(new St.Label({text: label}));
|
||||
this.addActor(new St.Label({text: value}), {align: St.Align.END});
|
||||
},
|
||||
@@ -144,27 +145,27 @@ const SensorsMenuButton = new Lang.Class({
|
||||
if (temp['temp'] > max)
|
||||
max = temp['temp'];
|
||||
|
||||
sensorsList.push(new SensorsItem(temp['label'], this._formatTemp(temp['temp'])));
|
||||
sensorsList.push(new SensorsItem('temperature', temp['label'], this._formatTemp(temp['temp'])));
|
||||
}
|
||||
if (tempInfo.length > 0){
|
||||
sensorsList.push(new PopupMenu.PopupSeparatorMenuItem());
|
||||
|
||||
// Add average and maximum entries
|
||||
sensorsList.push(new SensorsItem(_("Average"), this._formatTemp(sum/tempInfo.length)));
|
||||
sensorsList.push(new SensorsItem(_("Maximum"), this._formatTemp(max)));
|
||||
sensorsList.push(new SensorsItem('temperature', _("Average"), this._formatTemp(sum/tempInfo.length)));
|
||||
sensorsList.push(new SensorsItem('temperature', _("Maximum"), this._formatTemp(max)));
|
||||
|
||||
if(fanInfo.length > 0 || voltageInfo.length > 0)
|
||||
sensorsList.push(new PopupMenu.PopupSeparatorMenuItem());
|
||||
}
|
||||
|
||||
for each (let fan in fanInfo){
|
||||
sensorsList.push(new SensorsItem(fan['label'], _("%drpm").format(fan['rpm'])));
|
||||
sensorsList.push(new SensorsItem('fan', fan['label'], _("%drpm").format(fan['rpm'])));
|
||||
}
|
||||
if (fanInfo.length > 0 && voltageInfo.length > 0){
|
||||
sensorsList.push(new PopupMenu.PopupSeparatorMenuItem());
|
||||
}
|
||||
for each (let voltage in voltageInfo){
|
||||
sensorsList.push(new SensorsItem(voltage['label'], _("%s%.2fV").format(((voltage['volt'] >= 0) ? '+' : '-'), voltage['volt'])));
|
||||
sensorsList.push(new SensorsItem('voltage', voltage['label'], _("%s%.2fV").format(((voltage['volt'] >= 0) ? '+' : '-'), voltage['volt'])));
|
||||
}
|
||||
|
||||
this.statusLabel.set_text(_("N/A")); // Just in case
|
||||
@@ -239,6 +240,7 @@ let sensorsMenu;
|
||||
|
||||
function init(extensionMeta) {
|
||||
Convenience.initTranslations();
|
||||
Convenience.initIcons();
|
||||
settings = Convenience.getSettings();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user