Make y-position configurable.

master
Jens Lody 11 years ago
parent 2b3573f56f
commit 6cab93b472
  1. 4
      data/org.gnome.shell.extensions.panel-osd.gschema.xml.in
  2. 55
      data/panel-osd-settings.ui
  3. 8
      data/stylesheet.css
  4. 64
      src/extension.js
  5. 31
      src/prefs.js

@ -4,5 +4,9 @@
<default>50.0</default>
<_summary>Horizontal position of notification.</_summary>
</key>
<key name="y-pos" type="d">
<default>0.0</default>
<_summary>Vertical position of notification.</_summary>
</key>
</schema>
</schemalist>

@ -7,6 +7,11 @@
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">2</property>
</object>
<object class="GtkAdjustment" id="y-adjustment">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">2</property>
</object>
<object class="GtkBox" id="main-widget">
<property name="can_focus">False</property>
<property name="margin_top">5</property>
@ -30,6 +35,7 @@
</child>
<child>
<object class="GtkScale" id="scale-x-pos">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@ -44,6 +50,51 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-y-pos">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Vertical position [%] from 0% (bottom) to 100% (top)</property>
<property name="ellipsize">start</property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkScale" id="scale-y-pos">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">y-adjustment</property>
<property name="show_fill_level">True</property>
<property name="restrict_to_fill_level">False</property>
<property name="fill_level">100</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator1">
<property name="visible">True</property>
@ -56,7 +107,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">5</property>
</packing>
</child>
<child>
@ -70,7 +121,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">6</property>
</packing>
</child>
</object>

