fix merge conflicts
This commit is contained in:
commit
1ffb3b9870
9 changed files with 780 additions and 324 deletions
92
src/tab.rs
92
src/tab.rs
|
|
@ -336,7 +336,7 @@ pub fn scan_path(tab_path: &PathBuf, sizes: IconSizes) -> Vec<Item> {
|
|||
}
|
||||
};
|
||||
|
||||
let metadata = match entry.metadata() {
|
||||
let metadata = match fs::metadata(&path) {
|
||||
Ok(ok) => ok,
|
||||
Err(err) => {
|
||||
log::warn!("failed to read metadata for entry at {:?}: {}", path, err);
|
||||
|
|
@ -397,7 +397,7 @@ pub fn scan_search(tab_path: &PathBuf, term: &str, sizes: IconSizes) -> Vec<Item
|
|||
if regex.is_match(file_name) {
|
||||
let path = entry.path();
|
||||
|
||||
let metadata = match entry.metadata() {
|
||||
let metadata = match fs::metadata(&path) {
|
||||
Ok(ok) => ok,
|
||||
Err(err) => {
|
||||
log::warn!("failed to read metadata for entry at {:?}: {}", path, err);
|
||||
|
|
@ -652,7 +652,7 @@ impl Location {
|
|||
#[derive(Clone, Debug)]
|
||||
pub enum Command {
|
||||
Action(Action),
|
||||
ChangeLocation(String, Location),
|
||||
ChangeLocation(String, Location, Option<PathBuf>),
|
||||
EmptyTrash,
|
||||
FocusButton(widget::Id),
|
||||
FocusTextInput(widget::Id),
|
||||
|
|
@ -1003,6 +1003,7 @@ pub struct Tab {
|
|||
pub dialog: Option<DialogKind>,
|
||||
pub scroll_opt: Option<AbsoluteOffset>,
|
||||
pub size_opt: Cell<Option<Size>>,
|
||||
pub item_view_size_opt: Cell<Option<Size>>,
|
||||
pub edit_location: Option<Location>,
|
||||
pub edit_location_id: widget::Id,
|
||||
pub history_i: usize,
|
||||
|
|
@ -1029,6 +1030,7 @@ impl Tab {
|
|||
dialog: None,
|
||||
scroll_opt: None,
|
||||
size_opt: Cell::new(None),
|
||||
item_view_size_opt: Cell::new(None),
|
||||
edit_location: None,
|
||||
edit_location_id: widget::Id::unique(),
|
||||
history_i: 0,
|
||||
|
|
@ -1104,11 +1106,16 @@ impl Tab {
|
|||
*self.cached_selected.borrow_mut() = None;
|
||||
if let Some(ref mut items) = self.items_opt {
|
||||
for item in items.iter_mut() {
|
||||
if item.name == name {
|
||||
item.selected = true;
|
||||
} else {
|
||||
item.selected = false;
|
||||
}
|
||||
item.selected = item.name == name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_path(&mut self, path: PathBuf) {
|
||||
*self.cached_selected.borrow_mut() = None;
|
||||
if let Some(ref mut items) = self.items_opt {
|
||||
for item in items.iter_mut() {
|
||||
item.selected = item.path_opt.as_ref() == Some(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1211,7 +1218,10 @@ impl Tab {
|
|||
Some(offset) => Point::new(0.0, offset.y),
|
||||
None => Point::new(0.0, 0.0),
|
||||
};
|
||||
let size = self.size_opt.get().unwrap_or_else(|| Size::new(0.0, 0.0));
|
||||
let size = self
|
||||
.item_view_size_opt
|
||||
.get()
|
||||
.unwrap_or_else(|| Size::new(0.0, 0.0));
|
||||
Rectangle::new(point, size)
|
||||
};
|
||||
|
||||
|
|
@ -1949,8 +1959,13 @@ impl Tab {
|
|||
Location::Trash => true,
|
||||
Location::Recents => true,
|
||||
} {
|
||||
let prev_path = if let Location::Path(path) = &self.location {
|
||||
Some(path.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.change_location(&location, history_i_opt);
|
||||
commands.push(Command::ChangeLocation(self.title(), location));
|
||||
commands.push(Command::ChangeLocation(self.title(), location, prev_path));
|
||||
} else {
|
||||
log::warn!("tried to cd to {:?} which is not a directory", location);
|
||||
}
|
||||
|
|
@ -2187,9 +2202,9 @@ impl Tab {
|
|||
crate::mouse_area::MouseArea::new(
|
||||
widget::button(widget::icon::from_name("edit-symbolic").size(16))
|
||||
.padding(space_xxs)
|
||||
.style(theme::Button::Icon),
|
||||
.style(theme::Button::Icon)
|
||||
.on_press(Message::EditLocation(Some(self.location.clone()))),
|
||||
)
|
||||
.on_press(move |_| Message::EditLocation(Some(self.location.clone())))
|
||||
.on_middle_press(move |_| Message::OpenInNewTab(path.clone())),
|
||||
);
|
||||
w += 16.0 + 2.0 * space_xxs as f32;
|
||||
|
|
@ -2289,24 +2304,22 @@ impl Tab {
|
|||
let mut mouse_area = crate::mouse_area::MouseArea::new(
|
||||
widget::button(row)
|
||||
.padding(space_xxxs)
|
||||
.style(theme::Button::Link),
|
||||
)
|
||||
.on_press(move |_| {
|
||||
Message::Location(match &self.location {
|
||||
Location::Path(_) => Location::Path(ancestor.to_path_buf()),
|
||||
Location::Search(_, term) => {
|
||||
Location::Search(ancestor.to_path_buf(), term.clone())
|
||||
}
|
||||
other => other.clone(),
|
||||
})
|
||||
});
|
||||
.style(theme::Button::Link)
|
||||
.on_press(Message::Location(match &self.location {
|
||||
Location::Path(_) => Location::Path(ancestor.to_path_buf()),
|
||||
Location::Search(_, term) => {
|
||||
Location::Search(ancestor.to_path_buf(), term.clone())
|
||||
}
|
||||
other => other.clone(),
|
||||
})),
|
||||
);
|
||||
|
||||
if self.location_context_menu_index.is_some() {
|
||||
mouse_area = mouse_area.on_right_press(move |_point_opt| {
|
||||
Message::LocationContextMenuIndex(None)
|
||||
})
|
||||
} else {
|
||||
mouse_area = mouse_area.on_right_press_no_capture(move |point_opt| {
|
||||
mouse_area = mouse_area.on_right_press_no_capture(move |_point_opt| {
|
||||
Message::LocationContextMenuIndex(Some(index))
|
||||
})
|
||||
}
|
||||
|
|
@ -2619,9 +2632,16 @@ impl Tab {
|
|||
}
|
||||
}
|
||||
}
|
||||
let spacer_height = height
|
||||
.checked_sub(max_bottom + 7 * (space_xxs as usize))
|
||||
.unwrap_or(0);
|
||||
|
||||
let top_deduct = 7 * (space_xxs as usize);
|
||||
|
||||
self.item_view_size_opt
|
||||
.set(self.size_opt.get().map(|s| Size {
|
||||
width: s.width,
|
||||
height: s.height - top_deduct as f32,
|
||||
}));
|
||||
|
||||
let spacer_height = height.checked_sub(max_bottom + top_deduct).unwrap_or(0);
|
||||
if spacer_height > 0 {
|
||||
children.push(
|
||||
widget::container(vertical_space(Length::Fixed(spacer_height as f32)))
|
||||
|
|
@ -2973,12 +2993,18 @@ impl Tab {
|
|||
}
|
||||
//TODO: HACK If we don't reach the bottom of the view, go ahead and add a spacer to do that
|
||||
{
|
||||
let spacer_height =
|
||||
size.height as i32 - y as i32 - (if condensed { 6 } else { 9 }) * space_xxs as i32;
|
||||
if spacer_height > 0 {
|
||||
children.push(
|
||||
widget::container(vertical_space(Length::Fixed(spacer_height as f32))).into(),
|
||||
);
|
||||
let top_deduct = (if condensed { 6 } else { 9 }) * space_xxs;
|
||||
|
||||
self.item_view_size_opt
|
||||
.set(self.size_opt.get().map(|s| Size {
|
||||
width: s.width,
|
||||
height: s.height - top_deduct as f32,
|
||||
}));
|
||||
|
||||
let spacer_height = size.height - y as f32 - top_deduct as f32;
|
||||
if spacer_height > 0. {
|
||||
children
|
||||
.push(widget::container(vertical_space(Length::Fixed(spacer_height))).into());
|
||||
}
|
||||
}
|
||||
let drag_col = (!drag_items.is_empty()).then(|| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue