-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprefs.js
More file actions
89 lines (78 loc) · 2.24 KB
/
prefs.js
File metadata and controls
89 lines (78 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import Gio from "gi://Gio";
import Adw from "gi://Adw";
import Gtk from "gi://Gtk";
import {
ExtensionPreferences,
gettext as _,
} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
export default class GitHubPRStatusPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
const page = new Adw.PreferencesPage({
title: _("GitHub PR Status"),
icon_name: "applications-internet-symbolic",
});
window.add(page);
// Authentication
const authGroup = new Adw.PreferencesGroup({
title: _("Authentication"),
description: _(
'A GitHub Personal Access Token with "repo" scope is required to read PR and CI status.',
),
});
page.add(authGroup);
const tokenRow = new Adw.PasswordEntryRow({
title: _("GitHub Token"),
show_apply_button: true,
});
settings.bind(
"github-token",
tokenRow,
"text",
Gio.SettingsBindFlags.DEFAULT,
);
authGroup.add(tokenRow);
// Polling
const pollingGroup = new Adw.PreferencesGroup({
title: _("Polling"),
});
page.add(pollingGroup);
const intervalAdjustment = new Gtk.Adjustment({
lower: 60,
upper: 3600,
step_increment: 30,
page_increment: 60,
value: settings.get_int("refresh-interval"),
});
const intervalRow = new Adw.SpinRow({
title: _("Refresh Interval"),
subtitle: _("Seconds between GitHub API polls"),
adjustment: intervalAdjustment,
});
settings.bind(
"refresh-interval",
intervalAdjustment,
"value",
Gio.SettingsBindFlags.DEFAULT,
);
pollingGroup.add(intervalRow);
// Notifications
const notifyGroup = new Adw.PreferencesGroup({
title: _("Notifications"),
});
page.add(notifyGroup);
const notifyRow = new Adw.SwitchRow({
title: _("Notify on Status Change"),
subtitle: _("Show a desktop notification when a PR's CI status changes"),
});
settings.bind(
"notify-on-change",
notifyRow,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
notifyGroup.add(notifyRow);
// prevent GC of settings while window is open
window._settings = settings;
}
}