Remove code related to gnome-shell < 3.10, add 3.16 compatibility.

master
None 10 years ago
parent d2289c2569
commit aae436905c
  1. 2
      data/metadata.json.in
  2. 12
      data/panel-osd-settings.ui
  3. 439
      src/extension.js

@ -2,7 +2,7 @@
"uuid": "@uuid@", "uuid": "@uuid@",
"name": "Panel OSD", "name": "Panel OSD",
"description": "Configuring where on the (main) screen notifications will appear, instead of just above the message tray", "description": "Configuring where on the (main) screen notifications will appear, instead of just above the message tray",
"shell-version": [ "3.6", "3.8", "3.10", "3.12", "3.14", "3.15.91" ], "shell-version": [ "3.10", "3.12", "3.14", "3.16"],
"localedir": "@LOCALEDIR@", "localedir": "@LOCALEDIR@",
"url": "@url@" "url": "@url@"
} }

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 --> <!-- Generated with glade 3.18.3 -->
<interface> <interface>
<requires lib="gtk+" version="3.6"/> <requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="delay-adjustment"> <object class="GtkAdjustment" id="delay-adjustment">
<property name="lower">0.5</property> <property name="lower">0.5</property>
<property name="upper">20</property> <property name="upper">20</property>
@ -147,8 +147,6 @@
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -161,8 +159,6 @@
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -176,8 +172,6 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -191,8 +185,6 @@
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">1</property> <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing> </packing>
</child> </child>
</object> </object>

