This commit is contained in:
davedatum
2019-10-26 23:53:38 +01:00
parent e7adc8779e
commit 2f34697860
417 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,270 @@
/*
* Copyright (C) 2012 Thiago Bellini <hackedbellini@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Some parts of this code were forked from message-notifier:
* https://extensions.gnome.org/extension/150/message-notifier/
* The idea of setting the menu red were inspired by pidgin-persistent-notification:
* https://extensions.gnome.org/extension/170/pidgin-peristent-notification
*
*/
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const GnomeSession = imports.misc.gnomeSession;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Lib = Me.imports.lib;
const SETTING_BLINK_RATE = 'blinkrate';
const SETTING_COLOR = 'color';
const SETTING_CHAT_ONLY = 'chatonly';
const SETTING_FORCE = 'force';
const SETTING_BLACKLIST = 'application-list';
const SETTING_FILTER_TYPE = 'filter';
let settings, messageStyleHandler;
let originalCountUpdated, originalDestroy;
function _MessageStyleHandler() {
/*
Public API
*/
this.init = function() {
this._signals = {};
this._statusChangedId = null;
this._loopTimeoutId = null;
this._oldStyle = null;
this._hasStyleAdded = false;
this._presence = new GnomeSession.Presence(
Lang.bind(this, function(proxy, error) {
if (error) {
logError(error, 'Error while reading gnome-session presence');
return;
}
}));
}
this.enable = function() {
this._statusChangedId = this._presence.connectSignal(
'StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._presence.status = status;
this._onNotificationsSwitchToggled();
}));
// Connect settings change events, so we can update message style
// as soon as the user makes the change
this._connectSetting(SETTING_COLOR);
this._connectSetting(SETTING_CHAT_ONLY);
this._connectSetting(SETTING_FORCE);
this._connectSetting(SETTING_BLINK_RATE);
// Check for existing message counters when extension were
// loaded on an already running shell.
this.updateMessageStyle();
}
this.disable = function() {
this._presence.disconnectSignal(this._statusChangedId);
for (let key in this._signals) {
settings.disconnect(this._signals[key]);
delete this._signals[key];
}
this._removeMessageStyle();
}
this.updateMessageStyle = function() {
this.notificationStatus =
(this._presence.status != GnomeSession.PresenceStatus.BUSY);
let sources = Main.messageTray.getSources();
if (settings.get_boolean(SETTING_FORCE) || this.notificationStatus) {
let chatOnly = settings.get_boolean(SETTING_CHAT_ONLY);
let filter = settings.get_int(SETTING_FILTER_TYPE);
let currentItems = settings.get_strv(SETTING_BLACKLIST);
currentItems = Lib.getAppNamesFromAppInfos(currentItems);
for (let i = 0; i < sources.length; i++) {
let source = sources[i];
if (chatOnly && !source.isChat) {
// The user choose to only be alerted by real chat notifications
continue;
}
if (source.isMuted) {
// Do not alert for muted notifications
continue;
}
if((filter == 0) && (currentItems.indexOf(source.title) != -1)) {
// Blacklist
continue;
}
if((filter == 1) && (currentItems.indexOf(source.title) == -1)) {
// Whitelist
continue;
}
if (this._hasNotifications(source)) {
this._addMessageStyle();
return;
}
}
}
// If for above ended without adding the style, that means there's
// no counter and we need to remove the message style.
this._removeMessageStyle();
}
/*
Private
*/
this._connectSetting = function(setting) {
this._signals[setting] = settings.connect(
"changed::" + setting, Lang.bind(this, this._onSettingsChanged));
}
this._hasNotifications = function(source) {
if (source.countVisible) {
return true;
}
for (let n = 0; n < source.notifications.length; n++) {
if (!source.notifications[n].resident) {
return true;
}
}
return false;
}
this._toggleStyle = function() {
if (!this._hasStyleAdded) {
// Notifications may have been cleared since loop timer was added,
// return false to stop the timeout. Just a precaution, should not happen
return false;
}
let dateMenu = Main.panel.statusArea.dateMenu;
let actualStyle = (dateMenu.actor.style) ? dateMenu.actor.style : "";
let userStyle = "color: " + settings.get_string(SETTING_COLOR) + ";";
dateMenu.actor.style = (dateMenu.actor.style == this._oldStyle) ?
actualStyle.concat(userStyle) : this._oldStyle;
// keep looping
return true;
}
this._addMessageStyle = function() {
if (this._hasStyleAdded) {
this._removeMessageStyle();
}
let dateMenu = Main.panel.statusArea.dateMenu;
let loopDelay = settings.get_int(SETTING_BLINK_RATE);
this._oldStyle = dateMenu.actor.style;
this._hasStyleAdded = true;
if (loopDelay > 0) {
this._loopTimeoutId = Mainloop.timeout_add(
loopDelay, Lang.bind(this, this._toggleStyle))
} else {
this._toggleStyle();
}
}
this._removeMessageStyle = function() {
if (!this._hasStyleAdded) {
return;
}
this._hasStyleAdded = false;
if (this._loopTimeoutId != null) {
// Stop the looping
Mainloop.source_remove(this._loopTimeoutId);
this._loopTimeoutId = null;
}
let dateMenu = Main.panel.statusArea.dateMenu;
dateMenu.actor.style = this._oldStyle;
this._oldStyle = null;
}
/*
Callbacks
*/
this._onSettingsChanged = function() {
this.updateMessageStyle();
}
this._onNotificationsSwitchToggled = function() {
this.updateMessageStyle();
}
}
/*
Monkey-patchs for MessageTray.Source
*/
function _countUpdated() {
originalCountUpdated.call(this);
messageStyleHandler.updateMessageStyle();
}
function _destroy() {
originalDestroy.call(this);
messageStyleHandler.updateMessageStyle();
}
/*
Shell-extensions handlers
*/
function init() {
Lib.initTranslations(Me);
settings = Lib.getSettings(Me);
messageStyleHandler = new _MessageStyleHandler();
messageStyleHandler.init();
}
function enable() {
originalCountUpdated = MessageTray.Source.prototype.countUpdated;
originalDestroy = MessageTray.Source.prototype.destroy;
MessageTray.Source.prototype.countUpdated = _countUpdated;
MessageTray.Source.prototype.destroy = _destroy;
messageStyleHandler.enable();
}
function disable() {
MessageTray.Source.prototype.countUpdated = originalCountUpdated;
MessageTray.Source.prototype.destroy = originalDestroy;
messageStyleHandler.disable();
}

