Release v0.2.2

This commit is contained in:
burnintuna 2026-07-22 17:34:37 +09:00
parent 048df6355e
commit b31acd3f58
8 changed files with 309 additions and 16 deletions

View file

@ -182,10 +182,36 @@ pub struct FileViewerControls {
pub sibling_navigator: Option<SiblingNavigator>,
pub favorite_control: FavoriteControl,
pub download_control: FileDownloadControl,
pub file_drop_control: FileDropControl,
pub reuse_window: Option<gtk::ApplicationWindow>,
pub view_mode_control: Option<ViewModeControl>,
}
#[derive(Clone)]
pub struct FileDropControl {
pub handle: Rc<dyn Fn(Vec<gtk::gio::File>, gtk::Window)>,
}
pub(crate) fn install_file_drop_target(window: &gtk::ApplicationWindow, control: FileDropControl) {
if window.has_css_class("comicviewer-file-drop-target") {
return;
}
window.add_css_class("comicviewer-file-drop-target");
let target = gtk::DropTarget::new(gdk::FileList::static_type(), gdk::DragAction::COPY);
let weak_window = window.downgrade();
target.connect_drop(move |_, value, _, _| {
let Ok(file_list) = value.get::<gdk::FileList>() else {
return false;
};
let Some(window) = weak_window.upgrade() else {
return false;
};
(control.handle)(file_list.files(), window.upcast());
true
});
window.add_controller(target);
}
impl ViewerWindow {
pub fn open(
application: &gtk::Application,
@ -200,6 +226,7 @@ impl ViewerWindow {
sibling_navigator,
favorite_control,
download_control,
file_drop_control,
reuse_window,
view_mode_control: _,
} = controls;
@ -215,6 +242,7 @@ impl ViewerWindow {
.default_height(850)
.build()
});
install_file_drop_target(&window, file_drop_control);
ensure_viewer_close_handler(&window);
window.set_title(Some(&title));
let header = gtk::HeaderBar::new();
@ -1681,6 +1709,7 @@ impl MediaViewerWindow {
sibling_navigator,
favorite_control,
download_control,
file_drop_control,
reuse_window,
view_mode_control,
} = controls;
@ -1696,6 +1725,7 @@ impl MediaViewerWindow {
.default_height(850)
.build()
});
install_file_drop_target(&window, file_drop_control);
ensure_viewer_close_handler(&window);
window.set_title(Some(&title));
let header = gtk::HeaderBar::new();