Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better libreoffice support #71

Merged
merged 4 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ignore = "0.4"
flume = "0.11.1"

# for office support
dotext = "0.1.1"
dotext = { git = "https://github.com/anvie/dotext.git", rev = "06b1600" }

# for pdf support
poppler-rs = "0.24.1"
Expand Down
16 changes: 6 additions & 10 deletions core/src/extra/office.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ pub fn process(
}

fn extract(path: &Path) -> Result<String, Box<dyn Error>> {
let ext = path
.extension()
.unwrap_or_default()
.to_string_lossy()
.to_string();
let ext = path.extension().unwrap_or_default().to_string_lossy();

let mut string = String::new();
match ext.as_str() {
match ext.as_ref() {
"docx" => {
let mut docx = Docx::open(path)?;
docx.read_to_string(&mut string)?;
Expand All @@ -41,10 +37,10 @@ fn extract(path: &Path) -> Result<String, Box<dyn Error>> {
let mut odt = Odt::open(path)?;
odt.read_to_string(&mut string)?;
}
// "ods" => {
// let ods = Ods::open(&path)?;
// ods.read_to_string(&mut string)?;
// }
"ods" => {
let mut ods = Ods::open(path)?;
ods.read_to_string(&mut string)?;
}
"odp" => {
let mut odp = Odp::open(path)?;
odp.read_to_string(&mut string)?;
Expand Down
7 changes: 7 additions & 0 deletions gnome/src/ui/result_view/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct ResultView {
#[property(get, set)]
pub result: RefCell<Option<SearchResult>>,

#[template_child]
pub container: TemplateChild<gtk::Box>,
#[template_child]
pub content: TemplateChild<gtk::Label>,

Expand Down Expand Up @@ -108,6 +110,11 @@ impl ObjectImpl for ResultView {
obj.imp().update_content();
});
}

fn dispose(&self) {
// See https://gitlab.gnome.org/GNOME/gtk/-/issues/7302
self.container.unparent();
}
}

impl WidgetImpl for ResultView {}
2 changes: 1 addition & 1 deletion gnome/src/ui/result_view/result_view.blp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Gtk 4.0;
template $ClapgrepResultView: Widget {
layout-manager: Gtk.BinLayout {};

Box {
Box container {
orientation: horizontal;
margin-top: 2;
margin-start: 16;
Expand Down