diff --git a/.gitignore b/.gitignore
index e899205..afa6e8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,3 @@
/dist/*.tar.gz.part-*
/dist/*.tar.gz.parts.sha256
/dist/*-install.sh
-/.release-credentials
diff --git a/AGENTS.md b/AGENTS.md
index 39e7884..9d88581 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -10,7 +10,7 @@ standalone images, and videos.
- Rust
- GTK4 with GIO/GVfs for desktop and remote filesystem integration
-- SQLite for cached directory metadata and reading history
+- SQLite for cached directory metadata, search indexes, and reading history
- AppImage as the primary distribution format
- Korean-first UI with all user-facing strings kept translatable
@@ -38,28 +38,23 @@ standalone images, and videos.
- Support ascending and descending sorting by name, modification time, and
creation time. Treat unavailable creation times as unknown rather than
inventing values.
-- Filter the currently displayed browser directory by filename and restore all
- entries when the search text is cleared.
+- Search folder and ZIP names recursively below the current location using the
+ cached index.
- Provide 100%, fit-width, fit-height, two-page, and continuous vertical viewing.
- Support both right-to-left and left-to-right two-page layouts, plus controls
- that advance by one page to adjust page pairing. Persist the last selected
- two-page direction and restore it in newly opened archive viewers.
+ that advance by one page to adjust page pairing.
- Reuse viewer windows when moving between ZIP, image, and video files. Preserve
fullscreen state and keep the registered GTK titlebar widget stable while the
displayed header changes.
- Provide a toggleable file list on the right side of each viewer. Double-click
or Enter opens the selected viewable file; its context menu provides favorite
and download actions.
-- Filter each viewer's current file list with a temporary search field and
- restore the complete list when the search text is cleared.
- Accept one local file or folder dropped onto the main window or a viewer.
Browse dropped folders in the main window; for dropped files, browse the
parent folder and open the exact naturally sorted item in a new viewer window.
- Save favorites for local and remote folders and files, and preserve the saved
location profile needed to reconnect to remote favorites.
- Save progress per ZIP and save the most recently read ZIP for resume support.
-- Let users update from the About window by downloading the fixed Cafe24 latest
- bundle and checksum, verifying SHA-256, and reusing the atomic installer.
## Data Locations
diff --git a/Cargo.lock b/Cargo.lock
index 44ba40a..c37f0fc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -182,19 +182,17 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "comicviewer"
-version = "0.2.20"
+version = "0.2.3"
dependencies = [
"anyhow",
"chrono",
"filetime",
- "flate2",
"gtk4",
"image",
"percent-encoding",
"rusqlite",
"serde",
"sha2",
- "tar",
"tempfile",
"toml 0.9.12+spec-1.1.0",
"zip",
@@ -1213,17 +1211,6 @@ dependencies = [
"version-compare",
]
-[[package]]
-name = "tar"
-version = "0.4.46"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
-dependencies = [
- "filetime",
- "libc",
- "xattr",
-]
-
[[package]]
name = "target-lexicon"
version = "0.13.5"
@@ -1488,16 +1475,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "xattr"
-version = "1.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156"
-dependencies = [
- "libc",
- "rustix",
-]
-
[[package]]
name = "zerocopy"
version = "0.8.54"
diff --git a/Cargo.toml b/Cargo.toml
index 3b72bf0..a779210 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "comicviewer"
-version = "0.2.20"
+version = "0.2.3"
edition = "2024"
description = "A comic archive viewer for local and remote locations"
license = "GPL-3.0-or-later"
@@ -8,16 +8,14 @@ license = "GPL-3.0-or-later"
[dependencies]
anyhow = "1.0"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
-gtk = { package = "gtk4", version = "0.10", features = ["v4_12"] }
+gtk = { package = "gtk4", version = "0.10", features = ["v4_10"] }
image = { version = "0.25", default-features = false, features = ["avif-native", "bmp", "gif", "jpeg", "png", "webp"] }
filetime = "0.2"
-flate2 = "1.0"
percent-encoding = "2.3"
rusqlite = { version = "0.37", features = ["bundled"] }
serde = { version = "1.0", features = ["derive"] }
sha2 = "0.10"
tempfile = "3.20"
-tar = "0.4"
toml = "0.9"
zip = { version = "8", default-features = false, features = ["deflate"] }
diff --git a/data/io.github.comicviewer.Comicviewer.metainfo.xml b/data/io.github.comicviewer.Comicviewer.metainfo.xml
index 1949cfa..63dad52 100644
--- a/data/io.github.comicviewer.Comicviewer.metainfo.xml
+++ b/data/io.github.comicviewer.Comicviewer.metainfo.xml
@@ -26,23 +26,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/INSTALL.ko.md b/docs/INSTALL.ko.md
index 4c2b483..1094e7f 100644
--- a/docs/INSTALL.ko.md
+++ b/docs/INSTALL.ko.md
@@ -9,16 +9,15 @@ Comicviewer는 CachyOS와 Arch Linux에서 사용할 수 있는 만화·미디
설치합니다. 설치 과정에서 `sudo` 암호와 pacman 확인을 요청할 수 있습니다.
```sh
-sudo pacman -S fuse2 gtk4 dav1d gvfs gvfs-smb gstreamer curl \
+sudo pacman -S fuse2 gtk4 dav1d gvfs gvfs-smb gstreamer \
gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav
```
- `fuse2`: AppImage 마운트 및 실행
-- `gtk4` 4.12 이상, `dav1d`: 화면 표시와 이미지 디코딩
+- `gtk4`, `dav1d`: 화면 표시와 이미지 디코딩
- `gvfs`: FTP와 SFTP 접근
- `gvfs-smb`: SMB 공유 접근
- `gstreamer`, `gst-plugins-*`, `gst-libav`: MP4 등 동영상 재생
-- `curl`: About 창에서 최신 업데이트 다운로드
## 2. 권장 방법: 통합 번들로 설치 또는 업데이트
@@ -83,9 +82,6 @@ Comicviewer는 XDG 표준 경로를 사용합니다.
- 기본 영구 ZIP 캐시 한도는 10GB이며 오래된 파일부터 자동으로 삭제됩니다.
- 메인 창의 `캐시 비우기` 버튼으로 현재 열려 있지 않은 ZIP 캐시를 직접 삭제할 수 있습니다.
- 캐시 한도는 설정 파일의 `cache_quota_gb`로 변경하며, 0은 영구 캐시를 사용하지 않는 값입니다.
-- 메인 창 검색은 현재 표시 중인 폴더의 파일명을 필터링하며, 입력을 지우면 전체 목록을 복원합니다.
-- 위치 목록의 `최근 열어본 파일`은 성공적으로 연 ZIP·이미지·동영상을 최신순으로 최대 100개 보관합니다.
-- 최근 파일 기록에는 원격 위치 재접속 정보가 함께 저장되며 `최근 기록 비우기`로 전체 기록만 삭제할 수 있습니다.
## 뷰어 조작
@@ -93,16 +89,7 @@ Comicviewer는 XDG 표준 경로를 사용합니다.
- `Home`과 `End`: 폴더의 첫 번째/마지막 파일 열기
- 동영상에서 `←`와 `→`: 5초 뒤/앞으로 이동
- 동영상에서 `↑`와 `↓`: 음량을 5%씩 조절
-- 이미지에서 `1`, `2`, `3`, `4`: 폭 맞춤, 높이 맞춤, 2페이지, 100%로 전환 (`3`은 ZIP 뷰어에서 사용)
-- 창보다 크게 표시된 이미지에서 `←`, `→`, `↑`, `↓`: 해당 방향으로 최대 100px 이동
-- `L`: 우측 파일 목록 표시 또는 숨기기
-- 파일 목록 상단 검색: 현재 재생 목록을 임시로 필터링하며, 입력을 지우면 전체 목록 복원
-- About 창의 `업데이트`: Cafe24에서 최신 번들을 내려받아 검증 후 사용자 영역에 설치
-- 이미지에서 `+`/`=`와 `-`: 현재 화면의 이미지를 임시로 10%씩 확대 또는 축소
-- 이미지에서 `Ctrl` + 마우스 휠: 현재 화면의 이미지를 임시로 10%씩 확대 또는 축소
-- 2페이지의 `좌→우`/`우→좌` 방향은 마지막 선택을 저장해 다음 뷰어에서 복원
-- 전체 화면에서 마우스 클릭: 숨겨진 컨트롤을 5초 동안 표시
-- 전체 화면에서 `←`, `→`, `↑`, `↓`: 컨트롤을 즉시 숨기고 해당 키 동작 실행
+- `파일 목록`: 우측 폴더 목록 표시 또는 숨기기
- 파일 목록의 더블클릭 또는 선택 후 `Enter`: 해당 파일 열기
- 파일 목록의 우클릭: 즐겨찾기 추가·제거 또는 다운로드
- 메인 창이나 뷰어에 로컬 파일 드롭: 부모 폴더를 열고 새 뷰어에서 해당 파일 열기
diff --git a/docs/RELEASING.ko.md b/docs/RELEASING.ko.md
index b124f8f..fc4f5b0 100644
--- a/docs/RELEASING.ko.md
+++ b/docs/RELEASING.ko.md
@@ -55,7 +55,7 @@ AppImage 빌드가 끝나면 다음 스크립트로 체크섬과 통합 `tar.gz`
스크립트는 `Cargo.toml`에서 버전을 읽고 다음 파일을 생성합니다.
-- `dist/Comicviewer-0.2.20-x86_64.AppImage.sha256`
+- `dist/Comicviewer-0.2.3-x86_64.AppImage.sha256`
- `dist/Comicviewer-latest-x86_64.tar.gz`
- `dist/Comicviewer-latest-x86_64.tar.gz.sha256`
@@ -78,10 +78,10 @@ sha256sum -c Comicviewer-latest-x86_64.tar.gz.sha256
```sh
git add Cargo.toml Cargo.lock data packaging README.md docs
-git commit -m "Release v0.2.20"
-git tag -a v0.2.20 -m "Comicviewer v0.2.20"
+git commit -m "Release v0.2.3"
+git tag -a v0.2.3 -m "Comicviewer v0.2.3"
git push origin main
-git push origin v0.2.20
+git push origin v0.2.3
```
이미 원격에 공개한 태그는 이동하거나 덮어쓰지 않습니다. 수정이 필요하면 새
diff --git a/packaging/install-or-update.sh b/packaging/install-or-update.sh
index fbc1893..df1d294 100755
--- a/packaging/install-or-update.sh
+++ b/packaging/install-or-update.sh
@@ -39,7 +39,7 @@ install_dependencies() {
fi
set --
- for package in fuse2 gtk4 dav1d gvfs gvfs-smb gstreamer curl gst-plugins-base \
+ for package in fuse2 gtk4 dav1d gvfs gvfs-smb gstreamer gst-plugins-base \
gst-plugins-good gst-plugins-bad gst-libav; do
if ! pacman -Q "${package}" >/dev/null 2>&1; then
set -- "$@" "${package}"
diff --git a/src/config.rs b/src/config.rs
index 905b382..9378f78 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -12,10 +12,8 @@ pub struct AppConfig {
pub fast_image_loading: bool,
pub case_insensitive_sort: bool,
pub viewer_mode: ViewerMode,
- pub two_page_right_to_left: bool,
pub locations: Vec,
pub favorites: Vec,
- pub recent_files: Vec,
}
impl Default for AppConfig {
@@ -25,10 +23,8 @@ impl Default for AppConfig {
fast_image_loading: true,
case_insensitive_sort: true,
viewer_mode: ViewerMode::FitWidth,
- two_page_right_to_left: true,
locations: Vec::new(),
favorites: Vec::new(),
- recent_files: Vec::new(),
}
}
}
@@ -54,13 +50,6 @@ pub struct FavoriteEntry {
pub profile: LocationProfile,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct RecentFileEntry {
- pub name: String,
- pub uri: String,
- pub profile: LocationProfile,
-}
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum LocationKind {
@@ -190,7 +179,6 @@ mod tests {
fast_image_loading: true,
case_insensitive_sort: true,
viewer_mode: ViewerMode::FitWidth,
- two_page_right_to_left: true,
locations: vec![LocationProfile {
name: "테스트".into(),
kind: LocationKind::Sftp,
@@ -212,18 +200,6 @@ mod tests {
domain: String::new(),
},
}],
- recent_files: vec![RecentFileEntry {
- name: "최근 영상.mp4".into(),
- uri: "sftp://example.invalid/comics/recent.mp4".into(),
- profile: LocationProfile {
- name: "최근 서버".into(),
- kind: LocationKind::Sftp,
- address: "sftp://example.invalid/comics".into(),
- username: "recent-reader".into(),
- password: "recent-password".into(),
- domain: String::new(),
- },
- }],
};
let encoded = toml::to_string(&config).unwrap();
@@ -231,8 +207,6 @@ mod tests {
assert_eq!(decoded.locations[0].password, "plain-password");
assert_eq!(decoded.favorites[0].profile.username, "favorite-reader");
assert_eq!(decoded.favorites[0].profile.password, "favorite-password");
- assert_eq!(decoded.recent_files[0].profile.username, "recent-reader");
- assert_eq!(decoded.recent_files[0].profile.password, "recent-password");
}
#[test]
@@ -241,9 +215,7 @@ mod tests {
assert!(decoded.fast_image_loading);
assert!(decoded.case_insensitive_sort);
assert_eq!(decoded.viewer_mode, ViewerMode::FitWidth);
- assert!(decoded.two_page_right_to_left);
assert!(decoded.favorites.is_empty());
- assert!(decoded.recent_files.is_empty());
}
#[test]
@@ -259,17 +231,4 @@ mod tests {
}
assert_eq!(ViewerMode::from_dropdown_index(99), ViewerMode::FitWidth);
}
-
- #[test]
- fn two_page_direction_defaults_to_rtl_and_round_trips_ltr() {
- let existing: AppConfig = toml::from_str("cache_quota_gb = 10\n").unwrap();
- assert!(existing.two_page_right_to_left);
-
- let config = AppConfig {
- two_page_right_to_left: false,
- ..AppConfig::default()
- };
- let decoded: AppConfig = toml::from_str(&toml::to_string(&config).unwrap()).unwrap();
- assert!(!decoded.two_page_right_to_left);
- }
}
diff --git a/src/database.rs b/src/database.rs
index c8aa0af..41e114b 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -2,8 +2,11 @@ use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::{Context, Result};
+use gtk::gio::prelude::*;
use rusqlite::{Connection, OptionalExtension, params};
+use crate::browser::{BrowserEntry, EntryKind};
+
pub struct Database {
connection: Connection,
}
@@ -105,6 +108,124 @@ impl Database {
)?;
Ok(())
}
+
+ pub fn load_cached_tree(&self, location_id: &str, root_uri: &str) -> Result> {
+ let mut statement = self.connection.prepare(
+ "WITH RECURSIVE tree(uri, name, path, entry_kind, size, modified_at, created_at, etag) AS (
+ SELECT uri, name, name, entry_kind, size, modified_at, created_at, etag
+ FROM cached_entries
+ WHERE location_id = ?1 AND parent_uri = ?2
+ UNION ALL
+ SELECT child.uri, child.name, tree.path || '/' || child.name,
+ child.entry_kind, child.size, child.modified_at, child.created_at, child.etag
+ FROM cached_entries AS child
+ JOIN tree ON child.parent_uri = tree.uri
+ WHERE child.location_id = ?1
+ )
+ SELECT uri, name, path, entry_kind, size, modified_at, created_at, etag
+ FROM tree ORDER BY path",
+ )?;
+ let rows = statement.query_map(params![location_id, root_uri], |row| {
+ let kind = entry_kind_from_i64(row.get(3)?);
+ let size = row
+ .get::<_, Option>(4)?
+ .and_then(|value| u64::try_from(value).ok());
+ Ok(BrowserEntry {
+ uri: row.get(0)?,
+ name: row.get(1)?,
+ list_name: Some(row.get(2)?),
+ kind,
+ size,
+ modified: row.get::<_, Option>(5)?.and_then(system_time_from_i64),
+ created: row.get::<_, Option>(6)?.and_then(system_time_from_i64),
+ etag: row.get(7)?,
+ })
+ })?;
+ rows.collect::>>()
+ .map_err(Into::into)
+ }
+
+ pub fn replace_cached_tree(
+ &self,
+ location_id: &str,
+ root_uri: &str,
+ entries: &[BrowserEntry],
+ ) -> Result<()> {
+ let transaction = self.connection.unchecked_transaction()?;
+ transaction.execute(
+ "WITH RECURSIVE tree(uri) AS (
+ SELECT uri FROM cached_entries WHERE location_id = ?1 AND parent_uri = ?2
+ UNION
+ SELECT child.uri FROM cached_entries AS child
+ JOIN tree ON child.parent_uri = tree.uri
+ WHERE child.location_id = ?1
+ )
+ DELETE FROM cached_entries
+ WHERE location_id = ?1 AND uri IN (SELECT uri FROM tree)",
+ params![location_id, root_uri],
+ )?;
+ let refreshed_at = system_time_to_i64(SystemTime::now());
+ {
+ let mut statement = transaction.prepare(
+ "INSERT INTO cached_entries
+ (location_id, parent_uri, uri, name, entry_kind, size, modified_at,
+ created_at, etag, refreshed_at)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)",
+ )?;
+ for entry in entries {
+ let parent_uri = gtk::gio::File::for_uri(&entry.uri)
+ .parent()
+ .map(|parent| parent.uri().to_string())
+ .unwrap_or_else(|| root_uri.to_owned());
+ statement.execute(params![
+ location_id,
+ parent_uri,
+ entry.uri,
+ entry.name,
+ entry_kind_to_i64(entry.kind),
+ entry.size.and_then(|value| i64::try_from(value).ok()),
+ entry.modified.map(system_time_to_i64),
+ entry.created.map(system_time_to_i64),
+ entry.etag,
+ refreshed_at,
+ ])?;
+ }
+ }
+ transaction.commit()?;
+ Ok(())
+ }
+}
+
+fn entry_kind_to_i64(kind: EntryKind) -> i64 {
+ match kind {
+ EntryKind::Directory => 0,
+ EntryKind::ZipArchive => 1,
+ EntryKind::Image => 2,
+ EntryKind::Video => 3,
+ EntryKind::OtherFile => 4,
+ }
+}
+
+fn entry_kind_from_i64(value: i64) -> EntryKind {
+ match value {
+ 0 => EntryKind::Directory,
+ 1 => EntryKind::ZipArchive,
+ 2 => EntryKind::Image,
+ 3 => EntryKind::Video,
+ _ => EntryKind::OtherFile,
+ }
+}
+
+fn system_time_to_i64(time: SystemTime) -> i64 {
+ time.duration_since(UNIX_EPOCH)
+ .unwrap_or_default()
+ .as_secs() as i64
+}
+
+fn system_time_from_i64(seconds: i64) -> Option {
+ u64::try_from(seconds)
+ .ok()
+ .map(|seconds| UNIX_EPOCH + std::time::Duration::from_secs(seconds))
}
#[cfg(test)]
@@ -122,4 +243,51 @@ mod tests {
database.save_progress("test.zip", 9, 20).unwrap();
assert_eq!(database.load_progress("test.zip").unwrap(), Some(9));
}
+
+ #[test]
+ fn cached_tree_replaces_descendants_and_restores_relative_paths() {
+ let database = Database::open(Path::new(":memory:")).unwrap();
+ let entries = vec![
+ BrowserEntry {
+ uri: "file:///library/series".into(),
+ name: "series".into(),
+ list_name: Some("series".into()),
+ kind: EntryKind::Directory,
+ size: None,
+ modified: None,
+ created: None,
+ etag: None,
+ },
+ BrowserEntry {
+ uri: "file:///library/series/book.zip".into(),
+ name: "book.zip".into(),
+ list_name: Some("series/book.zip".into()),
+ kind: EntryKind::ZipArchive,
+ size: Some(42),
+ modified: None,
+ created: None,
+ etag: Some("v1".into()),
+ },
+ ];
+
+ database
+ .replace_cached_tree("library", "file:///library", &entries)
+ .unwrap();
+ let loaded = database
+ .load_cached_tree("library", "file:///library")
+ .unwrap();
+ assert_eq!(loaded.len(), 2);
+ assert_eq!(loaded[1].display_name(), "series/book.zip");
+
+ database
+ .replace_cached_tree("library", "file:///library", &entries[..1])
+ .unwrap();
+ assert_eq!(
+ database
+ .load_cached_tree("library", "file:///library")
+ .unwrap()
+ .len(),
+ 1
+ );
+ }
}
diff --git a/src/source.rs b/src/source.rs
index bf6b8e2..fc9b2c2 100644
--- a/src/source.rs
+++ b/src/source.rs
@@ -16,32 +16,6 @@ const RECURSIVE_ATTRIBUTES: &str = "standard::display-name,standard::name,standa
const MAX_RECURSIVE_DIRECTORIES: usize = 10_000;
const MAX_RECURSIVE_ENTRIES: usize = 100_000;
-#[derive(Default)]
-struct EnumerationProgress {
- seen: HashSet,
- new_in_batch: usize,
-}
-
-impl EnumerationProgress {
- fn begin_batch(&mut self) {
- self.new_in_batch = 0;
- }
-
- fn record(&mut self, uri: String) -> bool {
- let inserted = self.seen.insert(uri);
- self.new_in_batch += usize::from(inserted);
- inserted
- }
-
- fn repeated_batch(&self) -> bool {
- self.new_in_batch == 0
- }
-
- fn len(&self) -> usize {
- self.seen.len()
- }
-}
-
#[derive(Clone, Copy, Default)]
pub struct RecursiveProgress {
pub directories: usize,
@@ -138,7 +112,7 @@ where
}
};
let mut entries = Vec::new();
- let mut enumeration = EnumerationProgress::default();
+ let mut scanned = 0;
loop {
let batch = enumerator
@@ -147,21 +121,19 @@ where
if batch.is_empty() {
break;
}
- enumeration.begin_batch();
+ scanned += batch.len();
+ progress(scanned);
for info in batch {
- let child = enumerator.child(&info);
- let uri: String = info
- .attribute_string("standard::target-uri")
- .map_or_else(|| child.uri().into(), Into::into);
- if !enumeration.record(uri.clone()) {
- continue;
- }
let kind = match info.file_type() {
gio::FileType::Directory => EntryKind::Directory,
gio::FileType::Mountable | gio::FileType::Shortcut => EntryKind::Directory,
gio::FileType::Regular => classify_file(Path::new(info.display_name().as_str())),
_ => continue,
};
+ let child = enumerator.child(&info);
+ let uri = info
+ .attribute_string("standard::target-uri")
+ .map_or_else(|| child.uri().into(), Into::into);
entries.push(BrowserEntry {
uri,
name: info.display_name().into(),
@@ -181,10 +153,6 @@ where
.map(Into::into),
});
}
- if enumeration.repeated_batch() {
- break;
- }
- progress(enumeration.len());
}
Ok(entries)
}
@@ -481,26 +449,6 @@ mod tests {
assert!(encoded_input.equal(&encoded));
}
- #[test]
- fn enumeration_allows_large_unique_directories_and_stops_repeated_batches() {
- let mut enumeration = EnumerationProgress::default();
- for batch_start in (0..330_001).step_by(128) {
- enumeration.begin_batch();
- for index in batch_start..(batch_start + 128).min(330_001) {
- assert!(enumeration.record(format!("smb://server/share/file-{index}")));
- }
- assert!(!enumeration.repeated_batch());
- }
- assert_eq!(enumeration.len(), 330_001);
-
- enumeration.begin_batch();
- for index in 0..128 {
- assert!(!enumeration.record(format!("smb://server/share/file-{index}")));
- }
- assert!(enumeration.repeated_batch());
- assert_eq!(enumeration.len(), 330_001);
- }
-
#[test]
fn recursively_lists_viewable_files_without_following_symlinks() {
let directory = tempfile::tempdir().unwrap();
diff --git a/src/viewer.rs b/src/viewer.rs
index eb0ee7c..5050408 100644
--- a/src/viewer.rs
+++ b/src/viewer.rs
@@ -20,16 +20,8 @@ const FAST_CACHE_LIMIT_BYTES: usize = 1024 * 1024 * 1024;
const FAST_CACHE_LIMIT_PAGES: usize = 64;
const VIDEO_SEEK_STEP_US: i64 = 5_000_000;
const VIDEO_VOLUME_STEP: f64 = 0.05;
-const IMAGE_ZOOM_STEP: f64 = 0.1;
-const IMAGE_ZOOM_MIN: f64 = 0.1;
-const IMAGE_ZOOM_MAX: f64 = 4.0;
-const IMAGE_PAN_STEP: f64 = 100.0;
const VIEWER_CONTROLLER_KEY: &str = "comicviewer-viewer-controller";
const MEDIA_VIEWER_CONTROLLER_KEY: &str = "comicviewer-media-viewer-controller";
-const VIEWER_FILE_SEARCH_KEY: &str = "comicviewer-file-search";
-const VIEWER_FILE_SCROLL_KEY: &str = "comicviewer-file-scroll";
-const VIEWER_VIDEO_LOOP_KEY: &str = "comicviewer-video-loop";
-const PRESERVE_SEEK_CLASS: &str = "viewer-preserve-seek";
fn clear_viewer_controller(window: >k::ApplicationWindow) {
unsafe {
@@ -68,15 +60,15 @@ pub(crate) fn set_viewer_loading(window: >k::ApplicationWindow, loading: bool)
if !window.has_css_class("viewer-loading") || !window.is_fullscreen() {
return glib::Propagation::Proceed;
}
+ if let Some(titlebar) = window.titlebar() {
+ titlebar.set_visible(true);
+ }
if key == gdk::Key::Escape
|| key
.to_unicode()
.is_some_and(|character| character.eq_ignore_ascii_case(&'f'))
{
window.unfullscreen();
- if let Some(titlebar) = window.titlebar() {
- titlebar.set_visible(true);
- }
return glib::Propagation::Stop;
}
glib::Propagation::Proceed
@@ -115,10 +107,10 @@ pub(crate) fn set_viewer_header(
pub struct ViewerWindow;
pub struct SiblingNavigator {
+ position: Rc Option<(usize, usize)>>,
navigate: Rc bool>,
files: Rc Vec>,
actions: Rc,
- recursive: bool,
}
type SiblingActionResolver = dyn Fn(&str) -> Option;
@@ -138,16 +130,16 @@ pub struct SiblingFileActions {
impl SiblingNavigator {
pub fn new(
+ position: Rc Option<(usize, usize)>>,
navigate: Rc bool>,
files: Rc Vec>,
actions: Rc,
- recursive: bool,
) -> Self {
Self {
+ position,
navigate,
files,
actions,
- recursive,
}
}
@@ -170,12 +162,12 @@ impl SiblingNavigator {
)
}
- fn files(&self) -> Vec {
- (self.files)()
+ fn position(&self) -> Option<(usize, usize)> {
+ (self.position)()
}
- fn seek_files(&self, current_kind: EntryKind) -> Vec {
- seek_sibling_files(self.files(), current_kind, self.recursive)
+ fn files(&self) -> Vec {
+ (self.files)()
}
fn open_uri(&self, uri: &str, window: gtk::ApplicationWindow) -> bool {
@@ -226,11 +218,6 @@ pub struct ViewModeControl {
pub change: Rc,
}
-pub struct TwoPageDirectionControl {
- pub selected: u32,
- pub change: Rc bool>,
-}
-
pub struct FileViewerControls {
pub sibling_navigator: Option,
pub favorite_control: FavoriteControl,
@@ -238,7 +225,6 @@ pub struct FileViewerControls {
pub file_drop_control: FileDropControl,
pub reuse_window: Option,
pub view_mode_control: Option,
- pub two_page_direction_control: Option,
}
#[derive(Clone)]
@@ -283,23 +269,8 @@ impl ViewerWindow {
file_drop_control,
reuse_window,
view_mode_control: _,
- two_page_direction_control,
} = controls;
- let direction_control = two_page_direction_control
- .expect("archive viewer requires a two-page direction control");
- let title_files = sibling_navigator
- .as_ref()
- .map(SiblingNavigator::files)
- .unwrap_or_default();
- let title = viewer_file_title(&source.display_name, &source.source_uri, &title_files);
- let file_list_query = reuse_window
- .as_ref()
- .map(viewer_file_search_query)
- .unwrap_or_default();
- let file_list_scroll = reuse_window
- .as_ref()
- .map(viewer_file_scroll_position)
- .unwrap_or_default();
+ let title = source.display_name.clone();
if let Some(window) = reuse_window.as_ref() {
clear_viewer_controller(window);
}
@@ -316,7 +287,7 @@ impl ViewerWindow {
set_viewer_loading(&window, false);
window.set_title(Some(&title));
let header = gtk::HeaderBar::new();
- header.set_title_widget(Some(&viewer_title_label(&title)));
+ header.set_title_widget(Some(>k::Label::new(Some(&title))));
let favorite_button = gtk::Button::with_label(favorite_label(favorite_control.active));
let download_button = gtk::Button::with_label("파일 다운로드");
let file_list_button = gtk::ToggleButton::with_label("파일 목록");
@@ -346,8 +317,7 @@ impl ViewerWindow {
let page_label = gtk::Label::new(Some("- / -"));
page_label.set_hexpand(true);
let direction_dropdown = gtk::DropDown::from_strings(&["좌→우", "우→좌"]);
- let direction_selected = direction_control.selected.min(1);
- direction_dropdown.set_selected(direction_selected);
+ direction_dropdown.set_selected(1);
let mode_dropdown = gtk::DropDown::from_strings(&[
"100%",
"폭 맞춤",
@@ -378,11 +348,6 @@ impl ViewerWindow {
spread_box.set_homogeneous(true);
spread_box.append(&left_picture);
spread_box.append(&right_picture);
- let spread_scrolled = gtk::ScrolledWindow::builder()
- .hexpand(true)
- .vexpand(true)
- .child(&spread_box)
- .build();
let continuous_box = gtk::Box::new(gtk::Orientation::Vertical, 8);
continuous_box.set_halign(gtk::Align::Fill);
@@ -395,7 +360,7 @@ impl ViewerWindow {
stack.set_hexpand(true);
stack.set_vexpand(true);
stack.add_named(&single_scrolled, Some("single"));
- stack.add_named(&spread_scrolled, Some("spread"));
+ stack.add_named(&spread_box, Some("spread"));
stack.add_named(&continuous_scrolled, Some("continuous"));
let spinner = gtk::Spinner::new();
@@ -425,7 +390,7 @@ impl ViewerWindow {
window_overlay.add_overlay(&navigation_message);
window_overlay.set_hexpand(true);
window_overlay.set_vexpand(true);
- let file_list = viewer_file_list(&file_list_query);
+ let file_list = viewer_file_list();
file_list.panel.set_visible(file_list_button.is_active());
let viewer_layout = gtk::Box::new(gtk::Orientation::Horizontal, 0);
viewer_layout.append(&window_overlay);
@@ -443,8 +408,6 @@ impl ViewerWindow {
single_picture,
left_picture,
right_picture,
- spread_box,
- spread_scrolled,
continuous_box,
continuous_scrolled,
spinner,
@@ -464,29 +427,21 @@ impl ViewerWindow {
sibling_navigator,
file_list_button,
file_list_panel: file_list.panel,
- file_list_search: file_list.search,
- file_list_scrolled: file_list.scrolled,
file_list: file_list.list,
file_list_files: RefCell::new(Vec::new()),
- file_list_scroll_restore: Cell::new(Some(file_list_scroll)),
favorite_button,
favorite_toggle: favorite_control.toggle,
download_button,
file_download: download_control.download,
view_mode_change: view_mode_control.change,
- direction_change: direction_control.change,
- direction_selected: Cell::new(direction_selected),
seek_hide_timer: RefCell::new(None),
- seek_interacting: Cell::new(false),
last_pointer_position: Cell::new(None),
key_controller: RefCell::new(None),
motion_controller: RefCell::new(None),
fullscreen_key_controller: RefCell::new(None),
- fullscreen_click_controller: RefCell::new(None),
fullscreen_ui_hide_timer: RefCell::new(None),
fullscreen_ui_visible: Cell::new(false),
fullscreen_notify_handler: RefCell::new(None),
- image_zoom: Cell::new(1.0),
navigation_message,
navigation_message_label,
navigation_message_generation: Rc::new(Cell::new(0)),
@@ -510,14 +465,6 @@ impl ViewerWindow {
});
controller.connect_signals();
controller.fullscreen_changed();
- if controller.window.has_css_class(PRESERVE_SEEK_CLASS) {
- controller.window.remove_css_class(PRESERVE_SEEK_CLASS);
- if controller.window.is_fullscreen() {
- controller.show_fullscreen_ui_temporarily();
- } else {
- controller.show_seek_temporarily();
- }
- }
if controller.file_list_button.is_active() {
controller.refresh_file_list();
}
@@ -616,8 +563,6 @@ struct ViewerController {
single_picture: gtk::Picture,
left_picture: gtk::Picture,
right_picture: gtk::Picture,
- spread_box: gtk::Box,
- spread_scrolled: gtk::ScrolledWindow,
continuous_box: gtk::Box,
continuous_scrolled: gtk::ScrolledWindow,
spinner: gtk::Spinner,
@@ -636,30 +581,22 @@ struct ViewerController {
case_insensitive_sort: bool,
sibling_navigator: Option,
file_list_button: gtk::ToggleButton,
- file_list_panel: gtk::Box,
- file_list_search: gtk::SearchEntry,
- file_list_scrolled: gtk::ScrolledWindow,
+ file_list_panel: gtk::ScrolledWindow,
file_list: gtk::ListBox,
file_list_files: RefCell>,
- file_list_scroll_restore: Cell