@ -1,3 +1,9 @@
.jrlnotification {
.jrlnotification_top {
border-radius: 0px 0px 10px 10px;
}
.jrlnotification_bottom {
border-radius: 10px 10px 0px 0px;
}
.jrlnotification {
border-radius: 10px 10px 10px 10px;
}

@ -25,6 +25,7 @@ const EXTENSIONDIR = Me.dir.get_path();
const PANEL_OSD_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd';
const PANEL_OSD_X_POS_KEY = 'x-pos';
const PANEL_OSD_Y_POS_KEY = 'y-pos';
@ -79,6 +80,12 @@ let getX_position = function() {
return Settings.get_double(PANEL_OSD_X_POS_KEY);
}
let gety_position = function() {
if (!Settings)
loadConfig();
return Settings.get_double(PANEL_OSD_Y_POS_KEY);
}
/*
* Copied from MessageTray._showNotification()
@ -114,7 +121,10 @@ let extensionShowNotification = function () {
this._notificationWidget.opacity = 0;
// JRL changes begin
//this._notificationWidget.y = 0;
this._notificationWidget.y = -global.screen_height;
let yTop = -global.screen_height;
let yBottom = 0;
this._notificationWidget.y = (yTop - yBottom) * gety_position() / 100 + yBottom;
// JRL changes end
@ -170,12 +180,19 @@ let extensionHideNotification = function(animate) {
this._notification.disconnect(this._notificationExpandedId);
this._notificationExpandedId = 0;
}
// JRL changes begin
let yPos;
if (gety_position() < 50)
yPos = this.actor.height;
else
yPos = -global.screen_height;
// JRL changes end
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
if (this._notificationRemoved) {
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this._notificationWidget.y = -global.screen_height;
this._notificationWidget.y = yPos;
// JRL changes end
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
@ -184,7 +201,7 @@ let extensionHideNotification = function(animate) {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
// JRL changes begin
//{ y: this.actor.height,
{ y: -global.screen_height,
{ y: yPos,
// JRL changes end
opacity: 0,
time: ANIMATION_TIME,
@ -219,7 +236,7 @@ let extensionHideNotification = function(animate) {
Tweener.removeTweens(this._notificationWidget);
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this._notificationWidget.y = -global.screen_height;
this._notificationWidget.y = yPos;
// JRL changes end
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
@ -228,7 +245,7 @@ let extensionHideNotification = function(animate) {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
// JRL changes begin
//{ y: this.actor.height,
{ y: -global.screen_height,
{ y: yPos,
// JRL changes end
opacity: 0,
time: ANIMATION_TIME,
@ -252,7 +269,7 @@ let extensionHideNotification = function(animate) {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
// JRL changes begin
//{ y: this.actor.height,
{ y: -global.screen_height,
{ y: yPos,
// JRL changes end
opacity: 0,
time: ANIMATION_TIME,
@ -264,7 +281,7 @@ let extensionHideNotification = function(animate) {
Tweener.removeTweens(this._notificationWidget);
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this._notificationWidget.y = -global.screen_height;
this._notificationWidget.y = yPos;
// JRL changes end
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
@ -286,7 +303,16 @@ let extensionHideNotification = function(animate) {
let extensionUpdateShowingNotification = function() {
// JRL changes begin
// add own class-name to change border-radius, otherwise the changed value remains after switching off the extension
this._notification._table.add_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_bottom');
if (gety_position() <= 0.1)
this._notification._table.add_style_class_name('jrlnotification_bottom');
else if (gety_position() >= 99.9)
this._notification._table.add_style_class_name('jrlnotification_top');
else
this._notification._table.add_style_class_name('jrlnotification');
// JRL changes end
this._notification.acknowledged = true;
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
@ -310,9 +336,12 @@ let extensionUpdateShowingNotification = function() {
// top bar.
// "hide top panel" keeps the height and just moves the panel out of the visible area, so using
// the panels-height is not enough.
let yPos = panel.y + panel.height - global.screen_height;
if (yPos < (-global.screen_height))
yPos = -global.screen_height;
let yTop = panel.y + panel.height - global.screen_height;
if (yTop < (-global.screen_height))
yTop = -global.screen_height;
let yBottom = -this._notificationWidget.height;
let yPos = (yTop - yBottom) * gety_position() / 100 + yBottom;
//
this._notificationWidget.x = (global.screen_width - this._notificationWidget.width) * (getX_position() - 50) / 50 ;
// JRL changes end
@ -352,9 +381,12 @@ let extensionUpdateShowingNotification = function() {
let extensiononNotificationExpanded = function() {
// JRL changes begin
//let expandedY = - this._notificationWidget.height;
let expandedY = panel.y + panel.height - global.screen_height;
if (expandedY < (-global.screen_height))
expandedY = -global.screen_height;
let yTop = panel.y + panel.height - global.screen_height;
if (yTop < (-global.screen_height))
yTop = -global.screen_height;
let yBottom = -this._notificationWidget.height;
let expandedY = (yTop - yBottom) * gety_position() / 100 + yBottom;
// JRL changes end
this._closeButton.show();
@ -391,7 +423,11 @@ function enable() {
function disable() {
// remove our style, in case we just show a notification, otherwise the radius is drawn incorrect
if(Main.messageTray._notification)
{
Main.messageTray._notification._table.remove_style_class_name('jrlnotification');
Main.messageTray._notification._table.remove_style_class_name('jrlnotification_top');
Main.messageTray._notification._table.remove_style_class_name('jrlnotification_bottom');
}
// reset x-position
notificationWidget.x = originalNotificationWidgetX;
Main.messageTray._showNotification = originalShowNotification;

@ -15,6 +15,7 @@ const EXTENSIONDIR = Me.dir.get_path();
const PANEL_OSD_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd';
const PANEL_OSD_X_POS_KEY = 'x-pos';
const PANEL_OSD_Y_POS_KEY = 'y-pos';
const PanelOsdPrefsWidget = new GObject.Class({
Name: 'PanelOsdExtension.Prefs.Widget',
@ -52,8 +53,24 @@ const PanelOsdPrefsWidget = new GObject.Class({
}));
this.y_scale = this.Window.get_object("scale-y-pos");
this.y_scale.set_value(this.y_position);
// prevent from continously updating the value
this.yScaleTimeout = undefined;
this.y_scale.connect("value-changed", Lang.bind(this, function(slider) {
if (this.yScaleTimeout != undefined)
Mainloop.source_remove(this.yScaleTimeout);
this.yScaleTimeout = Mainloop.timeout_add(250, Lang.bind(this, function() {
this.y_position = slider.get_value();
return false;
}));
}));
this.Window.get_object("button-reset").connect("clicked", Lang.bind(this, function() {
this.x_scale.set_value(50);;
this.x_scale.set_value(50);
this.y_scale.set_value(0);
}));
@ -73,6 +90,18 @@ const PanelOsdPrefsWidget = new GObject.Class({
if (!this.Settings)
this.loadConfig();
this.Settings.set_double(PANEL_OSD_X_POS_KEY, v);
},
get y_position() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_double(PANEL_OSD_Y_POS_KEY);
},
set y_position(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_double(PANEL_OSD_Y_POS_KEY, v);
}
});

Loading…
Cancel
Save