@ -17,18 +17,20 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Config = imports . misc . config ;
const Config = imports . misc . config ;
const Main = imports . ui . main ;
const Main = imports . ui . main ;
const Tweener = imports . ui . tweener ;
const Tweener = imports . ui . tweener ;
const LayoutManager = Main . layoutManager ;
const Lang = imports . lang ;
const Lang = imports . lang ;
const Mainloop = imports . mainloop ;
const Me = ExtensionUtils . getCurrentExtension ( ) ;
const Me = ExtensionUtils . getCurrentExtension ( ) ;
const Convenience = Me . imports . convenience ;
const Convenience = Me . imports . convenience ;
const EXTENSIONDIR = Me . dir . get _path ( ) ;
const Gettext = imports . gettext . domain ( 'gnome-shell-extension-panel-osd' ) ;
const _ = Gettext . gettext ;
const PANEL _OSD _SETTINGS _SCHEMA = 'org.gnome.shell.extensions.panel-osd' ;
const PANEL _OSD _SETTINGS _SCHEMA = 'org.gnome.shell.extensions.panel-osd' ;
const PANEL _OSD _X _POS _KEY = 'x-pos' ;
const PANEL _OSD _X _POS _KEY = 'x-pos' ;
const PANEL _OSD _Y _POS _KEY = 'y-pos' ;
const PANEL _OSD _Y _POS _KEY = 'y-pos' ;
const PANEL _OSD _FORCE _EXPAND = 'force-expand' ;
const PANEL _OSD _TEST _DELAY = 'test-delay' ;
const PANEL _OSD _TEST _NOTIFICATION = 'test-notification' ;
/ *
/ *
* Save MessageTray 's original methods. We' re going to change these
* Save MessageTray 's original methods. We' re going to change these
@ -66,12 +68,28 @@ const State = {
HIDING : 3
HIDING : 3
} ;
} ;
function init ( ) { }
function init ( ) {
Convenience . initTranslations ( 'gnome-shell-extension-panel-osd' ) ;
}
let Settings ;
let Settings ;
let SettingsC ;
let showTestNotificationTimeout ;
let loadConfig = function ( ) {
let loadConfig = function ( ) {
Settings = Convenience . getSettings ( PANEL _OSD _SETTINGS _SCHEMA ) ;
Settings = Convenience . getSettings ( PANEL _OSD _SETTINGS _SCHEMA ) ;
SettingsC = Settings . connect ( "changed" , function ( ) {
if ( getTestNotification ( ) ) {
if ( showTestNotificationTimeout !== undefined )
Mainloop . source _remove ( showTestNotificationTimeout ) ;
showTestNotificationTimeout = Mainloop . timeout _add ( getTestDelay ( ) , Lang . bind ( this , function ( ) {
Main . notify ( "Panel OSD" , _ ( "This is just a multiline test-message to show where the notification will be placed and to test expansion (showing details)." ) ) ;
return false ;
} ) ) ;
setTestNotification ( false ) ;
}
} ) ;
} ;
} ;
let getX _position = function ( ) {
let getX _position = function ( ) {
@ -80,13 +98,35 @@ let getX_position = function() {
return Settings . get _double ( PANEL _OSD _X _POS _KEY ) ;
return Settings . get _double ( PANEL _OSD _X _POS _KEY ) ;
} ;
} ;
let gety _position = function ( ) {
let getY _position = function ( ) {
if ( ! Settings )
if ( ! Settings )
loadConfig ( ) ;
loadConfig ( ) ;
return Settings . get _double ( PANEL _OSD _Y _POS _KEY ) ;
return Settings . get _double ( PANEL _OSD _Y _POS _KEY ) ;
} ;
} ;
let getForce _expand = function ( ) {
if ( ! Settings )
loadConfig ( ) ;
return Settings . get _boolean ( PANEL _OSD _FORCE _EXPAND ) ;
} ;
let getTestDelay = function ( ) {
if ( ! Settings )
loadConfig ( ) ;
return Math . floor ( 1000 * Settings . get _double ( PANEL _OSD _TEST _DELAY ) ) ;
} ;
let getTestNotification = function ( ) {
if ( ! Settings )
loadConfig ( ) ;
return Settings . get _boolean ( PANEL _OSD _TEST _NOTIFICATION ) ;
} ;
let setTestNotification = function ( v ) {
if ( ! Settings )
loadConfig ( ) ;
Settings . set _boolean ( PANEL _OSD _TEST _NOTIFICATION , v ) ;
} ;
/ *
/ *
* Copied from MessageTray . _showNotification ( )
* Copied from MessageTray . _showNotification ( )
*
*
@ -124,7 +164,7 @@ let extensionShowNotification = function() {
let yTop = - global . screen _height ;
let yTop = - global . screen _height ;
let yBottom = 0 ;
let yBottom = 0 ;
this . _notificationWidget . y = ( yTop - yBottom ) * gety _position ( ) / 100 + yBottom ;
this . _notificationWidget . y = ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
// JRL changes end
// JRL changes end
@ -182,7 +222,7 @@ let extensionHideNotification = function(animate) {
}
}
// JRL changes begin
// JRL changes begin
let yPos ;
let yPos ;
if ( gety _position ( ) < 50 )
if ( getY _position ( ) < 50 )
yPos = this . actor . height ;
yPos = this . actor . height ;
else
else
yPos = - global . screen _height ;
yPos = - global . screen _height ;
@ -306,9 +346,9 @@ let extensionUpdateShowingNotification = function() {
this . _notification . _table . remove _style _class _name ( 'jrlnotification' ) ;
this . _notification . _table . remove _style _class _name ( 'jrlnotification' ) ;
this . _notification . _table . remove _style _class _name ( 'jrlnotification_top' ) ;
this . _notification . _table . remove _style _class _name ( 'jrlnotification_top' ) ;
this . _notification . _table . remove _style _class _name ( 'jrlnotification_bottom' ) ;
this . _notification . _table . remove _style _class _name ( 'jrlnotification_bottom' ) ;
if ( gety _position ( ) <= 0.1 )
if ( getY _position ( ) <= 0.1 )
this . _notification . _table . add _style _class _name ( 'jrlnotification_bottom' ) ;
this . _notification . _table . add _style _class _name ( 'jrlnotification_bottom' ) ;
else if ( gety _position ( ) >= 99.9 )
else if ( getY _position ( ) >= 99.9 )
this . _notification . _table . add _style _class _name ( 'jrlnotification_top' ) ;
this . _notification . _table . add _style _class _name ( 'jrlnotification_top' ) ;
else
else
this . _notification . _table . add _style _class _name ( 'jrlnotification' ) ;
this . _notification . _table . add _style _class _name ( 'jrlnotification' ) ;
@ -317,7 +357,11 @@ let extensionUpdateShowingNotification = function() {
this . _notification . acknowledged = true ;
this . _notification . acknowledged = true ;
if ( ExtensionUtils . versionCheck ( [ '3.6' ] , Config . PACKAGE _VERSION ) ) {
if ( ExtensionUtils . versionCheck ( [ '3.6' ] , Config . PACKAGE _VERSION ) ) {
// We auto-expand notifications with CRITICAL urgency.
// We auto-expand notifications with CRITICAL urgency.
if ( this . _notification . urgency == Urgency . CRITICAL )
// JRL changes begin
// if (this._notification.urgency == Urgency.CRITICAL)
if ( this . _notification . urgency == Urgency . CRITICAL ||
getForce _expand ( ) )
// JRL changes end
this . _expandNotification ( true ) ;
this . _expandNotification ( true ) ;
}
}
else
else
@ -326,6 +370,9 @@ let extensionUpdateShowingNotification = function() {
// We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
// We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
// is on in the control center.
// is on in the control center.
if ( this . _notification . urgency == Urgency . CRITICAL ||
if ( this . _notification . urgency == Urgency . CRITICAL ||
// JRL changes begin
getForce _expand ( ) ||
// JRL changes end
this . _notification . source . policy . forceExpanded )
this . _notification . source . policy . forceExpanded )
this . _expandNotification ( true ) ;
this . _expandNotification ( true ) ;
}
}
@ -341,7 +388,7 @@ let extensionUpdateShowingNotification = function() {
yTop = - global . screen _height ;
yTop = - global . screen _height ;
let yBottom = - this . _notificationWidget . height ;
let yBottom = - this . _notificationWidget . height ;
let yPos = ( yTop - yBottom ) * gety _position ( ) / 100 + yBottom ;
let yPos = ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
//
//
this . _notificationWidget . x = ( global . screen _width - this . _notificationWidget . width ) * ( getX _position ( ) - 50 ) / 50 ;
this . _notificationWidget . x = ( global . screen _width - this . _notificationWidget . width ) * ( getX _position ( ) - 50 ) / 50 ;
// JRL changes end
// JRL changes end
@ -386,7 +433,7 @@ let extensiononNotificationExpanded = function() {
yTop = - global . screen _height ;
yTop = - global . screen _height ;
let yBottom = - this . _notificationWidget . height ;
let yBottom = - this . _notificationWidget . height ;
let expandedY = ( yTop - yBottom ) * gety _position ( ) / 100 + yBottom ;
let expandedY = ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
// JRL changes end
// JRL changes end
this . _closeButton . show ( ) ;
this . _closeButton . show ( ) ;
@ -414,6 +461,7 @@ function enable() {
Main . messageTray . _hideNotification = extensionHideNotification ;
Main . messageTray . _hideNotification = extensionHideNotification ;
Main . messageTray . _updateShowingNotification = extensionUpdateShowingNotification ;
Main . messageTray . _updateShowingNotification = extensionUpdateShowingNotification ;
Main . messageTray . _onNotificationExpanded = extensiononNotificationExpanded ;
Main . messageTray . _onNotificationExpanded = extensiononNotificationExpanded ;
loadConfig ( ) ;
}
}
@ -421,6 +469,14 @@ function enable() {
* Put everything back .
* Put everything back .
* /
* /
function disable ( ) {
function disable ( ) {
if ( SettingsC ) {
Settings . disconnect ( SettingsC ) ;
SettingsC = undefined ;
}
if ( showTestNotificationTimeout !== undefined )
Mainloop . source _remove ( showTestNotificationTimeout ) ;
// remove our style, in case we just show a notification, otherwise the radius is drawn incorrect
// remove our style, in case we just show a notification, otherwise the radius is drawn incorrect
if ( Main . messageTray . _notification ) {
if ( Main . messageTray . _notification ) {
Main . messageTray . _notification . _table . remove _style _class _name ( 'jrlnotification' ) ;
Main . messageTray . _notification . _table . remove _style _class _name ( 'jrlnotification' ) ;