git.lucas.co / cce-files
file manager
git clone https://git.lucas.co/cce-files.git

commit97968f3d51fbd4b61b7d732ce4c6cbac63f28ce4
parentceec65552e
authorLucas Galante <[email protected]>
date2026-07-02 21:47
Refactor ScrollingList to List and fix window decoration blur and styling

 src/main.rs         | 17 ----------------
 src/pages/browse.rs | 56 +++++++++++++++++++++++++++++++++++++++++++++++------
 src/services/fs.rs  | 21 ++++++++++++++++++++
 3 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 585be07..b0ddd05 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -215,23 +215,6 @@ impl FilesystemApp {
         let mut pc = pages::PageContent::new();
         match self.current_page {
             Page::Browse => {
-                // Draw background plates for columns
-                let plate_bg = cce_ui::color::scrollinglist_bg_color();
-                let border_color = cce_ui::color::color_borders_color();
-
-                // Left column plate (Browse)
-                pc.rect(plate_bg, browse_x, content_y, browse_w, content_h);
-                pc.rect(border_color, browse_x, content_y, browse_w, 1.0);
-                pc.rect(border_color, browse_x, content_y + content_h - 1.0, browse_w, 1.0);
-                pc.rect(border_color, browse_x, content_y, 1.0, content_h);
-                pc.rect(border_color, browse_x + browse_w - 1.0, content_y, 1.0, content_h);
-
-                // Right column plate (Preview)
-                pc.rect(plate_bg, preview_x, content_y, preview_w, content_h);
-                pc.rect(border_color, preview_x, content_y, preview_w, 1.0);
-                pc.rect(border_color, preview_x, content_y + content_h - 1.0, preview_w, 1.0);
-                pc.rect(border_color, preview_x, content_y, 1.0, content_h);
-                pc.rect(border_color, preview_x + preview_w - 1.0, content_y, 1.0, content_h);
 
                 let browse_pc = pages::browse::view(&mut self.browse, browse_x, content_y, browse_w, content_h, self.select_mode, &mut self.ui_context);
 
diff --git a/src/pages/browse.rs b/src/pages/browse.rs
index 8ee313f..d98121b 100644
--- a/src/pages/browse.rs
+++ b/src/pages/browse.rs
@@ -23,7 +23,7 @@ pub struct BrowseState {
     pub entries: Vec<DirEntry>,
     pub show_hidden: bool,
     pub search_box: cce_ui::widget::TextBox,
-    pub list_box: cce_ui::widget::ScrollingList,
+    pub list_box: cce_ui::widget::List,
     pub selected: Option<usize>,
     pub breadcrumb: Breadcrumb,
     pub save_name_box: cce_ui::widget::TextBox,
@@ -43,7 +43,7 @@ impl Default for BrowseState {
             search_box: cce_ui::widget::TextBox::new(String::new())
                 .with_max_width(None)
                 .with_placeholder("Search"),
-            list_box: cce_ui::widget::ScrollingList::new(28.0, 2.0),
+            list_box: cce_ui::widget::List::new(28.0, 2.0),
             selected: None,
             breadcrumb,
             save_name_box: cce_ui::widget::TextBox::new(String::new()).with_max_width(None),
@@ -161,8 +161,8 @@ pub fn view(state: &mut BrowseState, cx: f32, cy: f32, cw: f32, ch: f32, select_
     let text_fg = cce_ui::color::TEXT_FG;
     let accent_fg = cce_ui::color::TEXT_ACCENT;
 
-    let selected_bg = cce_ui::color::scrollinglist_entry_highlight_color();
-    let row_bg = cce_ui::color::scrollinglist_entry_bg_color();
+    let selected_bg = cce_ui::color::list_entry_highlight_color();
+    let row_bg = cce_ui::color::list_entry_bg_color();
 
     let gap = 12.0;
     let margin = 12.0;
@@ -180,7 +180,7 @@ pub fn view(state: &mut BrowseState, cx: f32, cy: f32, cw: f32, ch: f32, select_
     let (bx, by, bw, bh) = layout.allocate(client_w, breadcrumb_h);
     cce_ui::layout::render_widget(&mut pc, &mut state.breadcrumb, bx, by, bw, bh, ctx);
 
-    // 2. Allocate and render ScrollingList (ScrollBox)
+    // 2. Allocate and render List (ScrollBox)
     // The scrolling list height occupies the remaining vertical space:
     // list_h = client_h - breadcrumb_h - textbox_h - (2 * gap)
     let list_h_val = client_h - breadcrumb_h - textbox_h - 2.0 * gap;
@@ -437,7 +437,7 @@ mod tests {
                 })
                 .collect(),
             search_box: cce_ui::widget::TextBox::new(String::new()).with_max_width(None),
-            list_box: cce_ui::widget::ScrollingList::new(28.0, 2.0),
+            list_box: cce_ui::widget::List::new(28.0, 2.0),
             ..BrowseState::default()
         }
     }
@@ -588,6 +588,7 @@ mod tests {
                     name: "delete_me.txt".to_string(),
                     path: file_path.clone(),
                     is_dir: false,
+
                     size: 19,
                     permissions: 0o644,
                     modified: String::new(),
@@ -630,4 +631,47 @@ mod tests {
         // Clean up directory
         let _ = std::fs::remove_dir_all(&test_subdir);
     }
+
+    #[test]
+    fn test_component_reconstruction() {
+        let current_dir = PathBuf::from("/home/lsgalante/documents");
+        
+        // Let's say seg is 1 (meaning "home/")
+        let seg = 1;
+        let mut target_path = std::path::PathBuf::new();
+        let mut current_idx = 0;
+        for component in current_dir.components() {
+            target_path.push(component);
+            if component == std::path::Component::RootDir {
+                if seg == 0 {
+                    break;
+                }
+            } else {
+                current_idx += 1;
+                if current_idx == seg {
+                    break;
+                }
+            }
+        }
+        assert_eq!(target_path, PathBuf::from("/home"));
+        
+        // Let's say seg is 0 (meaning "/")
+        let seg = 0;
+        let mut target_path = std::path::PathBuf::new();
+        let mut current_idx = 0;
+        for component in current_dir.components() {
+            target_path.push(component);
+            if component == std::path::Component::RootDir {
+                if seg == 0 {
+                    break;
+                }
+            } else {
+                current_idx += 1;
+                if current_idx == seg {
+                    break;
+                }
+            }
+        }
+        assert_eq!(target_path, PathBuf::from("/"));
+    }
 }
diff --git a/src/services/fs.rs b/src/services/fs.rs
index 1290f72..0a72493 100644
--- a/src/services/fs.rs
+++ b/src/services/fs.rs
@@ -556,7 +556,28 @@ mod tests {
 
     #[test]
     fn test_kdl() {
+        let unique_dir_name = format!("cce_test_kdl_{}", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
+        let temp_path = std::env::temp_dir().join(unique_dir_name);
+        let config_dir = temp_path.join(".config").join("cce");
+        std::fs::create_dir_all(&config_dir).unwrap();
+        let mime_file = config_dir.join("mime.kdl");
+        std::fs::write(&mime_file, "associations { association \"text/plain\" \"cce-text-editor\" }").unwrap();
+        
+        let old_home = std::env::var("HOME").ok();
+        unsafe { std::env::set_var("HOME", &temp_path); }
+        
         let assoc = load_kdl_associations();
+        
+        unsafe {
+            if let Some(ref h) = old_home {
+                std::env::set_var("HOME", h);
+            } else {
+                std::env::remove_var("HOME");
+            }
+        }
+        
+        let _ = std::fs::remove_dir_all(&temp_path);
+        
         println!("Parsed associations: {:?}", assoc);
         assert!(assoc.is_some());
     }