[polari] cleanup: Use proper abstract classes instead of rolling our own
- From: Florian MĂźllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] cleanup: Use proper abstract classes instead of rolling our own
- Date: Wed, 14 Aug 2019 19:05:55 +0000 (UTC)
commit 896442e8288c3aa92041c4225cb18f5a9c325835
Author: Florian MĂźllner <fmuellner gnome org>
Date: Wed Aug 7 01:41:22 2019 +0200
cleanup: Use proper abstract classes instead of rolling our own
gjs now supports passing in appropriate GObject.TypeFlags, so use
those over checking the constructor name.
https://gitlab.gnome.org/GNOME/polari/merge_requests/133
src/appNotifications.js | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 8dfeb21..aa561fa 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -6,12 +6,10 @@ const { GLib, GObject, Gtk, Pango } = imports.gi;
const TIMEOUT = 7;
const COMMAND_OUTPUT_REVEAL_TIME = 3;
-const AppNotification = GObject.registerClass(
-class AppNotification extends Gtk.Revealer {
+const AppNotification = GObject.registerClass({
+ GTypeFlags: GObject.TypeFlags.ABSTRACT,
+}, class AppNotification extends Gtk.Revealer {
_init() {
- if (this.constructor.name == 'AppNotification')
- throw new Error('Cannot instantiate abstract class AppNotification');
-
super._init({
reveal_child: true,
transition_type: Gtk.RevealerTransitionType.SLIDE_DOWN
@@ -97,12 +95,10 @@ var UndoNotification = GObject.registerClass({
}
});
-const CommandOutputNotification = GObject.registerClass(
-class CommandOutputNotification extends AppNotification {
+const CommandOutputNotification = GObject.registerClass({
+ GTypeFlags: GObject.TypeFlags.ABSTRACT,
+}, class CommandOutputNotification extends AppNotification {
_init() {
- if (this.constructor.name == 'CommandOutputNotification')
- throw new Error('Cannot instantiate abstract class CommandOutputNotification');
-
super._init();
this.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]