Add option to always show notifications expandend;add possibility to show a test notification; remove unneeded imports.

master
Jens Lody 11 years ago
parent 9c1e16ad7d
commit 376ad1fbc6
  1. 16
      data/org.gnome.shell.extensions.panel-osd.gschema.xml.in
  2. 143
      data/panel-osd-settings.ui
  3. 32
      po/de.po
  4. 32
      po/gnome-shell-extension-panel-osd.pot
  5. 82
      src/extension.js
  6. 69
      src/prefs.js

@ -10,11 +10,23 @@
</key>
<key name="x-res" type="b">
<default>false</default>
<_summary>Horizontal position of notification.</_summary>
<_summary>Allow resetting horizontal position of notification.</_summary>
</key>
<key name="y-res" type="b">
<default>false</default>
<_summary>Vertical position of notification.</_summary>
<_summary>Allow resetting vertical position of notification.</_summary>
</key>
<key name="force-expand" type="b">
<default>false</default>
<_summary>Always expand notifications.</_summary>
</key>
<key name="test-delay" type="d">
<default>1.0</default>
<_summary>Delay before test notification is shown.</_summary>
</key>
<key name="test-notification" type="b">
<default>false</default>
<_summary>If the value is true a test-notification is send and then set back to false.</_summary>
</key>
</schema>
</schemalist>

@ -2,6 +2,13 @@
<!-- Generated with glade 3.16.1 -->
<interface>
<requires lib="gtk+" version="3.6"/>
<object class="GtkAdjustment" id="delay-adjustment">
<property name="lower">0.5</property>
<property name="upper">20</property>
<property name="value">1</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="x-adjustment">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
@ -223,11 +230,145 @@
<object class="GtkSeparator" id="separator3">
<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">7</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkSwitch" id="switch-force-expand">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">7</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Force showing details for all notifications</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">5</property>
<property name="margin_right">5</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">9</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label-test-delay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Delay [s] before test-notification is shown. If it is too short, the notification might close immediately after it is shown.</property>
<property name="wrap">True</property>
<property name="track_visited_links">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="scale-test-delay">
<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">delay-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">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-test">
<property name="label" translatable="yes">Show test notification</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="margin_right">20</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">10</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">5</property>
<property name="margin_right">5</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">11</property>
</packing>
</child>
</object>

@ -1,19 +1,41 @@
#: ../data/panel-osd-settings.ui:26
#: ../src/extension.js:85
msgid ""
"This is just a multiline test-message to show where the notification will be "
"placed and to test expansion (showing details)."
msgstr "Dies ist nur eine einfache mehrzeilige Meldung um zu Zeigen, wo die"
"Meldung angezeigt wird, und um das Erweitern (Details) zu zeigen. "
#: ../data/panel-osd-settings.ui:39
msgid "Horizontal position [%] from 0% (left) to 100% (right)"
msgstr "Horizontale Position [%] von links (0%) bis rechts (100%)"
#: ../data/panel-osd-settings.ui:73
#: ../data/panel-osd-settings.ui:86
msgid "Vertical position [%] from 0% (bottom) to 100% (top)"
msgstr "Vertikale Position [%] von unten (0%) bis oben (100%)"
#: ../data/panel-osd-settings.ui:158
#: ../data/panel-osd-settings.ui:174
msgid "Reset horizontal position to defaults"
msgstr "Horizontale Position auf Standardwert zurücksetzen"
#: ../data/panel-osd-settings.ui:173
#: ../data/panel-osd-settings.ui:189
msgid "Reset vertical position to defaults"
msgstr "Vertikale Position auf Standardwert zurücksetzen"
#: ../data/panel-osd-settings.ui:191
#: ../data/panel-osd-settings.ui:207
msgid "Reset"
msgstr "Zurücksetzen"
#: ../data/panel-osd-settings.ui:265
msgid "Force showing details for all notifications"
msgstr "Zeige alle Meldungen erweitert"
#: ../data/panel-osd-settings.ui:307
msgid ""
"Delay [s] before test-notification is shown. If it is too short, the "
"notification might close immediately after it is shown."
msgstr "Verzögerung [s] before die Test-Meldung gezeigt wird. Ist die "
"Zeit zu kurz wird die Meldung sofort wieder geschlossen."
#: ../data/panel-osd-settings.ui:336
msgid "Show test notification"
msgstr "Zeige Test-Meldung"

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-02-23 13:47+0100\n"
"POT-Creation-Date: 2014-03-07 18:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,22 +17,42 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../data/panel-osd-settings.ui:26
#: ../src/extension.js:85
msgid ""
"This is just a multiline test-message to show where the notification will be "
"placed and to test expansion (showing details)."
msgstr ""
#: ../data/panel-osd-settings.ui:39
msgid "Horizontal position [%] from 0% (left) to 100% (right)"
msgstr ""
#: ../data/panel-osd-settings.ui:73
#: ../data/panel-osd-settings.ui:86
msgid "Vertical position [%] from 0% (bottom) to 100% (top)"
msgstr ""
#: ../data/panel-osd-settings.ui:158
#: ../data/panel-osd-settings.ui:174
msgid "Reset horizontal position to defaults"
msgstr ""
#: ../data/panel-osd-settings.ui:173
#: ../data/panel-osd-settings.ui:189
msgid "Reset vertical position to defaults"
msgstr ""
#: ../data/panel-osd-settings.ui:191
#: ../data/panel-osd-settings.ui:207
msgid "Reset"
msgstr ""
#: ../data/panel-osd-settings.ui:265
msgid "Force showing details for all notifications"
msgstr ""
#: ../data/panel-osd-settings.ui:307
msgid ""
"Delay [s] before test-notification is shown. If it is too short, the "
"notification might close immediately after it is shown."
msgstr ""
#: ../data/panel-osd-settings.ui:336
msgid "Show test notification"
msgstr ""

