updates
This commit is contained in:
1 parent
8b0cde6e86
commit
0389156702
10 files changed
+281
-120
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import GeminiService from "services/gemini.js";
|
||||
import GeminiService from "services/gemini.ts";
|
||||
import { MaterialIcon } from "icons.ts";
|
||||
import { ChatMessage, SystemMessage } from "modules/misc/ai_chat_message.ts";
|
||||
import { ChatMessage, SystemMessage } from "modules/misc/chat_message.ts";
|
||||
import { markdownTest } from "modules/misc/md2pango.ts";
|
||||
import Gdk from "gi://Gdk";
|
||||
|
||||
const TextView = Widget.subclass<typeof Gtk.TextView, Gtk.TextView.ConstructorProperties>(Gtk.TextView, "AgsTextView");
|
||||
import { enableClickThrough } from "../misc/clickthrough.js";
|
||||
import { TextView } from "modules/misc/textview.js";
|
||||
|
||||
function apiSendMessage(textView: any) {
|
||||
// Get text
|
||||
@@ -26,12 +26,15 @@ const chatEntry: any = TextView({
|
||||
wrap_mode: Gtk.WrapMode.WORD_CHAR,
|
||||
accepts_tab: false,
|
||||
class_name: "chat_entry",
|
||||
attribute: { placeholder: "Message Gemini..." },
|
||||
setup: (self: any) => {
|
||||
self.set_valign(Gtk.Align.CENTER);
|
||||
self.hook(
|
||||
GeminiService,
|
||||
(self) => {
|
||||
self.placeholderText =
|
||||
() => {
|
||||
self.attribute.placeholder =
|
||||
GeminiService.key.length > 0 ? "Message Gemini..." : "Enter Google AI API Key...";
|
||||
chatPlaceholder.label = self.attribute.placeholder;
|
||||
},
|
||||
"hasKey"
|
||||
).on("key-press-event", (widget, event) => {
|
||||
@@ -45,11 +48,6 @@ const chatEntry: any = TextView({
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const buffer = self.get_buffer();
|
||||
buffer.connect("changed", () => {
|
||||
const line_count = buffer.get_line_count();
|
||||
chatEntryWrapper.toggleClassName("chat_wrapper_extended", line_count >= 2);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -60,14 +58,69 @@ const chatEntryWrapper = Widget.Scrollable({
|
||||
child: chatEntry,
|
||||
setup: (self) => {
|
||||
chatEntry.connect("focus-in-event", () => {
|
||||
self.toggleClassName("focused", true);
|
||||
textboxArea.toggleClassName("focused", true);
|
||||
});
|
||||
chatEntry.connect("focus-out-event", () => {
|
||||
self.toggleClassName("focused", false);
|
||||
textboxArea.toggleClassName("focused", false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chatEntry.get_buffer().connect("changed", (buffer) => {
|
||||
const bufferText = buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), true);
|
||||
// chatSendButton.toggleClassName("chat_wrapper_extended", bufferText.length > 0);
|
||||
chatPlaceholderRevealer.reveal_child = bufferText.length == 0;
|
||||
if (buffer.get_line_count() > 2 || bufferText.length > 30) {
|
||||
chatEntryWrapper.toggleClassName("chat_wrapper_extended", true);
|
||||
chatEntry.set_valign(Gtk.Align.FILL);
|
||||
chatPlaceholder.set_valign(Gtk.Align.FILL);
|
||||
} else {
|
||||
chatEntryWrapper.toggleClassName("chat_wrapper_extended", false);
|
||||
chatEntry.set_valign(Gtk.Align.CENTER);
|
||||
chatPlaceholder.set_valign(Gtk.Align.CENTER);
|
||||
}
|
||||
});
|
||||
|
||||
const chatPlaceholder = Widget.Label({
|
||||
className: "placeholder",
|
||||
hpack: "start",
|
||||
vpack: "center",
|
||||
label: chatEntry.attribute.placeholder
|
||||
});
|
||||
|
||||
const chatPlaceholderRevealer = Widget.Revealer({
|
||||
revealChild: true,
|
||||
transition: "crossfade",
|
||||
transitionDuration: 200,
|
||||
child: chatPlaceholder,
|
||||
setup: enableClickThrough
|
||||
});
|
||||
|
||||
const chatSendButton = Widget.Button({
|
||||
className: "send standard_icon_button",
|
||||
child: MaterialIcon("send", "24px"),
|
||||
vpack: "center",
|
||||
hpack: "end",
|
||||
css: "font-size: 24px",
|
||||
onClicked: (self) => {
|
||||
apiSendMessage(chatEntry);
|
||||
}
|
||||
});
|
||||
|
||||
const textboxArea = Widget.Box({
|
||||
// Entry area
|
||||
className: "textbox",
|
||||
children: [
|
||||
Widget.Overlay({
|
||||
passThrough: true,
|
||||
child: chatEntryWrapper,
|
||||
overlays: [chatPlaceholderRevealer]
|
||||
}),
|
||||
Widget.Box({ className: "width-10" }),
|
||||
chatSendButton
|
||||
]
|
||||
});
|
||||
|
||||
const GeminiInfo = () => {
|
||||
const geminiLogo = Widget.Icon({
|
||||
hpack: "center",
|
||||
@@ -96,7 +149,7 @@ const GeminiInfo = () => {
|
||||
label: "Powered by Google"
|
||||
}),
|
||||
Widget.Button({
|
||||
class_name: "description",
|
||||
class_name: "description icon material_icon",
|
||||
label: "info",
|
||||
tooltipText:
|
||||
"Uses gemini-pro.\nNot affiliated, endorsed, or sponsored by Google.\n\nPrivacy: Chat messages aren't linked to your account,\n but will be read by human reviewers to improve the model."
|
||||
@@ -269,5 +322,5 @@ const geminiView = Widget.Box({
|
||||
export const geminiPage = Widget.Box({
|
||||
class_name: "page gemini",
|
||||
vertical: true,
|
||||
children: [geminiView, geminiCommands, chatEntryWrapper]
|
||||
children: [geminiView, geminiCommands, textboxArea]
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import popupwindow from "../misc/popupwindow.js";
|
||||
import popupwindow from "../misc/popupwindow.ts";
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import { MaterialIcon } from "icons.ts";
|
||||
import { WeatherBox } from "./weather.js";
|
||||
import { Media } from "./players.js";
|
||||
import { WeatherBox } from "./weather.ts";
|
||||
import { Media } from "./players.ts";
|
||||
import { Applauncher } from "./applauncher.ts";
|
||||
import { geminiPage } from "./gemini.ts";
|
||||
|
||||
@@ -31,13 +31,14 @@ type ButtonType = {
|
||||
page: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
icon_widget?: Gtk.Widget
|
||||
icon_widget?: Gtk.Widget;
|
||||
};
|
||||
|
||||
function Button({ page, label, icon, icon_widget }: ButtonType) {
|
||||
return Widget.Button({
|
||||
class_name: `navigation_button _${page}`,
|
||||
hexpand: true,
|
||||
vpack: "start",
|
||||
child: Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
class_name: "container_outer",
|
||||
@@ -48,7 +49,7 @@ function Button({ page, label, icon, icon_widget }: ButtonType) {
|
||||
hpack: "center",
|
||||
class_name: "container"
|
||||
}),
|
||||
overlay: (icon) ? MaterialIcon(icon!, "20px") : icon_widget!,
|
||||
overlay: icon ? MaterialIcon(icon!, "20px") : icon_widget!,
|
||||
pass_through: true
|
||||
}),
|
||||
Widget.Label({
|
||||
@@ -111,7 +112,7 @@ function Navigation() {
|
||||
size: 20,
|
||||
class_name: "icon"
|
||||
})
|
||||
})
|
||||
}),
|
||||
]
|
||||
});
|
||||
return Widget.Box({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MprisPlayer } from "types/service/mpris.js";
|
||||
import Label from "types/widgets/label.js";
|
||||
import { MprisPlayer } from "types/service/mpris.ts";
|
||||
import Label from "types/widgets/label.ts";
|
||||
import { MaterialIcon } from "icons.ts";
|
||||
const mpris = await Service.import("mpris");
|
||||
const players = mpris.bind("players");
|
||||
@@ -98,7 +98,7 @@ function Player(player: MprisPlayer) {
|
||||
on_clicked: () => player.playPause(),
|
||||
visible: player.bind("can_play"),
|
||||
child: MaterialIcon(
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
player.bind("play_back_status").transform((s) => {
|
||||
switch (s) {
|
||||
case "Playing":
|
||||
@@ -155,6 +155,7 @@ export function Media() {
|
||||
return Widget.Box({
|
||||
vertical: true,
|
||||
css: "min-height: 2px; min-width: 2px;",
|
||||
vpack: "start",
|
||||
visible: players.as((p) => p.length > 0),
|
||||
children: players.as((p) => p.map(Player))
|
||||
});
|
||||
|
||||
@@ -16,31 +16,32 @@ const MATERIAL_ICONS = {
|
||||
"40d": "air", "40n": "air"
|
||||
};
|
||||
const ICON_COLORS = {
|
||||
mist: "#90A4AE",
|
||||
clear_day: "#FFF176",
|
||||
bedtime: "#7986CB",
|
||||
partly_cloudy_day: "#2196F3",
|
||||
partly_cloudy_night: "#7986CB",
|
||||
cloud: "#4FC3F7",
|
||||
mist: "#B0BEC5",
|
||||
clear_day: "#FFEB3B",
|
||||
bedtime: "#9575CD",
|
||||
partly_cloudy_day: "#42A5F5",
|
||||
partly_cloudy_night: "#8C9EFF",
|
||||
cloud: "#81D4FA",
|
||||
rainy_heavy: "#039BE5",
|
||||
rainy: "#2196F3",
|
||||
thunderstorm: "#FFC107",
|
||||
weather_snowy: "#00BCD4",
|
||||
air: "#00BCD4"
|
||||
rainy: "#64B5F6",
|
||||
thunderstorm: "#FFB300",
|
||||
weather_snowy: "#4DD0E1",
|
||||
air: "#00ACC1"
|
||||
};
|
||||
const _T = "°";
|
||||
|
||||
function WeatherFirstCard(weather: WeatherJson) {
|
||||
const _box = (icon: string, info: string, tooltip?: string) => Widget.Box({
|
||||
class_name: "info_box",
|
||||
children: [
|
||||
MaterialIcon(icon, "20px"),
|
||||
Widget.Label({
|
||||
label: info
|
||||
})
|
||||
],
|
||||
tooltip_text: tooltip
|
||||
})
|
||||
const _box = (icon: string, info: string, tooltip?: string) =>
|
||||
Widget.Box({
|
||||
class_name: "info_box",
|
||||
children: [
|
||||
MaterialIcon(icon, "20px"),
|
||||
Widget.Label({
|
||||
label: info
|
||||
})
|
||||
],
|
||||
tooltip_text: tooltip
|
||||
});
|
||||
const temp_label = Widget.Label({
|
||||
class_name: "current",
|
||||
vpack: "end",
|
||||
@@ -83,7 +84,7 @@ function WeatherFirstCard(weather: WeatherJson) {
|
||||
_box("cloud", `${weather.clouds.all}%`, "Cloudiness"),
|
||||
_box("humidity_percentage", `${weather.main.humidity}%`, "Humidity")
|
||||
]
|
||||
})
|
||||
});
|
||||
const color = ICON_COLORS[MATERIAL_ICONS[weather.weather[0].icon]];
|
||||
const temp = Widget.Box({
|
||||
class_name: "card",
|
||||
@@ -96,7 +97,6 @@ function WeatherFirstCard(weather: WeatherJson) {
|
||||
hpack: "start",
|
||||
children: [
|
||||
MaterialIcon(MATERIAL_ICONS[weather.weather[0].icon], "", {
|
||||
vpack: "end",
|
||||
css: `font-size: 32px; color: ${color}`
|
||||
}),
|
||||
temp_label,
|
||||
@@ -178,11 +178,7 @@ export function WeatherBox() {
|
||||
label: cur_weather.name,
|
||||
hpack: "start"
|
||||
});
|
||||
self.children = [
|
||||
title,
|
||||
WeatherFirstCard(cur_weather),
|
||||
WeatherSecondCard(cur_weather)
|
||||
];
|
||||
self.children = [title, WeatherFirstCard(cur_weather), WeatherSecondCard(cur_weather)];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user