updates
This commit is contained in:
1 parent
07063c5eb7
commit
6bc3ebeaab
6 files changed
+73
-167
No files matched your search
@@ -82,7 +82,7 @@ const WeatherLocationKey = () =>
|
||||
text: conf.config.weather_location_id,
|
||||
on_accept: (self) => {
|
||||
self.css = "border: 2px solid; border-color: #66BB6A";
|
||||
Utils.timeout(1000, () => {
|
||||
Utils.timeout(100, () => {
|
||||
self.css = "border: 2px solid; border-color: transparent";
|
||||
});
|
||||
conf.set_value("weather_location_id", self.text!);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
@@ -4,7 +4,6 @@ import Gdk from "gi://Gdk";
|
||||
// widgets
|
||||
import { Bar, BarCornerTopLeft, BarCornerTopRight } from "./modules/bar.ts";
|
||||
import { Notifications } from "./modules/notificationPopups.ts";
|
||||
//import { cliphist } from "./modules/cliphist.ts";
|
||||
import { sideright } from "./modules/sideright/main.ts";
|
||||
import { sideleft } from "./modules/sideleft/main.ts";
|
||||
import {} from "apps/settings/main.ts";
|
||||
@@ -27,7 +26,6 @@ const Windows = () => [
|
||||
forMonitors(Notifications),
|
||||
forMonitors(BarCornerTopLeft),
|
||||
forMonitors(BarCornerTopRight),
|
||||
//cliphist,
|
||||
sideright,
|
||||
cheatsheet,
|
||||
sideleft
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
const WINDOW_NAME = "cliphist";
|
||||
import popupwindow from "./misc/popupwindow.ts";
|
||||
import Box from "types/widgets/box.js";
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
|
||||
type EntryObject = {
|
||||
id: string;
|
||||
content: string;
|
||||
entry: string;
|
||||
};
|
||||
|
||||
function ClipHistItem(entry: string) {
|
||||
let [id, ...content] = entry.split("\t");
|
||||
let clickCount = 0;
|
||||
let button = Widget.Button({
|
||||
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"
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
button.connect("clicked", () => {
|
||||
clickCount++;
|
||||
if (clickCount === 2) {
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`);
|
||||
clickCount = 0;
|
||||
}
|
||||
});
|
||||
|
||||
button.connect("focus-out-event", () => {
|
||||
clickCount = 0;
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
attribute: { content: content.join(" ").trim() },
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
button,
|
||||
Widget.Separator({
|
||||
class_name: "clip_divider",
|
||||
orientation: Gtk.Orientation.HORIZONTAL
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
|
||||
let output: string;
|
||||
let entries: string[];
|
||||
let clipHistItems: EntryObject[];
|
||||
let widgets: Box<any, any>[];
|
||||
|
||||
const list = Widget.Box({
|
||||
vertical: true,
|
||||
spacing
|
||||
});
|
||||
|
||||
async function repopulate() {
|
||||
output = await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --get`)
|
||||
.then((str) => str)
|
||||
.catch((err) => {
|
||||
print(err);
|
||||
return "";
|
||||
});
|
||||
entries = output.split("\n").filter((line) => line.trim() !== "");
|
||||
clipHistItems = entries.map((entry) => {
|
||||
let [id, ...content] = entry.split("\t");
|
||||
return { id: id.trim(), content: content.join(" ").trim(), entry: entry };
|
||||
});
|
||||
widgets = clipHistItems.map((item) => ClipHistItem(item.entry));
|
||||
list.children = widgets;
|
||||
}
|
||||
repopulate();
|
||||
|
||||
const entry = Widget.Entry({
|
||||
hexpand: true,
|
||||
class_name: "cliphistory_entry",
|
||||
placeholder_text: "Search",
|
||||
|
||||
on_change: ({ text }) => {
|
||||
const searchText = (text ?? "").toLowerCase();
|
||||
widgets.forEach((item) => {
|
||||
item.visible = item.attribute.content.toLowerCase().includes(searchText);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
vertical: true,
|
||||
class_name: "cliphistory_box",
|
||||
margin_top: 14,
|
||||
margin_right: 14,
|
||||
children: [
|
||||
entry,
|
||||
Widget.Separator(),
|
||||
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) {
|
||||
repopulate();
|
||||
entry.text = "";
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export const cliphist = popupwindow({
|
||||
name: WINDOW_NAME,
|
||||
|
||||
class_name: "cliphistory",
|
||||
visible: false,
|
||||
keymode: "exclusive",
|
||||
child: ClipHistWidget({
|
||||
width: 500,
|
||||
height: 500,
|
||||
spacing: 0
|
||||
}),
|
||||
anchor: ["top", "right"]
|
||||
});
|
||||
@@ -21,6 +21,20 @@ async function getClipboardHistory() {
|
||||
}
|
||||
}
|
||||
|
||||
async function clearClipboardHistory() {
|
||||
try {
|
||||
const process = new Gio.Subprocess({
|
||||
argv: ['bash', '-c', 'cliphist wipe'],
|
||||
flags: Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE
|
||||
});
|
||||
|
||||
process.init(null);
|
||||
await process.communicate_utf8(null, null);
|
||||
} catch (error) {
|
||||
// Handle error silently or log to a file if needed
|
||||
}
|
||||
}
|
||||
|
||||
async function copyById(id) {
|
||||
try {
|
||||
const command = `${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`;
|
||||
@@ -93,9 +107,8 @@ export const cliphist = () => {
|
||||
|
||||
if (entries.length > 0) {
|
||||
list.children = entries.map(ClipHistItem);
|
||||
} else {
|
||||
list.children = [Widget.Label({ label: "No history available", class_name: "no_history" })];
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
list.children = [Widget.Label({ label: "Error loading history", class_name: "error_loading" })];
|
||||
}
|
||||
@@ -115,13 +128,30 @@ export const cliphist = () => {
|
||||
}
|
||||
});
|
||||
|
||||
const clearButton = Widget.Button({
|
||||
label: "Clear",
|
||||
class_name: "clear_history_button",
|
||||
on_clicked: async () => {
|
||||
await clearClipboardHistory();
|
||||
repopulate();
|
||||
}
|
||||
});
|
||||
|
||||
const searchBox = Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
children: [
|
||||
entry,
|
||||
clearButton
|
||||
]
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
vertical: true,
|
||||
class_name: "cliphistory_box",
|
||||
margin_top: 14,
|
||||
margin_right: 14,
|
||||
children: [
|
||||
entry,
|
||||
searchBox,
|
||||
Widget.Separator(),
|
||||
Widget.Scrollable({
|
||||
hscroll: "never",
|
||||
|
||||
+39
-14
@@ -106,7 +106,7 @@ separator {
|
||||
|
||||
.outer-workspace {
|
||||
background-color: @surfaceContainerHigh;
|
||||
border-radius: 16px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.workspace {
|
||||
@@ -116,15 +116,15 @@ separator {
|
||||
|
||||
.workspace button {
|
||||
background-color: transparent;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
.workspace.first {
|
||||
border-radius: 16px 0 0 16px;
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
.workspace.last {
|
||||
border-radius: 0 16px 16px 0;
|
||||
border-radius: 0 20px 20px 0;
|
||||
}
|
||||
|
||||
.workspace.normal,
|
||||
@@ -134,7 +134,7 @@ separator {
|
||||
}
|
||||
|
||||
.workspace button.normal:hover {
|
||||
border-radius: 16px;
|
||||
border-radius: 20px;
|
||||
background-color: @secondary;
|
||||
color: @surfaceDim;
|
||||
}
|
||||
@@ -143,13 +143,13 @@ separator {
|
||||
background-color: @secondary;
|
||||
color: @background;
|
||||
font-weight: bold;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
border-radius: 16px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.workspace button.focused:hover {
|
||||
border-radius: 16px;
|
||||
border-radius: 20px;
|
||||
color: @primary;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
@@ -159,17 +159,17 @@ separator {
|
||||
}
|
||||
|
||||
.workspaces button.occupied:hover {
|
||||
border-radius: 16px;
|
||||
border-radius: 20px;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
color: @surfaceDim;
|
||||
}
|
||||
|
||||
.workspace.occupied-single {
|
||||
border-radius: 16px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.workspace.occupied-start {
|
||||
border-radius: 16px 0 0 16px;
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
|
||||
.workspace.occupied-middle {
|
||||
@@ -177,7 +177,7 @@ separator {
|
||||
}
|
||||
|
||||
.workspace.occupied-end {
|
||||
border-radius: 0px 16px 16px 0px;
|
||||
border-radius: 0px 20px 20px 0px;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
@@ -370,6 +370,31 @@ window.notification-popups box.notifications {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.clear_history_button {
|
||||
background-color: @surfaceContainerHigh;
|
||||
color: @onSurface;
|
||||
border: none;
|
||||
outline: none;
|
||||
margin: 8px;
|
||||
border-radius: 100px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.clear_history_button:hover {
|
||||
background-color: mix(@onSurface, @surface, 0.92);
|
||||
}
|
||||
|
||||
.clear_history_button:focus {
|
||||
background-color: mix(@onSurface, @surface, 0.8);
|
||||
border: 0px solid;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.clear_history_button:active {
|
||||
background-image: radial-gradient(circle, mix(@onSurface, @surface, 0.78) 10%, transparent 0%);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* Misc
|
||||
* ----------------------------------------------------- */
|
||||
|
||||
Reference in new issue
Block a user