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,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,
|
...params,
|
||||||
className: 'position-slider',
|
className: 'position-slider',
|
||||||
hexpand: true,
|
hexpand: true,
|
||||||
|
@ -86,12 +91,19 @@ export const PositionSlider = (player, params) => Slider({
|
||||||
},
|
},
|
||||||
properties: [
|
properties: [
|
||||||
['update', slider => {
|
['update', slider => {
|
||||||
if (slider.dragging)
|
if (slider.dragging) {
|
||||||
return;
|
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: [
|
connections: [
|
||||||
|
@ -105,6 +117,7 @@ export const PositionSlider = (player, params) => Slider({
|
||||||
trough { background-color: ${player.colors.value.buttonAccent}; }`);
|
trough { background-color: ${player.colors.value.buttonAccent}; }`);
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function lengthStr(length) {
|
function lengthStr(length) {
|
||||||
|
|
Loading…
Reference in a new issue