Compare commits

..

No commits in common. "96cd01bc77058d8e77532f9cb54633678d6a0ae8" and "0b287f755b524e660d09f6e7357a025331985932" have entirely different histories.

8 changed files with 13 additions and 44 deletions

View file

@ -8,7 +8,6 @@ raven_dep = dependency('raven')
executable( executable(
'filemanager', 'filemanager',
'./src/Dirs.cpp',
'./src/FileButton.cpp', './src/FileButton.cpp',
'./src/DirectoryView.cpp', './src/DirectoryView.cpp',
'./src/TopBar.cpp', './src/TopBar.cpp',

View file

@ -14,13 +14,11 @@ void AppWidget::on_init() {
top_bar->on_action = [directory_view](TopBar::Action action) { top_bar->on_action = [directory_view](TopBar::Action action) {
if (action == TopBar::Action::Back) { if (action == TopBar::Action::Back) {
directory_view->go_back(); directory_view->back();
} else if (action == TopBar::Action::Forward) { } else if (action == TopBar::Action::Forward) {
directory_view->go_forward(); directory_view->forward();
} else if (action == TopBar::Action::Home) { } else if (action == TopBar::Action::Home) {
directory_view->navigate_home(); directory_view->home();
} else if (action == TopBar::Action::ParentDirectory) {
directory_view->navigate_parent_directory();
} }
}; };

View file

@ -1,5 +1,4 @@
#include "DirectoryView.hpp" #include "DirectoryView.hpp"
#include "src/Dirs.hpp"
#include "src/Forward.hpp" #include "src/Forward.hpp"
DirectoryView::~DirectoryView() {} DirectoryView::~DirectoryView() {}
@ -34,22 +33,18 @@ void DirectoryView::on_init() {
m_target = make_target(); m_target = make_target();
m_target->set_layout<Raven::DocumentLayout>(12.0); m_target->set_layout<Raven::DocumentLayout>(12.0);
navigate_home(); navigate("/");
set_did_init(true); set_did_init(true);
} }
void DirectoryView::go_back() { void DirectoryView::back() {
m_checkpoint_stack.undo(); m_checkpoint_stack.undo();
} }
void DirectoryView::go_forward() { void DirectoryView::forward() {
m_checkpoint_stack.redo(); m_checkpoint_stack.redo();
} }
void DirectoryView::navigate_home() { void DirectoryView::home() {
navigate(get_home_directory()); std::cerr << "home(): not implemented" << std::endl;
}
void DirectoryView::navigate_parent_directory() {
navigate(m_current_path.parent_path());
} }

View file

@ -18,10 +18,9 @@ public:
void navigate(std::string path); void navigate(std::string path);
void navigate_relative(std::string path); void navigate_relative(std::string path);
void go_back(); void back();
void go_forward(); void forward();
void navigate_home(); void home();
void navigate_parent_directory();
protected: protected:
void set_current_path(std::filesystem::path path); void set_current_path(std::filesystem::path path);

View file

@ -1,11 +0,0 @@
#include "Dirs.hpp"
#include <cstdlib>
std::filesystem::path get_home_directory() {
auto home_env = std::getenv("HOME");
if (!home_env || !std::filesystem::exists(home_env)) {
return "/";
}
return home_env;
}

View file

@ -1,5 +0,0 @@
#pragma once
#include <filesystem>
std::filesystem::path get_home_directory();

View file

@ -9,7 +9,7 @@ void TopBar::on_init() {
set_style(&Raven::accent_widget_style); set_style(&Raven::accent_widget_style);
auto layout = set_layout<Raven::BoxLayout>(Raven::Direction::Horizontal); auto layout = set_layout<Raven::BoxLayout>(Raven::Direction::Horizontal);
layout->slot_pixel(24, 4); layout->slot_pixel(24, 3);
layout->set_margin(4); layout->set_margin(4);
layout->set_spacing(8); layout->set_spacing(8);
@ -17,8 +17,6 @@ void TopBar::on_init() {
back_button->set_style(&Raven::default_button_style); back_button->set_style(&Raven::default_button_style);
auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg"); auto forward_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/next.svg");
forward_button->set_style(&Raven::default_button_style); forward_button->set_style(&Raven::default_button_style);
auto parent_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/up.svg");
parent_button->set_style(&Raven::default_button_style);
auto home_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/go-home.svg"); auto home_button = add<Raven::SvgWidget>("/usr/share/icons/Papirus/24x24/actions/go-home.svg");
home_button->set_style(&Raven::default_button_style); home_button->set_style(&Raven::default_button_style);
@ -31,9 +29,6 @@ void TopBar::on_init() {
home_button->on_click = [this]() { home_button->on_click = [this]() {
on_action(Action::Home); on_action(Action::Home);
}; };
parent_button->on_click = [this]() {
on_action(Action::ParentDirectory);
};
set_did_init(true); set_did_init(true);
} }

View file

@ -8,8 +8,7 @@ public:
enum class Action { enum class Action {
Back = 0, Back = 0,
Forward, Forward,
Home, Home
ParentDirectory
}; };
public: public:
TopBar() TopBar()