feat(ags): add diff cursors on slider and fix player-icon
This commit is contained in:
parent
c018bdbece
commit
3433b9c3bd
1 changed files with 43 additions and 30 deletions
|
@ -1,6 +1,9 @@
|
||||||
const { CACHE_DIR, execAsync, ensureDirectory, lookUpIcon } = ags.Utils;
|
const { CACHE_DIR, execAsync, ensureDirectory, lookUpIcon } = ags.Utils;
|
||||||
const { Button, Icon, Label, Box, Stack, Slider, CenterBox } = ags.Widget;
|
const { Button, Icon, Label, Box, Stack, Slider, CenterBox } = ags.Widget;
|
||||||
const { GLib } = imports.gi;
|
const { GLib, Gtk, Gdk } = imports.gi;
|
||||||
|
const display = Gdk.Display.get_default();
|
||||||
|
|
||||||
|
import { EventBox } from '../misc/cursorbox.js';
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
mpris: {
|
mpris: {
|
||||||
|
@ -68,7 +71,8 @@ export const ArtistLabel = (player, params) => Label({
|
||||||
export const PlayerIcon = (player, { symbolic = true, ...params } = {}) => Icon({
|
export const PlayerIcon = (player, { symbolic = true, ...params } = {}) => Icon({
|
||||||
...params,
|
...params,
|
||||||
className: 'player-icon',
|
className: 'player-icon',
|
||||||
tooltipText: player.indentity || '',
|
size: 32,
|
||||||
|
tooltipText: player.identity || '',
|
||||||
connections: [[player, icon => {
|
connections: [[player, icon => {
|
||||||
const name = `${player.entry}${symbolic ? '-symbolic' : ''}`;
|
const name = `${player.entry}${symbolic ? '-symbolic' : ''}`;
|
||||||
lookUpIcon(name) ? icon.icon = name
|
lookUpIcon(name) ? icon.icon = name
|
||||||
|
@ -76,35 +80,44 @@ export const PlayerIcon = (player, { symbolic = true, ...params } = {}) => Icon(
|
||||||
}]],
|
}]],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PositionSlider = (player, params) => Slider({
|
export const PositionSlider = (player, params) => EventBox({
|
||||||
...params,
|
child: Slider({
|
||||||
className: 'position-slider',
|
...params,
|
||||||
hexpand: true,
|
className: 'position-slider',
|
||||||
drawValue: false,
|
hexpand: true,
|
||||||
onChange: ({ value }) => {
|
drawValue: false,
|
||||||
player.position = player.length * value;
|
onChange: ({ value }) => {
|
||||||
},
|
player.position = player.length * value;
|
||||||
properties: [
|
},
|
||||||
['update', slider => {
|
properties: [
|
||||||
if (slider.dragging)
|
['update', slider => {
|
||||||
return;
|
if (slider.dragging) {
|
||||||
|
slider.get_parent().window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (slider.get_parent() && slider.get_parent().window) {
|
||||||
|
slider.get_parent().window.set_cursor(Gdk.Cursor.new_from_name(display, 'pointer'));
|
||||||
|
}
|
||||||
|
|
||||||
slider.sensitive = player.length > 0;
|
slider.sensitive = player.length > 0;
|
||||||
if (player.length > 0)
|
if (player.length > 0) {
|
||||||
slider.value = player.position / player.length;
|
slider.value = player.position / player.length;
|
||||||
}],
|
}
|
||||||
],
|
}
|
||||||
connections: [
|
}],
|
||||||
[player, s => s._update(s), 'position'],
|
],
|
||||||
[1000, s => s._update(s)],
|
connections: [
|
||||||
[player.colors, s => {
|
[player, s => s._update(s), 'position'],
|
||||||
if (player.colors.value)
|
[1000, s => s._update(s)],
|
||||||
s.setCss(`highlight { background-color: ${player.colors.value.buttonAccent}; }
|
[player.colors, s => {
|
||||||
slider { background-color: ${player.colors.value.buttonAccent}; }
|
if (player.colors.value)
|
||||||
slider:hover { background-color: #303240; }
|
s.setCss(`highlight { background-color: ${player.colors.value.buttonAccent}; }
|
||||||
trough { background-color: ${player.colors.value.buttonAccent}; }`);
|
slider { background-color: ${player.colors.value.buttonAccent}; }
|
||||||
}],
|
slider:hover { background-color: #303240; }
|
||||||
],
|
trough { background-color: ${player.colors.value.buttonAccent}; }`);
|
||||||
|
}],
|
||||||
|
],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function lengthStr(length) {
|
function lengthStr(length) {
|
||||||
|
|
Loading…
Reference in a new issue