mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Fix toggle play button icon change
This commit is contained in:
@@ -1,18 +1,22 @@
|
|||||||
const { GObject, Gtk } = imports.gi;
|
const { GObject, Gtk } = imports.gi;
|
||||||
|
|
||||||
var IconButton = GObject.registerClass(
|
var CustomButton = GObject.registerClass(
|
||||||
class ClapperIconButton extends Gtk.Button
|
class ClapperCustomButton extends Gtk.Button
|
||||||
{
|
{
|
||||||
_init(icon)
|
_init(opts)
|
||||||
{
|
{
|
||||||
super._init({
|
opts = opts || {};
|
||||||
|
|
||||||
|
let defaults = {
|
||||||
margin_top: 4,
|
margin_top: 4,
|
||||||
margin_bottom: 4,
|
margin_bottom: 4,
|
||||||
margin_start: 1,
|
margin_start: 1,
|
||||||
margin_end: 1,
|
margin_end: 1,
|
||||||
can_focus: false,
|
can_focus: false,
|
||||||
icon_name: icon,
|
};
|
||||||
});
|
Object.assign(opts, defaults);
|
||||||
|
|
||||||
|
super._init(opts);
|
||||||
|
|
||||||
this.isFullscreen = false;
|
this.isFullscreen = false;
|
||||||
this.add_css_class('flat');
|
this.add_css_class('flat');
|
||||||
@@ -20,10 +24,47 @@ class ClapperIconButton extends Gtk.Button
|
|||||||
|
|
||||||
setFullscreenMode(isFullscreen)
|
setFullscreenMode(isFullscreen)
|
||||||
{
|
{
|
||||||
|
if(this.isFullscreen === isFullscreen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.margin_top = (isFullscreen) ? 6 : 4;
|
||||||
this.isFullscreen = isFullscreen;
|
this.isFullscreen = isFullscreen;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var IconButton = GObject.registerClass(
|
||||||
|
class ClapperIconButton extends CustomButton
|
||||||
|
{
|
||||||
|
_init(icon)
|
||||||
|
{
|
||||||
|
super._init({
|
||||||
|
icon_name: icon,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var IconToggleButton = GObject.registerClass(
|
||||||
|
class ClapperIconToggleButton extends IconButton
|
||||||
|
{
|
||||||
|
_init(primaryIcon, secondaryIcon)
|
||||||
|
{
|
||||||
|
super._init(primaryIcon);
|
||||||
|
|
||||||
|
this.primaryIcon = primaryIcon;
|
||||||
|
this.secondaryIcon = secondaryIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPrimaryIcon()
|
||||||
|
{
|
||||||
|
this.icon_name = this.primaryIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSecondaryIcon()
|
||||||
|
{
|
||||||
|
this.icon_name = this.secondaryIcon;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var PopoverButton = GObject.registerClass(
|
var PopoverButton = GObject.registerClass(
|
||||||
class ClapperPopoverButton extends IconButton
|
class ClapperPopoverButton extends IconButton
|
||||||
{
|
{
|
||||||
@@ -53,7 +94,8 @@ class ClapperPopoverButton extends IconButton
|
|||||||
if(this.isFullscreen === isFullscreen)
|
if(this.isFullscreen === isFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.margin_top = (isFullscreen) ? 6 : 4;
|
super.setFullscreenMode(isFullscreen);
|
||||||
|
|
||||||
this.popover.set_offset(0, -this.margin_top);
|
this.popover.set_offset(0, -this.margin_top);
|
||||||
|
|
||||||
let cssClass = 'osd';
|
let cssClass = 'osd';
|
||||||
@@ -62,8 +104,6 @@ class ClapperPopoverButton extends IconButton
|
|||||||
|
|
||||||
let action = (isFullscreen) ? 'add' : 'remove';
|
let action = (isFullscreen) ? 'add' : 'remove';
|
||||||
this.popover[action + '_css_class'](cssClass);
|
this.popover[action + '_css_class'](cssClass);
|
||||||
|
|
||||||
super.setFullscreenMode(isFullscreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_clicked()
|
vfunc_clicked()
|
||||||
|
45
clapper_src/controls.js
vendored
45
clapper_src/controls.js
vendored
@@ -63,6 +63,8 @@ var Controls = GObject.registerClass({
|
|||||||
this.setDefaultWidgetBehaviour(this.openMenuButton);
|
this.setDefaultWidgetBehaviour(this.openMenuButton);
|
||||||
//this.forall(this.setDefaultWidgetBehaviour);
|
//this.forall(this.setDefaultWidgetBehaviour);
|
||||||
|
|
||||||
|
this.add_css_class('playercontrols');
|
||||||
|
|
||||||
this.realizeSignal = this.connect('realize', this._onRealize.bind(this));
|
this.realizeSignal = this.connect('realize', this._onRealize.bind(this));
|
||||||
this.destroySignal = this.connect('destroy', this._onDestroy.bind(this));
|
this.destroySignal = this.connect('destroy', this._onDestroy.bind(this));
|
||||||
}
|
}
|
||||||
@@ -75,9 +77,12 @@ var Controls = GObject.registerClass({
|
|||||||
this.unfullscreenButton.set_visible(isFullscreen);
|
this.unfullscreenButton.set_visible(isFullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton(iconName)
|
addButton(buttonIcon)
|
||||||
{
|
{
|
||||||
let button = new Buttons.IconButton(iconName);
|
let button = (buttonIcon instanceof Gtk.Button)
|
||||||
|
? buttonIcon
|
||||||
|
: new Buttons.IconButton(buttonIcon);
|
||||||
|
|
||||||
this.append(button);
|
this.append(button);
|
||||||
this.buttonsArr.push(button);
|
this.buttonsArr.push(button);
|
||||||
|
|
||||||
@@ -87,10 +92,8 @@ var Controls = GObject.registerClass({
|
|||||||
addPopoverButton(iconName)
|
addPopoverButton(iconName)
|
||||||
{
|
{
|
||||||
let button = new Buttons.PopoverButton(iconName);
|
let button = new Buttons.PopoverButton(iconName);
|
||||||
this.append(button);
|
|
||||||
this.buttonsArr.push(button);
|
|
||||||
|
|
||||||
return button;
|
return this.addButton(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCheckButtons(box, array, activeId)
|
addCheckButtons(box, array, activeId)
|
||||||
@@ -172,28 +175,11 @@ var Controls = GObject.registerClass({
|
|||||||
|
|
||||||
_addTogglePlayButton()
|
_addTogglePlayButton()
|
||||||
{
|
{
|
||||||
this.togglePlayButton = this.addButton(
|
this.togglePlayButton = new Buttons.IconToggleButton(
|
||||||
'media-playback-start-symbolic',
|
'media-playback-start-symbolic',
|
||||||
Gtk.IconSize.LARGE_TOOLBAR
|
'media-playback-pause-symbolic'
|
||||||
);
|
);
|
||||||
this.togglePlayButton.setPlayImage = () =>
|
this.addButton(this.togglePlayButton);
|
||||||
{
|
|
||||||
/*
|
|
||||||
this.togglePlayButton.image.set_from_icon_name(
|
|
||||||
'media-playback-start-symbolic',
|
|
||||||
this.togglePlayButton.image.icon_size
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
this.togglePlayButton.setPauseImage = () =>
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
this.togglePlayButton.image.set_from_icon_name(
|
|
||||||
'media-playback-pause-symbolic',
|
|
||||||
this.togglePlayButton.image.icon_size
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addPositionScale()
|
_addPositionScale()
|
||||||
@@ -203,7 +189,16 @@ var Controls = GObject.registerClass({
|
|||||||
value_pos: Gtk.PositionType.LEFT,
|
value_pos: Gtk.PositionType.LEFT,
|
||||||
draw_value: true,
|
draw_value: true,
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
|
valign: Gtk.Align.CENTER,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.togglePlayButton.bind_property('margin_top',
|
||||||
|
this.positionScale, 'margin_top', GObject.BindingFlags.SYNC_CREATE
|
||||||
|
);
|
||||||
|
this.togglePlayButton.bind_property('margin_bottom',
|
||||||
|
this.positionScale, 'margin_bottom', GObject.BindingFlags.SYNC_CREATE
|
||||||
|
);
|
||||||
|
|
||||||
this.positionScale.add_css_class('positionscale');
|
this.positionScale.add_css_class('positionscale');
|
||||||
this.positionScale.set_format_value_func(
|
this.positionScale.set_format_value_func(
|
||||||
this._onPositionScaleFormatValue.bind(this)
|
this._onPositionScaleFormatValue.bind(this)
|
||||||
|
@@ -350,10 +350,10 @@ class ClapperInterface extends Gtk.Grid
|
|||||||
case GstPlayer.PlayerState.STOPPED:
|
case GstPlayer.PlayerState.STOPPED:
|
||||||
this.needsTracksUpdate = true;
|
this.needsTracksUpdate = true;
|
||||||
case GstPlayer.PlayerState.PAUSED:
|
case GstPlayer.PlayerState.PAUSED:
|
||||||
this.controls.togglePlayButton.setPlayImage();
|
this.controls.togglePlayButton.setPrimaryIcon();
|
||||||
break;
|
break;
|
||||||
case GstPlayer.PlayerState.PLAYING:
|
case GstPlayer.PlayerState.PLAYING:
|
||||||
this.controls.togglePlayButton.setPauseImage();
|
this.controls.togglePlayButton.setSecondaryIcon();
|
||||||
if(this.needsTracksUpdate) {
|
if(this.needsTracksUpdate) {
|
||||||
this.needsTracksUpdate = false;
|
this.needsTracksUpdate = false;
|
||||||
this.updateMediaTracks();
|
this.updateMediaTracks();
|
||||||
|
@@ -7,9 +7,10 @@ scale marks {
|
|||||||
font-size: 22px;
|
font-size: 22px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
.osd .playercontrols {
|
||||||
|
-gtk-icon-size: 24px;
|
||||||
|
}
|
||||||
.osd button {
|
.osd button {
|
||||||
margin-left: 1px;
|
|
||||||
margin-right: 1px;
|
|
||||||
min-width: 36px;
|
min-width: 36px;
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
}
|
}
|
||||||
@@ -28,7 +29,7 @@ scale marks {
|
|||||||
}
|
}
|
||||||
.reavealertop {
|
.reavealertop {
|
||||||
min-height: 100px;
|
min-height: 100px;
|
||||||
box-shadow: inset 0px 200px 10px -124px rgba(0,0,0,0.4);
|
box-shadow: inset 0px 200px 10px -124px rgba(0,0,0,0.3);
|
||||||
font-family: 'Cantarell', 'Noto Sans', sans-serif;
|
font-family: 'Cantarell', 'Noto Sans', sans-serif;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
Reference in New Issue
Block a user