[fractal] Message Widget: Wrap SourceView in scrolled window
- From: Alejandro Domínguez <aledomu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Message Widget: Wrap SourceView in scrolled window
- Date: Wed, 3 Feb 2021 00:56:03 +0000 (UTC)
commit 735ca936f4f2195664ce07588b8c536e49e7ca04
Author: Maximiliano Sandoval R <msandova protonmail com>
Date: Thu Nov 19 16:38:05 2020 +0100
Message Widget: Wrap SourceView in scrolled window
This way the code blocks do not try to take up all the space, prevents
the collapse of the leaflet when there are big code chunks.
fractal-gtk/src/widgets/message.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index fe5b40b5..218906d0 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -580,15 +580,17 @@ fn render_html_block(container: &MessageBoxContainer, msg: &Message, block: &Htm
bx.upcast::<gtk::Widget>()
}
HtmlBlock::Code(s) => {
+ let scrolled = gtk::ScrolledWindow::new(gtk::NONE_ADJUSTMENT, gtk::NONE_ADJUSTMENT);
+ scrolled.set_policy(gtk::PolicyType::Automatic, gtk::PolicyType::Never);
let buffer = sourceview4::Buffer::new::<gtk::TextTagTable>(None);
buffer.set_highlight_matching_brackets(false);
buffer.set_text(&s);
let view = sourceview4::View::with_buffer(&buffer);
view.set_editable(false);
- view.set_wrap_mode(gtk::WrapMode::WordChar);
view.get_style_context().add_class("codeview");
container.connect_right_click_menu(msg, Some(&view.upcast_ref::<gtk::Widget>()));
- view.upcast::<gtk::Widget>()
+ scrolled.add(&view);
+ scrolled.upcast::<gtk::Widget>()
}
HtmlBlock::Quote(blocks) => {
let bx = gtk::Box::new(gtk::Orientation::Vertical, 6);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]