Skip to content

Commit

Permalink
chore: update docs to latest github wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
matt1432 committed Dec 24, 2023
1 parent 74f432a commit 11bee9b
Show file tree
Hide file tree
Showing 24 changed files with 934 additions and 1,036 deletions.
10 changes: 4 additions & 6 deletions docs/src/App.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import App from 'resource:///com/github/Aylur/ags/app.js';

// this is only signaled for windows exported in config.js
// or added with App.addWindow
const label = Widget.Label({
connections: [
[App, (self, windowName, visible) => {
self.label = `${windowName} is ${visible ? 'visible' : 'not visible'}`;
}, 'window-toggled'],
],
const label = Widget.Label()
.hook(App, (self, windowName, visible) => {
self.label = `${windowName} is ${visible ? 'visible' : 'not visible'}`;
}, 'window-toggled')
});
```

Expand Down
3 changes: 2 additions & 1 deletion docs/src/Applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#### methods
* `launch`: `() => void` launches the app, you could also do `Utils.execAsync(['bash', '-c', app.executable])`, but the launch method keeps track of the frequency of launches which is used to sort the query
* `match`: `(string) => boolean`: returns wether a search term matches the app
* `match`: `(string) => boolean` returns whether a search term matches the app
- `reload`: `() => void` rereads .desktop files

## [Example Applauncher](https://github.com/Aylur/ags/tree/main/example/applauncher)
35 changes: 17 additions & 18 deletions docs/src/Audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';

/** @param {'speaker' | 'microphone'} type */
const VolumeSlider = (type = 'speaker') => Widget.Slider({
hexpand: true,
drawValue: false,
onChange: ({ value }) => Audio[type].volume = value,
connections: [[Audio, self => {
setup: self => self.hook(Audio, () => {
// Audio.speaker and Audio.microphone can be undefined
// to workaround this use the ? chain operator
self.value = Audio[type]?.volume || 0;
}, `${type}-changed`]],
}, `${type}-changed`),
});

const speakerSlider = VolumeSlider('speaker');
Expand All @@ -55,23 +56,21 @@ import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';

const volumeIndicator = Widget.Button({
onClicked: () => Audio.speaker.isMuted = !Audio.speaker.isMuted,
child: Widget.Icon({
connections: [[Audio, self => {
if (!Audio.speaker)
return;
child: Widget.Icon().hook(Audio, self => {
if (!Audio.speaker)
return;

const vol = Audio.speaker.volume * 100;
const icon = [
[101, 'overamplified'],
[67, 'high'],
[34, 'medium'],
[1, 'low'],
[0, 'muted'],
].find(([threshold]) => threshold <= vol)[1];
const vol = Audio.speaker.volume * 100;
const icon = [
[101, 'overamplified'],
[67, 'high'],
[34, 'medium'],
[1, 'low'],
[0, 'muted'],
].find(([threshold]) => threshold <= vol)[1];

self.icon = `audio-volume-${icon}-symbolic`;
self.tooltipText = `Volume ${Math.floor(vol)}%`;
}, 'speaker-changed']],
}),
self.icon = `audio-volume-${icon}-symbolic`;
self.tooltipText = `Volume ${Math.floor(vol)}%`;
}, 'speaker-changed'),
});
```
Loading

0 comments on commit 11bee9b

Please sign in to comment.