Skip to content

Commit 528c071

Browse files
Handle user-places.xbel file not existing
+ Call user_places_xbel::read_user_places() instead of user_places_xbel::parse_file() to create file if missing + Fixed alignment of bookmarks column STILL TO DO: - Reduced file calls to user_places.xbel
1 parent 21a8610 commit 528c071

2 files changed

Lines changed: 45 additions & 32 deletions

File tree

Cargo.lock

Lines changed: 31 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tab.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,14 +1230,14 @@ pub fn scan_search<F: Fn(SearchItem) -> bool + Sync>(
12301230
}
12311231
}
12321232
SearchLocation::Bookmarks => {
1233-
let bookmarks = match user_places_xbel::parse_file() {
1234-
Ok(bookmarks) => bookmarks,
1233+
let user_places = match user_places_xbel::read_user_places() {
1234+
Ok(user_places) => user_places,
12351235
Err(err) => {
1236-
log::warn!("Error reading bookmarks files: {err:?}");
1236+
log::warn!("Error reading user-places.xbel file: {err:?}");
12371237
return;
12381238
}
12391239
};
1240-
for bookmark in bookmarks.bookmarks {
1240+
for bookmark in user_places.bookmarks {
12411241
let path = uri_to_path(bookmark.href);
12421242
if let Some(path) = path
12431243
&& path.exists()
@@ -1340,14 +1340,14 @@ pub fn scan_recents(sizes: IconSizes) -> Vec<Item> {
13401340
}
13411341

13421342
pub fn user_bookmarks() -> Vec<user_places_xbel::Bookmark> {
1343-
let bookmarks = match user_places_xbel::parse_file() {
1344-
Ok(user_places_file) => user_places_file.bookmarks,
1343+
let user_places = match user_places_xbel::read_user_places() {
1344+
Ok(user_places) => user_places.bookmarks,
13451345
Err(err) => {
1346-
log::warn!("Error reading bookmarks files: {err:?}");
1346+
log::warn!("Error reading user-places.xbel files: {err:?}");
13471347
return Vec::new();
13481348
}
13491349
};
1350-
return bookmarks;
1350+
return user_places;
13511351
}
13521352

13531353
pub fn is_bookmarked(path: PathBuf) -> bool {
@@ -5487,10 +5487,11 @@ impl Tab {
54875487
show_bookmarks = true;
54885488
}
54895489
//TODO: allow resizing?
5490+
let sort_offset = space_xxs as f32;
54905491
let name_width = 300.0;
5491-
let modified_width = 200.0;
5492-
let size_width = 100.0;
5493-
let bookmarked_width = if show_bookmarks { 40.0 } else { 0.0 };
5492+
let modified_width = 200.0 + sort_offset;
5493+
let size_width = 100.0 + sort_offset;
5494+
let bookmarked_width = if show_bookmarks { 32.0 + sort_offset } else { 0.0 };
54945495
let condensed = size.width < (name_width + modified_width + size_width + bookmarked_width);
54955496

54965497
let (sort_name, sort_direction, _) = self.sort_options();
@@ -6236,7 +6237,7 @@ impl Tab {
62366237
let name_width = 300.0;
62376238
let modified_width = 200.0;
62386239
let size_width = 100.0;
6239-
let bookmarked_width = if show_bookmarks { 40.0 } else { 0.0 };
6240+
let bookmarked_width = if show_bookmarks { 32.0 + (space_xxs as f32 * 2.0) } else { 0.0 };
62406241
let condensed = size.width < (name_width + modified_width + size_width + bookmarked_width);
62416242
let is_search = matches!(self.location, Location::Search(..));
62426243
let icon_size = if condensed || is_search {
@@ -6457,7 +6458,7 @@ impl Tab {
64576458
widget::tooltip::Position::Top,
64586459
)
64596460
})
6460-
.width(Length::Fixed(bookmarked_width + 8.0)) // Align with heading icon
6461+
.width(Length::Fixed(bookmarked_width))
64616462
.into()
64626463
)
64636464
};

0 commit comments

Comments
 (0)