@ -37,18 +37,18 @@ 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
* in our extension to move the OSD. * in our extension to move the OSD.
*/ */
let originalExpandMethod = Main.messageTray._onNotificationExpanded; let originalExpandMethod;
let originalShowNotification = Main.messageTray._showNotification; let originalShowNotification;
let originalUpdateShowingNotification = Main.messageTray._updateShowingNotification; let originalUpdateShowingNotification;
let originalHideNotification = Main.messageTray._hideNotification; let originalHideNotification;
/* /*
* The widget we're interested in * The widget we're interested in
*/ */
let notificationWidget = Main.messageTray._notificationWidget; let notificationWidget;
let panel = Main.layoutManager.panelBox; let panel;
let originalNotificationWidgetX = notificationWidget.x; let originalNotificationWidgetX;
/* /*
* We need these constants to call Tween with values consistent to the * We need these constants to call Tween with values consistent to the
@ -84,6 +84,7 @@ let loadConfig = function() {
if (getTestNotification()) { if (getTestNotification()) {
if (showTestNotificationTimeout !== undefined) if (showTestNotificationTimeout !== undefined)
Mainloop.source_remove(showTestNotificationTimeout); Mainloop.source_remove(showTestNotificationTimeout);
showTestNotificationTimeout = Mainloop.timeout_add(getTestDelay(), Lang.bind(this, function() { 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).")); 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; return false;
@ -137,39 +138,59 @@ let setTestNotification = function(v) {
*/ */
let extensionShowNotification = function() { let extensionShowNotification = function() {
this._notification = this._notificationQueue.shift(); this._notification = this._notificationQueue.shift();
if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
this.emit('queue-changed');
}
this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME; this._userActiveWhileNotificationShown = this.idleMonitor.get_idletime() <= IDLE_TIME;
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) { if (!this._userActiveWhileNotificationShown) {
this._idleMonitorWatchId = this.idleMonitor.add_watch(IDLE_TIME, // If the user isn't active, set up a watch to let us know
Lang.bind(this, this._onIdleMonitorWatch)); // when the user becomes active.
} this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
else
{
if (!this._userActiveWhileNotificationShown) {
// If the user isn't active, set up a watch to let us know
// when the user becomes active.
this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
}
} }
this._notificationClickedId = this._notification.connect('done-displaying', if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
Lang.bind(this, this._escapeTray)); this._banner = this._notification.createBanner();
this._notificationUnfocusedId = this._notification.connect('unfocused', Lang.bind(this, function() { this._bannerClickedId = this._banner.connect('done-displaying',
this._updateState(); Lang.bind(this, this._escapeTray));
})); this._bannerUnfocusedId = this._banner.connect('unfocused', Lang.bind(this, function() {
this._notificationBin.child = this._notification.actor; this._updateState();
}));
this._notificationWidget.opacity = 0; this._bannerBin.add_actor(this._banner.actor);
// JRL changes begin
//this._notificationWidget.y = 0;
let yTop = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height);
let yBottom = 0;
this._notificationWidget.y = (yTop - yBottom) * getY_position() / 100 + yBottom; this._bannerBin._opacity = 0;
// JRL changes end this._bannerBin.opacity = 0;
let yTop = (Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height);
let yBottom = this._banner.actor.height;
this._notificationWidget.show(); this._bannerBin.y = -(yTop - yBottom) * getY_position() / 100 + yBottom;
this._bannerBin.y = -this._banner.actor.height;
this.actor.show();
} else
{
this._notificationClickedId = this._notification.connect('done-displaying',
Lang.bind(this, this._escapeTray));
this._notificationUnfocusedId = this._notification.connect('unfocused', Lang.bind(this, function() {
this._updateState();
}));
this._notificationBin.child = this._notification.actor;
this._notificationWidget.opacity = 0;
// JRL changes begin
//this._notificationWidget.y = 0;
let yTop = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height);
let yBottom = 0;
this._notificationWidget.y = (yTop - yBottom) * getY_position() / 100 + yBottom;
// JRL changes end
this._notificationWidget.show();
}
this._updateShowingNotification(); this._updateShowingNotification();
@ -186,7 +207,7 @@ let extensionShowNotification = function() {
// the mouse is moving towards it or within it. // the mouse is moving towards it or within it.
this._lastSeenMouseX = x; this._lastSeenMouseX = x;
this._lastSeenMouseY = y; this._lastSeenMouseY = y;
if (ExtensionUtils.versionCheck(['3.14'], Config.PACKAGE_VERSION)) { if (ExtensionUtils.versionCheck(['3.14','3.16'], Config.PACKAGE_VERSION)) {
this._resetNotificationLeftTimeout(); this._resetNotificationLeftTimeout();
} }
}; };
@ -200,64 +221,36 @@ let extensionShowNotification = function() {
* entire screen. * entire screen.
*/ */
let extensionHideNotification = function(animate) { let extensionHideNotification = function(animate) {
if (ExtensionUtils.versionCheck(['3.6', '3.8'], Config.PACKAGE_VERSION)) { this._notificationFocusGrabber.ungrabFocus();
// HACK!
// There seems to be a reentrancy issue in calling .ungrab() here,
// which causes _updateState to be called before _notificationState
// becomes HIDING. That hides the notification again, nullifying the
// object but not setting _notificationState (and that's the weird part)
// As then _notificationState is stuck into SHOWN but _notification
// is null, every new _updateState fails and the message tray is
// lost forever.
//
// See more at https://bugzilla.gnome.org/show_bug.cgi?id=683986
this._notificationState = State.HIDING;
this._grabHelper.ungrab({ actor: this._notification.actor });
}
else
{
this._notificationFocusGrabber.ungrabFocus();
}
if (this._notificationExpandedId) {
this._notification.disconnect(this._notificationExpandedId);
this._notificationExpandedId = 0;
}
// JRL changes begin
let yPos; let yPos;
if (getY_position() < 50) if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
yPos = this.actor.height; if (getY_position() < 50)
else yPos = Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height;
yPos = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height); else
// JRL changes end yPos = -this._bannerBin.height;
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
if (this._notificationRemoved) {
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this._notificationWidget.y = yPos;
// JRL changes end
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
this._hideNotificationCompleted();
} else {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
// JRL changes begin
//{ y: this.actor.height,
{ y: yPos,
// JRL changes end
opacity: 0,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this._hideNotificationCompleted,
onCompleteScope: this
});
if (this._bannerClickedId) {
this._banner.disconnect(this._bannerClickedId);
this._bannerClickedId = 0;
} }
} if (this._bannerUnfocusedId) {
else this._banner.disconnect(this._bannerUnfocusedId);
this._bannerUnfocusedId = 0;
}
}else
{ {
if (this._notificationExpandedId) {
this._notification.disconnect(this._notificationExpandedId);
this._notificationExpandedId = 0;
}
// JRL changes begin
if (getY_position() < 50)
yPos = this.actor.height;
else
yPos = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height);
// JRL changes end
if (this._notificationClickedId) { if (this._notificationClickedId) {
this._notification.disconnect(this._notificationClickedId); this._notification.disconnect(this._notificationClickedId);
this._notificationClickedId = 0; this._notificationClickedId = 0;
@ -266,78 +259,51 @@ let extensionHideNotification = function(animate) {
this._notification.disconnect(this._notificationUnfocusedId); this._notification.disconnect(this._notificationUnfocusedId);
this._notificationUnfocusedId = 0; this._notificationUnfocusedId = 0;
} }
}
if (ExtensionUtils.versionCheck(['3.8'], Config.PACKAGE_VERSION)) { if (ExtensionUtils.versionCheck(['3.14','3.16'], Config.PACKAGE_VERSION)) {
this._useLongerTrayLeftTimeout = false; this._resetNotificationLeftTimeout();
if (this._trayLeftTimeoutId) { }
Mainloop.source_remove(this._trayLeftTimeoutId); else
this._trayLeftTimeoutId = 0; {
this._trayLeftMouseX = -1; if (this._notificationLeftTimeoutId) {
this._trayLeftMouseY = -1; Mainloop.source_remove(this._notificationLeftTimeoutId);
} this._notificationLeftTimeoutId = 0;
this._notificationLeftMouseX = -1;
this._notificationLeftMouseY = -1;
}
}
if (this._notificationRemoved) { // JRL changes begin
Tweener.removeTweens(this._notificationWidget); let theNotification;
// JRL changes begin if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
//this._notificationWidget.y = this.actor.height; theNotification = this._bannerBin;
this._notificationWidget.y = yPos; }else
// JRL changes end {
this._notificationWidget.opacity = 0; theNotification =this._notificationWidget;
this._notificationState = State.HIDDEN; }
this._hideNotificationCompleted(); // JRL changes end
} else {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
// JRL changes begin
//{ y: this.actor.height,
{ y: yPos,
// JRL changes end
opacity: 0,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this._hideNotificationCompleted,
onCompleteScope: this
});
}
}
else
{
if (ExtensionUtils.versionCheck(['3.14'], Config.PACKAGE_VERSION)) {
this._resetNotificationLeftTimeout();
}
else
{
if (this._notificationLeftTimeoutId) {
Mainloop.source_remove(this._notificationLeftTimeoutId);
this._notificationLeftTimeoutId = 0;
this._notificationLeftMouseX = -1;
this._notificationLeftMouseY = -1;
}
}
if (animate) { if (animate) {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN, // JRL changes begin
// JRL changes begin this._tween(theNotification, '_notificationState', State.HIDDEN,
//{ y: this.actor.height, { y: yPos,
{ y: yPos, // JRL changes end
// JRL changes end opacity: 0,
opacity: 0, time: ANIMATION_TIME,
time: ANIMATION_TIME, transition: 'easeOutQuad',
transition: 'easeOutQuad', onComplete: this._hideNotificationCompleted,
onComplete: this._hideNotificationCompleted, onCompleteScope: this
onCompleteScope: this });
}); } else {
} else { // JRL changes begin
Tweener.removeTweens(this._notificationWidget); Tweener.removeTweens(theNotification);
// JRL changes begin theNotification.y = yPos;
//this._notificationWidget.y = this.actor.height; theNotification.opacity = 0;
this._notificationWidget.y = yPos; // JRL changes end
// JRL changes end this._notificationState = State.HIDDEN;
this._notificationWidget.opacity = 0; this._hideNotificationCompleted();
this._notificationState = State.HIDDEN;
this._hideNotificationCompleted();
}
}
} }
}; };
@ -353,65 +319,84 @@ let extensionHideNotification = function(animate) {
let extensionUpdateShowingNotification = function() { let extensionUpdateShowingNotification = function() {
// JRL changes begin // JRL changes begin
// first reset the border-radius to the default // first reset the border-radius to the default
this._notification._table.set_style('border-radius:;'); if (!ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
if (getY_position() > 0.1) this._notification._table.set_style('border-radius:;');
{ if (getY_position() > 0.1)
// fix the border-radiuses, depending on the position
let tl, tr;
let bl = this._notification._table.get_theme_node().get_border_radius(St.Corner.TOPLEFT);
let br = this._notification._table.get_theme_node().get_border_radius(St.Corner.TOPRIGHT);
if (getY_position() >= 99.9)
{
tl = this._notification._table.get_theme_node().get_border_radius(St.Corner.BOTTOMLEFT);
tr = this._notification._table.get_theme_node().get_border_radius(St.Corner.BOTTOMRIGHT);
}
else
{ {
tl = bl; // fix the border-radiuses, depending on the position
tr = br; let tl, tr;
let bl = this._notification._table.get_theme_node().get_border_radius(St.Corner.TOPLEFT);
let br = this._notification._table.get_theme_node().get_border_radius(St.Corner.TOPRIGHT);
if (getY_position() >= 99.9)
{
tl = this._notification._table.get_theme_node().get_border_radius(St.Corner.BOTTOMLEFT);
tr = this._notification._table.get_theme_node().get_border_radius(St.Corner.BOTTOMRIGHT);
}
else
{
tl = bl;
tr = br;
}
this._notification._table.set_style(_('border-radius: %dpx %dpx %dpx %dpx;').format(tl, tr, bl, br));
} }
this._notification._table.set_style(_('border-radius: %dpx %dpx %dpx %dpx;').format(tl, tr, bl, br));
} }
// JRL changes end // JRL changes end
this._notification.acknowledged = true; this._notification.acknowledged = true;
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) { this._notification.playSound();
// We auto-expand notifications with CRITICAL urgency. // We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
// is on in the control center.
if (this._notification.urgency == Urgency.CRITICAL ||
// JRL changes begin // JRL changes begin
// if (this._notification.urgency == Urgency.CRITICAL) getForce_expand() ||
if (this._notification.urgency == Urgency.CRITICAL ||
getForce_expand())
// JRL changes end // JRL changes end
this._expandNotification(true); this._notification.source.policy.forceExpanded)
} {
else if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION))
{ this._expandBanner(true);
this._notification.playSound(); else
// We auto-expand notifications with CRITICAL urgency, or for which the relevant setting this._expandNotification(true);
// is on in the control center. }
if (this._notification.urgency == Urgency.CRITICAL ||
// JRL changes begin
getForce_expand() ||
// JRL changes end
this._notification.source.policy.forceExpanded)
this._expandNotification(true);
}
// JRL changes begin // JRL changes begin
let theNotification;
if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
theNotification = this._bannerBin;
}else
{
theNotification =this._notificationWidget;
}
// use panel's y and height property to determine the bottom of the top-panel. // use panel's y and height property to determine the bottom of the top-panel.
// needed because the "hide top bar" and "hide top panel" use different approaches to hide the // needed because the "hide top bar" and "hide top panel" use different approaches to hide the
// top bar. // top bar.
// "hide top panel" keeps the height and just moves the panel out of the visible area, so using // "hide top panel" keeps the height and just moves the panel out of the visible area, so using
// the panels-height is not enough. // the panels-height is not enough.
let yTop = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height); let yPos;
if (Main.layoutManager.bottomMonitor == Main.layoutManager.primaryMonitor) if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
yTop += (panel.y + panel.height); let yTop = Main.layoutManager.bottomMonitor.y
if (yTop < (-Main.layoutManager.bottomMonitor.height))
yTop = -Main.layoutManager.bottomMonitor.height;
let yBottom = -this._notificationWidget.height;
let yPos = (yTop - yBottom) * getY_position() / 100 + yBottom; if (Main.layoutManager.bottomMonitor == Main.layoutManager.primaryMonitor)
// yTop += (panel.y + panel.height);
this._notificationWidget.x = (Main.layoutManager.bottomMonitor.width - this._notificationWidget.width) * (getX_position() - 50) / 50;
let yBottom = theNotification.height;
yPos = (Main.layoutManager.bottomMonitor.height - yTop - yBottom) * (100-getY_position()) / 100;
if (yPos > (Main.layoutManager.bottomMonitor.height - theNotification.height))
yPos = Main.layoutManager.bottomMonitor.height - theNotification.height;
}else
{
let yTop = -(Main.layoutManager.bottomMonitor.y + Main.layoutManager.bottomMonitor.height);
if (Main.layoutManager.bottomMonitor == Main.layoutManager.primaryMonitor)
yTop += (panel.y + panel.height);
if (yTop < (-Main.layoutManager.bottomMonitor.height))
yTop = -Main.layoutManager.bottomMonitor.height;
let yBottom = -theNotification.height;
yPos = (yTop - yBottom) * getY_position() / 100 + yBottom;
//
}
theNotification.x = (Main.layoutManager.bottomMonitor.width - theNotification.width) * (getX_position() - 50) / 50;
// JRL changes end // JRL changes end
// We tween all notifications to full opacity. This ensures that both new notifications and // We tween all notifications to full opacity. This ensures that both new notifications and
// notifications that might have been in the process of hiding get full opacity. // notifications that might have been in the process of hiding get full opacity.
@ -424,18 +409,31 @@ let extensionUpdateShowingNotification = function() {
// We use this._showNotificationCompleted() onComplete callback to extend the time the updated // We use this._showNotificationCompleted() onComplete callback to extend the time the updated
// notification is being shown. // notification is being shown.
let tweenParams = { opacity: 255, let tweenParams;
// JRL changes begin if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
//y: -this._notificationWidget.height, tweenParams = { _opacity: 255,
y: yPos, y: yPos,
// JRL changes end time: ANIMATION_TIME,
time: ANIMATION_TIME, transition: 'easeOutBack',
transition: 'easeOutQuad', onUpdate: this._clampOpacity,
onComplete: this._showNotificationCompleted, onUpdateScope: this,
onCompleteScope: this onComplete: this._showNotificationCompleted,
}; onCompleteScope: this
};
this._tween(this._notificationWidget, '_notificationState', State.SHOWN, tweenParams); }else
{
tweenParams = { opacity: 255,
// JRL changes begin
y: yPos,
// JRL changes end
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this._showNotificationCompleted,
onCompleteScope: this
};
}
this._tween(theNotification, '_notificationState', State.SHOWN, tweenParams);
}; };
/* /*
@ -496,6 +494,23 @@ let extensiononNotificationExpanded = function() {
* Overload the methods. * Overload the methods.
*/ */
function enable() { function enable() {
if (ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
notificationWidget = Main.messageTray._bannerBin;
}else
{
notificationWidget = Main.messageTray._notificationWidget;
originalExpandMethod = Main.messageTray._onNotificationExpanded;
}
originalShowNotification = Main.messageTray._showNotification;
originalUpdateShowingNotification = Main.messageTray._updateShowingNotification;
originalHideNotification = Main.messageTray._hideNotification;
panel = Main.layoutManager.panelBox;
originalNotificationWidgetX = notificationWidget.x;
Main.messageTray._showNotification = extensionShowNotification; Main.messageTray._showNotification = extensionShowNotification;
Main.messageTray._hideNotification = extensionHideNotification; Main.messageTray._hideNotification = extensionHideNotification;
Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification; Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification;
@ -524,5 +539,7 @@ function disable() {
Main.messageTray._showNotification = originalShowNotification; Main.messageTray._showNotification = originalShowNotification;
Main.messageTray._hideNotification = originalHideNotification; Main.messageTray._hideNotification = originalHideNotification;
Main.messageTray._updateShowingNotification = originalUpdateShowingNotification; Main.messageTray._updateShowingNotification = originalUpdateShowingNotification;
Main.messageTray._onNotificationExpanded = originalExpandMethod; if (!ExtensionUtils.versionCheck(['3.16'], Config.PACKAGE_VERSION)) {
Main.messageTray._onNotificationExpanded = originalExpandMethod;
}
} }

Loading…
Cancel
Save