View File

@@ -0,0 +1,131 @@
/*
* Copyright (C) 2012 Thiago Bellini <hackedbellini@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Most of this code was forked from gnome-shell-extensions convenience.js:
* http://git.gnome.org/browse/gnome-shell-extensions/tree/lib/convenience.js
*
*/
const Gettext = imports.gettext;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Config = imports.misc.config;
/*
Extension utils
*/
function initTranslations(extension) {
// This is the same as UUID from metadata.json
let domain = 'gnome-shell-notifications-alert';
// check if this extension was built with "make zip-file", and thus
// has the locale files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell
let localeDir = extension.dir.get_child('locale');
if (localeDir.query_exists(null)) {
Gettext.bindtextdomain(domain, localeDir.get_path());
} else {
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
}
}
function getSettings(extension) {
let schema = 'org.gnome.shell.extensions.notifications-alert';
const GioSSS = Gio.SettingsSchemaSource;
// check if this extension was built with "make zip-file", and thus
// has the schema files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell (and therefore schemas are available
// in the standard folders)
let schemaDir = extension.dir.get_child('schemas');
let schemaSource;
if (schemaDir.query_exists(null)) {
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),
GioSSS.get_default(),
false);
} else {
schemaSource = GioSSS.get_default();
}
let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj) {
throw new Error('Schema ' + schema + ' could not be found for extension ' +
extension.metadata.uuid + '. Please check your installation.');
}
return new Gio.Settings({settings_schema: schemaObj});
}
/*
Color utils
*/
function _scaleRound(value) {
// Based on gtk/gtkcoloreditor.c
value = Math.floor((value / 255) + 0.5);
value = Math.max(value, 0);
value = Math.min(value, 255);
return value;
}
function _dec2Hex(value) {
value = value.toString(16);
while (value.length < 2) {
value = '0' + value;
}
return value;
}
function getColorByHexadecimal(hex) {
let colorArray = Gdk.Color.parse(hex);
let color = null;
if (colorArray[0]) {
color = colorArray[1];
} else {
// On any error, default to red
color = new Gdk.Color({red: 65535});
}
return color;
}
function getHexadecimalByColor(color) {
let red = _scaleRound(color.red);
let green = _scaleRound(color.green);
let blue = _scaleRound(color.blue);
return "#" + _dec2Hex(red) + _dec2Hex(green) + _dec2Hex(blue);
}
function getAppNamesFromAppInfos(list) {
let appNames = [ ];
for (let i = 0; i < list.length; i++) {
let id = list[i];
let appInfo = Gio.DesktopAppInfo.new(id);
if (!appInfo)
continue;
appNames.push(appInfo.get_name());
}
return appNames;
}

