Drop document_get_information: it was failing for no apparent reason anyway
This commit is contained in:
67
src/lib.rs
67
src/lib.rs
@@ -58,7 +58,7 @@ pub static zathura_plugin_6_7: zathura::zathura_plugin_definition_s =
|
|||||||
document_save_as: Some(document_save_as),
|
document_save_as: Some(document_save_as),
|
||||||
document_attachments_get: None,
|
document_attachments_get: None,
|
||||||
document_attachment_save: None,
|
document_attachment_save: None,
|
||||||
document_get_information: Some(document_get_information),
|
document_get_information: None,
|
||||||
page_init: Some(page_init),
|
page_init: Some(page_init),
|
||||||
page_clear: Some(page_clear),
|
page_clear: Some(page_clear),
|
||||||
page_search_text: None, // TODO?
|
page_search_text: None, // TODO?
|
||||||
@@ -102,71 +102,6 @@ unsafe extern "C" fn document_free(_: *mut zathura_document_s, data: *mut c_void
|
|||||||
ZathuraResult::OK
|
ZathuraResult::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn document_get_information(
|
|
||||||
_: *mut zathura_document_s,
|
|
||||||
doc: *mut c_void,
|
|
||||||
res: *mut ZathuraResult,
|
|
||||||
) -> *mut girara_list_t {
|
|
||||||
let res = if let Some(mut r) = NonNull::new(res) {
|
|
||||||
unsafe {
|
|
||||||
r.write(ZathuraResult::Unknown);
|
|
||||||
r.as_mut()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
&mut ZathuraResult::OK
|
|
||||||
};
|
|
||||||
|
|
||||||
let doc = unsafe { &mut *(doc as *mut TypstDocument) };
|
|
||||||
let i = &doc.doc.info;
|
|
||||||
let mut lst = unsafe {
|
|
||||||
GiraraList::<zathura_document_information_entry_t>::from_raw(
|
|
||||||
zathura_document_information_entry_list_new(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
[
|
|
||||||
(
|
|
||||||
zathura_document_information_type_e_ZATHURA_DOCUMENT_INFORMATION_TITLE,
|
|
||||||
i.title.clone().unwrap_or_default().to_string(),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
zathura_document_information_type_e_ZATHURA_DOCUMENT_INFORMATION_AUTHOR,
|
|
||||||
i.author.join(", "),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
zathura_document_information_type_e_ZATHURA_DOCUMENT_INFORMATION_KEYWORDS,
|
|
||||||
i.keywords.join(", "),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
zathura_document_information_type_e_ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE,
|
|
||||||
i.date.unwrap_or_default().map_or(String::new(), |d| {
|
|
||||||
d.display(Default::default())
|
|
||||||
.expect("Defaults do the right thing")
|
|
||||||
.to_string()
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
zathura_document_information_type_e_ZATHURA_DOCUMENT_INFORMATION_PRODUCER,
|
|
||||||
"Typst (via zathura-plugin-typst)".to_owned(),
|
|
||||||
),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.filter(|(_, st)| !st.is_empty())
|
|
||||||
.map(|(ty, st)| {
|
|
||||||
unsafe extern "C" {
|
|
||||||
safe fn calloc(n: usize, s: usize) -> *mut c_void;
|
|
||||||
}
|
|
||||||
let st_m = calloc(st.len() + 1, 1);
|
|
||||||
unsafe { slice::from_raw_parts_mut(st_m as *mut u8, st.len()) }
|
|
||||||
.copy_from_slice(st.as_bytes());
|
|
||||||
(ty, st_m as *const i8)
|
|
||||||
})
|
|
||||||
.for_each(|(ty, st)| {
|
|
||||||
unsafe { lst.append_allocated(zathura_document_information_entry_new(ty, st)) };
|
|
||||||
});
|
|
||||||
*res = ZathuraResult::OK;
|
|
||||||
lst.into_raw()
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe extern "C" fn document_save_as(
|
unsafe extern "C" fn document_save_as(
|
||||||
_: *mut zathura_document_s,
|
_: *mut zathura_document_s,
|
||||||
data: *mut c_void,
|
data: *mut c_void,
|
||||||
|
|||||||
Reference in New Issue
Block a user