Change elapsed time into button

This commit is contained in:
Rafostar
2020-10-07 23:10:11 +02:00
parent 4c5d922d47
commit 43a54920ef
4 changed files with 54 additions and 27 deletions

View File

@@ -84,7 +84,7 @@ var App = GObject.registerClass({
{ {
super.vfunc_activate(); super.vfunc_activate();
this.window.show(); this.window.present();
Gtk.StyleContext.add_provider_for_display( Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(), Gdk.Display.get_default(),
this.cssProvider, this.cssProvider,
@@ -307,8 +307,10 @@ var App = GObject.registerClass({
if(!this.inhibitCookie) if(!this.inhibitCookie)
return; return;
/* Uninhibit seems to be broken as of GTK 3.99.2
this.uninhibit(this.inhibitCookie); this.uninhibit(this.inhibitCookie);
this.inhibitCookie = null; this.inhibitCookie = null;
*/
} }
debug(`set prevent suspend to: ${isInhibited}`); debug(`set prevent suspend to: ${isInhibited}`);

View File

@@ -65,6 +65,31 @@ class ClapperIconToggleButton extends IconButton
} }
}); });
var LabelButton = GObject.registerClass(
class ClapperLabelButton extends CustomButton
{
_init(text)
{
super._init({
margin_start: 0,
margin_end: 0,
});
this.customLabel = new Gtk.Label({
label: text,
single_line_mode: true,
});
this.customLabel.add_css_class('labelbutton');
this.set_child(this.customLabel);
}
set_label(text)
{
this.customLabel.set_text(text);
}
});
var PopoverButton = GObject.registerClass( var PopoverButton = GObject.registerClass(
class ClapperPopoverButton extends IconButton class ClapperPopoverButton extends IconButton
{ {

View File

@@ -32,6 +32,7 @@ var Controls = GObject.registerClass({
}); });
this.durationFormated = '00:00:00'; this.durationFormated = '00:00:00';
this.elapsedInitial = '00:00:00/00:00:00';
this.buttonsArr = []; this.buttonsArr = [];
this._addTogglePlayButton(); this._addTogglePlayButton();
@@ -89,6 +90,14 @@ var Controls = GObject.registerClass({
return button; return button;
} }
addLabelButton(text)
{
text = text || '';
let button = new Buttons.LabelButton(text);
return this.addButton(button);
}
addPopoverButton(iconName) addPopoverButton(iconName)
{ {
let button = new Buttons.PopoverButton(iconName); let button = new Buttons.PopoverButton(iconName);
@@ -184,10 +193,11 @@ var Controls = GObject.registerClass({
_addPositionScale() _addPositionScale()
{ {
this.elapsedButton = this.addLabelButton(this.elapsedInitial);
this.positionScale = new Gtk.Scale({ this.positionScale = new Gtk.Scale({
orientation: Gtk.Orientation.HORIZONTAL, orientation: Gtk.Orientation.HORIZONTAL,
value_pos: Gtk.PositionType.LEFT, value_pos: Gtk.PositionType.LEFT,
draw_value: true, draw_value: false,
hexpand: true, hexpand: true,
valign: Gtk.Align.CENTER, valign: Gtk.Align.CENTER,
}); });
@@ -200,9 +210,7 @@ var Controls = GObject.registerClass({
); );
this.positionScale.add_css_class('positionscale'); this.positionScale.add_css_class('positionscale');
this.positionScale.set_format_value_func( this.positionScale.connect('value-changed', this._onPositionScaleValueChanged.bind(this));
this._onPositionScaleFormatValue.bind(this)
);
/* /*
this.positionScale.connect( this.positionScale.connect(
'button-press-event', this._onPositionScaleButtonPressEvent.bind(this) 'button-press-event', this._onPositionScaleButtonPressEvent.bind(this)
@@ -284,10 +292,12 @@ var Controls = GObject.registerClass({
} }
} }
_onPositionScaleFormatValue(self, value) _onPositionScaleValueChanged()
{ {
return this._getFormatedTime(value) let elapsed = this._getFormatedTime(this.positionScale.get_value())
+ '/' + this.durationFormated; + '/' + this.durationFormated;
this.elapsedButton.set_label(elapsed);
} }
_onPositionScaleButtonPressEvent() _onPositionScaleButtonPressEvent()
@@ -345,7 +355,6 @@ var Controls = GObject.registerClass({
{ {
this.disconnect(this.destroySignal); this.disconnect(this.destroySignal);
this.positionScale.set_format_value_func(null);
this.visualizationsButton.emit('destroy'); this.visualizationsButton.emit('destroy');
this.videoTracksButton.emit('destroy'); this.videoTracksButton.emit('destroy');
this.audioTracksButton.emit('destroy'); this.audioTracksButton.emit('destroy');

View File

@@ -24,6 +24,11 @@ scale marks {
min-width: 18px; min-width: 18px;
min-height: 18px; min-height: 18px;
} }
.labelbutton {
font-family: 'Cantarell', 'Noto Sans', sans-serif;
font-variant-numeric: tabular-nums;
font-weight: 600;
}
.videobox { .videobox {
background: black; background: black;
} }
@@ -45,25 +50,13 @@ scale marks {
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
} }
.osd .labelbutton {
/* Position Scale */
.positionscale value {
font-weight: 600;
color: currentColor;
}
.positionscale trough highlight {
min-height: 4px;
}
.osd .positionscale value {
font-size: 24px; font-size: 24px;
} }
.positionscale contents {
margin-left: 4px; /* Position Scale */
margin-right: 2px; .positionscale trough highlight {
} min-height: 4px;
.osd .positionscale contents {
margin-left: 8px;
margin-right: 2px;
} }
.osd .positionscale trough slider { .osd .positionscale trough slider {
color: transparent; color: transparent;
@@ -77,12 +70,10 @@ scale marks {
/* Volume Scale */ /* Volume Scale */
.volumescale { .volumescale {
margin-left: 4px;
min-height: 180px; min-height: 180px;
} }
.osd .volumescale { .osd .volumescale {
margin: 6px; margin: 6px;
margin-left: 10px;
min-height: 280px; min-height: 280px;
} }
.volumescale marks label { .volumescale marks label {