@ -17,18 +17,20 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Config = imports.misc.config;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const LayoutManager = Main.layoutManager;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Me = ExtensionUtils.getCurrentExtension();
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_X_POS_KEY = 'x-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
@ -66,12 +68,28 @@ const State = {
HIDING: 3
};
function init() {}
function init() {
Convenience.initTranslations('gnome-shell-extension-panel-osd');
}
let Settings;
let SettingsC;
let showTestNotificationTimeout;
let loadConfig = function() {
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() {
@ -80,13 +98,35 @@ let getX_position = function() {
return Settings.get_double(PANEL_OSD_X_POS_KEY);
};
let gety_position = function() {
let getY_position = function() {
if (!Settings)
loadConfig();
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()
*
@ -124,7 +164,7 @@ let extensionShowNotification = function() {
let yTop = -global.screen_height;
let yBottom = 0;
this._notificationWidget.y = (yTop - yBottom) * gety_position() / 100 + yBottom;
this._notificationWidget.y = (yTop - yBottom) * getY_position() / 100 + yBottom;
// JRL changes end
@ -182,7 +222,7 @@ let extensionHideNotification = function(animate) {
}
// JRL changes begin
let yPos;
if (gety_position() < 50)
if (getY_position() < 50)
yPos = this.actor.height;
else
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_top');
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');
else if (gety_position() >= 99.9)
else if (getY_position() >= 99.9)
this._notification._table.add_style_class_name('jrlnotification_top');
else
this._notification._table.add_style_class_name('jrlnotification');
@ -317,7 +357,11 @@ let extensionUpdateShowingNotification = function() {
this._notification.acknowledged = true;
if (ExtensionUtils.versionCheck(['3.6'], Config.PACKAGE_VERSION)) {
// 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);
}
else
@ -326,6 +370,9 @@ let extensionUpdateShowingNotification = function() {
// 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
getForce_expand() ||
// JRL changes end
this._notification.source.policy.forceExpanded)
this._expandNotification(true);
}
@ -341,7 +388,7 @@ let extensionUpdateShowingNotification = function() {
yTop = -global.screen_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;
// JRL changes end
@ -386,7 +433,7 @@ let extensiononNotificationExpanded = function() {
yTop = -global.screen_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
this._closeButton.show();
@ -414,6 +461,7 @@ function enable() {
Main.messageTray._hideNotification = extensionHideNotification;
Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification;
Main.messageTray._onNotificationExpanded = extensiononNotificationExpanded;
loadConfig();
}
@ -421,6 +469,14 @@ function enable() {
* Put everything back.
*/
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
if (Main.messageTray._notification) {
Main.messageTray._notification._table.remove_style_class_name('jrlnotification');

@ -19,6 +19,9 @@ const PANEL_OSD_X_POS_KEY = 'x-pos';
const PANEL_OSD_Y_POS_KEY = 'y-pos';
const PANEL_OSD_ALLOW_X_RESET = 'x-res';
const PANEL_OSD_ALLOW_Y_RESET = 'y-res';
const PANEL_OSD_FORCE_EXPAND = 'force-expand';
const PANEL_OSD_TEST_DELAY = 'test-delay';
const PANEL_OSD_TEST_NOTIFICATION = 'test-notification';
const PanelOsdPrefsWidget = new GObject.Class({
Name: 'PanelOsdExtension.Prefs.Widget',
@ -36,6 +39,9 @@ const PanelOsdPrefsWidget = new GObject.Class({
Window: new Gtk.Builder(),
initWindow: function() {
if (this.test_notification)
this.test_notification = false;
this.Window.set_translation_domain('gnome-shell-extension-panel-osd');
this.Window.add_from_file(EXTENSIONDIR + "/panel-osd-settings.ui");
@ -95,6 +101,33 @@ const PanelOsdPrefsWidget = new GObject.Class({
if (this.y_reset) this.y_scale.set_value(100);
}));
this.switch_force_expand = this.Window.get_object("switch-force-expand");
this.switch_force_expand.set_active(this.force_expand);
this.switch_force_expand.connect("notify::active", Lang.bind(this, function() {
this.force_expand = arguments[0].active;
}));
this.delay_scale = this.Window.get_object("scale-test-delay");
this.delay_scale.set_value(this.test_delay);
// prevent from continously updating the value
this.delayScaleTimeout = undefined;
this.delay_scale.connect("value-changed", Lang.bind(this, function(slider) {
if (this.delayScaleTimeout !== undefined)
Mainloop.source_remove(this.delayScaleTimeout);
this.delayScaleTimeout = Mainloop.timeout_add(250, Lang.bind(this, function() {
this.test_delay = slider.get_value();
return false;
}));
}));
this.Window.get_object("button-test").connect("clicked", Lang.bind(this, function() {
this.test_notification = true;
}));
},
@ -148,6 +181,42 @@ const PanelOsdPrefsWidget = new GObject.Class({
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(PANEL_OSD_ALLOW_Y_RESET, v);
},
get force_expand() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_boolean(PANEL_OSD_FORCE_EXPAND);
},
set force_expand(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(PANEL_OSD_FORCE_EXPAND, v);
},
get test_delay() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_double(PANEL_OSD_TEST_DELAY);
},
set test_delay(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_double(PANEL_OSD_TEST_DELAY, v);
},
get test_notification() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_boolean(PANEL_OSD_TEST_NOTIFICATION);
},
set test_notification(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(PANEL_OSD_TEST_NOTIFICATION, v);
}
});

Loading…
Cancel
Save