Reduce nav_bar width and misc improvements
This commit is contained in:
parent
b354a7d9e2
commit
8a46c4bbe1
3 changed files with 29 additions and 12 deletions
27
src/main.rs
27
src/main.rs
|
|
@ -10,13 +10,7 @@ use cosmic::{
|
||||||
widget::{self, segmented_button},
|
widget::{self, segmented_button},
|
||||||
Application, ApplicationExt, Element,
|
Application, ApplicationExt, Element,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{any::TypeId, env, fs, path::PathBuf, process, time::Instant};
|
||||||
any::TypeId,
|
|
||||||
env, fs,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
process,
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
|
|
||||||
use config::{AppTheme, Config, CONFIG_VERSION};
|
use config::{AppTheme, Config, CONFIG_VERSION};
|
||||||
mod config;
|
mod config;
|
||||||
|
|
@ -370,6 +364,25 @@ impl Application for App {
|
||||||
(app, Command::batch(commands))
|
(app, Command::batch(commands))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default nav_bar widget needs to have its width reduced for cosmic-files
|
||||||
|
fn nav_bar(&self) -> Option<Element<message::Message<Self::Message>>> {
|
||||||
|
if !self.core().nav_bar_active() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let nav_model = self.nav_model()?;
|
||||||
|
|
||||||
|
let mut nav = crate::widget::nav_bar(nav_model, |entity| {
|
||||||
|
message::cosmic(cosmic::app::cosmic::Message::NavBar(entity))
|
||||||
|
});
|
||||||
|
|
||||||
|
if !self.core().is_condensed() {
|
||||||
|
nav = nav.max_width(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(Element::from(nav))
|
||||||
|
}
|
||||||
|
|
||||||
fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> {
|
fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> {
|
||||||
Some(&self.nav_model)
|
Some(&self.nav_model)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use cosmic::{
|
||||||
Element,
|
Element,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{fl, Action, Config, Message};
|
use crate::{fl, Action, Message};
|
||||||
|
|
||||||
macro_rules! menu_button {
|
macro_rules! menu_button {
|
||||||
($($x:expr),+ $(,)?) => (
|
($($x:expr),+ $(,)?) => (
|
||||||
|
|
|
||||||
12
src/tab.rs
12
src/tab.rs
|
|
@ -331,7 +331,7 @@ pub fn scan_trash() -> Vec<Item> {
|
||||||
items
|
items
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum Location {
|
pub enum Location {
|
||||||
Path(PathBuf),
|
Path(PathBuf),
|
||||||
Trash,
|
Trash,
|
||||||
|
|
@ -548,9 +548,13 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(location) = cd {
|
if let Some(location) = cd {
|
||||||
self.location = location;
|
if location != self.location {
|
||||||
self.items_opt = None;
|
self.location = location;
|
||||||
true
|
self.items_opt = None;
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue