Converted a significant amount of files from js to ts.
This commit is contained in:
63
modules/bar/network/index.ts
Normal file
63
modules/bar/network/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import Gdk from 'gi://Gdk?version=3.0';
|
||||
const network = await Service.import("network");
|
||||
import options from "options";
|
||||
import { openMenu } from "../utils.js";
|
||||
|
||||
const Network = () => {
|
||||
const wifiIndicator = [
|
||||
Widget.Icon({
|
||||
class_name: "bar-network-icon",
|
||||
icon: network.wifi.bind("icon_name"),
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "bar-network-label",
|
||||
label: Utils.merge(
|
||||
[network.bind("wifi"), options.bar.network.label.bind("value")],
|
||||
(wifi, showLabel) => {
|
||||
if (showLabel) {
|
||||
return wifi.ssid ? ` ${wifi.ssid.substring(0, 7)}` : " --";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
),
|
||||
}),
|
||||
];
|
||||
|
||||
const wiredIndicator = [
|
||||
Widget.Icon({
|
||||
class_name: "bar-network-icon",
|
||||
icon: network.wired.bind("icon_name"),
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "bar-network-label",
|
||||
label: Utils.merge(
|
||||
[network.bind("wired"), options.bar.network.label.bind("value")],
|
||||
(_, showLabel) => {
|
||||
if (showLabel) {
|
||||
return " Wired";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
),
|
||||
}),
|
||||
];
|
||||
|
||||
return {
|
||||
component: Widget.Box({
|
||||
vpack: "center",
|
||||
class_name: "bar-network",
|
||||
children: network
|
||||
.bind("primary")
|
||||
.as((w) => (w === "wired" ? wiredIndicator : wifiIndicator)),
|
||||
}),
|
||||
isVisible: true,
|
||||
boxClass: "network",
|
||||
props: {
|
||||
on_primary_click: (clicked: any, event: Gdk.Event) => {
|
||||
openMenu(clicked, event, "networkmenu");
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export { Network };
|
||||
Reference in New Issue
Block a user