// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-

// contain various tweaks/fixes that are not main features of SLE Classic but
// nevertheless needed. This file is organized in structure similar to that of
// an extension, however it's _manually_ loaded by the "extension.js".

const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Shell = imports.gi.Shell;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Signals = imports.signals;
const St = imports.gi.St;

const DND = imports.ui.dnd;
const Main = imports.ui.main;
const Params = imports.misc.params;
const Search = imports.ui.search;
const Util = imports.misc.util;

// lock screen AggregateMenu update
let hidePowerIndicatorHandlerId;

function init(){
    // hide power indicator when it's locked, as the computer is not allowed to
    // turn off in locked state.
    //
    // See bnc#865977. WARNING: This is not a complete fix for the issue of
    // power management in lock screen, as currently any user can still switch
    // to gdm and turn off the computer without any authorization. (A upstream
    // bug in fact)
    //
    let MAggretegatePowerIndicator = Main.panel.statusArea.aggregateMenu._power;
    hidePowerIndicatorHandlerId =
        Main.sessionMode.connect('updated',
                                 Lang.bind(MAggretegatePowerIndicator,
                                           function (){
                                               let sensitive = Main.sessionMode.isLocked || Main.sessionMode.isGreeter;
                                               if ( sensitive ){
                                                   MAggretegatePowerIndicator.indicators.hide();
                                               }
                                               else {
                                                   MAggretegatePowerIndicator.indicators.show();
                                               }
                                           }));

    // force an update to avoid background failure bnc#893979
    Main.layoutManager.emit('monitors-changed');
}

function enable(){
    
}

function disable(){
    
}
