forked from Shinonome/dots-hyprland
Merge branch 'main' into patch-1
This commit is contained in:
@@ -10,8 +10,8 @@ import md2pango from '../../.miscutils/md2pango.js';
|
||||
import { darkMode } from "../../.miscutils/system.js";
|
||||
|
||||
const LATEX_DIR = `${GLib.get_user_cache_dir()}/ags/media/latex`;
|
||||
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/assets/themes/sourceviewtheme${darkMode ? '' : '-light'}.xml`;
|
||||
const CUSTOM_SCHEME_ID = `custom${darkMode ? '' : '-light'}`;
|
||||
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/assets/themes/sourceviewtheme${darkMode.value ? '' : '-light'}.xml`;
|
||||
const CUSTOM_SCHEME_ID = `custom${darkMode.value ? '' : '-light'}`;
|
||||
const USERNAME = GLib.get_user_name();
|
||||
|
||||
/////////////////////// Custom source view colorscheme /////////////////////////
|
||||
@@ -82,7 +82,7 @@ const Latex = (content = '') => {
|
||||
const latexViewArea = Box({
|
||||
// vscroll: 'never',
|
||||
// hscroll: 'automatic',
|
||||
homogeneous: true,
|
||||
// homogeneous: true,
|
||||
attribute: {
|
||||
render: async (self, text) => {
|
||||
if (text.length == 0) return;
|
||||
@@ -107,7 +107,7 @@ const Latex = (content = '') => {
|
||||
text=$(cat ${filePath} | sed 's/$/ \\\\\\\\/g' | sed 's/&=/=/g')
|
||||
LaTeX -headless -input="$text" -output=${outFilePath} -textsize=${fontSize * 1.1} -padding=0 -maxwidth=${latexViewArea.get_allocated_width() * 0.85}
|
||||
sed -i 's/fill="rgb(0%, 0%, 0%)"/style="fill:#000000"/g' ${outFilePath}
|
||||
sed -i 's/stroke="rgb(0%, 0%, 0%)"/stroke="${darkMode ? '#ffffff' : '#000000'}"/g' ${outFilePath}
|
||||
sed -i 's/stroke="rgb(0%, 0%, 0%)"/stroke="${darkMode.value ? '#ffffff' : '#000000'}"/g' ${outFilePath}
|
||||
`;
|
||||
Utils.writeFile(renderScript, scriptFilePath).catch(print);
|
||||
Utils.exec(`chmod a+x ${scriptFilePath}`)
|
||||
|
||||
@@ -39,7 +39,6 @@ const CommandButton = (command) => Button({
|
||||
|
||||
export const booruTabIcon = Box({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-apiswitcher-icon',
|
||||
homogeneous: true,
|
||||
children: [
|
||||
MaterialIcon('gallery_thumbnail', 'norm'),
|
||||
@@ -349,7 +348,7 @@ export const booruView = Scrollable({
|
||||
// Always scroll to bottom with new content
|
||||
const adjustment = scrolledWindow.get_vadjustment();
|
||||
adjustment.connect("changed", () => {
|
||||
if(!chatEntry.hasFocus) return;
|
||||
if (!chatEntry.hasFocus) return;
|
||||
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size());
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import { chatEntry } from '../apiwidgets.js';
|
||||
|
||||
export const chatGPTTabIcon = Icon({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-apiswitcher-icon',
|
||||
icon: `openai-symbolic`,
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ const MODEL_NAME = `Gemini`;
|
||||
|
||||
export const geminiTabIcon = Icon({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-apiswitcher-icon',
|
||||
icon: `google-gemini-symbolic`,
|
||||
})
|
||||
|
||||
@@ -104,6 +103,15 @@ export const GeminiSettings = () => MarginRevealer({
|
||||
GeminiService.assistantPrompt = newValue;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
icon: 'shield',
|
||||
name: 'Safety',
|
||||
desc: 'When turned off, tells the API (not the model) \nto not block harmful/explicit content',
|
||||
initValue: GeminiService.safe,
|
||||
onChange: (self, newValue) => {
|
||||
GeminiService.safe = newValue;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
icon: 'history',
|
||||
name: 'History',
|
||||
|
||||
@@ -39,8 +39,6 @@ const CommandButton = (command) => Button({
|
||||
|
||||
export const waifuTabIcon = Box({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-apiswitcher-icon',
|
||||
homogeneous: true,
|
||||
children: [
|
||||
MaterialIcon('photo', 'norm'),
|
||||
]
|
||||
@@ -251,7 +249,7 @@ const WaifuImage = (taglist) => {
|
||||
else Utils.execAsync(['bash', '-c', `wget -O '${thisBlock.attribute.imagePath}' '${url}'`])
|
||||
.then(showImage)
|
||||
.catch(print);
|
||||
thisBlock.css = `background-color: mix(${darkMode ? 'black' : 'white'}, ${dominant_color}, 0.97);`;
|
||||
thisBlock.css = `background-color: mix(${darkMode.value ? 'black' : 'white'}, ${dominant_color}, 0.97);`;
|
||||
},
|
||||
},
|
||||
children: [
|
||||
|
||||
@@ -16,6 +16,7 @@ import { checkKeybind } from '../.widgetutils/keybind.js';
|
||||
const TextView = Widget.subclass(Gtk.TextView, "AgsTextView");
|
||||
|
||||
import { widgetContent } from './sideleft.js';
|
||||
import { IconTabContainer } from '../.commonwidgets/tabcontainer.js';
|
||||
|
||||
const EXPAND_INPUT_THRESHOLD = 30;
|
||||
const APIS = [
|
||||
@@ -53,7 +54,6 @@ const APIS = [
|
||||
},
|
||||
];
|
||||
let currentApiId = 0;
|
||||
APIS[currentApiId].tabIcon.toggleClassName('sidebar-chat-apiswitcher-icon-enabled', true);
|
||||
|
||||
function apiSendMessage(textView) {
|
||||
// Get text
|
||||
@@ -75,6 +75,11 @@ export const chatEntry = TextView({
|
||||
acceptsTab: false,
|
||||
className: 'sidebar-chat-entry txt txt-smallie',
|
||||
setup: (self) => self
|
||||
.hook(App, (self, currentName, visible) => {
|
||||
if (visible && currentName === 'sideleft') {
|
||||
self.grab_focus();
|
||||
}
|
||||
})
|
||||
.hook(GPTService, (self) => {
|
||||
if (APIS[currentApiId].name != 'Assistant (GPTs)') return;
|
||||
self.placeholderText = (GPTService.key.length > 0 ? 'Message the model...' : 'Enter API Key...');
|
||||
@@ -170,16 +175,6 @@ const textboxArea = Box({ // Entry area
|
||||
]
|
||||
});
|
||||
|
||||
const apiContentStack = Stack({
|
||||
vexpand: true,
|
||||
transition: 'slide_left_right',
|
||||
transitionDuration: userOptions.animations.durationLarge,
|
||||
children: APIS.reduce((acc, api) => {
|
||||
acc[api.name] = api.contentWidget;
|
||||
return acc;
|
||||
}, {}),
|
||||
})
|
||||
|
||||
const apiCommandStack = Stack({
|
||||
transition: 'slide_up_down',
|
||||
transitionDuration: userOptions.animations.durationLarge,
|
||||
@@ -189,41 +184,23 @@ const apiCommandStack = Stack({
|
||||
}, {}),
|
||||
})
|
||||
|
||||
function switchToTab(id) {
|
||||
APIS[currentApiId].tabIcon.toggleClassName('sidebar-chat-apiswitcher-icon-enabled', false);
|
||||
APIS[id].tabIcon.toggleClassName('sidebar-chat-apiswitcher-icon-enabled', true);
|
||||
apiContentStack.shown = APIS[id].name;
|
||||
apiCommandStack.shown = APIS[id].name;
|
||||
chatPlaceholder.label = APIS[id].placeholderText;
|
||||
currentApiId = id;
|
||||
}
|
||||
|
||||
const apiSwitcher = EventBox({
|
||||
onScrollUp: () => apiWidgets.attribute.prevTab(),
|
||||
onScrollDown: () => apiWidgets.attribute.nextTab(),
|
||||
child: CenterBox({
|
||||
centerWidget: Box({
|
||||
className: 'sidebar-chat-apiswitcher spacing-h-5',
|
||||
hpack: 'center',
|
||||
children: APIS.map((api, id) => Button({
|
||||
child: api.tabIcon,
|
||||
tooltipText: api.name,
|
||||
setup: setupCursorHover,
|
||||
onClicked: () => {
|
||||
switchToTab(id);
|
||||
}
|
||||
})),
|
||||
}),
|
||||
endWidget: Button({
|
||||
hpack: 'end',
|
||||
className: 'txt-subtext txt-norm icon-material',
|
||||
label: 'lightbulb',
|
||||
tooltipText: 'Use PageUp/PageDown to switch between API pages',
|
||||
setup: setupCursorHoverInfo,
|
||||
}),
|
||||
})
|
||||
export const apiContentStack = IconTabContainer({
|
||||
tabSwitcherClassName: 'sidebar-chat-apiswitcher',
|
||||
className: 'margin-top-5',
|
||||
iconWidgets: APIS.map((api) => api.tabIcon),
|
||||
names: APIS.map((api) => api.name),
|
||||
children: APIS.map((api) => api.contentWidget),
|
||||
onChange: (self, id) => {
|
||||
apiCommandStack.shown = APIS[id].name;
|
||||
chatPlaceholder.label = APIS[id].placeholderText;
|
||||
currentApiId = id;
|
||||
}
|
||||
});
|
||||
|
||||
function switchToTab(id) {
|
||||
apiContentStack.shown.value = id;
|
||||
}
|
||||
|
||||
const apiWidgets = Widget.Box({
|
||||
attribute: {
|
||||
'nextTab': () => switchToTab(Math.min(currentApiId + 1, APIS.length - 1)),
|
||||
@@ -233,7 +210,6 @@ const apiWidgets = Widget.Box({
|
||||
className: 'spacing-v-10',
|
||||
homogeneous: false,
|
||||
children: [
|
||||
apiSwitcher,
|
||||
apiContentStack,
|
||||
apiCommandStack,
|
||||
textboxArea,
|
||||
|
||||
Reference in New Issue
Block a user