This commit is contained in:
@@ -123,6 +123,38 @@ export class SettingsEditor {
|
||||
clear.connect('clicked', () => { changed(''); row.subtitle = field.description; });
|
||||
row.add_suffix(choose); row.add_suffix(clear);
|
||||
row._setValue = value => { row.subtitle = value || field.description; };
|
||||
} else if (field.type === 'text') {
|
||||
const box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, spacing: 6, margin_start: 12, margin_end: 12, margin_top: 6, margin_bottom: 8 });
|
||||
const title = new Gtk.Label({ label: field.title, xalign: 0, wrap: true });
|
||||
title.add_css_class('heading');
|
||||
const help = new Gtk.Label({ label: field.description, wrap: true, xalign: 0 });
|
||||
help.add_css_class('dim-label');
|
||||
const view = new Gtk.TextView({ wrap_mode: Gtk.WrapMode.WORD_CHAR, accepts_tab: false, left_margin: 8, right_margin: 8, top_margin: 8, bottom_margin: 8 });
|
||||
view.add_css_class('jarvis-prompt');
|
||||
const text = String(this.values[field.key] || '');
|
||||
view.buffer.set_text(text, -1);
|
||||
view.buffer.connect('changed', () => {
|
||||
const buffer = view.buffer;
|
||||
changed(buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), false));
|
||||
});
|
||||
const scroll = new Gtk.ScrolledWindow({
|
||||
min_content_height: 140,
|
||||
max_content_height: 220,
|
||||
hexpand: true,
|
||||
vexpand: false,
|
||||
has_frame: true,
|
||||
propagate_natural_height: true,
|
||||
});
|
||||
scroll.set_child(view);
|
||||
box.append(title);
|
||||
box.append(help);
|
||||
box.append(scroll);
|
||||
box._setValue = value => {
|
||||
const next = String(value || '');
|
||||
const buffer = view.buffer;
|
||||
if (buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter(), false) !== next) buffer.set_text(next, -1);
|
||||
};
|
||||
row = box;
|
||||
} else {
|
||||
row = new Adw.EntryRow({ title: field.title, tooltip_text: field.description, text: field.type === 'list' ? this.values[field.key].join(', ') : this.values[field.key] });
|
||||
row.connect('changed', () => changed(field.type === 'list' ? row.text.split(',').map(v => v.trim()).filter(Boolean) : row.text));
|
||||
|
||||
Reference in New Issue
Block a user