Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Fixed Typo and added modularity
Browse files Browse the repository at this point in the history
Fixed the lettemp typo and added modularity by determining the menu type on enable() rather than on initialization (i.e. in case noally is enabled prior to enabling presentation mode). I also added some comments.
  • Loading branch information
Mystro256 committed Nov 30, 2011
1 parent 58c06b7 commit e39a105
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,36 @@ const SessionIface = {
};
let SessionProxy = DBus.makeProxyClass(SessionIface);

// Put your extension initialization code here
// Initialization code here:
function init(extensionMeta) {
// To Avoid issues and glitching, this needs to be placed here as
// batteryMenu must be constant after initialization to avoid
// problems with enable and disable functions

//Default Value on batteryMenu, it maybe changed on enable()
batteryMenu = Main.panel._statusArea.battery;

imports.gettext.bindtextdomain("gnome-shell-extension-presentationmode",
extensionMeta.path + "/locale");
imports.gettext.textdomain("gnome-shell-extension-presentationmode");
}

function enable() {
//Temporary variable to check power devices
let temp = Main.panel._statusArea.battery._deviceItems;
if(temp == "")
{//check for no battery or power device, i.e. no power menu
lettemp = new Main.Panel.STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION["a11y"]
{ //check for no battery or power device, i.e. no battery menu
let temp = new Main.Panel.STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION["a11y"]
if(Main.panel._statusArea.a11y != null)
{//check for no a11y (such as from noa11y extension)
{ //check for no a11y (such as from noa11y extension)
batteryMenu = Main.panel._statusArea.a11y;
}
else
{//else use the user menu
{ //else wise, resort to using the user menu
batteryMenu = Main.panel._statusArea.userMenu;
}
}
imports.gettext.bindtextdomain("gnome-shell-extension-presentationmode",
extensionMeta.path + "/locale");
imports.gettext.textdomain("gnome-shell-extension-presentationmode");
}

function enable() {
else
{ //If all else is good, the battery menu is fine
batteryMenu = Main.panel._statusArea.battery;
}
//Add the Presentation mode Option
batteryMenu._itemSeparator = new PopupMenu.PopupSeparatorMenuItem();
batteryMenu.menu.addMenuItem(batteryMenu._itemSeparator);
batteryMenu._presentationswitch = new PopupMenu.PopupSwitchMenuItem(_("Presentation mode"), false);
Expand Down

0 comments on commit e39a105

Please sign in to comment.