View File

@@ -0,0 +1,94 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-15 11:35-0300\n"
"PO-Revision-Date: 2017-08-03 08:47+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: cs_CZ\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.1\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#: src/prefs.js:264
msgid "Add"
msgstr ""
#: src/prefs.js:245
msgid "Add Rule"
msgstr ""
#: src/prefs.js:173
msgid "Alert color"
msgstr "Zvýraznění barvou"
#: src/prefs.js:195
msgid "Alert even if you set notifications to OFF on user menu (default: OFF)"
msgstr ""
"Bude zvýrazňovat notifikace i když je jejich zobrazování vypnuto (tato "
"funkce je ve výchozím stavu vypnuta)"
#: src/prefs.js:229
msgid "Application"
msgstr ""
#: src/prefs.js:140
msgid "Blacklist"
msgstr ""
#: src/prefs.js:259
msgid "Blacklist app"
msgstr ""
#: src/prefs.js:180
msgid "Blink rate (in ms)"
msgstr "Rychlost blikání (v ms)"
#: src/prefs.js:269
msgid "Choose an application to blacklist:"
msgstr ""
#: src/prefs.js:123
msgid "Filter List"
msgstr ""
#: src/prefs.js:133
msgid "Filter Type"
msgstr ""
#: src/prefs.js:194
msgid "Force alerting even when notifications are set to OFF"
msgstr "Zvýrazňovat i pokud jsou notifikace vypnuty"
#: src/prefs.js:190
msgid "Only alert for chat notifications"
msgstr "Výrazně upozorňovat pouze na zprávy konverzací"
#: src/prefs.js:191
msgid ""
"Only chat notifications (like Empathy ones) will get alerted (default: OFF)"
msgstr ""
"Pouze zprávy konverzací (například Empathy) budou zvýrazňovány (tato funkce "
"je ve výchozím stavu vypnuta)"
#: src/prefs.js:174
msgid "The color used to paint the message on user's menu"
msgstr "Barva, kterou je zobrazena zpráva v uživatelské nabídce"
#: src/prefs.js:181
msgid "The rate that the alert blinks, in ms. 0 means no blink (default: 800)"
msgstr ""
"Určuje, jakou rychlostí má problikávat zvýrazňující a výchozí barva "
"(800=výchozí hodnota, méně=rychleji, více=pomaleji, 0=žádné blikání)"
#: src/prefs.js:141
msgid "Whitelist"
msgstr ""

View File

@@ -0,0 +1,94 @@
# German translations for gnome-shell-notifications-alert package.
# Copyright (C) 2013 Jonatan Zeidler
# This file is distributed under the same license as the gnome-shell-notifications-alert package.
# Jonatan Zeidler <jonatan_zeidler@gmx.de>, 2013.
# Onno Giesmann <nutzer3105@gmail.com>, 2019.
#
msgid ""
msgstr ""
"Project-Id-Version: gnome-shell-notifications-alert\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-15 11:35-0300\n"
"PO-Revision-Date: 2019-06-16 18:07+0200\n"
"Last-Translator: Onno Giesmann <nutzer3105@gmail.com>\n"
"Language-Team: German <--->\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"X-Poedit-Language: German\n"
"X-Poedit-Country: GERMANY\n"
"X-Generator: Gtranslator 3.32.1\n"
#: src/prefs.js:264
msgid "Add"
msgstr "Hinzufügen"
#: src/prefs.js:245
msgid "Add Rule"
msgstr "Regel hinzufügen"
#: src/prefs.js:173
msgid "Alert color"
msgstr "Benachrichtigungsfarbe"
#: src/prefs.js:195
msgid "Alert even if you set notifications to OFF on user menu (default: OFF)"
msgstr ""
"Benachrichtigen trotzdem anzeigen, auch wenn sie im Nutzermenü ausgeschaltet "
"sind (Vorgabe: AUS)"
#: src/prefs.js:229
msgid "Application"
msgstr "Anwendung"
#: src/prefs.js:140
msgid "Blacklist"
msgstr "Schwarze Liste"
#: src/prefs.js:259
msgid "Blacklist app"
msgstr "Anwendung für schwarze Liste"
#: src/prefs.js:180
msgid "Blink rate (in ms)"
msgstr "Blinkrate (in ms)"
#: src/prefs.js:269
msgid "Choose an application to blacklist:"
msgstr "Anwendung für schwarze Liste auswählen:"
#: src/prefs.js:123
msgid "Filter List"
msgstr "Filterliste"
#: src/prefs.js:133
msgid "Filter Type"
msgstr "Filtertyp"
#: src/prefs.js:194
msgid "Force alerting even when notifications are set to OFF"
msgstr "Auch benachrichtigen, wenn sie allgemein auf AUS gestellt sind"
#: src/prefs.js:190
msgid "Only alert for chat notifications"
msgstr "Nur bei Chat-Benachrichtigungen aktivieren"
#: src/prefs.js:191
msgid ""
"Only chat notifications (like Empathy ones) will get alerted (default: OFF)"
msgstr ""
"Benachrichtigt nur bei Chat-Meldungen (z.B. von Empathy) (Vorgabe: AUS)"
#: src/prefs.js:174
msgid "The color used to paint the message on user's menu"
msgstr "Farbe, in der die Benachrichtigung im Nutzermenü erscheint"
#: src/prefs.js:181
msgid "The rate that the alert blinks, in ms. 0 means no blink (default: 800)"
msgstr "Rate des Blinkens in ms. Wert 0 bedeutet kein Blinken (Vorgabe: 800)"
#: src/prefs.js:141
msgid "Whitelist"
msgstr "Weiße Liste"

