JustPerfection review: refactored Lang uses
This commit is contained in:
+5
-3
@@ -23,7 +23,6 @@ const Me = ExtensionUtils.getCurrentExtension();
|
|||||||
const Prefs = Me.imports.prefs;
|
const Prefs = Me.imports.prefs;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const MessageTray = imports.ui.messageTray.MessageTray;
|
const MessageTray = imports.ui.messageTray.MessageTray;
|
||||||
const Lang = imports.lang;
|
|
||||||
|
|
||||||
const BannerBin = Main.messageTray._bannerBin;
|
const BannerBin = Main.messageTray._bannerBin;
|
||||||
|
|
||||||
@@ -150,8 +149,7 @@ class Extension {
|
|||||||
|
|
||||||
_loadSettings() {
|
_loadSettings() {
|
||||||
this._settings = Prefs.SettingsSchema;
|
this._settings = Prefs.SettingsSchema;
|
||||||
this._settingsChangedId = this._settings.connect('changed',
|
this._settingsChangedId = this._settings.connect('changed', this._onSettingsChange.bind(this));
|
||||||
Lang.bind(this, this._onSettingsChange));
|
|
||||||
this._fetchSettings();
|
this._fetchSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +189,10 @@ class Extension {
|
|||||||
BannerBin.x = 0
|
BannerBin.x = 0
|
||||||
BannerBin.y = 0
|
BannerBin.y = 0
|
||||||
this.restore()
|
this.restore()
|
||||||
|
if (this._settingsChangedId) {
|
||||||
|
this._settings.disconnect(this._settingsChangedId);
|
||||||
|
this._settingsChangedId = null;
|
||||||
|
}
|
||||||
this._settings = null;
|
this._settings = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,13 +21,9 @@
|
|||||||
https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator
|
https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator
|
||||||
https://extensions.gnome.org/extension/779/clipboard-indicator/
|
https://extensions.gnome.org/extension/779/clipboard-indicator/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const GObject = imports.gi.GObject;
|
const GObject = imports.gi.GObject;
|
||||||
const Gtk = imports.gi.Gtk;
|
const Gtk = imports.gi.Gtk;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const Lang = imports.lang;
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const Me = ExtensionUtils.getCurrentExtension();
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
|
||||||
@@ -51,9 +47,8 @@ function init() {
|
|||||||
Gettext.bindtextdomain('notification-banner-reloaded', localeDir.get_path());
|
Gettext.bindtextdomain('notification-banner-reloaded', localeDir.get_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
const App = new Lang.Class({
|
class Preferences {
|
||||||
Name: 'NotificationBannerReloaded.App',
|
constructor() {
|
||||||
_init: function() {
|
|
||||||
this.main = new Gtk.Grid({
|
this.main = new Gtk.Grid({
|
||||||
margin_top: 10,
|
margin_top: 10,
|
||||||
margin_bottom: 10,
|
margin_bottom: 10,
|
||||||
@@ -83,7 +78,7 @@ const App = new Lang.Class({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let rendererText = new Gtk.CellRendererText();
|
let rendererText = new Gtk.CellRendererText();
|
||||||
for (widget of [this.anchorHorizontal, this.anchorVertical, this.animationDirection]) {
|
for (const widget of [this.anchorHorizontal, this.anchorVertical, this.animationDirection]) {
|
||||||
widget.pack_start(rendererText, false);
|
widget.pack_start(rendererText, false);
|
||||||
widget.add_attribute(rendererText, "text", 0);
|
widget.add_attribute(rendererText, "text", 0);
|
||||||
}
|
}
|
||||||
@@ -140,9 +135,9 @@ const App = new Lang.Class({
|
|||||||
SettingsSchema.bind(Fields.ANCHOR_VERTICAL, this.anchorVertical, 'active', Gio.SettingsBindFlags.DEFAULT);
|
SettingsSchema.bind(Fields.ANCHOR_VERTICAL, this.anchorVertical, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
SettingsSchema.bind(Fields.ANIMATION_DIRECTION, this.animationDirection, 'active', Gio.SettingsBindFlags.DEFAULT);
|
SettingsSchema.bind(Fields.ANIMATION_DIRECTION, this.animationDirection, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||||
SettingsSchema.bind(Fields.ANIMATION_TIME, this.animationTime, 'value', Gio.SettingsBindFlags.DEFAULT);
|
SettingsSchema.bind(Fields.ANIMATION_TIME, this.animationTime, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||||
},
|
}
|
||||||
|
|
||||||
_create_options : function(opts){
|
_create_options(opts) {
|
||||||
let options = opts.map(function (v) { return { name: v }});
|
let options = opts.map(function (v) { return { name: v }});
|
||||||
let liststore = new Gtk.ListStore();
|
let liststore = new Gtk.ListStore();
|
||||||
liststore.set_column_types([GObject.TYPE_STRING])
|
liststore.set_column_types([GObject.TYPE_STRING])
|
||||||
@@ -153,10 +148,10 @@ const App = new Lang.Class({
|
|||||||
}
|
}
|
||||||
return liststore;
|
return liststore;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
function buildPrefsWidget(){
|
function buildPrefsWidget() {
|
||||||
let widget = new App();
|
let widget = new Preferences();
|
||||||
return widget.main;
|
return widget.main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user