update
This commit is contained in:
1 parent
b7d5040c58
commit
6e2d0fb6bd
14 files changed
+342
-104
No files matched your search
+31
-25
@@ -172,25 +172,31 @@ function BatteryLabel() {
|
||||
|
||||
|
||||
function SysTray() {
|
||||
const items = systemtray.bind("items")
|
||||
.as(items => items.map(item => {
|
||||
if (item.id.trim() != "nm-applet" && item.id.trim() != "blueman") {
|
||||
return Widget.Button({
|
||||
child: Widget.Icon({ icon: item.bind("icon") }),
|
||||
on_primary_click: (_, event) => item.activate(event),
|
||||
on_secondary_click: (_, event) => item.openMenu(event),
|
||||
tooltip_markup: item.bind("tooltip_markup"),
|
||||
})
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}))
|
||||
|
||||
// @ts-ignore
|
||||
return Widget.Box({
|
||||
class_name: "tray",
|
||||
spacing: 5,
|
||||
children: items,
|
||||
setup: (self) => {
|
||||
self.hook(systemtray, () => {
|
||||
const items = systemtray.items;
|
||||
// @ts-expect-error
|
||||
self.children = items.map(item => {
|
||||
if (item.id.trim() != "nm-applet" && item.id.trim() != "blueman") {
|
||||
return Widget.Button({
|
||||
child: Widget.Icon({ icon: item.bind("icon") }),
|
||||
on_primary_click_release: (_, event) => item.activate(event),
|
||||
on_secondary_click_release: (_, event) => item.openMenu(event),
|
||||
tooltip_markup: item.bind("tooltip_markup"),
|
||||
})
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
});
|
||||
if (self.children.length > 0)
|
||||
self.visible = true;
|
||||
else
|
||||
self.visible = false;
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -217,7 +223,7 @@ function Wifi() {
|
||||
on_primary_click: () => {
|
||||
OpenSettings("network")
|
||||
},
|
||||
on_secondary_click: (_, event) => {
|
||||
on_secondary_click_release: (_, event) => {
|
||||
const nm_applet = systemtray.items.find(item => item.id == "nm-applet")
|
||||
if (nm_applet) {
|
||||
nm_applet.openMenu(event)
|
||||
@@ -243,10 +249,10 @@ function Wifi() {
|
||||
function Bluetooth() {
|
||||
return Widget.Button({
|
||||
class_name: "bar_bluetooth",
|
||||
on_primary_click: () => {
|
||||
on_primary_click_release: () => {
|
||||
OpenSettings("bluetooth")
|
||||
},
|
||||
on_secondary_click: (_, event) => {
|
||||
on_secondary_click_release: (_, event) => {
|
||||
const blueman = systemtray.items.find(item => item.id == "blueman")
|
||||
if (blueman) {
|
||||
blueman.openMenu(event)
|
||||
@@ -278,10 +284,10 @@ function MediaPlayer() {
|
||||
let metadata = mpris.players[0]?.metadata;
|
||||
const button = Widget.Button({
|
||||
class_name: "filled_tonal_button awesome_icon",
|
||||
on_primary_click: () => {
|
||||
on_primary_click_release: () => {
|
||||
App.toggleWindow("media")
|
||||
},
|
||||
on_secondary_click: () => {
|
||||
on_secondary_click_release: () => {
|
||||
Utils.execAsync(["playerctl", "play-pause"]).catch(print)
|
||||
},
|
||||
child: MaterialIcon("play_circle"),
|
||||
@@ -316,11 +322,11 @@ function KeyboardLayout() {
|
||||
function OpenSideBar() {
|
||||
const button = Widget.Button({
|
||||
class_name: "filled_tonal_button awesome_icon",
|
||||
on_primary_click: () => {
|
||||
on_primary_click_release: () => {
|
||||
App.toggleWindow("sidebar")
|
||||
},
|
||||
|
||||
on_secondary_click: () => {
|
||||
on_secondary_click_release: () => {
|
||||
OpenSettings()
|
||||
},
|
||||
child: MaterialIcon("dock_to_left")
|
||||
@@ -387,8 +393,8 @@ function volumeIndicator() {
|
||||
onScrollDown: () => audio.speaker.volume -= 0.01,
|
||||
class_name: "filled_tonal_button volume_box",
|
||||
child: Widget.Button({
|
||||
on_primary_click: () => Utils.execAsync("pavucontrol").catch(print),
|
||||
on_secondary_click: () => audio.speaker.is_muted = !audio.speaker.is_muted,
|
||||
on_primary_click_release: () => Utils.execAsync("pavucontrol").catch(print),
|
||||
on_secondary_click_release: () => audio.speaker.is_muted = !audio.speaker.is_muted,
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
MaterialIcon("volume_off", "20px").hook(audio.speaker, self => {
|
||||
|
||||
@@ -9,19 +9,35 @@ type EntryObject = {
|
||||
content: string;
|
||||
entry: string;
|
||||
};
|
||||
|
||||
// ·
|
||||
|
||||
function ClipHistItem(entry: string) {
|
||||
let [id, ...content] = entry.split('\t');
|
||||
let clickCount = 0;
|
||||
let button = Widget.Button({
|
||||
class_name: "entry_container",
|
||||
child: Widget.Label({
|
||||
label: entry,
|
||||
class_name: "entry_label",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
truncate: "end",
|
||||
class_name: "clip_container",
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Label({
|
||||
label: id,
|
||||
class_name: "clip_id",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
}),
|
||||
Widget.Label({
|
||||
label: "・",
|
||||
class_name: "dot_divider",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
}),
|
||||
Widget.Label({
|
||||
label: content.join(' ').trim(),
|
||||
class_name: "clip_label",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
truncate: "end",
|
||||
}),
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
@@ -44,7 +60,7 @@ function ClipHistItem(entry: string) {
|
||||
children: [
|
||||
button,
|
||||
Widget.Separator({
|
||||
class_name: "entry_divider",
|
||||
class_name: "clip_divider",
|
||||
orientation: Gtk.Orientation.HORIZONTAL
|
||||
})
|
||||
]
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
const WINDOW_NAME = "musicplayer";
|
||||
import popupwindow from './misc/popupwindow.ts';
|
||||
import Box from 'types/widgets/box.js';
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import GLib from "gi://GLib?version=2.0";
|
||||
|
||||
type Track = {
|
||||
id: string;
|
||||
title: string;
|
||||
artist: string;
|
||||
url: string; // Assuming we use URLs for identification, but not playback.
|
||||
};
|
||||
|
||||
function MusicPlayerItem(track: Track) {
|
||||
let button = Widget.Button({
|
||||
class_name: "track_container",
|
||||
child: Widget.Label({
|
||||
label: `${track.title} - ${track.artist}`,
|
||||
class_name: "track_label",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
truncate: "end",
|
||||
})
|
||||
});
|
||||
|
||||
button.connect('clicked', () => {
|
||||
playTrack(track); // Function to handle playback
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
button,
|
||||
Widget.Separator({
|
||||
orientation: Gtk.Orientation.HORIZONTAL
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async function playTrack(track: Track) {
|
||||
try {
|
||||
// Placeholder for playing audio via libcanberra or other suitable GTK audio APIs
|
||||
GLib.spawn_command_line_async(`canberra-gtk-play -i audio-file-id`);
|
||||
} catch (error) {
|
||||
console.error(`Error playing track: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
function MusicPlayerWidget({ width = 500, height = 500, spacing = 12 }) {
|
||||
let tracks: Track[] = [
|
||||
{ id: "1", title: "Track 1", artist: "Artist 1", url: "1" },
|
||||
{ id: "2", title: "Track 2", artist: "Artist 2", url: "2" },
|
||||
{ id: "3", title: "Track 3", artist: "Artist 3", url: "3" }
|
||||
// Add more tracks as needed
|
||||
];
|
||||
|
||||
let widgets: Box<any, any>[] = tracks.map(track => MusicPlayerItem(track));
|
||||
|
||||
const list = Widget.Box({
|
||||
vertical: true,
|
||||
spacing,
|
||||
children: widgets
|
||||
});
|
||||
|
||||
const entry = Widget.Entry({
|
||||
hexpand: true,
|
||||
class_name: "musicplayer_entry",
|
||||
placeholder_text: "Search",
|
||||
|
||||
on_change: ({ text }) => widgets.forEach(item => {
|
||||
item.visible = item.attribute.content.match(text ?? "")
|
||||
}),
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
vertical: true,
|
||||
class_name: "musicplayer_box",
|
||||
margin_top: 14,
|
||||
margin_right: 14,
|
||||
children: [
|
||||
entry,
|
||||
Widget.Scrollable({
|
||||
hscroll: "never",
|
||||
css: `min-width: ${width}px;`
|
||||
+ `min-height: ${height}px;`,
|
||||
child: list,
|
||||
}),
|
||||
],
|
||||
setup: self => self.hook(App, (_, windowName, visible) => {
|
||||
if (windowName !== WINDOW_NAME)
|
||||
return;
|
||||
|
||||
if (visible) {
|
||||
entry.text = "";
|
||||
}
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export const musicplayer = popupwindow({
|
||||
name: WINDOW_NAME,
|
||||
class_name: "musicplayer",
|
||||
visible: false,
|
||||
keymode: "exclusive",
|
||||
child: MusicPlayerWidget({
|
||||
width: 500,
|
||||
height: 500,
|
||||
spacing: 0,
|
||||
}),
|
||||
anchor: ["bottom", "right"]
|
||||
});
|
||||
@@ -38,7 +38,7 @@ export const Notification = (notification: NotificationType, dismiss = true) =>
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.EventBox({
|
||||
on_primary_click: (box) => {
|
||||
on_primary_click_release: (box) => {
|
||||
// @ts-ignore
|
||||
const label: Label<any> = box.child.children[1].children[1];
|
||||
if (label.lines < 0) {
|
||||
|
||||
@@ -149,17 +149,17 @@ function Page1() {
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
hexpand: true,
|
||||
spacing: 2.5,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Widget.Button({
|
||||
hexpand: true,
|
||||
class_name: network.wifi.bind("enabled")
|
||||
.as(enabled => enabled ? "management_button active" : "management_button"),
|
||||
child: NetworkIndicator(),
|
||||
on_primary_click: () => {
|
||||
on_primary_click_release: () => {
|
||||
network.toggleWifi();
|
||||
},
|
||||
on_secondary_click: () => {
|
||||
on_secondary_click_release: () => {
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
App.openWindow("network");
|
||||
}
|
||||
@@ -174,11 +174,11 @@ function Page1() {
|
||||
icon: "bluetooth",
|
||||
arrow: true,
|
||||
}),
|
||||
on_primary_click: () => {
|
||||
on_primary_click_release: () => {
|
||||
Utils.execAsync(`${App.configDir}/scripts/bluetooth.sh --toggle`)
|
||||
.then(out => { bluetooth_enabled.setValue(out) })
|
||||
},
|
||||
on_secondary_click: () => {
|
||||
on_secondary_click_release: () => {
|
||||
OpenSettings("bluetooth")
|
||||
App.closeWindow(WINDOW_NAME)
|
||||
}
|
||||
@@ -187,7 +187,7 @@ function Page1() {
|
||||
}),
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
spacing: 2.5,
|
||||
spacing: 5,
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Button({
|
||||
@@ -225,7 +225,7 @@ function Page1() {
|
||||
}),
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
spacing: 2.5,
|
||||
spacing: 5,
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Button({
|
||||
@@ -310,7 +310,7 @@ function Page2() {
|
||||
children: [
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
spacing: 2.5,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Widget.Button({
|
||||
hexpand: true,
|
||||
@@ -320,7 +320,7 @@ function Page2() {
|
||||
icon: "colorize",
|
||||
arrow: true,
|
||||
}),
|
||||
on_primary_click: () => {
|
||||
on_clicked: () => {
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
Utils.execAsync("sleep 0.5")
|
||||
.then(() =>
|
||||
@@ -369,7 +369,7 @@ function Page2() {
|
||||
}),
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
spacing: 2.5,
|
||||
spacing: 5,
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Button({
|
||||
@@ -380,7 +380,7 @@ function Page2() {
|
||||
icon: "settings",
|
||||
arrow: true,
|
||||
}),
|
||||
on_primary_click: () => {
|
||||
on_clicked: () => {
|
||||
OpenSettings()
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { SystemBox } from "./system.ts"
|
||||
let shown = Variable("Messages");
|
||||
import Gtk from "gi://Gtk?version=3.0"
|
||||
import { MaterialIcon } from "icons.ts";
|
||||
import { enableClickThrough } from "modules/misc/clickthrough.js";
|
||||
|
||||
|
||||
type ButtonType = {
|
||||
@@ -20,11 +21,14 @@ function Button({ page, label, icon }: ButtonType) {
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
class_name: "container_outer",
|
||||
children: [
|
||||
Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
hpack: "center",
|
||||
class_name: "container",
|
||||
child: MaterialIcon(icon, "20px"),
|
||||
Widget.Overlay({
|
||||
child: Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
hpack: "center",
|
||||
class_name: "container",
|
||||
}),
|
||||
overlay: MaterialIcon(icon, "20px"),
|
||||
pass_through: true
|
||||
}),
|
||||
Widget.Label({
|
||||
label: label,
|
||||
|
||||
@@ -4,7 +4,6 @@ import Box from "types/widgets/box";
|
||||
|
||||
const notifications = await Service.import("notifications")
|
||||
|
||||
|
||||
type NotificationsBoxType = {
|
||||
exclude?: string[],
|
||||
include?: string[]
|
||||
@@ -66,7 +65,7 @@ export function NotificationsBox({ exclude = [], include = [] }: NotificationsBo
|
||||
return Widget.EventBox({
|
||||
vexpand: true,
|
||||
hexpand: true,
|
||||
on_secondary_click: (_, event) => {
|
||||
on_secondary_click_release: (_, event) => {
|
||||
menu.popup_at_pointer(event)
|
||||
},
|
||||
child: Widget.Scrollable({
|
||||
|
||||
Reference in new issue
Block a user