View File

@@ -0,0 +1,87 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-15 11:35-0300\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"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/prefs.js:264
msgid "Add"
msgstr ""
#: src/prefs.js:245
msgid "Add Rule"
msgstr ""
#: src/prefs.js:173
msgid "Alert color"
msgstr ""
#: src/prefs.js:195
msgid "Alert even if you set notifications to OFF on user menu (default: OFF)"
msgstr ""
#: src/prefs.js:229
msgid "Application"
msgstr ""
#: src/prefs.js:140
msgid "Blacklist"
msgstr ""
#: src/prefs.js:259
msgid "Blacklist app"
msgstr ""
#: src/prefs.js:180
msgid "Blink rate (in ms)"
msgstr ""
#: src/prefs.js:269
msgid "Choose an application to blacklist:"
msgstr ""
#: src/prefs.js:123
msgid "Filter List"
msgstr ""
#: src/prefs.js:133
msgid "Filter Type"
msgstr ""
#: src/prefs.js:194
msgid "Force alerting even when notifications are set to OFF"
msgstr ""
#: src/prefs.js:190
msgid "Only alert for chat notifications"
msgstr ""
#: src/prefs.js:191
msgid ""
"Only chat notifications (like Empathy ones) will get alerted (default: OFF)"
msgstr ""
#: src/prefs.js:174
msgid "The color used to paint the message on user's menu"
msgstr ""
#: src/prefs.js:181
msgid "The rate that the alert blinks, in ms. 0 means no blink (default: 800)"
msgstr ""
#: src/prefs.js:141
msgid "Whitelist"
msgstr ""

View File

@@ -0,0 +1,87 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-15 11:35-0300\n"
"PO-Revision-Date: 2019-08-06 12:16+0200\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.3\n"
"Last-Translator: Heimen Stoffels <vistausss@outlook.com>\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: nl\n"
#: src/prefs.js:264
msgid "Add"
msgstr "Toevoegen"
#: src/prefs.js:245
msgid "Add Rule"
msgstr "Regel toevoegen"
#: src/prefs.js:173
msgid "Alert color"
msgstr "Meldingskleur"
#: src/prefs.js:195
msgid "Alert even if you set notifications to OFF on user menu (default: OFF)"
msgstr "Ook knipperen bij nieuwe meldingen als meldingen zijn uitgeschakeld (standaard: UIT)"
#: src/prefs.js:229
msgid "Application"
msgstr "Toepassing"
#: src/prefs.js:140
msgid "Blacklist"
msgstr "Zwarte lijst"
#: src/prefs.js:259
msgid "Blacklist app"
msgstr "Toev. aan zwarte lijst"
#: src/prefs.js:180
msgid "Blink rate (in ms)"
msgstr "Knippersnelheid (in ms)"
#: src/prefs.js:269
msgid "Choose an application to blacklist:"
msgstr "Kies een toepassing voor de zwarte lijst:"
#: src/prefs.js:123
msgid "Filter List"
msgstr "Filterlijst"
#: src/prefs.js:133
msgid "Filter Type"
msgstr "Soort filter"
#: src/prefs.js:194
msgid "Force alerting even when notifications are set to OFF"
msgstr "Knipperen bij nieuwe meldingen afdwingen als meldingen zijn uitgeschakeld"
#: src/prefs.js:190
msgid "Only alert for chat notifications"
msgstr "Alleen knipperen bij chatmeldingen"
#: src/prefs.js:191
msgid "Only chat notifications (like Empathy ones) will get alerted (default: OFF)"
msgstr "Alleen knipperen bij chatmeldingen (zoals bijv. die van Empathy - standaard: UIT)"
#: src/prefs.js:174
msgid "The color used to paint the message on user's menu"
msgstr "De kleur van het knipperpatroon"
#: src/prefs.js:181
msgid "The rate that the alert blinks, in ms. 0 means no blink (default: 800)"
msgstr "De snelheid waarmee wordt geknipperd, in ms. 0 = niet knipperen (standaard: 800)"
#: src/prefs.js:141
msgid "Whitelist"
msgstr "Witte lijst"

