feat(ags): add diff cursors on slider and fix player-icon

This commit is contained in:
matt1432 2023-09-18 10:22:12 -04:00
parent c018bdbece
commit 3433b9c3bd

View file

@ -1,6 +1,9 @@
const { CACHE_DIR, execAsync, ensureDirectory, lookUpIcon } = ags.Utils;
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 = {
mpris: {
@ -68,7 +71,8 @@ export const ArtistLabel = (player, params) => Label({
export const PlayerIcon = (player, { symbolic = true, ...params } = {}) => Icon({
...params,
className: 'player-icon',
tooltipText: player.indentity || '',
size: 32,
tooltipText: player.identity || '',
connections: [[player, icon => {
const name = `${player.entry}${symbolic ? '-symbolic' : ''}`;
lookUpIcon(name) ? icon.icon = name
@ -76,7 +80,8 @@ export const PlayerIcon = (player, { symbolic = true, ...params } = {}) => Icon(
}]],
});
export const PositionSlider = (player, params) => Slider({
export const PositionSlider = (player, params) => EventBox({
child: Slider({
...params,
className: 'position-slider',
hexpand: true,
@ -86,12 +91,19 @@ export const PositionSlider = (player, params) => Slider({
},
properties: [
['update', slider => {
if (slider.dragging)
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;
if (player.length > 0)
if (player.length > 0) {
slider.value = player.position / player.length;
}
}
}],
],
connections: [
@ -105,6 +117,7 @@ export const PositionSlider = (player, params) => Slider({
trough { background-color: ${player.colors.value.buttonAccent}; }`);
}],
],
}),
});
function lengthStr(length) {