diff --git a/extension/prefs.js b/extension/prefs.js index 93ab15e5..608034a7 100644 --- a/extension/prefs.js +++ b/extension/prefs.js @@ -31,13 +31,13 @@ const Lang = imports.lang; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); -const HamsterSettingsWidget = new GObject.Class({ - Name: 'ProjectHamster.Prefs.HamsterSettingsWidget', - GTypeName: 'HamsterSettingsWidget', - Extends: Gtk.VBox, +const HamsterSettingsWidget = GObject.registerClass( +class HamsterSettingsWidget extends Gtk.VBox { + _init(params) { + super._init(params); + + this.name = 'ProjectHamster.Prefs.HamsterSettingsWidget'; - _init : function(params) { - this.parent(params); this.margin = 10; this._settings = ExtensionUtils.getSettings(); @@ -114,9 +114,9 @@ const HamsterSettingsWidget = new GObject.Class({ let version_text = ExtensionUtils.getCurrentExtension().metadata.version; let version_label_text = "You are running hamster-shell-extension version " + version_text; vbox.add(new Gtk.Label({label: version_label_text, margin_top: 10})); - }, + } - _onPlacementChange: function(widget) { + _onPlacementChange(widget) { let [success, iter] = widget.get_active_iter(); if (!success) return; @@ -127,9 +127,9 @@ const HamsterSettingsWidget = new GObject.Class({ return; this._settings.set_int("panel-placement", newPlacement); - }, + } - _onAppearanceChange: function(widget) { + _onAppearanceChange(widget) { let [success, iter] = widget.get_active_iter(); if (!success) return; @@ -140,9 +140,9 @@ const HamsterSettingsWidget = new GObject.Class({ return; this._settings.set_int("panel-appearance", newAppearance); - }, + } - _onHotkeyChange: function(widget, bananas) { + _onHotkeyChange(widget, bananas) { //global.log(widget, bananas); let hotkey = widget.get_text(); let [key, mods] = Gtk.accelerator_parse(hotkey); diff --git a/extension/widgets/categoryTotalsWidget.js b/extension/widgets/categoryTotalsWidget.js index 683fe920..17af7473 100644 --- a/extension/widgets/categoryTotalsWidget.js +++ b/extension/widgets/categoryTotalsWidget.js @@ -25,6 +25,7 @@ const Lang = imports.lang; const St = imports.gi.St; const Clutter = imports.gi.Clutter; const GLib = imports.gi.GLib; +const GObject = imports.gi.GObject; const Me = imports.misc.extensionUtils.getCurrentExtension(); const Stuff = Me.imports.stuff; @@ -33,19 +34,16 @@ const Stuff = Me.imports.stuff; /** * Custom Label widget that displays category totals. */ -var CategoryTotalsWidget = new Lang.Class({ - Name: 'CategoryTotals', - Extends: St.Label, - - _init: function() { - this.parent({style_class: 'summary-label'}); - - }, +var CategoryTotalsWidget = GObject.registerClass( +class CategoryTotals extends St.Label { + _init() { + super._init({style_class: 'summary-label'}); + } /** * Recompute values and replace old string with new one based on passed facts. */ - refresh: function(facts) { + refresh(facts) { /** * Construct a string representing category totals. */ @@ -67,5 +65,5 @@ var CategoryTotalsWidget = new Lang.Class({ } this.set_text(getString(facts)); - }, + } }); diff --git a/extension/widgets/factsBox.js b/extension/widgets/factsBox.js index 42857f5a..aa5a3369 100644 --- a/extension/widgets/factsBox.js +++ b/extension/widgets/factsBox.js @@ -27,6 +27,7 @@ const PopupMenu = imports.ui.popupMenu; const Clutter = imports.gi.Clutter; const Mainloop = imports.mainloop; const GLib = imports.gi.GLib; +const GObject = imports.gi.GObject; const Gettext = imports.gettext.domain('hamster-shell-extension'); const _ = Gettext.gettext; @@ -43,11 +44,10 @@ const TodaysFactsWidget = Me.imports.widgets.todaysFactsWidget.TodaysFactsWidget * well as todays facts. * @class */ -var FactsBox = new Lang.Class({ - Name: 'FactsBox', - Extends: PopupMenu.PopupBaseMenuItem, - _init: function(controller, panelWidget) { - this.parent({reactive: false}); +var FactsBox = +class FactsBox extends PopupMenu.PopupBaseMenuItem { + constructor(controller, panelWidget) { + super({reactive: false}); this._controller = controller; @@ -79,32 +79,32 @@ var FactsBox = new Lang.Class({ // Setup category summery this.summaryLabel = new CategoryTotalsWidget(); main_box.add(this.summaryLabel); - }, + } // [FIXME] // The best solution would be to listen for a 'FactsChanged' Signal that carries the new // facts as payload and just refresh with this. But for now we stick with this // simpler version. - refresh: function(facts, ongoingFact) { + refresh(facts, ongoingFact) { this.todaysFactsWidget.refresh(facts, ongoingFact); this.summaryLabel.refresh(facts); - }, + } /** * Focus the fact entry and make sure todaysFactsWidget are scrolled to the bottom. */ - focus: function() { + focus() { Mainloop.timeout_add(20, Lang.bind(this, function() { this._scrollAdjustment.value = this._scrollAdjustment.upper; global.stage.set_key_focus(this.ongoingFactEntry); })); - }, + } /** * Remove any existing focus. */ - unfocus: function() { + unfocus() { global.stage.set_key_focus(null); - }, -}); + } +}; diff --git a/extension/widgets/ongoingFactEntry.js b/extension/widgets/ongoingFactEntry.js index a46948d0..b90238e1 100644 --- a/extension/widgets/ongoingFactEntry.js +++ b/extension/widgets/ongoingFactEntry.js @@ -22,6 +22,7 @@ Copyright (c) 2016 - 2018 Eric Goller / projecthamster