mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Use virtual functions
This commit is contained in:
@@ -40,9 +40,46 @@ var App = GObject.registerClass({
|
|||||||
this.interface = null;
|
this.interface = null;
|
||||||
this.player = null;
|
this.player = null;
|
||||||
this.dragStartReady = false;
|
this.dragStartReady = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.connect('startup', this._buildUI.bind(this));
|
vfunc_startup()
|
||||||
this.connect('activate', this._openWindow.bind(this));
|
{
|
||||||
|
super.vfunc_startup();
|
||||||
|
this.window = new Window(this, APP_NAME);
|
||||||
|
|
||||||
|
this.windowRealizeSignal = this.window.connect(
|
||||||
|
'realize', this._onWindowRealize.bind(this)
|
||||||
|
);
|
||||||
|
this.window.connect(
|
||||||
|
'key-press-event', this._onWindowKeyPressEvent.bind(this)
|
||||||
|
);
|
||||||
|
this.window.connect(
|
||||||
|
'fullscreen-changed', this._onWindowFullscreenChanged.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.interface = new Interface();
|
||||||
|
let headerBar = new Gtk.HeaderBar({
|
||||||
|
title: APP_NAME,
|
||||||
|
show_close_button: true,
|
||||||
|
});
|
||||||
|
headerBar.pack_end(this.interface.controls.openMenuButton);
|
||||||
|
headerBar.pack_end(this.interface.controls.fullscreenButton);
|
||||||
|
this.interface.addHeaderBar(headerBar, APP_NAME);
|
||||||
|
this.interface.controls.fullscreenButton.connect(
|
||||||
|
'clicked', () => this._onInterfaceToggleFullscreenClicked(true)
|
||||||
|
);
|
||||||
|
this.interface.controls.unfullscreenButton.connect(
|
||||||
|
'clicked', () => this._onInterfaceToggleFullscreenClicked(false)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.window.set_titlebar(this.interface.headerBar);
|
||||||
|
this.window.add(this.interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_activate()
|
||||||
|
{
|
||||||
|
super.vfunc_activate();
|
||||||
|
this.window.show_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
run(arr)
|
run(arr)
|
||||||
@@ -105,44 +142,6 @@ var App = GObject.registerClass({
|
|||||||
debug('cleared update time interval');
|
debug('cleared update time interval');
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildUI()
|
|
||||||
{
|
|
||||||
this.window = new Window(this, APP_NAME);
|
|
||||||
|
|
||||||
this.windowRealizeSignal = this.window.connect(
|
|
||||||
'realize', this._onWindowRealize.bind(this)
|
|
||||||
);
|
|
||||||
this.window.connect(
|
|
||||||
'key-press-event', this._onWindowKeyPressEvent.bind(this)
|
|
||||||
);
|
|
||||||
this.window.connect(
|
|
||||||
'fullscreen-changed', this._onWindowFullscreenChanged.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.interface = new Interface();
|
|
||||||
let headerBar = new Gtk.HeaderBar({
|
|
||||||
title: APP_NAME,
|
|
||||||
show_close_button: true,
|
|
||||||
});
|
|
||||||
headerBar.pack_end(this.interface.controls.openMenuButton);
|
|
||||||
headerBar.pack_end(this.interface.controls.fullscreenButton);
|
|
||||||
this.interface.addHeaderBar(headerBar, APP_NAME);
|
|
||||||
this.interface.controls.fullscreenButton.connect(
|
|
||||||
'clicked', () => this._onInterfaceToggleFullscreenClicked(true)
|
|
||||||
);
|
|
||||||
this.interface.controls.unfullscreenButton.connect(
|
|
||||||
'clicked', () => this._onInterfaceToggleFullscreenClicked(false)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.window.set_titlebar(this.interface.headerBar);
|
|
||||||
this.window.add(this.interface);
|
|
||||||
}
|
|
||||||
|
|
||||||
_openWindow()
|
|
||||||
{
|
|
||||||
this.window.show_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
_onWindowRealize()
|
_onWindowRealize()
|
||||||
{
|
{
|
||||||
this.window.disconnect(this.windowRealizeSignal);
|
this.window.disconnect(this.windowRealizeSignal);
|
||||||
|
@@ -81,9 +81,7 @@ class BoxedPopoverButton extends BoxedIconButton
|
|||||||
});
|
});
|
||||||
this.popover.add(this.popoverBox);
|
this.popover.add(this.popoverBox);
|
||||||
this.popoverBox.show();
|
this.popoverBox.show();
|
||||||
this.connect(
|
|
||||||
'clicked', this._onPopoverButtonClicked.bind(this)
|
|
||||||
);
|
|
||||||
if(this.isFullscreen)
|
if(this.isFullscreen)
|
||||||
this.popover.get_style_context().add_class('osd');
|
this.popover.get_style_context().add_class('osd');
|
||||||
}
|
}
|
||||||
@@ -99,7 +97,7 @@ class BoxedPopoverButton extends BoxedIconButton
|
|||||||
super.setFullscreenMode(isEnabled);
|
super.setFullscreenMode(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPopoverButtonClicked()
|
vfunc_clicked()
|
||||||
{
|
{
|
||||||
this.popover.popup();
|
this.popover.popup();
|
||||||
}
|
}
|
||||||
|
@@ -20,10 +20,6 @@ var Window = GObject.registerClass({
|
|||||||
height_request: 642
|
height_request: 642
|
||||||
});
|
});
|
||||||
this.isFullscreen = false;
|
this.isFullscreen = false;
|
||||||
|
|
||||||
this.connect(
|
|
||||||
'window-state-event', this._onWindowStateEvent.bind(this)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleFullscreen()
|
toggleFullscreen()
|
||||||
@@ -32,12 +28,14 @@ var Window = GObject.registerClass({
|
|||||||
this[`${un}fullscreen`]();
|
this[`${un}fullscreen`]();
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWindowStateEvent(self, event)
|
vfunc_window_state_event(event)
|
||||||
{
|
{
|
||||||
let window = event.get_window();
|
super.vfunc_window_state_event(event);
|
||||||
let state = window.get_state();
|
|
||||||
|
|
||||||
let isFullscreen = Boolean(state & Gdk.WindowState.FULLSCREEN);
|
let isFullscreen = Boolean(
|
||||||
|
event.new_window_state
|
||||||
|
& Gdk.WindowState.FULLSCREEN
|
||||||
|
);
|
||||||
|
|
||||||
if(this.isFullscreen === isFullscreen)
|
if(this.isFullscreen === isFullscreen)
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user