-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yggverse
committed
Jan 22, 2025
1 parent
ba96581
commit 972fa6c
Showing
21 changed files
with
271 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/app/browser/window/tab/item/page/input/response/control/widget.rs
This file was deleted.
Oops, something went wrong.
60 changes: 51 additions & 9 deletions
60
src/app/browser/window/tab/item/page/input/response/form.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,63 @@ | ||
mod widget; | ||
use gtk::{ | ||
gio::SimpleAction, | ||
glib::GString, | ||
prelude::{ActionExt, TextBufferExt, TextViewExt, WidgetExt}, | ||
TextView, WrapMode, | ||
}; | ||
use libspelling::{Checker, TextBufferAdapter}; | ||
use sourceview::Buffer; | ||
|
||
use widget::Widget; | ||
|
||
use gtk::gio::SimpleAction; | ||
use std::rc::Rc; | ||
const MARGIN: i32 = 8; | ||
|
||
pub struct Form { | ||
pub widget: Rc<Widget>, | ||
pub text_view: TextView, | ||
} | ||
|
||
impl Form { | ||
// Constructors | ||
|
||
/// Build new `Self` | ||
pub fn build(action_update: SimpleAction) -> Self { | ||
Self { | ||
widget: Rc::new(Widget::build(action_update)), | ||
} | ||
// Init [SourceView](https://gitlab.gnome.org/GNOME/gtksourceview) type buffer | ||
let buffer = Buffer::builder().build(); | ||
|
||
// Init [libspelling](https://gitlab.gnome.org/GNOME/libspelling) | ||
let checker = Checker::default(); | ||
let adapter = TextBufferAdapter::new(&buffer, &checker); | ||
adapter.set_enabled(true); | ||
|
||
// Init main widget | ||
let text_view = TextView::builder() | ||
.bottom_margin(MARGIN) | ||
.buffer(&buffer) | ||
.css_classes(["frame", "view"]) | ||
.extra_menu(&adapter.menu_model()) | ||
.left_margin(MARGIN) | ||
.margin_bottom(MARGIN / 4) | ||
.right_margin(MARGIN) | ||
.top_margin(MARGIN) | ||
.wrap_mode(WrapMode::Word) | ||
.build(); | ||
|
||
text_view.insert_action_group("spelling", Some(&adapter)); | ||
|
||
// Init events | ||
text_view.buffer().connect_changed(move |_| { | ||
action_update.activate(None); | ||
}); | ||
|
||
text_view.connect_realize(move |this| { | ||
this.grab_focus(); | ||
}); | ||
|
||
// Return activated `Self` | ||
Self { text_view } | ||
} | ||
|
||
// Getters | ||
|
||
pub fn text(&self) -> GString { | ||
let buffer = self.text_view.buffer(); | ||
buffer.text(&buffer.start_iter(), &buffer.end_iter(), true) | ||
} | ||
} |
63 changes: 0 additions & 63 deletions
63
src/app/browser/window/tab/item/page/input/response/form/widget.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.