View File

@@ -0,0 +1,92 @@
# Brazilian Portuguese translations for gnome-shell-notifications-alert package.
# Copyright (C) 2013 THE gnome-shell-notifications-alert's COPYRIGHT HOLDER
# This file is distributed under the same license as the gnome-shell-notifications-alert package.
# Thiago Bellini <hackedbellini@gmail.com>, 2013.
#
msgid ""
msgstr ""
"Project-Id-Version: gnome-shell-notifications-alert\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-15 11:35-0300\n"
"PO-Revision-Date: 2013-02-02 17:09-0200\n"
"Last-Translator: Thiago Bellini <hackedbellini@gmail.com>\n"
"Language-Team: Brazilian Portuguese\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: src/prefs.js:264
msgid "Add"
msgstr "Adicionar"
#: src/prefs.js:245
msgid "Add Rule"
msgstr "Adicionar Regra"
#: src/prefs.js:173
msgid "Alert color"
msgstr "Cor do alerta"
#: src/prefs.js:195
msgid "Alert even if you set notifications to OFF on user menu (default: OFF)"
msgstr ""
"Alertar mesmo se as suas notificações estão desligadas no menu do usuário "
"(padrão: Desligado)"
#: src/prefs.js:229
msgid "Application"
msgstr "Aplicativo"
#: src/prefs.js:140
msgid "Blacklist"
msgstr "Lista negra"
#: src/prefs.js:259
msgid "Blacklist app"
msgstr "Aplicativos na lista negra"
#: src/prefs.js:180
msgid "Blink rate (in ms)"
msgstr "Taxa de intermitência (em ms)"
#: src/prefs.js:269
msgid "Choose an application to blacklist:"
msgstr "Escolha um aplicativo para adicionar na lista negra:"
#: src/prefs.js:123
msgid "Filter List"
msgstr "Lista do filtro"
#: src/prefs.js:133
msgid "Filter Type"
msgstr "Tipo do filtro"
#: src/prefs.js:194
msgid "Force alerting even when notifications are set to OFF"
msgstr "Alerta forçado mesmo quando as notificações estão desligadas"
#: src/prefs.js:190
msgid "Only alert for chat notifications"
msgstr "Alertar apenas para notificações de bate-papo"
#: src/prefs.js:191
msgid ""
"Only chat notifications (like Empathy ones) will get alerted (default: OFF)"
msgstr ""
"Apenas notificações de bate-papo (como as do Empathy) serão alertadas "
"(padrão: Desligado)"
#: src/prefs.js:174
msgid "The color used to paint the message on user's menu"
msgstr "A cor utilizada para pintar a mensagem no menu do usuário"
#: src/prefs.js:181
msgid "The rate that the alert blinks, in ms. 0 means no blink (default: 800)"
msgstr ""
"A taxa em que o alerta pisca, em ms. 0 significa não piscar (padrão: 800)"
#: src/prefs.js:141
msgid "Whitelist"
msgstr "Lista branca"

View File

