Name our classes

In order to not end up with random names prefixed with Gjs_, give each class a proper name, so its easier to inspect and allows usage with UI files
This commit is contained in:
Rafał Dzięgiel
2021-09-02 20:12:39 +02:00
parent 914292612b
commit dc25ec976a
20 changed files with 94 additions and 32 deletions

View File

@@ -5,7 +5,9 @@ const Debug = imports.src.debug;
const { debug } = Debug;
var App = GObject.registerClass(
var App = GObject.registerClass({
GTypeName: 'ClapperApp',
},
class ClapperApp extends AppBase
{
_init()

View File

@@ -7,7 +7,9 @@ const Actions = imports.src.actions;
const { debug } = Debug;
const { settings } = Misc;
var AppBase = GObject.registerClass(
var AppBase = GObject.registerClass({
GTypeName: 'ClapperAppBase',
},
class ClapperAppBase extends Gtk.Application
{
_init()

View File

@@ -3,7 +3,9 @@ const { AppBase } = imports.src.appBase;
const { HeaderBarRemote } = imports.src.headerbarRemote;
const { WidgetRemote } = imports.src.widgetRemote;
var AppRemote = GObject.registerClass(
var AppRemote = GObject.registerClass({
GTypeName: 'ClapperAppRemote',
},
class ClapperAppRemote extends AppBase
{
vfunc_startup()

View File

@@ -1,7 +1,9 @@
const { GObject, Gtk } = imports.gi;
const Misc = imports.src.misc;
var CustomButton = GObject.registerClass(
var CustomButton = GObject.registerClass({
GTypeName: 'ClapperCustomButton',
},
class ClapperCustomButton extends Gtk.Button
{
_init(opts)
@@ -30,7 +32,9 @@ class ClapperCustomButton extends Gtk.Button
}
});
var IconToggleButton = GObject.registerClass(
var IconToggleButton = GObject.registerClass({
GTypeName: 'ClapperIconToggleButton',
},
class ClapperIconToggleButton extends CustomButton
{
_init(primaryIcon, secondaryIcon)

4
src/controls.js vendored
View File

@@ -9,7 +9,9 @@ const { settings } = Misc;
const INITIAL_ELAPSED = '00:00/00:00';
var Controls = GObject.registerClass(
var Controls = GObject.registerClass({
GTypeName: 'ClapperControls',
},
class ClapperControls extends Gtk.Box
{
_init()

View File

@@ -3,7 +3,9 @@ const Debug = imports.src.debug;
const { debug } = Debug;
var Daemon = GObject.registerClass(
var Daemon = GObject.registerClass({
GTypeName: 'ClapperDaemon',
},
class ClapperDaemon extends Gio.SubprocessLauncher
{
_init()

View File

@@ -6,7 +6,9 @@ const Misc = imports.src.misc;
const { debug } = Debug;
var FileChooser = GObject.registerClass(
var FileChooser = GObject.registerClass({
GTypeName: 'ClapperFileChooser',
},
class ClapperFileChooser extends Gtk.FileChooserNative
{
_init(window, purpose)
@@ -121,7 +123,9 @@ class ClapperFileChooser extends Gtk.FileChooserNative
}
});
var UriDialog = GObject.registerClass(
var UriDialog = GObject.registerClass({
GTypeName: 'ClapperUriDialog',
},
class ClapperUriDialog extends Gtk.Dialog
{
_init(window)
@@ -200,7 +204,9 @@ class ClapperUriDialog extends Gtk.Dialog
}
});
var ResumeDialog = GObject.registerClass(
var ResumeDialog = GObject.registerClass({
GTypeName: 'ClapperResumeDialog',
},
class ClapperResumeDialog extends Gtk.MessageDialog
{
_init(window, resumeInfo)
@@ -239,7 +245,9 @@ class ClapperResumeDialog extends Gtk.MessageDialog
}
});
var AboutDialog = GObject.registerClass(
var AboutDialog = GObject.registerClass({
GTypeName: 'ClapperAboutDialog',
},
class ClapperAboutDialog extends Gtk.AboutDialog
{
_init(window)

View File

@@ -1,7 +1,9 @@
const { GObject } = imports.gi;
const { HeaderBarBase } = imports.src.headerbarBase;
var HeaderBar = GObject.registerClass(
var HeaderBar = GObject.registerClass({
GTypeName: 'ClapperHeaderBar',
},
class ClapperHeaderBar extends HeaderBarBase
{
_onWindowButtonActivate(action)

View File

@@ -4,7 +4,9 @@ const Misc = imports.src.misc;
const { debug } = Debug;
var HeaderBarBase = GObject.registerClass(
var HeaderBarBase = GObject.registerClass({
GTypeName: 'ClapperHeaderBarBase',
},
class ClapperHeaderBarBase extends Gtk.Box
{
_init()
@@ -259,7 +261,9 @@ class ClapperHeaderBarBase extends Gtk.Box
}
});
var HeaderBarPopover = GObject.registerClass(
var HeaderBarPopover = GObject.registerClass({
GTypeName: 'ClapperHeaderBarPopover',
},
class ClapperHeaderBarPopover extends Gtk.PopoverMenu
{
_init(model)

View File

@@ -1,7 +1,9 @@
const { GObject } = imports.gi;
const { HeaderBarBase } = imports.src.headerbarBase;
var HeaderBarRemote = GObject.registerClass(
var HeaderBarRemote = GObject.registerClass({
GTypeName: 'ClapperHeaderBarRemote',
},
class ClapperHeaderBarRemote extends HeaderBarBase
{
_init()

View File

@@ -11,7 +11,9 @@ const { settings } = Misc;
let WebServer;
var Player = GObject.registerClass(
var Player = GObject.registerClass({
GTypeName: 'ClapperPlayer',
},
class ClapperPlayer extends GstClapper.Clapper
{
_init()

View File

@@ -8,7 +8,9 @@ var ClapperState = {
PLAYING: 3,
};
var PlayerRemote = GObject.registerClass(
var PlayerRemote = GObject.registerClass({
GTypeName: 'ClapperPlayerRemote',
},
class ClapperPlayerRemote extends GObject.Object
{
_init()

View File

@@ -18,7 +18,9 @@ const repeatIcons = [
'media-playlist-shuffle-symbolic',
];
var PlaylistWidget = GObject.registerClass(
var PlaylistWidget = GObject.registerClass({
GTypeName: 'ClapperPlaylistWidget',
},
class ClapperPlaylistWidget extends Gtk.ListBox
{
_init()
@@ -234,7 +236,9 @@ class ClapperPlaylistWidget extends Gtk.ListBox
}
});
let PlaylistItem = GObject.registerClass(
let PlaylistItem = GObject.registerClass({
GTypeName: 'ClapperPlaylistItem',
},
class ClapperPlaylistItem extends Gtk.ListBoxRow
{
_init(uri)

View File

@@ -210,8 +210,10 @@ class ClapperPrefsSpin extends PrefsActionRow
}
});
let PrefsPluginFeature = GObject.registerClass(
class PrefsPluginFeature extends Adw.ActionRow
let PrefsPluginFeature = GObject.registerClass({
GTypeName: 'ClapperPrefsPluginFeature',
},
class ClapperPrefsPluginFeature extends Adw.ActionRow
{
_init(featureObj)
{
@@ -344,7 +346,9 @@ class ClapperPrefsPluginRankingSubpageRow extends PrefsSubpageRow
}
});
let PrefsPluginExpander = GObject.registerClass(
let PrefsPluginExpander = GObject.registerClass({
GTypeName: 'ClapperPrefsPluginExpander',
},
class ClapperPrefsPluginExpander extends Adw.ExpanderRow
{
_init(plugin)

View File

@@ -7,7 +7,9 @@ const Misc = imports.src.misc;
const { debug } = Debug;
const { settings } = Misc;
var CustomRevealer = GObject.registerClass(
var CustomRevealer = GObject.registerClass({
GTypeName: 'ClapperCustomRevealer',
},
class ClapperCustomRevealer extends Gtk.Revealer
{
_init(opts)
@@ -41,7 +43,9 @@ class ClapperCustomRevealer extends Gtk.Revealer
}
});
var RevealerTop = GObject.registerClass(
var RevealerTop = GObject.registerClass({
GTypeName: 'ClapperRevealerTop',
},
class ClapperRevealerTop extends CustomRevealer
{
_init()
@@ -215,7 +219,9 @@ class ClapperRevealerTop extends CustomRevealer
}
});
var RevealerBottom = GObject.registerClass(
var RevealerBottom = GObject.registerClass({
GTypeName: 'ClapperRevealerBottom',
},
class ClapperRevealerBottom extends CustomRevealer
{
_init()
@@ -272,7 +278,9 @@ class ClapperRevealerBottom extends CustomRevealer
}
});
var ControlsRevealer = GObject.registerClass(
var ControlsRevealer = GObject.registerClass({
GTypeName: 'ClapperControlsRevealer',
},
class ClapperControlsRevealer extends Gtk.Revealer
{
_init()
@@ -342,7 +350,9 @@ class ClapperControlsRevealer extends Gtk.Revealer
}
});
var ButtonsRevealer = GObject.registerClass(
var ButtonsRevealer = GObject.registerClass({
GTypeName: 'ClapperButtonsRevealer',
},
class ClapperButtonsRevealer extends Gtk.Revealer
{
_init(trType, toggleButton)

View File

@@ -4,7 +4,9 @@ const Misc = imports.src.misc;
const { debug } = Debug;
var WebApp = GObject.registerClass(
var WebApp = GObject.registerClass({
GTypeName: 'ClapperWebApp',
},
class ClapperWebApp extends Gio.SubprocessLauncher
{
_init()

View File

@@ -6,7 +6,9 @@ const WebHelpers = imports.src.webHelpers;
const { debug } = Debug;
const { settings } = Misc;
var WebClient = GObject.registerClass(
var WebClient = GObject.registerClass({
GTypeName: 'ClapperWebClient',
},
class ClapperWebClient extends Soup.Session
{
_init(port)

View File

@@ -4,7 +4,9 @@ const WebHelpers = imports.src.webHelpers;
const { debug } = Debug;
var WebServer = GObject.registerClass(
var WebServer = GObject.registerClass({
GTypeName: 'ClapperWebServer',
},
class ClapperWebServer extends Soup.Server
{
_init(port)

View File

@@ -10,7 +10,9 @@ const Revealers = imports.src.revealers;
const { debug } = Debug;
const { settings } = Misc;
var Widget = GObject.registerClass(
var Widget = GObject.registerClass({
GTypeName: 'ClapperWidget',
},
class ClapperWidget extends Gtk.Grid
{
_init()

View File

@@ -3,7 +3,9 @@ const Buttons = imports.src.buttons;
const Misc = imports.src.misc;
const { PlayerRemote, ClapperState } = imports.src.playerRemote;
var WidgetRemote = GObject.registerClass(
var WidgetRemote = GObject.registerClass({
GTypeName: 'ClapperWidgetRemote',
},
class ClapperWidgetRemote extends Gtk.Grid
{
_init(opts)