Skip to content

Commit

Permalink
Merge pull request #26 from andr3slelouch/development
Browse files Browse the repository at this point in the history
Fixed extension for being accepted in the store
  • Loading branch information
andr3slelouch authored May 15, 2021
2 parents 0d714c3 + f7626e8 commit 9c8c9a9
Showing 1 changed file with 34 additions and 36 deletions.
70 changes: 34 additions & 36 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@ const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const ByteArray = imports.byteArray;
const Gtk = imports.gi.Gtk;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Gettext = imports.gettext;
const Prime = Me.imports.prime;

Gettext.bindtextdomain(
"OptimusManagerIndicator",
Me.dir.get_child("locale").get_path()
);
Gettext.textdomain("OptimusManagerIndicator");

const _ = Gettext.gettext;
const Domain = Gettext.domain("OptimusManagerIndicator");
const _ = Domain.gettext;

let nvidiaSettings = "nvidia-settings -p 'PRIME Profiles'";
let panelTempText,
timeout,
statusIcon,
panelGpuUtilizationText,
panelGpuMemoryText;

/**
* This is our Optimus Manager Indicator instance.
*/
let optimusManagerIndicator;
/**
* Optimus Manager Dialog Class:
* Dialog for asking confirmation to the user for switching profiles
Expand Down Expand Up @@ -164,6 +163,27 @@ const OptimusManagerIndicator = new Lang.Class({
Name: "OptimusManagerIndicator",
Extends: PanelMenu.Button,

/**
* This function is called by GNOME Shell to enable the extension.
*/
enable: function () {
optimusManagerIndicator = new OptimusManagerIndicator();
Main.panel.addToStatusArea(
"optimus-manager-indicator",
optimusManagerIndicator
);
},

/**
* This function is called by GNOME Shell to disable the extension.
*/
disable: function () {
Mainloop.source_remove(timeout);
optimusManagerIndicator.destroy();
panelTempText.destroy();
panelGpuUtilizationText.destroy();
panelGpuMemoryText.destroy();
},
/**
* This function sets the status icon.
*/
Expand Down Expand Up @@ -568,33 +588,6 @@ const OptimusManagerIndicator = new Lang.Class({
},
});

/**
* This is our Optimus Manager Indicator instance.
*/
let optimusManagerIndicator;

/**
* This function is called by GNOME Shell to enable the extension.
*/
function enable() {
optimusManagerIndicator = new OptimusManagerIndicator();
Main.panel.addToStatusArea(
"optimus-manager-indicator",
optimusManagerIndicator
);
}

/**
* This function is called by GNOME Shell to disable the extension.
*/
function disable() {
Mainloop.source_remove(timeout);
optimusManagerIndicator.destroy();
panelTempText.destroy();
panelGpuUtilizationText.destroy();
panelGpuMemoryText.destroy();
}

function getSettings() {
let GioSSS = Gio.SettingsSchemaSource;
let schemaSource = GioSSS.new_from_directory(
Expand All @@ -611,3 +604,8 @@ function getSettings() {
}
return new Gio.Settings({ settings_schema: schemaObj });
}

function init() {
ExtensionUtils.initTranslations("OptimusManagerIndicator");
return new OptimusManagerIndicator();
}

0 comments on commit 9c8c9a9

Please sign in to comment.