@@ -0,0 +1,22 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Whenever there is an unread notification (e.g. chat messages), blinks the message in the user's menu with a color chosen by the user.\n\nNow configurable (3.4+ only)!! Alert color and blink rate can be changed on settings ;)\n\nIf you have any question, be sure to take a look at the FAQ:\nhttp://goo.gl/lmwtW\n\nCredits: The idea of painting the message on user's menu was borrowed from 'Pidgin Persistent Notification' extension by nemo. The code itself has some parts forked from 'Message Notifier' extension by barisione, 'Media player indicator' extension by eon and convenience.js from git.gnome.org/gnome-shell-extensions. The blink idea and it's initial code was written by hossman. The initial gnome 3.10 support was done by Anthony25. The filtering support was done by ilgarmehmetali",
"name": "Notifications Alert",
"original-authors": [
"Thiago Bellini"
],
"shell-version": [
"3.16",
"3.18",
"3.20",
"3.22",
"3.24",
"3.26",
"3.28",
"3.30",
"3.32"
],
"url": "https://github.com/hackedbellini/Gnome-Shell-Notifications-Alert",
"uuid": "notifications-alert-on-user-menu@hackedbellini.gmail.com",
"version": 38
}

View File

@@ -0,0 +1,403 @@
/*
* Copyright (C) 2012 Thiago Bellini <hackedbellini@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Most of this code was forked from media-player-indicator:
* https://extensions.gnome.org/extension/55/media-player-indicator/
*
*/
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Gettext = imports.gettext.domain('gnome-shell-notifications-alert');
const _ = Gettext.gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Lib = Me.imports.lib;
const SETTING_BLACKLIST = 'application-list';
const SETTING_FILTER_TYPE = 'filter';
const Columns = {
APPINFO: 0,
DISPLAY_NAME: 1,
ICON: 2,
};
let settings;
let boolSettings;
let intSettings;
let colorSettings;
function _createBoolSetting(setting) {
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
let settingLabel = new Gtk.Label({label: boolSettings[setting].label,
xalign: 0});
let settingSwitch = new Gtk.Switch({active: settings.get_boolean(setting)});
settingSwitch.connect('notify::active', function(button) {
settings.set_boolean(setting, button.active);
});
if (boolSettings[setting].help) {
settingLabel.set_tooltip_text(boolSettings[setting].help);
settingSwitch.set_tooltip_text(boolSettings[setting].help);
}
hbox.pack_start(settingLabel, true, true, 0);
hbox.add(settingSwitch);
return hbox;
}
function _createIntSetting(setting) {
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
let settingLabel = new Gtk.Label({label: intSettings[setting].label,
xalign: 0});
let spinButton = Gtk.SpinButton.new_with_range(
intSettings[setting].min,
intSettings[setting].max,
intSettings[setting].step)
spinButton.set_value(settings.get_int(setting));
spinButton.connect('notify::value', function(spin) {
settings.set_int(setting, spin.get_value_as_int());
});
if (intSettings[setting].help) {
settingLabel.set_tooltip_text(intSettings[setting].help);
spinButton.set_tooltip_text(intSettings[setting].help);
}
hbox.pack_start(settingLabel, true, true, 0);
hbox.add(spinButton);
return hbox;
}
function _createColorSetting(setting) {
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
let settingLabel = new Gtk.Label({label: colorSettings[setting].label,
xalign: 0});
let color = Lib.getColorByHexadecimal(settings.get_string(setting));
let colorButton = new Gtk.ColorButton();
colorButton.set_color(color);
colorButton.connect('notify::color', function(button) {
let hex = Lib.getHexadecimalByColor(button.get_color());
settings.set_string(setting, hex);
});
if (colorSettings[setting].help) {
settingLabel.set_tooltip_text(colorSettings[setting].help);
colorButton.set_tooltip_text(colorSettings[setting].help);
}
hbox.pack_start(settingLabel, true, true, 0);
hbox.add(colorButton);
return hbox;
}
function _createFilterListSetting() {
let settingLabel = new Gtk.Label({label: _("Filter List"), xalign: 0});
let widget = new Widget();
let blbox = new Gtk.Grid({column_spacing: 5, row_spacing: 5, margin: 0});
blbox.attach(settingLabel,0,0,1,1);
blbox.attach(widget,0,1,1,1);
return blbox;
}
function _createFilterTypeSetting() {
let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
let settingLabel = new Gtk.Label({label: _("Filter Type"), xalign: 0});
let listStore = new Gtk.ListStore();
listStore.set_column_types ([
GObject.TYPE_STRING,
GObject.TYPE_STRING]);
listStore.insert_with_valuesv (-1, [0, 1], [0, _("Blacklist")]);
listStore.insert_with_valuesv (-1, [0, 1], [1, _("Whitelist")]);
let filterComboBox = new Gtk.ComboBox({ model: listStore });
filterComboBox.set_active (settings.get_int(SETTING_FILTER_TYPE));
filterComboBox.set_id_column(0);
let rendererText = new Gtk.CellRendererText();
filterComboBox.pack_start (rendererText, false);
filterComboBox.add_attribute (rendererText, "text", 1);
filterComboBox.connect('changed', function(entry) {
let id = filterComboBox.get_active_id();
if (id == null)
return;
settings.set_int(SETTING_FILTER_TYPE, id);
});
hbox.pack_start(settingLabel, true, true, 0);
hbox.add(filterComboBox);
return hbox;
}
/*
Shell-extensions handlers
*/
function init() {
Lib.initTranslations(Me);
settings = Lib.getSettings(Me);
colorSettings = {
color: {
label: _("Alert color"),
help: _("The color used to paint the message on user's menu")
},
};
intSettings = {
blinkrate: {
label: _("Blink rate (in ms)"),
help: _("The rate that the alert blinks, in ms. 0 means no blink (default: 800)"),
min: 0,
max: 10000,
step: 1
},
};
boolSettings = {
chatonly: {
label: _("Only alert for chat notifications"),
help: _("Only chat notifications (like Empathy ones) will get alerted (default: OFF)")
},
force: {
label: _("Force alerting even when notifications are set to OFF"),
help: _("Alert even if you set notifications to OFF on user menu (default: OFF)")
},
};
}
/*
Blacklist widget
*/
const Widget = new GObject.Class({
Name: 'NotificationsAlert.Prefs.BlackListWidget',
GTypeName: 'NotificationsAlertBlackListPrefsWidget',
Extends: Gtk.Grid,
_init: function(params) {
this.parent(params);
this.set_orientation(Gtk.Orientation.VERTICAL);
Lib.initTranslations(Me);
this._settings = Lib.getSettings(Me);
this._store = new Gtk.ListStore();
this._store.set_column_types([Gio.AppInfo, GObject.TYPE_STRING, Gio.Icon]);
let scrolled = new Gtk.ScrolledWindow({ shadow_type: Gtk.ShadowType.IN});
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
scrolled.set_min_content_height(150);
this.add(scrolled);
this._treeView = new Gtk.TreeView({ model: this._store,
hexpand: true, vexpand: true });
this._treeView.get_selection().set_mode(Gtk.SelectionMode.SINGLE);
let appColumn = new Gtk.TreeViewColumn({ expand: true, sort_column_id: Columns.DISPLAY_NAME,
title: _("Application") });
let iconRenderer = new Gtk.CellRendererPixbuf;
appColumn.pack_start(iconRenderer, false);
appColumn.add_attribute(iconRenderer, "gicon", Columns.ICON);
let nameRenderer = new Gtk.CellRendererText;
appColumn.pack_start(nameRenderer, true);
appColumn.add_attribute(nameRenderer, "text", Columns.DISPLAY_NAME);
this._treeView.append_column(appColumn);
scrolled.add(this._treeView);
let toolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.SMALL_TOOLBAR });
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR);
this.add(toolbar);
let newButton = new Gtk.ToolButton({ icon_name: 'bookmark-new-symbolic',
label: _("Add Rule"),
is_important: true });
newButton.connect('clicked', Lang.bind(this, this._createNew));
toolbar.add(newButton);
let delButton = new Gtk.ToolButton({ icon_name: 'edit-delete-symbolic' });
delButton.connect('clicked', Lang.bind(this, this._deleteSelected));
toolbar.add(delButton);
this._changedPermitted = true;
this._refresh();
},
_createNew: function() {
let dialog = new Gtk.Dialog({ title: _("Blacklist app"),
transient_for: this.get_toplevel(),
use_header_bar: true,
modal: true });
dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
let addButton = dialog.add_button(_("Add"), Gtk.ResponseType.OK);
dialog.set_default_response(Gtk.ResponseType.OK);
dialog._appChooser = new Gtk.AppChooserWidget({ show_all: true });
let lbl = new Gtk.Label({label: _("Choose an application to blacklist:"),
xalign: 0.5});
let hbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL,
margin: 5});
hbox.pack_start(lbl, false, true, 0);
hbox.pack_start(dialog._appChooser, true, true, 0);
dialog.get_content_area().pack_start(hbox, true, true, 0);
dialog.connect('response', Lang.bind(this, function(dialog, id) {
if (id != Gtk.ResponseType.OK) {
dialog.destroy();
return;
}
let appInfo = dialog._appChooser.get_app_info();
if (!appInfo) return;
if (this._checkId( appInfo.get_id())){
dialog.destroy();
return;
}
this._changedPermitted = false;
this._appendItem(appInfo.get_id());
this._changedPermitted = true;
let iter = this._store.append();
this._store.set(iter,
[Columns.APPINFO, Columns.ICON, Columns.DISPLAY_NAME],
[appInfo, appInfo.get_icon(), appInfo.get_display_name()]);
dialog.destroy();
}));
dialog.show_all();
},
_deleteSelected: function() {
let [any, model, iter] = this._treeView.get_selection().get_selected();
if (any) {
let appInfo = this._store.get_value(iter, Columns.APPINFO);
this._changedPermitted = false;
this._removeItem(appInfo.get_id());
this._changedPermitted = true;
this._store.remove(iter);
}
},
_refresh: function() {
if (!this._changedPermitted)
// Ignore this notification, model is being modified outside
return;
this._store.clear();
let currentItems = this._settings.get_strv(SETTING_BLACKLIST);
let validItems = [ ];
for (let i = 0; i < currentItems.length; i++) {
let id = currentItems[i];
let appInfo = Gio.DesktopAppInfo.new(id);
if (!appInfo)
continue;
validItems.push(currentItems[i]);
let iter = this._store.append();
this._store.set(iter,
[Columns.APPINFO, Columns.ICON, Columns.DISPLAY_NAME],
[appInfo, appInfo.get_icon(), appInfo.get_display_name()]);
}
if (validItems.length != currentItems.length) // some items were filtered out
this._settings.set_strv(SETTING_BLACKLIST, validItems);
},
_checkId: function(id) {
let items = this._settings.get_strv(SETTING_BLACKLIST);
return (items.indexOf(id) != -1);
},
_appendItem: function(id) {
let currentItems = this._settings.get_strv(SETTING_BLACKLIST);
currentItems.push(id);
this._settings.set_strv(SETTING_BLACKLIST, currentItems);
},
_removeItem: function(id) {
let currentItems = this._settings.get_strv(SETTING_BLACKLIST);
let index = currentItems.indexOf(id);
if (index < 0)
return;
currentItems.splice(index, 1);
this._settings.set_strv(SETTING_BLACKLIST, currentItems);
}
});
function buildPrefsWidget() {
let frame = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL,
border_width: 10});
let vbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL,
margin: 20, margin_top: 10, spacing: 5});
let setting;
// Add all color settings
for (setting in colorSettings) {
let hbox = _createColorSetting(setting);
vbox.add(hbox);
}
// Add all bool settings
for (setting in boolSettings) {
let hbox = _createBoolSetting(setting);
vbox.add(hbox);
}
// Add all int settings
for (setting in intSettings) {
let hbox = _createIntSetting(setting);
vbox.add(hbox);
}
// Add filter type setting
let filterType = _createFilterTypeSetting();
vbox.add(filterType);
// Add filter list
let blbox = _createFilterListSetting();
vbox.add(blbox);
frame.add(vbox);
frame.show_all();
return frame;
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="gnome-shell-notifications-alert">
<schema path="/org/gnome/shell/extensions/notifications-alert/" id="org.gnome.shell.extensions.notifications-alert">
<key name="force" type="b">
<default>false</default>
<summary>Force alerting even when notifications are set to OFF</summary>
<description>Alert even if you set notifications to OFF on user menu</description>
</key>
<key name="chatonly" type="b">
<default>false</default>
<summary>Only alert for chat notifications</summary>
<description>Only chat notifications (like Empathy ones) will get alerted</description>
</key>
<key name="blinkrate" type="i">
<default>800</default>
<summary>Blink rate</summary>
<description>The rate that the alert blinks, in ms. 0 means no blink</description>
</key>
<key name="color" type="s">
<default>'#ff0000'</default>
<summary>Alert color</summary>
<description>The color used to paint the message on user's menu</description>
</key>
<key name="application-list" type="as">
<default>[ ]</default>
<summary>Blacklist</summary>
<description>A list of strings, each containing an application id (desktop file name), followed by a colon</description>
</key>
<key name="filter" type="i">
<default>0</default>
<summary>Filter type</summary>
<description>Filter type to use. 0 mean Blacklist, 1 means Whitelist</description>
</key>
</schema>
</schemalist>